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

1.6     ! paf         1: /**    @file
        !             2:        Parser: object class decl.
1.1       paf         3:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.2       paf         4:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1       paf         5: 
1.6     ! paf         6:        $Id: pa_vobject.h,v 1.5 2001/03/13 13:43:32 paf Exp $
1.1       paf         7: */
                      8: 
                      9: #ifndef PA_VOBJECT_H
                     10: #define PA_VOBJECT_H
                     11: 
                     12: #include "pa_valiased.h"
                     13: #include "pa_vjunction.h"
                     14: #include "pa_vclass.h"
1.4       paf        15: #include "pa_vstateless_object.h"
1.1       paf        16: 
1.6     ! paf        17: 
        !            18: /**    parser class instance,
        !            19:        stores fields VObject::ffields (dynamic, not static, which are stored in class).
        !            20: */
1.4       paf        21: class VObject : public VStateless_object {
1.1       paf        22: public: // Value
                     23:        
1.6     ! paf        24:        /// all: for error reporting after fail(), etc
1.1       paf        25:        const char *type() const { return "object"; }
                     26: 
1.6     ! paf        27:        /// VObject : (field)=value;(CLASS)=vclass;(method)=method_ref
1.1       paf        28:        Value *get_element(const String& name) {
1.3       paf        29:                // $CLASS,$BASE,$method
1.4       paf        30:                if(Value *result=VStateless_object::get_element(name))
1.3       paf        31:                        return result;
1.1       paf        32:                // $field=ffields.field
                     33:                return static_cast<Value *>(ffields.get(name));
                     34:        }
                     35: 
1.6     ! paf        36:        /// VObject : (field)=value
1.1       paf        37:        void put_element(const String& name, Value *value) {
                     38:                // speed1:
                     39:                //   will not check for '$CLASS(subst)' trick
                     40:                //   will hope that user ain't THAT self-hating person
                     41:                // speed2:
                     42:                //   will not check for '$method_name(subst)' trick
                     43:                //   -same-
                     44: 
                     45:                ffields.put(name, value);
                     46:        }
                     47: 
                     48: public: // creation
                     49: 
1.5       paf        50:        VObject(Pool& apool, VStateless_class& aclass_real) : 
                     51:                VStateless_object(apool, aclass_real), 
                     52: 
1.1       paf        53:                ffields(apool) {
                     54:        }
                     55: 
                     56: private:
                     57: 
                     58:        Hash ffields;
                     59: };
                     60: 
                     61: #endif

E-mail: