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

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.7     ! paf         8:        $Id: pa_vtable.h,v 1.6 2001/03/24 19:12:23 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:        }
1.7     ! paf        39: 
        !            40: protected: // VAliased
        !            41: 
        !            42:        VStateless_class *get_class_alias() { return 0; }
1.1       paf        43: 
                     44: public: // usage
                     45: 
                     46:        VTable(Pool& apool) : VStateless_object(apool, *table_class), 
1.4       paf        47:                ftable(0) {
1.1       paf        48:        }
1.4       paf        49:        void set_table(Table& avalue) { ftable=&avalue; }
1.1       paf        50:        Table& table() { 
1.4       paf        51:                if(!ftable)
1.1       paf        52:                        bark("getting unset vtable value");
                     53: 
1.4       paf        54:                return *ftable; 
1.1       paf        55:        }
                     56: 
                     57: private:
                     58: 
1.4       paf        59:        Table *ftable;
1.1       paf        60: 
                     61: };
                     62: 
                     63: #endif

E-mail: