Annotation of parser3/src/types/pa_vtable.h, revision 1.41
1.6 paf 1: /** @file
1.15 paf 2: Parser: @b table parser class decl.
1.6 paf 3:
1.36 paf 4: Copyright (c) 2001, 2002 ArtLebedev Group (http://www.artlebedev.com)
1.37 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1 paf 6: */
7:
8: #ifndef PA_VTABLE_H
9: #define PA_VTABLE_H
1.39 paf 10:
1.41 ! paf 11: static const char* IDENT_VTABLE_H="$Date: 2002/08/01 11:41:25 $";
1.1 paf 12:
13: #include "pa_vstateless_object.h"
14: #include "pa_table.h"
1.26 parser 15: #include "pa_vvoid.h"
1.30 parser 16: #include "pa_vint.h"
1.1 paf 17:
1.27 parser 18: #define TABLE_FIELDS_ELEMENT_NAME "fields"
19:
1.16 paf 20: extern Methoded *table_class;
21:
1.6 paf 22: /// value of type 'table'. implemented with Table
1.1 paf 23: class VTable : public VStateless_object {
24: public: // Value
25:
26: const char *type() const { return "table"; }
1.38 paf 27: VStateless_class *get_class() { return table_class; }
1.32 parser 28: /// VTable: count
1.31 parser 29: int as_int() const { return table().size(); }
1.32 parser 30: /// VTable: count
1.31 parser 31: double as_double() const { return as_int(); }
1.29 parser 32: /// VTable: count!=0
1.31 parser 33: bool is_defined() const { return as_int()!=0; }
34: /// VTable: 0 or !0
1.34 parser 35: bool as_bool() const { return is_defined(); }
1.32 parser 36: /// VTable: count
37: Value *as_expr_result(bool return_string_as_is=false) { return NEW VInt(pool(), as_int()); }
1.6 paf 38: /// extract VTable
1.10 paf 39: Table *get_table() { return ftable; }
1.18 paf 40: /// VTable: columns,methods
1.27 parser 41: Value *get_element(const String& name);
1.1 paf 42:
43: public: // usage
44:
1.38 paf 45: VTable(Pool& apool, Table* atable=0) : VStateless_object(apool),
1.28 parser 46: ftable(atable) {
1.1 paf 47: }
1.14 paf 48: void set_table(Table& avalue) {
49: ftable=&avalue;
50: }
1.30 parser 51: Table& table() const {
1.4 paf 52: if(!ftable)
1.1 paf 53: bark("getting unset vtable value");
54:
1.4 paf 55: return *ftable;
1.1 paf 56: }
57:
58: private:
1.27 parser 59:
60: Value *fields_element();
1.1 paf 61:
1.18 paf 62: private:
63:
64: Table *ftable;
1.1 paf 65:
66: };
67:
68: #endif
E-mail: