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