Annotation of parser3/src/types/pa_vtable.h, revision 1.1
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:
! 6: $Id: pa_vtable.h,v 1.4 2001/03/11 21:23:59 paf Exp $
! 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) {
! 30: if(fvalue)
! 31: if(const String *string=fvalue->item(name))
! 32: return NEW VString(*string);
! 33:
! 34: return NEW VUnknown(pool());
! 35: }
! 36:
! 37: public: // usage
! 38:
! 39: VTable(Pool& apool) : VStateless_object(apool, *table_class),
! 40: fvalue(0) {
! 41: }
! 42: /*
! 43: VTable(const Table& avalue) : VStateless_object(avalue.pool(), *table_class),
! 44: fvalue(avalue) {
! 45: }
! 46: */
! 47:
! 48: void set_table(Table& avalue) { fvalue=&avalue; }
! 49: Table& table() {
! 50: if(!fvalue)
! 51: bark("getting unset vtable value");
! 52:
! 53: return *fvalue;
! 54: }
! 55:
! 56: private:
! 57:
! 58: Table *fvalue;
! 59:
! 60: };
! 61:
! 62: #endif
E-mail: