Annotation of parser3/src/types/pa_vhashfile.h, revision 1.18
1.1 parser 1: /** @file
2: Parser: @b hashfile parser type decl.
3:
1.17 paf 4: Copyright (c) 2001-2003 ArtLebedev Group (http://www.artlebedev.com)
1.15 paf 5: Author: Alexandr Petrosian <paf@design.ru> (http://paf.design.ru)
1.1 parser 6: */
7:
8: #ifndef PA_VHASHFILE_H
9: #define PA_VHASHFILE_H
10:
1.18 ! paf 11: static const char* IDENT_VHASHFILE_H="$Date: 2003/11/06 08:22:50 $";
1.17 paf 12:
1.1 parser 13: #include "classes.h"
14: #include "pa_value.h"
15: #include "pa_hash.h"
16: #include "pa_vint.h"
1.17 paf 17:
18: #include "apr_sdbm.h"
19:
20: // defines
21:
22: #define VHASHFILE_TYPE "hashfile"
1.1 parser 23:
1.7 parser 24: // externs
25:
1.17 paf 26: extern Methoded *hashfile_class;
1.1 parser 27:
1.7 parser 28: // forwards
29:
30: class Autosave_marked_to_cancel_cache ;
31:
1.17 paf 32: /// value of type 'hashfile', implemented with SDBM library bundled in ../libs/sdbm
33: class VHashfile : public VStateless_object, PA_Cleaned {
1.1 parser 34: public: // value
35:
1.17 paf 36: override const char *type() const { return VHASHFILE_TYPE; }
37: override VStateless_class *get_class() { return hashfile_class; }
1.1 parser 38:
39: /// VHashfile: true
1.17 paf 40: override bool is_defined() const { return true; }
1.1 parser 41:
42: /// VHashfile: convert to VHash
1.17 paf 43: override HashStringValue *get_hash(const String *source);
1.1 parser 44:
45: /// VHashfile: (key)=value
1.17 paf 46: override Value* get_element(const String& aname, Value& aself, bool looking_up) {
1.1 parser 47: // $CLASS,$method
1.17 paf 48: if(Value *result=VStateless_object::get_element(aname, aself, looking_up))
1.1 parser 49: return result;
50:
51: // $element
1.17 paf 52: return get_field(aname);
1.1 parser 53: }
54:
1.5 parser 55: /// VHashfile: (key)=value, (key)=(value+expires)
1.17 paf 56: override bool put_element(const String& aname, Value* avalue, bool /*replace*/) {
57: put_field(aname, avalue);
58: return false; // nobody is supposed to derive from hashfile, so does not matter
1.6 parser 59: }
1.1 parser 60:
61: public: // usage
62:
1.17 paf 63: VHashfile(): db(0) {}
1.18 ! paf 64: override ~VHashfile();
1.9 paf 65:
1.17 paf 66: void open(const String& afile_name);
1.1 parser 67:
1.17 paf 68: void clear();
1.9 paf 69:
1.1 parser 70: private:
71:
1.9 paf 72: Value *get_field(const String& aname);
73: void put_field(const String& aname, Value *avalue);
1.1 parser 74:
75: private:
76:
1.17 paf 77: apr_sdbm_t *db;
78:
1.1 parser 79: };
80:
81: #endif
E-mail: