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