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

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.10    ! paf         8:        $Id: pa_vtable.h,v 1.9 2001/03/27 15:43:21 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
1.10    ! paf        26:        Table *get_table() { return ftable; }
1.6       paf        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: 
1.9       paf        42:        /// disable .CLASS element. @see VAliased::get_element
                     43:        bool are_static_calls_disabled() { return true; }
1.1       paf        44: 
                     45: public: // usage
                     46: 
                     47:        VTable(Pool& apool) : VStateless_object(apool, *table_class), 
1.4       paf        48:                ftable(0) {
1.1       paf        49:        }
1.4       paf        50:        void set_table(Table& avalue) { ftable=&avalue; }
1.1       paf        51:        Table& table() { 
1.4       paf        52:                if(!ftable)
1.1       paf        53:                        bark("getting unset vtable value");
                     54: 
1.4       paf        55:                return *ftable; 
1.1       paf        56:        }
                     57: 
                     58: private:
                     59: 
1.4       paf        60:        Table *ftable;
1.1       paf        61: 
                     62: };
                     63: 
                     64: #endif

E-mail: