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

1.6       paf         1: /** @file
1.15      paf         2:        Parser: @b table parser class decl.
1.6       paf         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.15.2.1! paf         8:        $Id: pa_vtable.h,v 1.15 2001/04/26 15:01:52 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"
1.15.2.1! paf        18: 
        !            19: extern Methoded *table_class;
1.1       paf        20: 
1.6       paf        21: /// value of type 'table'. implemented with Table
1.1       paf        22: class VTable : public VStateless_object {
                     23: public: // Value
                     24: 
1.6       paf        25:        /// all: for error reporting after fail(), etc
1.1       paf        26:        const char *type() const { return "table"; }
1.6       paf        27:        /// extract VTable
1.10      paf        28:        Table *get_table() { return ftable; }
1.6       paf        29:        /// VTable: column
1.1       paf        30:        Value *get_element(const String& name) {
1.3       paf        31:                // methods
1.2       paf        32:                if(Value *result=VStateless_object::get_element(name))
                     33:                        return result;
                     34: 
1.4       paf        35:                if(ftable)
                     36:                        if(const String *string=ftable->item(name))
1.1       paf        37:                                return NEW VString(*string);
                     38: 
                     39:                return NEW VUnknown(pool());
                     40:        }
1.7       paf        41: 
1.11      paf        42: public:
                     43: 
                     44:        bool last_locate_was_successful;
                     45: 
1.7       paf        46: protected: // VAliased
                     47: 
1.9       paf        48:        /// disable .CLASS element. @see VAliased::get_element
1.13      paf        49:        bool hide_class() { return true; }
1.1       paf        50: 
                     51: public: // usage
                     52: 
1.12      paf        53:        VTable(Pool& apool, Table* atable=0) : VStateless_object(apool, *table_class), 
1.14      paf        54:                ftable(atable), locked(false),
1.11      paf        55:                last_locate_was_successful(false) {
1.1       paf        56:        }
1.14      paf        57:        void lock() { locked=true; }
                     58:        void unlock() { locked=false; }
                     59:        void set_table(Table& avalue) { 
                     60:                if(locked)
                     61:                        bark("is locked");
                     62:                ftable=&avalue; 
                     63:        }
1.1       paf        64:        Table& table() { 
1.4       paf        65:                if(!ftable)
1.1       paf        66:                        bark("getting unset vtable value");
                     67: 
1.4       paf        68:                return *ftable; 
1.1       paf        69:        }
                     70: 
                     71: private:
                     72: 
1.4       paf        73:        Table *ftable;
1.14      paf        74:        bool locked;
1.1       paf        75: 
                     76: };
                     77: 
                     78: #endif

E-mail: