Annotation of parser3/src/types/pa_vhashfile.C, revision 1.7

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.7     ! parser      7:        $Id: pa_vhashfile.C,v 1.6 2001/10/24 09:36:52 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: 
1.5       parser     26: void VHashfile::put_element(const String& name, Value *value) {
                     27:        put_field(name, value, 0);
                     28: }
                     29: 
                     30: 
                     31: void VHashfile::put_field(const String& name, Value *value, time_t time_to_die) {
1.3       parser     32:        DB_Connection& connection=get_connection(&name);
1.5       parser     33:        connection.put(name, value->as_string(), time_to_die);
1.1       parser     34: }
                     35: 
                     36: Value *VHashfile::get_field(const String& name) {
1.3       parser     37:        DB_Connection& connection=get_connection(&name);
                     38:        if(String *string=connection.get(name))
                     39:                return NEW VString(*string);
                     40:        else
                     41:                return 0;
1.1       parser     42: }
                     43: 
1.4       parser     44: Hash *VHashfile::get_hash(const String *source) {
                     45:        Hash& result=*NEW Hash(pool());
                     46:        DB_Connection& connection=get_connection(0/*source*/);
1.6       parser     47:        DB_Cursor cursor(connection, source);
1.4       parser     48: 
                     49:        while(true) {
1.5       parser     50:                String *key;
                     51:                String *data;
1.4       parser     52:                if(!cursor.get(key, data, DB_NEXT))
                     53:                        break;
                     54: 
1.7     ! parser     55:                if(key) // not expired
        !            56:                        result.put(*key, NEW VString(*data));
1.4       parser     57:        }
                     58: 
                     59:        return &result;
1.1       parser     60: }
                     61: 
                     62: #endif

E-mail: