|
|
1.1 paf 1: /*
2: Parser
3: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
4: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
5:
1.3 ! paf 6: $Id: pa_vtable.h,v 1.2 2001/03/12 20:36:53 paf Exp $
1.1 paf 7: */
8:
9: #ifndef PA_VTABLE_H
10: #define PA_VTABLE_H
11:
12: #include "pa_vstateless_object.h"
13: #include "pa_table.h"
14: #include "_table.h"
15: #include "pa_vunknown.h"
16:
17: class VTable : public VStateless_object {
18: public: // Value
19:
20: // all: for error reporting after fail(), etc
21: const char *type() const { return "table"; }
22: // table: fvalue
23: // const Table *get_table() { return &fvalue; };
24: // table: empty or not
25: bool get_bool() { return table().size()!=0; }
26: // table: itself
27: VTable *get_vtable() { return this; }
28: // table: column
29: Value *get_element(const String& name) {
1.3 ! paf 30: // methods
1.2 paf 31: if(Value *result=VStateless_object::get_element(name))
32: return result;
33:
1.1 paf 34: if(fvalue)
35: if(const String *string=fvalue->item(name))
36: return NEW VString(*string);
37:
38: return NEW VUnknown(pool());
39: }
40:
41: public: // usage
42:
43: VTable(Pool& apool) : VStateless_object(apool, *table_class),
44: fvalue(0) {
45: }
46: /*
47: VTable(const Table& avalue) : VStateless_object(avalue.pool(), *table_class),
48: fvalue(avalue) {
49: }
50: */
51:
52: void set_table(Table& avalue) { fvalue=&avalue; }
53: Table& table() {
54: if(!fvalue)
55: bark("getting unset vtable value");
56:
57: return *fvalue;
58: }
59:
60: private:
61:
62: Table *fvalue;
63:
64: };
65:
66: #endif