Annotation of parser3/src/types/pa_vhash.h, revision 1.5

1.1       paf         1: /*
                      2:        Parser
                      3:        Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
1.3       paf         4:        Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
1.1       paf         5: 
1.5     ! paf         6:        $Id: pa_vhash.h,v 1.4 2001/03/13 17:17:29 paf Exp $
1.1       paf         7: */
                      8: 
                      9: #ifndef PA_VHASH_H
                     10: #define PA_VHASH_H
                     11: 
                     12: #include "pa_value.h"
                     13: #include "pa_hash.h"
                     14: 
                     15: class VHash : public Value {
                     16: public: // value
                     17: 
                     18:        // all: for error reporting after fail(), etc
1.2       paf        19:        const char *type() const { return "hash"; }
1.1       paf        20: 
                     21:        // value: (key)=value
                     22:        Value *get_element(const String& name) { 
1.5     ! paf        23:                return static_cast<Value *>(fhash.get(name));
1.1       paf        24:        }
                     25:        
                     26:        // value: (key)=value
                     27:        void put_element(const String& name, Value *value) { 
1.5     ! paf        28:                fhash.put(name, value);
1.1       paf        29:        }
                     30: 
                     31: public: // usage
                     32: 
1.4       paf        33:        VHash(Pool& apool, Hash *ahash=0) : Value(apool), 
1.5     ! paf        34:                fhash(ahash?*ahash:*new(apool) Hash(apool)) {}
1.1       paf        35: 
                     36: private:
1.5     ! paf        37:        Hash& fhash;
1.1       paf        38: };
                     39: 
                     40: #endif

E-mail: