aboutsummaryrefslogtreecommitdiff
path: root/src/db.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.hh')
-rw-r--r--src/db.hh25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/db.hh b/src/db.hh
index 57b6e4d8e..4bac943e5 100644
--- a/src/db.hh
+++ b/src/db.hh
@@ -3,6 +3,7 @@
#include <string>
#include <list>
+#include <map>
#include <db_cxx.h>
@@ -26,6 +27,7 @@ public:
Transaction(Database & _db);
~Transaction();
+ void abort();
void commit();
};
@@ -33,6 +35,9 @@ public:
#define noTxn Transaction()
+typedef unsigned int TableId; /* table handles */
+
+
class Database
{
friend class Transaction;
@@ -40,10 +45,12 @@ class Database
private:
DbEnv * env;
+ TableId nextId;
+ map<TableId, Db *> tables;
+
void requireEnv();
- Db * openDB(const Transaction & txn,
- const string & table, bool create);
+ Db * getDb(TableId table);
public:
Database();
@@ -51,24 +58,24 @@ public:
void open(const string & path);
- void createTable(const string & table);
+ TableId openTable(const string & table);
- bool queryString(const Transaction & txn, const string & table,
+ bool queryString(const Transaction & txn, TableId table,
const string & key, string & data);
- bool queryStrings(const Transaction & txn, const string & table,
+ bool queryStrings(const Transaction & txn, TableId table,
const string & key, Strings & data);
- void setString(const Transaction & txn, const string & table,
+ void setString(const Transaction & txn, TableId table,
const string & key, const string & data);
- void setStrings(const Transaction & txn, const string & table,
+ void setStrings(const Transaction & txn, TableId table,
const string & key, const Strings & data);
- void delPair(const Transaction & txn, const string & table,
+ void delPair(const Transaction & txn, TableId table,
const string & key);
- void enumTable(const Transaction & txn, const string & table,
+ void enumTable(const Transaction & txn, TableId table,
Strings & keys);
};