Annotation of parser3/src/types/pa_vobject.h, revision 1.38.2.10.2.2

1.6       paf         1: /**    @file
1.7       paf         2:        Parser: @b object class decl.
                      3: 
1.38.2.6  paf         4:        Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
1.16      paf         5:        Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1       paf         6: */
                      7: 
                      8: #ifndef PA_VOBJECT_H
                      9: #define PA_VOBJECT_H
                     10: 
1.38.2.10.2.2! (paf       11:: static const char* IDENT_VOBJECT_H="$Date: 2003/03/18 15:14:21 $";
1.38.2.2  paf        12: 
                     13: // includes
1.19      paf        14: 
1.1       paf        15: #include "pa_vjunction.h"
                     16: #include "pa_vclass.h"
1.4       paf        17: #include "pa_vstateless_object.h"
1.38.2.2  paf        18: #include "pa_vfile.h"
1.6       paf        19: 
1.23      paf        20: // defines
                     21: 
                     22: #define BASE_NAME "BASE"
1.38.2.1  paf        23: 
1.26      paf        24: /**    parser class instance, stores 
                     25:        - class VObject::fclass;
                     26:        - fields VObject::ffields (dynamic, not static, which are stored in class).
                     27:        - links to base/derived instances [VObject::fbase, VObject::fderived]
1.6       paf        28: */
1.24      paf        29: class VObject: public VStateless_object {
1.38.2.1  paf        30: 
                     31:        VStateless_class& fclass;
                     32:        HashStringValue ffields;
1.38.2.9  paf        33:        VObject* fderived;
1.38.2.10.2.2! (paf       34::       Value* fbase;
1.38.2.1  paf        35: 
1.1       paf        36: public: // Value
                     37:        
1.38.2.6  paf        38:        const char* type() const { return fclass.name_cstr(); }
1.38.2.8  paf        39:        override Value* as(const char* atype, bool looking_up);
1.12      parser     40: 
1.25      paf        41:        /// VObject: fclass
1.38.2.1  paf        42:        override VStateless_class *get_class() { return &fclass; }
                     43:        override VStateless_class *get_last_derived_class() { return get_last_derived().get_class(); }
1.38.2.10.2.2! (paf       44::       override Value* base() { return fbase; }
1.38.2.1  paf        45: 
                     46:        override bool is_defined() const;
1.38.2.10.2.2! (paf       47::       override Value* as_expr_result(bool);
1.38.2.1  paf        48:        override int as_int() const;
                     49:        override double as_double();
                     50:        override bool as_bool() const;
1.38.2.10.2.2! (paf       51::       override VFile* as_vfile(String::Language lang=String::L_UNSPECIFIED);
1.33      paf        52:        
1.38.2.10.2.1  (paf       53::       override HashStringValue* get_hash(const String* source);
1.38.2.1  paf        54:        override Table *get_table();
1.33      paf        55: 
1.38.2.10.2.2! (paf       56::       override Value* get_element(const String& aname, Value& aself, bool /*looking_up*/);
        !            57::       override bool put_element(const String& aname, Value* avalue, bool replace);
1.1       paf        58: 
1.37      paf        59:        /// VObject: remember derived [the only client]
1.38.2.9  paf        60:        override VObject* set_derived(VObject* aderived) { 
                     61:                VObject* result=fderived;
1.25      paf        62:                fderived=aderived;
1.34      paf        63:                return result;
1.24      paf        64:        }
                     65: 
1.1       paf        66: public: // creation
                     67: 
1.38.2.9  paf        68:        VObject(VStateless_class& aclass): fclass(aclass), fderived(0) {
1.38.2.6  paf        69:                if(VStateless_class* base_class=fclass.base_class()) {
1.38.2.1  paf        70:                        fbase=fclass.base_class()->create_new_value();
1.38.2.9  paf        71:                        fbase->set_derived(this);
1.38.2.1  paf        72:                }
1.1       paf        73:        }
1.38.2.10  paf        74: 
                     75:        override ~VObject();
1.1       paf        76: 
                     77: private:
                     78: 
1.37      paf        79:        VObject& get_last_derived() {
                     80:                return fderived?fderived->get_last_derived():*this;
1.26      paf        81:        }
1.37      paf        82: 
1.38.2.10.2.2! (paf       83::       Value* stateless_object__get_element(const String& aname, Value& aself);
1.25      paf        84: };
                     85: 
                     86: class Temp_derived {
                     87:        Value& fvalue;
1.38.2.9  paf        88:        VObject* fsaved_derived;
1.25      paf        89: public:
1.38.2.9  paf        90:        Temp_derived(Value& avalue, VObject* aderived) : 
1.25      paf        91:                fvalue(avalue),
                     92:                fsaved_derived(avalue.set_derived(aderived)) {}
                     93:        ~Temp_derived() { fvalue.set_derived(fsaved_derived); }
1.1       paf        94: };
                     95: 
                     96: #endif

E-mail: