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

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

E-mail: