Annotation of parser3/src/types/pa_vhashfile.C, revision 1.4
1.1 parser 1: /** @file
2: Parser: @b table class.
3:
4: Copyright(c) 2001 ArtLebedev Group(http://www.artlebedev.com)
5: Author: Alexander Petrosyan <paf@design.ru>(http://design.ru/paf)
6:
1.4 ! parser 7: $Id: pa_vhashfile.C,v 1.3 2001/10/22 16:44:43 parser Exp $
1.1 parser 8: */
9:
10: #include "pa_config_includes.h"
11: #ifdef HAVE_LIBDB
12:
13: #include "pa_vtable.h"
14: #include "pa_vstring.h"
15: #include "pa_vhashfile.h"
16: #include "pa_threads.h"
17:
18:
19: // methods
20:
1.3 parser 21: void VHashfile_cleanup(void *vhashfile) {
22: //_asm int 3;
23: static_cast<VHashfile *>(vhashfile)->cleanup();
1.1 parser 24: }
25:
26: void VHashfile::put_field(const String& name, Value *value) {
1.3 parser 27: DB_Connection& connection=get_connection(&name);
28: connection.put(name, value->as_string());
1.1 parser 29: }
30:
31: Value *VHashfile::get_field(const String& name) {
1.3 parser 32: DB_Connection& connection=get_connection(&name);
33: if(String *string=connection.get(name))
34: return NEW VString(*string);
35: else
36: return 0;
1.1 parser 37: }
38:
1.4 ! parser 39: Hash *VHashfile::get_hash(const String *source) {
! 40: Hash& result=*NEW Hash(pool());
! 41: DB_Connection& connection=get_connection(0/*source*/);
! 42: DB_Cursor cursor=connection.cursor(source);
! 43:
! 44: while(true) {
! 45: String& key=*NEW String(pool());
! 46: String& data=*NEW String(pool());
! 47: if(!cursor.get(key, data, DB_NEXT))
! 48: break;
! 49:
! 50: result.put(key, NEW VString(data));
! 51: }
! 52:
! 53: return &result;
1.1 parser 54: }
55:
56: #endif
E-mail: