Commit 686d25d5 authored by Bradley C. Kuszmaul's avatar Bradley C. Kuszmaul

More fiddling around with c++. Addresses #197.

git-svn-id: file:///svn/tokudb@1177 c7de825b-a66e-492c-adef-691d508d4ae1
parent bf69b717
CPPFLAGS = -I../include
CC = c++
test1: test1.o dbt.o
test1: test1.o dbt.o db.o
#include "db_cxx.h"
Db::~Db() {
if (!the_db) {
the_db->close(db, 0);
the_db->toku_internal = 0;
// Do we need to clean up "private environments"?
}
}
int DB::close (u_int32_t flags) {
if (!the_db) {
return EINVAL;
}
int ret = the_db->close(flags);
the_db->toku_internal = 0;
// Do we need to clean up "private environments"?
return ret;
}
......@@ -21,6 +21,39 @@ class Dbt : private DBT
private:
// Nothing here.
}
;
};
class Db {
public:
/* Functions to make C++ work, defined in the BDB C++ API documents */
Db(DbEnv *dbenv, u_int32_t flags);
~Db();
DB *Db::get_DB(void) {
return the_db;
}
const DB *Db::get_const_DB() const {
return the_db;
}
static Db *Db::get_Db(DB *db) {
return (Db*)db->toku_internal;
}
static const Db *Db::get_const_Db(const DB *db) {
return (Db*)db->toku_internal;
}
/* C++ analogues of the C functions. */
int close(u_int32_t /*flags*/);
int cursor(DbTxn */*txnid*/, Dbc **/*cursorp*/, u_int32_t /*flags*/);
int del(DbTxn */*txnid*/, Dbt */*key*/, u_int32_t /*flags*/);
int get(DbTxn */*txnid*/, Dbt */*key*/, Dbt */*data*/, u_int32_t /*flags*/);
int open(DbTxn */*txnid*/, const char */*name*/, const char */*subname*/, DBTYPE, u_int32_t, int);
int put(DbTxn *, Dbt *, Dbt *, u_int32_t);
int get_flags(u_int32_t *);
int set_flags(u_int32_t);
private:
DB *the_db;
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment