diff --git a/Makefile b/Makefile index 15c7d1d..8474858 100644 --- a/Makefile +++ b/Makefile @@ -3,10 +3,11 @@ #INCLUDES=-Ilmdb-LMDB_0.9.22/libraries/liblmdb LIBS=-llmdb -CXXFLAGS:=-std=gnu++17 -Wall -O2 -MMD -MP -ggdb -pthread $(INCLUDES) # -fsanitize=address -fno-omit-frame-pointer +CXXVERSIONFLAG= -std=gnu++11 +CXXFLAGS:= $(CXXVERSIONFLAG) -Wall -O2 -MMD -MP -ggdb -pthread $(INCLUDES) # -fsanitize=address -fno-omit-frame-pointer CFLAGS:= -Wall -O2 -MMD -MP -ggdb -CXXVERSIONFLAG= -std=gnu++17 + PROGRAMS = lmdb-test basic-example scale-example multi-example rel-example \ resize-example diff --git a/README.md b/README.md index 34956dc..96eef10 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ # lmdb-safe -A safe modern & performant C++ wrapper of LMDB. For now briefly only -available for C++17, will support C++ 11 again soon. MIT licensed. - +A safe modern & performant C++ wrapper of LMDB. +Requires C++17, or C++11 + Boost. [LMDB](http://www.lmdb.tech/doc/index.html) is an outrageously fast key/value store with semantics that make it highly interesting for many applications. Of specific note, besides speed, is the full support for diff --git a/basic-example.cc b/basic-example.cc index 85d0143..40216db 100644 --- a/basic-example.cc +++ b/basic-example.cc @@ -1,4 +1,5 @@ #include "lmdb-safe.hh" +using namespace std; void checkLMDB(MDBEnv* env, MDBDbi dbi) { diff --git a/lmdb-safe.cc b/lmdb-safe.cc index 0f34ae4..df10c31 100644 --- a/lmdb-safe.cc +++ b/lmdb-safe.cc @@ -6,6 +6,8 @@ #include #include +using namespace std; + static string MDBError(int rc) { return mdb_strerror(rc); diff --git a/lmdb-safe.hh b/lmdb-safe.hh index 7fc5960..dec982a 100644 --- a/lmdb-safe.hh +++ b/lmdb-safe.hh @@ -1,3 +1,4 @@ +#pragma once #include #include #include @@ -9,7 +10,13 @@ #include #include -using namespace std; +#if __cplusplus < 201703L +#include +using boost::string_view; +#else +using std::string_view; +#endif + /* open issues: * @@ -49,15 +56,6 @@ public: ~MDBEnv() { - for(auto& a : d_RWtransactionsOut) { - if(a.second) - cout << "thread " < inline std::string MDBOutVal::get() return std::string((char*)d_mdbval.mv_data, d_mdbval.mv_size); } -template<> inline std::string_view MDBOutVal::get() +template<> inline string_view MDBOutVal::get() { - return std::string_view((char*)d_mdbval.mv_data, d_mdbval.mv_size); + return string_view((char*)d_mdbval.mv_data, d_mdbval.mv_size); } class MDBInVal @@ -169,7 +167,7 @@ public: d_mdbval.mv_data = (void*)&v[0]; } - MDBInVal(const string& v) + MDBInVal(const std::string& v) { d_mdbval.mv_size = v.size(); d_mdbval.mv_data = (void*)&v[0]; @@ -249,7 +247,7 @@ public: MDBOutVal out; int rc = get(dbi, key, out); if(!rc) - val = out.get(); + val = out.get(); return rc; } @@ -429,7 +427,7 @@ public: MDBOutVal out; int rc = get(dbi, key, out); if(!rc) - val = out.get(); + val = out.get(); return rc; } @@ -483,7 +481,6 @@ public: } MDBRWCursor(MDBRWCursor&& rhs) { - cout<<"Got move constructed, this was: "<<(void*)&rhs<<", now: "<<(void*)this< #include #include +using namespace std; static void closeTest() { diff --git a/multi-example.cc b/multi-example.cc index d751c91..0a02d31 100644 --- a/multi-example.cc +++ b/multi-example.cc @@ -1,4 +1,5 @@ #include "lmdb-safe.hh" +using namespace std; int main() { @@ -15,7 +16,7 @@ int main() txn.put(dbi, "lmdb", "c"); txn.put(dbi, "mdb", "old name"); - std::string_view v1; + string_view v1; if(!txn.get(dbi, "mdb", v1)) { cout< #include #include - +using namespace std; struct Record { diff --git a/scale-example.cc b/scale-example.cc index f18a4c0..0ee9065 100644 --- a/scale-example.cc +++ b/scale-example.cc @@ -1,5 +1,5 @@ #include "lmdb-safe.hh" - +using namespace std; struct MDBVal {