source: tags/0.56/tmp/gdbm_pool.h @ 9

Last change on this file since 9 was 9, checked in by willem, 11 years ago

willem

File size: 1.9 KB
Line 
1#ifndef GDBM_POOL_H
2#define GDBM_POOL_H
3#include <string>
4#include "gdbm.h"
5 
6class gdbm_pool
7{
8  private:
9    typedef unsigned long long intkeytype;
10    //typedef char charkeytype[16];
11    typedef unsigned long long charkeytype;
12    const static int keylen = sizeof(charkeytype);  // including trailing zero
13    const static int maxvallen = 1024;  // including trailing zero
14    char* file_name;        // gdmb file name
15    std::string value;      // value of requested record
16    charkeytype key;        // record to search or insert
17    std::string statuskey;  // record to store the status
18    std::string nextkey;    // key for next datarecord
19    std::string lastkey;    // key for getting last datakey
20    std::string firstkey;   // key for getting first key;
21    charkeytype zerokey;    // key for getting zero record
22    GDBM_FILE dbf;          // handle for access database
23    static const int sync = GDBM_SYNC;
24    //static const int sync = 0;
25    struct datarecord
26    {
27      charkeytype prev;
28      charkeytype next;
29      charkeytype retrieved;
30      char value[maxvallen];
31    } ;
32    struct zerorecord
33    {
34      charkeytype next;
35      charkeytype first;
36      charkeytype last;
37      charkeytype count;
38    } zero;
39
40
41    //void genkey(charkeytype key,const intkeytype n);
42    void genkey(charkeytype &key,const charkeytype n);
43
44
45  int get_record(datarecord &r,charkeytype &k);
46  int put_record(datarecord &r,charkeytype &k);
47  int get_zero(void);
48  int put_zero(void);
49
50
51  public:
52  // constructor ()
53  gdbm_pool();
54
55  // destructor
56
57  ~gdbm_pool();
58
59  void set_file_name(std::string filename);
60  std::string get_file_name(void);
61
62  int create_db(void);
63  int add_line(std::string line);
64  int get_line(std::string &line);
65
66  int open_db(char rw);
67  int close_db(void);
68    const static int NOFILENAME  = 1;
69    const static int OPENERROR   = 2;
70    const static int STOREERROR  = 3;
71    const static int FETCHERROR  = 4;
72    const static int NOTFOUND    = 5;
73
74};
75#endif
Note: See TracBrowser for help on using the repository browser.