Annotation of parser3/src/types/pa_vfile.h, revision 1.52.2.16.2.6
1.4 paf 1: /** @file
1.18 paf 2: Parser: @b file parser type decl.
1.4 paf 3:
1.52.2.8 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.16.2.6! (paf 11:: static const char* IDENT_VFILE_H="$Date: 2003/03/25 12:10:09 $";
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.9 paf 20: // defines
1.52.2.5 paf 21:
1.52.2.9 paf 22: #define NONAME_DAT "noname.dat"
1.52.2.5 paf 23:
1.52.2.9 paf 24: // forwards
1.52.2.1 paf 25:
1.52.2.16.2.4 (paf 26:: class Methoded;
1.52.2.1 paf 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.52.2.4 paf 33:
1.52.2.16.2.1 (paf 34:: const char* ffile_name_cstr;
1.52.2.16.2.3 (paf 35:: const char* fvalue_ptr;
1.52.2.4 paf 36: size_t fvalue_size;
37: HashStringValue ffields;
38:
1.1 paf 39: public: // Value
40:
1.52.2.8 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.16.2.6! (paf 48:: override Value& as_expr_result(bool return_string_as_is=false) { return *new VBool(as_bool()); }
1.2 paf 49:
1.16 paf 50: /// VFile: this
1.52.2.16.2.5 (paf 51:: override VFile* as_vfile(String::Language /*lang*/,
52:: const Request_charsets* /*charsets*/) { return this; }
1.16 paf 53:
1.47 paf 54: /// VFile: method,field
1.52.2.16.2.4 (paf 55:: override Value* get_element(const String& aname, Value& aself, bool looking_up);
1.1 paf 56:
57: public: // usage
58:
1.52.2.16.2.4 (paf 59:: VFile::VFile(): fvalue_ptr(0), fvalue_size(0) {
1.52.2.15 paf 60: }
61:
1.52.2.16.2.1 (paf 62:: void set(
1.52.2.4 paf 63: bool tainted,
1.52.2.14 paf 64: const char* avalue_ptr, size_t avalue_size,
1.52.2.12 paf 65: const char* afile_name_cstr=0,
1.52.2.16.2.4 (paf 66:: Value* acontent_type=0);
1.13 paf 67:
1.52.2.16.2.1 (paf 68:: void save(const String& file_spec, bool is_text) {
1.13 paf 69: if(fvalue_ptr)
1.38 paf 70: file_write(file_spec, fvalue_ptr, fvalue_size, is_text);
1.13 paf 71: else
1.41 paf 72: throw Exception("parser.runtime",
1.52.2.16.2.4 (paf 73:: &file_spec,
1.18 paf 74: "saving stat-ed file");
1.1 paf 75: }
76:
1.52.2.13 paf 77: const char* value_ptr() const {
1.18 paf 78: if(!fvalue_ptr)
1.41 paf 79: throw Exception("parser.runtime",
1.52.2.16.2.2 (paf 80:: 0,
1.18 paf 81: "getting value of stat-ed file");
82:
83: return fvalue_ptr;
84: }
1.16 paf 85: size_t value_size() const { return fvalue_size; }
1.52.2.1 paf 86: HashStringValue& fields() { return ffields; }
1.30 parser 87:
88: private:
89:
1.52.2.16.2.4 (paf 90:: Value* fields_element();
1.1 paf 91:
92: };
93:
94: #endif
E-mail: