From a58dc6af93c8f56ec032e02ba727dc737068abee Mon Sep 17 00:00:00 2001 From: "Bradley C. Kuszmaul" Date: Mon, 17 Dec 2007 22:00:54 +0000 Subject: [PATCH] Start trying to write a c++ interface. Addresses #197. git-svn-id: file:///svn/tokudb@1175 c7de825b-a66e-492c-adef-691d508d4ae1 --- cxx/Makefile | 2 ++ cxx/db_cxx.h | 26 ++++++++++++++++++++++++++ cxx/dbt.cpp | 6 ++++++ cxx/test1.cpp | 12 ++++++++++++ 4 files changed, 46 insertions(+) create mode 100644 cxx/Makefile create mode 100644 cxx/db_cxx.h create mode 100644 cxx/dbt.cpp create mode 100644 cxx/test1.cpp diff --git a/cxx/Makefile b/cxx/Makefile new file mode 100644 index 00000000000..eb9fc30c6ec --- /dev/null +++ b/cxx/Makefile @@ -0,0 +1,2 @@ +CPPFLAGS = -I../include +test1: test1.o dbt.o diff --git a/cxx/db_cxx.h b/cxx/db_cxx.h new file mode 100644 index 00000000000..17748a989a9 --- /dev/null +++ b/cxx/db_cxx.h @@ -0,0 +1,26 @@ +#include +#include + +class Dbt; + +// DBT and Dbt objects are interchangeable. So watch out if you use Dbt to make other classes (e.g., with subclassing) +class Dbt : private DBT +{ + public: + + void * get_data(void) const { return data; } + void set_data(void *p) { data = p; } + + u_int32_t get_size(void) const { return size; } + void set_size(u_int32_t p) { size = p; } + + DBT *get_DBT(void) { return (DBT*)this; } + + Dbt(void); + ~Dbt(); + + private: + // Nothing here. +} +; + diff --git a/cxx/dbt.cpp b/cxx/dbt.cpp new file mode 100644 index 00000000000..d8d163d9cb9 --- /dev/null +++ b/cxx/dbt.cpp @@ -0,0 +1,6 @@ +#include "db_cxx.h" + +Dbt::Dbt(void) { + DBT *dbt = this; + memset(dbt, 0, sizeof(*dbt)); +} diff --git a/cxx/test1.cpp b/cxx/test1.cpp new file mode 100644 index 00000000000..b405afc7767 --- /dev/null +++ b/cxx/test1.cpp @@ -0,0 +1,12 @@ +#include + + +#include +using namespace std; +int main() +{ + Dbt dbt; + dbt.set_size(3); + cout << "Hello World!" << endl; cout << "Welcome to C++ Programming" << endl; + return 0; +}