Annotation of parser3/src/types/pa_vfile.h, revision 1.52.2.1
1.4 paf 1: /** @file
1.18 paf 2: Parser: @b file parser type decl.
1.4 paf 3:
1.52 paf 4: Copyright (c) 2001, 2003 ArtLebedev Group (http://www.artlebedev.com)
1.40 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1 paf 6: */
7:
8: #ifndef PA_VFILE_H
9: #define PA_VFILE_H
1.43 paf 10:
1.52.2.1! paf 11: static const char* IDENT_VFILE_H="$Date: 2003/01/21 15:51:19 $";
1.1 paf 12:
1.25 paf 13: #include "classes.h"
1.1 paf 14: #include "pa_common.h"
15: #include "pa_globals.h"
1.3 paf 16: #include "pa_vstateless_object.h"
1.23 paf 17:
1.52.2.1! paf 18: // externs
! 19:
1.23 paf 20: extern Methoded *file_class;
1.1 paf 21:
1.52.2.1! paf 22: // forwards
! 23:
! 24: class VFile;
! 25:
! 26: DECLARE_OBJECT_PTR(VFile)
! 27:
1.22 paf 28: /** holds received from user or read from disk file.
1.1 paf 29:
1.4 paf 30: @see VForm
31: */
1.52.2.1! paf 32: class VFile: public VStateless_object {
1.1 paf 33: public: // Value
34:
1.52.2.1! paf 35: override const char *type() const { return "file"; }
! 36: override VStateless_class *get_class() { return file_class; }
1.11 paf 37:
1.2 paf 38: /// VFile: true
1.52.2.1! paf 39: override bool as_bool() const { return true; }
1.35 parser 40:
41: /// VFile: true
1.52.2.1! paf 42: override ValuePtr as_expr_result(bool return_string_as_is=false) {
! 43: return ValuePtr(new VBool(as_bool()));
! 44: }
1.2 paf 45:
1.16 paf 46: /// VFile: this
1.52.2.1! paf 47: override VFilePtr as_vfile(String::Untaint_lang lang=String::UL_UNSPECIFIED,
1.27 parser 48: bool origins_mode=false) {
1.19 paf 49: return this;
50: }
1.16 paf 51:
1.47 paf 52: /// VFile: method,field
1.52.2.1! paf 53: override Value *get_element(const String& aname, Value& aself, bool looking_up);
1.1 paf 54:
55: public: // usage
56:
1.17 paf 57: void set(bool tainted,
58: const void *avalue_ptr, size_t avalue_size, const char *afile_name=0,
1.52.2.1! paf 59: ValuePtr acontent_type=ValuePtrZero);
1.13 paf 60:
1.52.2.1! paf 61: void save(ConstStringPtr file_spec, bool is_text) {
1.13 paf 62: if(fvalue_ptr)
1.38 paf 63: file_write(file_spec, fvalue_ptr, fvalue_size, is_text);
1.13 paf 64: else
1.41 paf 65: throw Exception("parser.runtime",
1.52.2.1! paf 66: file_spec,
1.18 paf 67: "saving stat-ed file");
1.1 paf 68: }
69:
1.18 paf 70: const void *value_ptr() const {
71: if(!fvalue_ptr)
1.41 paf 72: throw Exception("parser.runtime",
1.52.2.1! paf 73: Exception::undefined_source,
1.18 paf 74: "getting value of stat-ed file");
75:
76: return fvalue_ptr;
77: }
1.16 paf 78: size_t value_size() const { return fvalue_size; }
1.52.2.1! paf 79: HashStringValue& fields() { return ffields; }
! 80: //const HashStringValue& fields() const { return ffields; }
1.30 parser 81:
82: private:
83:
1.52.2.1! paf 84: ValuePtr fields_element();
1.16 paf 85:
1.1 paf 86: private:
87:
1.12 paf 88: const void *fvalue_ptr;
1.1 paf 89: size_t fvalue_size;
1.52.2.1! paf 90: HashStringValue ffields;
1.1 paf 91:
92: };
93:
94: #endif
E-mail: