Annotation of parser3/src/types/pa_vfile.h, revision 1.34
1.4 paf 1: /** @file
1.18 paf 2: Parser: @b file parser type decl.
1.4 paf 3:
1.1 paf 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
5: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
6:
1.34 ! parser 7: $Id: pa_vfile.h,v 1.33 2001/09/24 15:00:35 parser Exp $
1.1 paf 8: */
9:
10: #ifndef PA_VFILE_H
11: #define PA_VFILE_H
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:
18: extern Methoded *file_class;
1.1 paf 19:
1.22 paf 20: /** holds received from user or read from disk file.
1.1 paf 21:
1.4 paf 22: @see VForm
23: */
1.3 paf 24: class VFile : public VStateless_object {
1.1 paf 25: public: // Value
26:
27: const char *type() const { return "file"; }
1.11 paf 28:
1.2 paf 29: /// VFile: true
1.33 parser 30: bool as_bool() const { return true; }
1.2 paf 31:
1.16 paf 32: /// VFile: this
1.27 parser 33: VFile *as_vfile(String::Untaint_lang lang=String::UL_UNSPECIFIED,
34: bool origins_mode=false) {
1.19 paf 35: return this;
36: }
1.16 paf 37:
1.28 parser 38: /// VFile: CLASS,method,field
1.1 paf 39: Value *VFile::get_element(const String& aname) {
1.28 parser 40: // $CLASS,$method
1.3 paf 41: if(Value *result=VStateless_object::get_element(aname))
1.1 paf 42: return result;
43:
1.12 paf 44: // $name, $size, $text
1.16 paf 45: return static_cast<Value *>(ffields.get(aname));
1.1 paf 46: }
1.7 paf 47:
48: protected: // VAliased
49:
1.10 paf 50: /// disable .CLASS element. @see VAliased::get_element
1.15 paf 51: bool hide_class() { return true; }
1.1 paf 52:
53: public: // usage
54:
1.13 paf 55: VFile::VFile(Pool& apool) : VStateless_object(apool, *file_class),
56: fvalue_ptr(0),
57: fvalue_size(0),
1.16 paf 58: ffields(apool) {
1.13 paf 59: }
1.1 paf 60:
1.17 paf 61: void set(bool tainted,
62: const void *avalue_ptr, size_t avalue_size, const char *afile_name=0,
1.31 parser 63: Value *amime_type=0);
1.13 paf 64:
1.29 parser 65: void save(const String& file_spec, bool is_text) {
1.13 paf 66: if(fvalue_ptr)
1.29 parser 67: file_write(pool(), file_spec, fvalue_ptr, fvalue_size, is_text);
1.13 paf 68: else
69: THROW(0, 0,
70: &file_spec,
1.18 paf 71: "saving stat-ed file");
1.1 paf 72: }
73:
1.18 paf 74: const void *value_ptr() const {
75: if(!fvalue_ptr)
76: THROW(0, 0,
77: 0,
78: "getting value of stat-ed file");
79:
80: return fvalue_ptr;
81: }
1.16 paf 82: size_t value_size() const { return fvalue_size; }
1.21 paf 83: Hash& fields() { return ffields; }
84: const Hash& fields() const { return ffields; }
1.30 parser 85:
86: private:
87:
88: Value *fields_element();
1.16 paf 89:
1.1 paf 90: private:
91:
1.12 paf 92: const void *fvalue_ptr;
1.1 paf 93: size_t fvalue_size;
1.16 paf 94: Hash ffields;
1.1 paf 95:
96: };
97:
98: #endif
E-mail: