Annotation of parser3/src/types/pa_vhashfile.h, revision 1.1
1.1 ! parser 1: /** @file
! 2: Parser: @b hashfile parser type decl.
! 3:
! 4: Copyright (c) 2001 ArtLebedev Group (http://www.artlebedev.com)
! 5: Author: Alexander Petrosyan <paf@design.ru> (http://design.ru/paf)
! 6:
! 7: $Id: pa_vhash.h,v 1.23 2001/10/16 14:39:09 parser Exp $
! 8: */
! 9:
! 10: #ifndef PA_VHASHFILE_H
! 11: #define PA_VHASHFILE_H
! 12:
! 13: #include "classes.h"
! 14: #include "pa_value.h"
! 15: #include "pa_hash.h"
! 16: #include "pa_vint.h"
! 17:
! 18: extern Methoded *hash_base_class;
! 19:
! 20: /// value of type 'hashfile', implemented with GDBM library
! 21: class VHashfile : public VStateless_class {
! 22: public: // value
! 23:
! 24: const char *type() const { return "hashfile"; }
! 25:
! 26: /// VHashfile: true
! 27: bool is_defined() const { return true; }
! 28:
! 29: /// VHashfile: convert to VHash
! 30: Hash *get_hash();
! 31:
! 32: /// VHashfile: 0
! 33: VStateless_class *get_class() { return 0; }
! 34:
! 35: /// VHashfile: (key)=value
! 36: Value *get_element(const String& name) {
! 37: // $CLASS,$method
! 38: if(Value *result=VStateless_class::get_element(name))
! 39: return result;
! 40:
! 41: // $element
! 42: return get_field(name);
! 43: }
! 44:
! 45: /// VHashfile: (key)=value
! 46: void put_element(const String& name, Value *value) {
! 47: put_field(name, value);
! 48: }
! 49:
! 50:
! 51: public: // usage
! 52:
! 53: VHashfile(Pool& apool) : VStateless_class(apool, hash_base_class),
! 54: ffile_spec(0), ffile_spec_cstr(0) {
! 55: }
! 56:
! 57: void set_file_spec(const String& afile_spec) {
! 58: ffile_spec=&afile_spec;
! 59: ffile_spec_cstr=afile_spec.cstr(String::UL_FILE_SPEC);
! 60: }
! 61: const String& get_file_spec(const String *source) const {
! 62: if(!ffile_spec)
! 63: throw Exception(0, 0,
! 64: source,
! 65: "can not be applied to uninitialized instance");
! 66:
! 67: return *ffile_spec;
! 68: }
! 69: const char *get_file_spec_cstr(const String *source) {
! 70: if(!ffile_spec_cstr)
! 71: throw Exception(0, 0,
! 72: source,
! 73: "can not be applied to uninitialized instance");
! 74:
! 75: return ffile_spec_cstr;
! 76: }
! 77:
! 78: private:
! 79:
! 80: void check(const char *operation, const String *source, int error);
! 81:
! 82: Value *get_field(const String& name);
! 83:
! 84: void put_field(const String& name, Value *value);
! 85:
! 86: private:
! 87:
! 88: const String *ffile_spec;
! 89: const char *ffile_spec_cstr;
! 90:
! 91: };
! 92:
! 93: #endif
E-mail: