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