Annotation of parser3/src/types/pa_vfile.h, revision 1.52.2.3
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.3! paf 11: static const char* IDENT_VFILE_H="$Date: 2003/01/29 09:16:16 $";
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.1 paf 30: public: // Value
31:
1.52.2.1 paf 32: override const char *type() const { return "file"; }
1.52.2.2 paf 33: override VStateless_class *get_class() { return file_class.get(); }
1.11 paf 34:
1.2 paf 35: /// VFile: true
1.52.2.1 paf 36: override bool as_bool() const { return true; }
1.35 parser 37:
38: /// VFile: true
1.52.2.1 paf 39: override ValuePtr as_expr_result(bool return_string_as_is=false) {
40: return ValuePtr(new VBool(as_bool()));
41: }
1.2 paf 42:
1.16 paf 43: /// VFile: this
1.52.2.1 paf 44: override VFilePtr as_vfile(String::Untaint_lang lang=String::UL_UNSPECIFIED,
1.27 parser 45: bool origins_mode=false) {
1.19 paf 46: return this;
47: }
1.16 paf 48:
1.47 paf 49: /// VFile: method,field
1.52.2.1 paf 50: override Value *get_element(const String& aname, Value& aself, bool looking_up);
1.1 paf 51:
52: public: // usage
53:
1.17 paf 54: void set(bool tainted,
55: const void *avalue_ptr, size_t avalue_size, const char *afile_name=0,
1.52.2.3! paf 56: ValuePtr acontent_type=ValuePtr(0));
1.13 paf 57:
1.52.2.1 paf 58: void save(ConstStringPtr file_spec, bool is_text) {
1.13 paf 59: if(fvalue_ptr)
1.38 paf 60: file_write(file_spec, fvalue_ptr, fvalue_size, is_text);
1.13 paf 61: else
1.41 paf 62: throw Exception("parser.runtime",
1.52.2.1 paf 63: file_spec,
1.18 paf 64: "saving stat-ed file");
1.1 paf 65: }
66:
1.18 paf 67: const void *value_ptr() const {
68: if(!fvalue_ptr)
1.41 paf 69: throw Exception("parser.runtime",
1.52.2.1 paf 70: Exception::undefined_source,
1.18 paf 71: "getting value of stat-ed file");
72:
73: return fvalue_ptr;
74: }
1.16 paf 75: size_t value_size() const { return fvalue_size; }
1.52.2.1 paf 76: HashStringValue& fields() { return ffields; }
77: //const HashStringValue& fields() const { return ffields; }
1.30 parser 78:
79: private:
80:
1.52.2.1 paf 81: ValuePtr fields_element();
1.16 paf 82:
1.1 paf 83: private:
84:
1.12 paf 85: const void *fvalue_ptr;
1.1 paf 86: size_t fvalue_size;
1.52.2.1 paf 87: HashStringValue ffields;
1.1 paf 88:
89: };
90:
91: #endif
E-mail: