Annotation of parser3/src/types/pa_vtable.h, revision 1.16
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.16 ! paf 8: $Id: pa_vtable.h,v 1.15.2.3 2001/04/28 08:30:38 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"
17:
1.16 ! paf 18: extern Methoded *table_class;
! 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.16 ! paf 56: void lock() {
! 57: check_lock();
! 58: locked=true;
! 59: }
1.14 paf 60: void unlock() { locked=false; }
61: void set_table(Table& avalue) {
1.16 ! paf 62: check_lock();
1.14 paf 63: ftable=&avalue;
64: }
1.1 paf 65: Table& table() {
1.4 paf 66: if(!ftable)
1.1 paf 67: bark("getting unset vtable value");
68:
1.4 paf 69: return *ftable;
1.1 paf 70: }
71:
72: private:
73:
1.4 paf 74: Table *ftable;
1.14 paf 75: bool locked;
1.16 ! paf 76:
! 77: private:
! 78:
! 79: void check_lock() {
! 80: if(locked)
! 81: bark("is locked");
! 82: }
1.1 paf 83:
84: };
85:
86: #endif
E-mail: