Annotation of parser3/src/types/pa_vtable.h, revision 1.2

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: 
1.2     ! paf         6:        $Id: pa_vtable.h,v 1.1 2001/03/12 13:39:44 paf Exp $
1.1       paf         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) {
1.2     ! paf        30:                if(Value *result=VStateless_object::get_element(name))
        !            31:                        return result;
        !            32: 
1.1       paf        33:                if(fvalue)
                     34:                        if(const String *string=fvalue->item(name))
                     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), 
                     43:                fvalue(0) {
                     44:        }
                     45: /*
                     46:        VTable(const Table& avalue) : VStateless_object(avalue.pool(), *table_class),
                     47:                fvalue(avalue) {
                     48:        }
                     49: */
                     50: 
                     51:        void set_table(Table& avalue) { fvalue=&avalue; }
                     52:        Table& table() { 
                     53:                if(!fvalue)
                     54:                        bark("getting unset vtable value");
                     55: 
                     56:                return *fvalue; 
                     57:        }
                     58: 
                     59: private:
                     60: 
                     61:        Table *fvalue;
                     62: 
                     63: };
                     64: 
                     65: #endif

E-mail: