Annotation of parser3/src/types/pa_vtable.h, revision 1.31
1.6 paf 1: /** @file
1.15 paf 2: Parser: @b table parser class decl.
1.6 paf 3:
1.1 paf 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.6 paf 5:
1.1 paf 6: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
7:
1.31 ! parser 8: $Id: pa_vtable.h,v 1.30 2001/09/18 16:05:43 parser Exp $
1.1 paf 9: */
10:
11: #ifndef PA_VTABLE_H
12: #define PA_VTABLE_H
13:
14: #include "pa_vstateless_object.h"
15: #include "pa_table.h"
1.26 parser 16: #include "pa_vvoid.h"
1.30 parser 17: #include "pa_vint.h"
1.1 paf 18:
1.27 parser 19: #define TABLE_FIELDS_ELEMENT_NAME "fields"
20:
1.16 paf 21: extern Methoded *table_class;
22:
1.6 paf 23: /// value of type 'table'. implemented with Table
1.1 paf 24: class VTable : public VStateless_object {
25: public: // Value
26:
27: const char *type() const { return "table"; }
1.31 ! parser 28: /// VTable: finteger
! 29: int as_int() const { return table().size(); }
! 30: /// VTable: finteger
! 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
! 35: bool as_bool() const { return as_int()!=0; }
1.6 paf 36: /// extract VTable
1.10 paf 37: Table *get_table() { return ftable; }
1.18 paf 38: /// VTable: columns,methods
1.27 parser 39: Value *get_element(const String& name);
1.7 paf 40:
41: protected: // VAliased
42:
1.9 paf 43: /// disable .CLASS element. @see VAliased::get_element
1.13 paf 44: bool hide_class() { return true; }
1.1 paf 45:
46: public: // usage
47:
1.12 paf 48: VTable(Pool& apool, Table* atable=0) : VStateless_object(apool, *table_class),
1.28 parser 49: ftable(atable) {
1.1 paf 50: }
1.14 paf 51: void set_table(Table& avalue) {
52: ftable=&avalue;
53: }
1.30 parser 54: Table& table() const {
1.4 paf 55: if(!ftable)
1.1 paf 56: bark("getting unset vtable value");
57:
1.4 paf 58: return *ftable;
1.1 paf 59: }
60:
61: private:
1.27 parser 62:
63: Value *fields_element();
1.1 paf 64:
1.18 paf 65: private:
66:
67: Table *ftable;
1.1 paf 68:
69: };
70:
71: #endif
E-mail: