#include "../lmdb-safe.hh" #include using namespace std; using namespace LMDBSafe; template struct Pair { First first; Second second; }; int main(int argc, char**) { auto env = getMDBEnv("resize", MDB_NOSUBDIR | MDB_NOSYNC, 0600); auto main = env->openDB("ahu", MDB_CREATE ); MDBInVal key("counter"); auto rwtxn = env->getRWTransaction(); rwtxn->put(main, "counter", "1234"); rwtxn->put(main, MDBInVal::fromStruct(Pair{12,13}), "hoi dan 12,13"); rwtxn->put(main, MDBInVal::fromStruct(Pair{14,15}), MDBInVal::fromStruct(Pair{20,23})); MDBOutVal out; if(!rwtxn->get(main, MDBInVal::fromStruct(Pair{12,13}), out)) cout << "Got: " << out.get() << endl; else cout << "Got nothing!1"<get(main, MDBInVal::fromStruct(Pair{14,15}), out)) { auto res = out.get_struct>(); cout << "Got: " << res.first<<", "<put(main, 12.12, 7.3); if(!rwtxn->get(main, 12.12, out)) { cout<<"Got: "<< out.get() <commit(); return 0; if(argc==1) { for(;;) { auto rotxn = env->getROTransaction(); MDBOutVal data; if(!rotxn->get(main, key, data)) { cout<<"Counter is "<() << endl; cout <() << endl; cout<() << endl; struct Bert { uint16_t x,y; }; auto b = data.get_struct(); cout<() << endl; } else cout<<"Didn't find it"<getRWTransaction(); txn->put(main, key, MDBInVal(n)); for(unsigned int k=0; k < 100; ++k) txn->put(main, MDBInVal(n+1000*k), MDBInVal(n+1000*k)); txn->commit(); } } }