dbind
Introduction
dbind is an experimental database library for C++0x. It provides template metaprogramming facilities for
operating on database primitives: lists and tables.
Download
Installing and using
cd dbind
cmake .
make install
g++46 -std=c++0x -O3 example.cc -ldbind
Example
#include
#include
#include
#include
using namespace dbind;
using namespace std;
DBIND_FIELD(a, int)
DBIND_FIELD(b, char)
DBIND_SCHEMA(s, (a, b))
int main() {
table<s> t;
t.push(5, 'x');
t.push(6, 'y');
t.push(7, 'z');
cout << display(t) << '\n';
auto t1 = t.select(_a != 6);
cout << display(t1) << '\n';
auto t2 = t1.update<a>(_a + 10);
cout << display(t2) << '\n';
auto u = make_table<b, a>(list<char>{ 'z', 'w' },
list<int> { 42, 43 });
auto t3 = t2.left_join<b>(u);
cout << display(t3) << '\n';
return 0;
}
|
_a__b_
5 x
6 y
7 z
_a__b_
5 x
7 z
_a___b_
15 x
17 z
_a___b_
15 x
42 z
|