From b4d45cd7a8836be87f4c2ddec2f09a326e5b502c Mon Sep 17 00:00:00 2001 From: Rich Prohaska Date: Mon, 31 Dec 2007 15:00:07 +0000 Subject: [PATCH] add DbEnv::set_errcall closes #228 git-svn-id: file:///svn/tokudb@1441 c7de825b-a66e-492c-adef-691d508d4ae1 --- cxx/dbenv.cpp | 10 ++++++++++ include/db_cxx.h | 16 ++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/cxx/dbenv.cpp b/cxx/dbenv.cpp index 4ba97afad5e..250829f6845 100644 --- a/cxx/dbenv.cpp +++ b/cxx/dbenv.cpp @@ -109,3 +109,13 @@ void DbEnv::err(int error, const char *fmt, ...) { void DbEnv::set_errfile(FILE *errfile) { the_env->set_errfile(the_env, errfile); } + +extern "C" void toku_db_env_errcall_c(DB_ENV *dbenv_c, const char *errpfx, const char *msg) { + DbEnv *dbenv = (DbEnv *) dbenv_c->api1_internal; + dbenv->errcall(dbenv, errpfx, msg); +} + +void DbEnv::set_errcall(void (*db_errcall_fcn)(const DbEnv *, const char *, const char *)) { + errcall = db_errcall_fcn; + the_env->set_errcall(the_env, toku_db_env_errcall_c); +} diff --git a/include/db_cxx.h b/include/db_cxx.h index d479887538e..ce386d59a20 100644 --- a/include/db_cxx.h +++ b/include/db_cxx.h @@ -97,21 +97,31 @@ class Db { } /* C++ analogues of the C functions. */ + int open(DbTxn */*txn*/, const char */*name*/, const char */*subname*/, DBTYPE, u_int32_t/*flags*/, int/*mode*/); int close(u_int32_t /*flags*/); + int cursor(DbTxn */*txn*/, Dbc **/*cursorp*/, u_int32_t /*flags*/); + int del(DbTxn */*txn*/, Dbt */*key*/, u_int32_t /*flags*/); + int get(DbTxn */*txn*/, Dbt */*key*/, Dbt */*data*/, u_int32_t /*flags*/); int pget(DbTxn *, Dbt *, Dbt *, Dbt *, u_int32_t); - int open(DbTxn */*txn*/, const char */*name*/, const char */*subname*/, DBTYPE, u_int32_t/*flags*/, int/*mode*/); + int put(DbTxn *, Dbt *, Dbt *, u_int32_t); + int get_flags(u_int32_t *); int set_flags(u_int32_t); + int set_pagesize(u_int32_t); + int remove(const char *file, const char *database, u_int32_t flags); + int set_bt_compare(bt_compare_fcn_type bt_compare_fcn); int set_bt_compare(int (*)(Db *, const Dbt *, const Dbt *)); + int set_dup_compare(dup_compare_fcn_type dup_compare_fcn); int set_dup_compare(int (*)(Db *, const Dbt *, const Dbt *)); + int associate(DbTxn *, Db *, int (*)(Db *, const Dbt *, const Dbt *, Dbt *), u_int32_t); /* the cxx callbacks must be public so they can be called by the c callback. But it's really private. */ @@ -152,12 +162,14 @@ class DbEnv { void set_errpfx(const char *errpfx); void err(int error, const char *fmt, ...); void set_errfile(FILE *errfile); + void set_errcall(void (*)(const DbEnv *, const char *, const char *)); int do_no_exceptions; // This should be private!!! + void (*errcall)(const DbEnv *, const char *, const char *); private: DB_ENV *the_env; - + DbEnv(DB_ENV *, u_int32_t /*flags*/); int maybe_throw_error(int /*err*/) throw (DbException); static int maybe_throw_error(int, DbEnv*, int /*no_exceptions*/) throw (DbException);