Annotation of parser3/src/types/pa_vtable.h, revision 1.6
1.6 ! paf 1: /** @file
! 2: Parser: table parser class decl.
! 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.6 ! paf 8: $Id: pa_vtable.h,v 1.5 2001/03/19 20:07:40 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
! 26: VTable *get_vtable() { return this; }
! 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: }
39:
40: public: // usage
41:
42: VTable(Pool& apool) : VStateless_object(apool, *table_class),
1.4 paf 43: ftable(0) {
1.1 paf 44: }
1.4 paf 45: void set_table(Table& avalue) { ftable=&avalue; }
1.1 paf 46: Table& table() {
1.4 paf 47: if(!ftable)
1.1 paf 48: bark("getting unset vtable value");
49:
1.4 paf 50: return *ftable;
1.1 paf 51: }
52:
53: private:
54:
1.4 paf 55: Table *ftable;
1.1 paf 56:
57: };
58:
59: #endif
E-mail: