File: cgdbm.h

package info (click to toggle)
sms-pl 2.1.0-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 376 kB
  • ctags: 355
  • sloc: cpp: 2,618; perl: 109; makefile: 103; sh: 26
file content (78 lines) | stat: -rw-r--r-- 1,679 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef __cgdbm_h_
#define __cgdbm_h_

#include <stdlib.h>
#include <string>
#include <gdbm.h>
#include <exception>

// typy danych rozpoznawane przez klase Cdatum - takich typow mozna uzywac
// bezposrednio w konstruktorach

class Cdatum
{
protected:
	datum dat;
   void Clear();
public:
   Cdatum();
   Cdatum(const Cdatum &cd);
   Cdatum(const datum &d);
   Cdatum(const void *ptr, int size);
   Cdatum(const std::string &str);
   Cdatum(long val);
   Cdatum(float val);
   virtual ~Cdatum();
   Cdatum &operator=(const Cdatum &cd);
   Cdatum &operator=(const datum &d);

   bool isNull() { return dat.dptr==NULL; };

   operator datum&();
   operator std::string();
   operator long();
   operator float();
   operator const void*();
};    

class Cgdbm
{
public:
	class Cgdbm_exception : public std::exception {
		public:
		Cgdbm_exception() {};
	};
protected:
   std::string filename;     
   GDBM_FILE db;
   Cdatum tmp_key;
public:
   Cgdbm() : db(NULL) {};
   Cgdbm(const std::string &_filename, int block_size, int read_write, int mode = 0600);
   virtual ~Cgdbm();

   bool Open(const std::string &_filename, int block_size, int read_write, int mode = 0600);
   void Close();
   
   bool store(Cdatum &key, Cdatum &content, int flag);
   bool insert(Cdatum &key, Cdatum &content);
   bool replace(Cdatum &key, Cdatum &content);

   Cdatum operator[](Cdatum &key);
   Cdatum begin();
   Cdatum next();

   bool Exists(Cdatum &key);

   bool Delete(Cdatum &key);

   bool Reorganize();
   void Sync();
   int SetOpt(int option, int *value, int size);

   const char *StrError(gdbm_error err = (gdbm_error)-1);
   const char *Version();
   const int Status();
};

#endif