1 #include "../impl/sqlite3_traits.hpp" // sqlite3 traits
2 #include "demo_cxx_gen.hpp" // generated
8 typedef sqlgg
<sqlite3_traits
> gen_t
;
9 typedef long long int64
;
11 struct output_transfers
13 void operator()(std::string
const& fullname
, int total
)
15 cout
<< fullname
<< " = " << total
<< endl
;
21 void operator()(std::string
const& surname
)
23 cout
<< surname
<< endl
;
30 sqlite3_open(":memory:", &db
);
38 // add all person records
39 gen
.add_person("John","Black");
40 int64 john
= sqlite3_last_insert_rowid(db
);
41 gen
.add_person("Ivan","Petrov");
42 int64 ivan
= sqlite3_last_insert_rowid(db
);
43 gen
.add_person("Sancho","Alvares");
44 int64 sancho
= sqlite3_last_insert_rowid(db
);
46 // add money relations
47 gen
.add_money(john
,ivan
,200);
48 gen
.add_money(john
,sancho
,100);
49 gen
.add_money(john
,sancho
,250);
50 gen
.add_money(sancho
,ivan
,300);
52 // summarize by person
53 cout
<< "Total transfers:" << endl
;
54 gen
.calc_total(output_transfers());
57 cout
<< "Donors:" << endl
;
58 gen
.list_donors("petrov",100,output_donors());
60 // properly close database