Annotation of parser3/src/types/pa_vtable.h, revision 1.15
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.15 ! paf 8: $Id: pa_vtable.h,v 1.14 2001/04/23 10:58:32 paf 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"
16: #include "_table.h"
17: #include "pa_vunknown.h"
18:
1.6 paf 19: /// value of type 'table'. implemented with Table
1.1 paf 20: class VTable : public VStateless_object {
21: public: // Value
22:
1.6 paf 23: /// all: for error reporting after fail(), etc
1.1 paf 24: const char *type() const { return "table"; }
1.6 paf 25: /// extract VTable
1.10 paf 26: Table *get_table() { return ftable; }
1.6 paf 27: /// VTable: column
1.1 paf 28: Value *get_element(const String& name) {
1.3 paf 29: // methods
1.2 paf 30: if(Value *result=VStateless_object::get_element(name))
31: return result;
32:
1.4 paf 33: if(ftable)
34: if(const String *string=ftable->item(name))
1.1 paf 35: return NEW VString(*string);
36:
37: return NEW VUnknown(pool());
38: }
1.7 paf 39:
1.11 paf 40: public:
41:
42: bool last_locate_was_successful;
43:
1.7 paf 44: protected: // VAliased
45:
1.9 paf 46: /// disable .CLASS element. @see VAliased::get_element
1.13 paf 47: bool hide_class() { return true; }
1.1 paf 48:
49: public: // usage
50:
1.12 paf 51: VTable(Pool& apool, Table* atable=0) : VStateless_object(apool, *table_class),
1.14 paf 52: ftable(atable), locked(false),
1.11 paf 53: last_locate_was_successful(false) {
1.1 paf 54: }
1.14 paf 55: void lock() { locked=true; }
56: void unlock() { locked=false; }
57: void set_table(Table& avalue) {
58: if(locked)
59: bark("is locked");
60: ftable=&avalue;
61: }
1.1 paf 62: Table& table() {
1.4 paf 63: if(!ftable)
1.1 paf 64: bark("getting unset vtable value");
65:
1.4 paf 66: return *ftable;
1.1 paf 67: }
68:
69: private:
70:
1.4 paf 71: Table *ftable;
1.14 paf 72: bool locked;
1.1 paf 73:
74: };
75:
76: #endif
E-mail: