mirror of
https://github.com/MariaDB/server.git
synced 2025-01-22 14:54:20 +01:00
Start trying to write a c++ interface. Addresses #197.
git-svn-id: file:///svn/tokudb@1175 c7de825b-a66e-492c-adef-691d508d4ae1
This commit is contained in:
parent
d7319d8d19
commit
a58dc6af93
4 changed files with 46 additions and 0 deletions
2
cxx/Makefile
Normal file
2
cxx/Makefile
Normal file
|
@ -0,0 +1,2 @@
|
|||
CPPFLAGS = -I../include
|
||||
test1: test1.o dbt.o
|
26
cxx/db_cxx.h
Normal file
26
cxx/db_cxx.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#include <db.h>
|
||||
#include <string.h>
|
||||
|
||||
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.
|
||||
}
|
||||
;
|
||||
|
6
cxx/dbt.cpp
Normal file
6
cxx/dbt.cpp
Normal file
|
@ -0,0 +1,6 @@
|
|||
#include "db_cxx.h"
|
||||
|
||||
Dbt::Dbt(void) {
|
||||
DBT *dbt = this;
|
||||
memset(dbt, 0, sizeof(*dbt));
|
||||
}
|
12
cxx/test1.cpp
Normal file
12
cxx/test1.cpp
Normal file
|
@ -0,0 +1,12 @@
|
|||
#include <db_cxx.h>
|
||||
|
||||
|
||||
#include <iostream>
|
||||
using namespace std;
|
||||
int main()
|
||||
{
|
||||
Dbt dbt;
|
||||
dbt.set_size(3);
|
||||
cout << "Hello World!" << endl; cout << "Welcome to C++ Programming" << endl;
|
||||
return 0;
|
||||
}
|
Loading…
Add table
Reference in a new issue