15#error "<lmdb++.h> requires a C++ compiler"
18#if __cplusplus < 201703L
19#error "<lmdb++.h> requires a C++17 compiler (CXXFLAGS='-std=c++17')"
49 class key_exist_error;
50 class not_found_error;
51 class corrupted_error;
53 class version_mismatch_error;
71 [[noreturn]]
static inline void raise(
const char*
origin,
int rc);
77 const int rc) noexcept
84 int code() const noexcept {
91 const char*
origin() const noexcept {
98 virtual const char*
what() const noexcept {
99 static thread_local char buffer[1024];
100 std::snprintf(buffer,
sizeof(buffer),
137 using runtime_error::runtime_error;
147 using runtime_error::runtime_error;
157 using fatal_error::fatal_error;
167 using fatal_error::fatal_error;
177 using fatal_error::fatal_error;
187 using runtime_error::runtime_error;
198 using runtime_error::runtime_error;
231 static inline void env_open(MDB_env* env,
232 const char* path,
unsigned int flags,
mode mode);
233#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
234 static inline void env_copy(MDB_env* env,
const char* path,
unsigned int flags);
235 static inline void env_copy_fd(MDB_env* env, mdb_filehandle_t fd,
unsigned int flags);
237 static inline void env_copy(MDB_env* env,
const char* path);
238 static inline void env_copy_fd(MDB_env* env, mdb_filehandle_t fd);
240 static inline void env_stat(MDB_env* env, MDB_stat* stat);
241 static inline void env_info(MDB_env* env, MDB_envinfo* stat);
242 static inline void env_sync(MDB_env* env,
bool force);
243 static inline void env_close(MDB_env* env)
noexcept;
244 static inline void env_set_flags(MDB_env* env,
unsigned int flags,
bool onoff);
245 static inline void env_get_flags(MDB_env* env,
unsigned int* flags);
246 static inline void env_get_path(MDB_env* env,
const char** path);
247 static inline void env_get_fd(MDB_env* env, mdb_filehandle_t* fd);
253#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
259 static inline void reader_check(MDB_env *env,
int *dead);
268 const int rc = ::mdb_env_create(
env);
269 if (rc != MDB_SUCCESS) {
280 const char*
const path,
281 const unsigned int flags,
283 const int rc = ::mdb_env_open(
env, path, flags,
mode);
284 if (rc != MDB_SUCCESS) {
296#
if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
297 const char*
const path,
298 const unsigned int flags = 0) {
299 const int rc = ::mdb_env_copy2(
env, path, flags);
301 const char*
const path) {
302 const int rc = ::mdb_env_copy(
env, path);
304 if (rc != MDB_SUCCESS) {
316#
if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
317 const mdb_filehandle_t fd,
318 const unsigned int flags = 0) {
319 const int rc = ::mdb_env_copyfd2(
env, fd, flags);
321 const mdb_filehandle_t fd) {
322 const int rc = ::mdb_env_copyfd(
env, fd);
324 if (rc != MDB_SUCCESS) {
335 MDB_stat*
const stat) {
336 const int rc = ::mdb_env_stat(
env, stat);
337 if (rc != MDB_SUCCESS) {
348 MDB_envinfo*
const stat) {
349 const int rc = ::mdb_env_info(
env, stat);
350 if (rc != MDB_SUCCESS) {
361 const bool force =
true) {
362 const int rc = ::mdb_env_sync(
env, force);
363 if (rc != MDB_SUCCESS) {
373 ::mdb_env_close(
env);
382 const unsigned int flags,
383 const bool onoff =
true) {
384 const int rc = ::mdb_env_set_flags(
env, flags, onoff ? 1 : 0);
385 if (rc != MDB_SUCCESS) {
396 unsigned int*
const flags) {
397 const int rc = ::mdb_env_get_flags(
env, flags);
398 if (rc != MDB_SUCCESS) {
410 const int rc = ::mdb_env_get_path(
env, path);
411 if (rc != MDB_SUCCESS) {
422 mdb_filehandle_t*
const fd) {
423 const int rc = ::mdb_env_get_fd(
env, fd);
424 if (rc != MDB_SUCCESS) {
435 const std::size_t size) {
436 const int rc = ::mdb_env_set_mapsize(
env, size);
437 if (rc != MDB_SUCCESS) {
448 const unsigned int count) {
449 const int rc = ::mdb_env_set_maxreaders(
env, count);
450 if (rc != MDB_SUCCESS) {
461 unsigned int*
const count) {
462 const int rc = ::mdb_env_get_maxreaders(
env, count);
463 if (rc != MDB_SUCCESS) {
474 const MDB_dbi count) {
475 const int rc = ::mdb_env_set_maxdbs(
env, count);
476 if (rc != MDB_SUCCESS) {
484static inline unsigned int
486 const int rc = ::mdb_env_get_maxkeysize(
env);
490 return static_cast<unsigned int>(rc);
493#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
502 const int rc = ::mdb_env_set_userctx(
env, ctx);
503 if (rc != MDB_SUCCESS) {
509#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
516 return ::mdb_env_get_userctx(
env);
522 const int rc = ::mdb_reader_check(
env, dead);
523 if (rc != MDB_SUCCESS) {
533 MDB_env* env, MDB_txn* parent,
unsigned int flags, MDB_txn** txn);
534 static inline MDB_env*
txn_env(MDB_txn* txn)
noexcept;
536 static inline std::size_t txn_id(MDB_txn* txn)
noexcept;
539 static inline void txn_abort(MDB_txn* txn)
noexcept;
540 static inline void txn_reset(MDB_txn* txn)
noexcept;
541 static inline void txn_renew(MDB_txn* txn);
550 MDB_txn*
const parent,
551 const unsigned int flags,
553 const int rc = ::mdb_txn_begin(
env, parent, flags,
txn);
554 if (rc != MDB_SUCCESS) {
562static inline MDB_env*
564 return ::mdb_txn_env(
txn);
571static inline std::size_t
572lmdb::txn_id(MDB_txn*
const txn)
noexcept {
573 return ::mdb_txn_id(txn);
583 const int rc = ::mdb_txn_commit(
txn);
584 if (rc != MDB_SUCCESS) {
594 ::mdb_txn_abort(
txn);
602 ::mdb_txn_reset(
txn);
611 const int rc = ::mdb_txn_renew(
txn);
612 if (rc != MDB_SUCCESS) {
622 MDB_txn* txn,
const char* name,
unsigned int flags, MDB_dbi* dbi);
623 static inline void dbi_stat(MDB_txn* txn, MDB_dbi dbi, MDB_stat* stat);
624 static inline void dbi_flags(MDB_txn* txn, MDB_dbi dbi,
unsigned int* flags);
625 static inline void dbi_close(MDB_env* env, MDB_dbi dbi)
noexcept;
626 static inline void dbi_drop(MDB_txn* txn, MDB_dbi dbi,
bool del);
627 static inline void dbi_set_compare(MDB_txn* txn, MDB_dbi dbi, MDB_cmp_func* cmp);
628 static inline void dbi_set_dupsort(MDB_txn* txn, MDB_dbi dbi, MDB_cmp_func* cmp);
629 static inline void dbi_set_relfunc(MDB_txn* txn, MDB_dbi dbi, MDB_rel_func* rel);
630 static inline void dbi_set_relctx(MDB_txn* txn, MDB_dbi dbi,
void* ctx);
631 static inline bool dbi_get(MDB_txn* txn, MDB_dbi dbi,
const MDB_val* key, MDB_val* data);
632 static inline bool dbi_put(MDB_txn* txn, MDB_dbi dbi,
const MDB_val* key, MDB_val* data,
unsigned int flags);
633 static inline bool dbi_del(MDB_txn* txn, MDB_dbi dbi,
const MDB_val* key,
const MDB_val* data);
644 const char*
const name,
645 const unsigned int flags,
646 MDB_dbi*
const dbi) {
647 const int rc = ::mdb_dbi_open(
txn, name, flags,
dbi);
648 if (rc != MDB_SUCCESS) {
660 MDB_stat*
const result) {
661 const int rc = ::mdb_stat(
txn,
dbi, result);
662 if (rc != MDB_SUCCESS) {
674 unsigned int*
const flags) {
675 const int rc = ::mdb_dbi_flags(
txn,
dbi, flags);
676 if (rc != MDB_SUCCESS) {
686 const MDB_dbi
dbi)
noexcept {
687 ::mdb_dbi_close(
env,
dbi);
696 const bool del =
false) {
697 const int rc = ::mdb_drop(
txn,
dbi, del ? 1 : 0);
698 if (rc != MDB_SUCCESS) {
710 MDB_cmp_func*
const cmp =
nullptr) {
711 const int rc = ::mdb_set_compare(
txn,
dbi, cmp);
712 if (rc != MDB_SUCCESS) {
724 MDB_cmp_func*
const cmp =
nullptr) {
725 const int rc = ::mdb_set_dupsort(
txn,
dbi, cmp);
726 if (rc != MDB_SUCCESS) {
738 MDB_rel_func*
const rel) {
739 const int rc = ::mdb_set_relfunc(
txn,
dbi, rel);
740 if (rc != MDB_SUCCESS) {
753 const int rc = ::mdb_set_relctx(
txn,
dbi, ctx);
754 if (rc != MDB_SUCCESS) {
767 const MDB_val*
const key,
768 MDB_val*
const data) {
769 const int rc = ::mdb_get(
txn,
dbi,
const_cast<MDB_val*
>(key), data);
770 if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
773 return (rc == MDB_SUCCESS);
784 const MDB_val*
const key,
786 const unsigned int flags = 0) {
787 const int rc = ::mdb_put(
txn,
dbi,
const_cast<MDB_val*
>(key), data, flags);
788 if (rc != MDB_SUCCESS && rc != MDB_KEYEXIST) {
791 return (rc == MDB_SUCCESS);
802 const MDB_val*
const key,
803 const MDB_val*
const data =
nullptr) {
804 const int rc = ::mdb_del(
txn,
dbi,
const_cast<MDB_val*
>(key),
const_cast<MDB_val*
>(data));
805 if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
808 return (rc == MDB_SUCCESS);
815 static inline void cursor_open(MDB_txn* txn, MDB_dbi dbi, MDB_cursor** cursor);
816 static inline void cursor_close(MDB_cursor* cursor)
noexcept;
817 static inline void cursor_renew(MDB_txn* txn, MDB_cursor* cursor);
818 static inline MDB_txn*
cursor_txn(MDB_cursor* cursor)
noexcept;
819 static inline MDB_dbi
cursor_dbi(MDB_cursor* cursor)
noexcept;
820 static inline bool cursor_get(MDB_cursor* cursor, MDB_val* key, MDB_val* data, MDB_cursor_op op);
821 static inline bool cursor_put(MDB_cursor* cursor, MDB_val* key, MDB_val* data,
unsigned int flags);
822 static inline void cursor_del(MDB_cursor* cursor,
unsigned int flags);
823 static inline void cursor_count(MDB_cursor* cursor, std::size_t& count);
833 MDB_cursor**
const cursor) {
835 if (rc != MDB_SUCCESS) {
845 ::mdb_cursor_close(
cursor);
854 MDB_cursor*
const cursor) {
855 const int rc = ::mdb_cursor_renew(
txn,
cursor);
856 if (rc != MDB_SUCCESS) {
864static inline MDB_txn*
866 return ::mdb_cursor_txn(
cursor);
874 return ::mdb_cursor_dbi(
cursor);
885 const MDB_cursor_op op) {
886 const int rc = ::mdb_cursor_get(
cursor, key, data, op);
887 if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
890 return (rc == MDB_SUCCESS);
901 const unsigned int flags = 0) {
902 const int rc = ::mdb_cursor_put(
cursor, key, data, flags);
903 if (rc != MDB_SUCCESS && rc != MDB_KEYEXIST) {
906 return (rc == MDB_SUCCESS);
915 const unsigned int flags = 0) {
916 const int rc = ::mdb_cursor_del(
cursor, flags);
917 if (rc != MDB_SUCCESS) {
928 std::size_t& count) {
929 const int rc = ::mdb_cursor_count(
cursor, &count);
930 if (rc != MDB_SUCCESS) {
950 MDB_env* _handle{
nullptr};
953 static constexpr unsigned int default_flags = 0;
954 static constexpr mode default_mode = 0644;
962 static env create(
const unsigned int flags = default_flags) {
963 MDB_env* handle{
nullptr};
966 assert(handle !=
nullptr);
985 env(MDB_env*
const handle) noexcept
992 std::swap(_handle, other._handle);
999 if (
this != &other) {
1000 std::swap(_handle, other._handle);
1009 try { close(); }
catch (...) {}
1015 operator MDB_env*()
const noexcept {
1032 void sync(
const bool force =
true) {
1064 const unsigned int flags = default_flags,
1076 const bool onoff =
true) {
1124 MDB_txn* _handle{
nullptr};
1127 static constexpr unsigned int default_flags = 0;
1138 MDB_txn*
const parent =
nullptr,
1139 const unsigned int flags = default_flags) {
1140 MDB_txn* handle{
nullptr};
1143 assert(handle !=
nullptr);
1153 txn(MDB_txn*
const handle) noexcept
1154 : _handle{handle} {}
1160 std::swap(_handle, other._handle);
1167 if (
this != &other) {
1168 std::swap(_handle, other._handle);
1178 try { abort(); }
catch (...) {}
1186 operator MDB_txn*()
const noexcept {
1200 MDB_env*
env() const noexcept {
1258 MDB_dbi _handle{(std::numeric_limits<MDB_dbi>::max)()};
1261 static constexpr unsigned int default_flags = 0;
1262 static constexpr unsigned int default_put_flags = 0;
1274 const char*
const name =
nullptr,
1275 const unsigned int flags = default_flags) {
1287 : _handle{(std::numeric_limits<MDB_dbi>::max)()} {}
1294 dbi(
const MDB_dbi handle) noexcept
1295 : _handle{handle} {}
1309 operator MDB_dbi() const noexcept {
1339 unsigned int result{};
1351 return stat(
txn).ms_entries;
1360 const bool del =
false) {
1372 MDB_cmp_func*
const cmp =
nullptr) {
1387 const std::string_view key,
1388 std::string_view& data) {
1389 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1390 MDB_val dataV{data.size(),
const_cast<char*
>(data.data())};
1393 data = std::string_view(
static_cast<char*
>(dataV.mv_data), dataV.mv_size);
1408 const std::string_view key,
1409 std::string_view data,
1410 const unsigned int flags = default_put_flags) {
1411 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1412 MDB_val dataV{data.size(),
const_cast<char*
>(data.data())};
1424 const std::string_view key) {
1425 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1438 const std::string_view key,
1439 const std::string_view val) {
1440 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1441 const MDB_val valV{val.size(),
const_cast<char*
>(val.data())};
1461 MDB_cursor* _handle{
nullptr};
1464 static constexpr unsigned int default_flags = 0;
1475 const MDB_dbi
dbi) {
1476 MDB_cursor* handle{};
1479 assert(handle !=
nullptr);
1490 : _handle{handle} {}
1496 std::swap(_handle, other._handle);
1503 if (
this != &other) {
1504 std::swap(_handle, other._handle);
1513 try { close(); }
catch (...) {}
1519 operator MDB_cursor*()
const noexcept {
1556 MDB_txn*
txn() const noexcept {
1563 MDB_dbi
dbi() const noexcept {
1574 bool get(std::string_view &key,
1575 const MDB_cursor_op op) {
1576 MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1579 key = std::string_view(
static_cast<char*
>(keyV.mv_data), keyV.mv_size);
1592 bool get(std::string_view &key,
1593 std::string_view &val,
1594 const MDB_cursor_op op) {
1595 MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1596 MDB_val valV{val.size(),
const_cast<char*
>(val.data())};
1599 key = std::string_view(
static_cast<char*
>(keyV.mv_data), keyV.mv_size);
1600 val = std::string_view(
static_cast<char*
>(valV.mv_data), valV.mv_size);
1615 bool put(
const std::string_view &key,
1616 const std::string_view &val,
1617 const unsigned int flags = 0) {
1618 MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1619 MDB_val valV{val.size(),
const_cast<char*
>(val.data())};
1629 void del(
unsigned int flags = 0) {
1649 template<
typename T>
1651 return std::string_view(
reinterpret_cast<char*
>(v),
sizeof(*v));
1659 template<
typename T>
1660 static inline std::string_view
to_sv(
const T &v) {
1661 return std::string_view(
reinterpret_cast<const char*
>(std::addressof(v)),
sizeof(v));
1669 template<
typename T>
1671 if (v.size() !=
sizeof(T))
error::raise(
"from_sv", MDB_BAD_VALSIZE);
1672 return reinterpret_cast<T*
>(
const_cast<char*
>(v.data()));
1680 template<
typename T>
1682 if (v.size() !=
sizeof(T))
error::raise(
"from_sv", MDB_BAD_VALSIZE);
1684 std::memcpy(&ret,
const_cast<char*
>(v.data()),
sizeof(T));
Exception class for MDB_BAD_DBI errors.
Definition lmdb++.h:196
Exception class for MDB_CORRUPTED errors.
Definition lmdb++.h:155
Resource class for MDB_cursor* handles.
Definition lmdb++.h:1459
MDB_cursor * handle() const noexcept
Returns the underlying MDB_cursor* handle.
Definition lmdb++.h:1526
void close() noexcept
Closes this cursor.
Definition lmdb++.h:1536
~cursor() noexcept
Destructor.
Definition lmdb++.h:1512
bool put(const std::string_view &key, const std::string_view &val, const unsigned int flags=0)
Stores key/data pairs into the database.
Definition lmdb++.h:1615
bool get(std::string_view &key, std::string_view &val, const MDB_cursor_op op)
Retrieves a key/value pair from the database.
Definition lmdb++.h:1592
MDB_txn * txn() const noexcept
Returns the cursor's transaction handle.
Definition lmdb++.h:1556
size_t count()
Return count of duplicates for current key.
Definition lmdb++.h:1636
cursor(cursor &&other) noexcept
Move constructor.
Definition lmdb++.h:1495
MDB_dbi dbi() const noexcept
Returns the cursor's database handle.
Definition lmdb++.h:1563
static cursor open(MDB_txn *const txn, const MDB_dbi dbi)
Creates an LMDB cursor.
Definition lmdb++.h:1474
cursor & operator=(cursor &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1502
cursor(MDB_cursor *const handle) noexcept
Constructor.
Definition lmdb++.h:1489
void del(unsigned int flags=0)
Delete current key/data pair.
Definition lmdb++.h:1629
bool get(std::string_view &key, const MDB_cursor_op op)
Retrieves a key from the database.
Definition lmdb++.h:1574
void renew(MDB_txn *const txn)
Renews this cursor.
Definition lmdb++.h:1549
Resource class for MDB_dbi handles.
Definition lmdb++.h:1256
bool put(MDB_txn *const txn, const std::string_view key, std::string_view data, const unsigned int flags=default_put_flags)
Stores a key/value pair into this database.
Definition lmdb++.h:1407
std::size_t size(MDB_txn *const txn) const
Returns the number of records in this database.
Definition lmdb++.h:1350
dbi(const MDB_dbi handle) noexcept
Constructor.
Definition lmdb++.h:1294
bool del(MDB_txn *const txn, const std::string_view key)
Removes a key from this database.
Definition lmdb++.h:1423
dbi & set_compare(MDB_txn *const txn, MDB_cmp_func *const cmp=nullptr)
Sets a custom key comparison function for this database.
Definition lmdb++.h:1371
~dbi() noexcept
Destructor.
Definition lmdb++.h:1300
MDB_stat stat(MDB_txn *const txn) const
Returns statistics for this database.
Definition lmdb++.h:1326
unsigned int flags(MDB_txn *const txn) const
Retrieves the flags for this database handle.
Definition lmdb++.h:1338
dbi() noexcept
Constructor.
Definition lmdb++.h:1286
static dbi open(MDB_txn *const txn, const char *const name=nullptr, const unsigned int flags=default_flags)
Opens a database handle.
Definition lmdb++.h:1273
bool del(MDB_txn *const txn, const std::string_view key, const std::string_view val)
Removes a key/value pair from this database.
Definition lmdb++.h:1437
void drop(MDB_txn *const txn, const bool del=false)
Definition lmdb++.h:1359
MDB_dbi handle() const noexcept
Returns the underlying MDB_dbi handle.
Definition lmdb++.h:1316
bool get(MDB_txn *const txn, const std::string_view key, std::string_view &data)
Retrieves a key/value pair from this database.
Definition lmdb++.h:1386
Resource class for MDB_env* handles.
Definition lmdb++.h:948
env & set_flags(const unsigned int flags, const bool onoff=true)
Definition lmdb++.h:1075
void close() noexcept
Closes this environment, releasing the memory map.
Definition lmdb++.h:1042
env & set_mapsize(const std::size_t size)
Definition lmdb++.h:1085
env & set_max_dbs(const MDB_dbi count)
Definition lmdb++.h:1103
~env() noexcept
Destructor.
Definition lmdb++.h:1008
env(MDB_env *const handle) noexcept
Constructor.
Definition lmdb++.h:985
env(env &&other) noexcept
Move constructor.
Definition lmdb++.h:991
void sync(const bool force=true)
Flushes data buffers to disk.
Definition lmdb++.h:1032
MDB_env * handle() const noexcept
Returns the underlying MDB_env* handle.
Definition lmdb++.h:1022
env & operator=(env &&other) noexcept
Move assignment operator.
Definition lmdb++.h:998
static env create(const unsigned int flags=default_flags)
Creates a new LMDB environment.
Definition lmdb++.h:962
env & open(const char *const path, const unsigned int flags=default_flags, const mode mode=default_mode)
Opens this environment.
Definition lmdb++.h:1063
int reader_check()
Definition lmdb++.h:1049
env & set_max_readers(const unsigned int count)
Definition lmdb++.h:1094
Base class for LMDB exception conditions.
Definition lmdb++.h:63
const char * origin() const noexcept
Returns the origin of the LMDB error.
Definition lmdb++.h:91
const int _code
Definition lmdb++.h:65
virtual const char * what() const noexcept
Returns the underlying LMDB error code.
Definition lmdb++.h:98
error(const char *const origin, const int rc) noexcept
Constructor.
Definition lmdb++.h:76
static void raise(const char *origin, int rc)
Throws an error based on the given LMDB return code.
Definition lmdb++.h:202
int code() const noexcept
Returns the underlying LMDB error code.
Definition lmdb++.h:84
Base class for fatal error conditions.
Definition lmdb++.h:117
Exception class for MDB_KEYEXIST errors.
Definition lmdb++.h:135
Base class for logic error conditions.
Definition lmdb++.h:109
Exception class for MDB_MAP_FULL errors.
Definition lmdb++.h:185
Exception class for MDB_NOTFOUND errors.
Definition lmdb++.h:145
Exception class for MDB_PANIC errors.
Definition lmdb++.h:165
Base class for runtime error conditions.
Definition lmdb++.h:125
Resource class for MDB_txn* handles.
Definition lmdb++.h:1122
MDB_txn * handle() const noexcept
Returns the underlying MDB_txn* handle.
Definition lmdb++.h:1193
void commit()
Commits this transaction.
Definition lmdb++.h:1210
MDB_env * env() const noexcept
Returns the transaction's MDB_env* handle.
Definition lmdb++.h:1200
void abort() noexcept
Aborts this transaction.
Definition lmdb++.h:1221
void reset() noexcept
Resets this read-only transaction.
Definition lmdb++.h:1230
txn & operator=(txn &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1166
~txn() noexcept
Destructor.
Definition lmdb++.h:1176
void renew()
Renews this read-only transaction.
Definition lmdb++.h:1239
txn(txn &&other) noexcept
Move constructor.
Definition lmdb++.h:1159
txn(MDB_txn *const handle) noexcept
Constructor.
Definition lmdb++.h:1153
static txn begin(MDB_env *const env, MDB_txn *const parent=nullptr, const unsigned int flags=default_flags)
Creates a new LMDB transaction.
Definition lmdb++.h:1137
Exception class for MDB_VERSION_MISMATCH errors.
Definition lmdb++.h:175
<lmdb++.h> - C++17 wrapper for LMDB.
Definition lmdb++.h:37
static void env_info(MDB_env *env, MDB_envinfo *stat)
Definition lmdb++.h:347
static void * env_get_userctx(MDB_env *env)
Definition lmdb++.h:515
static void dbi_flags(MDB_txn *txn, MDB_dbi dbi, unsigned int *flags)
Definition lmdb++.h:672
static void cursor_renew(MDB_txn *txn, MDB_cursor *cursor)
Definition lmdb++.h:853
static void env_copy_fd(MDB_env *env, mdb_filehandle_t fd, unsigned int flags)
Definition lmdb++.h:315
static void txn_commit(MDB_txn *txn)
Definition lmdb++.h:582
static void env_open(MDB_env *env, const char *path, unsigned int flags, mode mode)
Definition lmdb++.h:279
static MDB_txn * cursor_txn(MDB_cursor *cursor) noexcept
Definition lmdb++.h:865
static void dbi_drop(MDB_txn *txn, MDB_dbi dbi, bool del)
Definition lmdb++.h:694
static bool dbi_put(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, MDB_val *data, unsigned int flags)
Definition lmdb++.h:782
static void env_create(MDB_env **env)
Definition lmdb++.h:267
static std::string_view to_sv(const T &v)
Creates a std::string_view that points to the memory occupied by v.
Definition lmdb++.h:1660
static unsigned int env_get_max_keysize(MDB_env *env)
Definition lmdb++.h:485
static void cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor)
Definition lmdb++.h:831
static void reader_check(MDB_env *env, int *dead)
Definition lmdb++.h:521
static void env_get_fd(MDB_env *env, mdb_filehandle_t *fd)
Definition lmdb++.h:421
static void cursor_del(MDB_cursor *cursor, unsigned int flags)
Definition lmdb++.h:914
static T from_sv(std::string_view v)
Takes a std::string_view and dereferences it, returning a value of the parameterized type.
Definition lmdb++.h:1681
static void dbi_set_relfunc(MDB_txn *txn, MDB_dbi dbi, MDB_rel_func *rel)
Definition lmdb++.h:736
static void dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
Definition lmdb++.h:643
static void dbi_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Definition lmdb++.h:708
static void env_set_max_readers(MDB_env *env, unsigned int count)
Definition lmdb++.h:447
static MDB_env * txn_env(MDB_txn *txn) noexcept
Definition lmdb++.h:563
static void env_set_mapsize(MDB_env *env, std::size_t size)
Definition lmdb++.h:434
static void env_set_max_dbs(MDB_env *env, MDB_dbi count)
Definition lmdb++.h:473
static void env_close(MDB_env *env) noexcept
Definition lmdb++.h:372
static void env_set_flags(MDB_env *env, unsigned int flags, bool onoff)
Definition lmdb++.h:381
static void txn_renew(MDB_txn *txn)
Definition lmdb++.h:610
static bool cursor_put(MDB_cursor *cursor, MDB_val *key, MDB_val *data, unsigned int flags)
Definition lmdb++.h:898
static void cursor_close(MDB_cursor *cursor) noexcept
Definition lmdb++.h:844
static bool cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op)
Definition lmdb++.h:882
static void cursor_count(MDB_cursor *cursor, std::size_t &count)
Definition lmdb++.h:927
static void env_get_max_readers(MDB_env *env, unsigned int *count)
Definition lmdb++.h:460
static MDB_dbi cursor_dbi(MDB_cursor *cursor) noexcept
Definition lmdb++.h:873
static void txn_abort(MDB_txn *txn) noexcept
Definition lmdb++.h:593
static void env_get_path(MDB_env *env, const char **path)
Definition lmdb++.h:408
static void dbi_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat)
Definition lmdb++.h:658
static bool dbi_del(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, const MDB_val *data)
Definition lmdb++.h:800
static bool dbi_get(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, MDB_val *data)
Definition lmdb++.h:765
static void env_copy(MDB_env *env, const char *path, unsigned int flags)
Definition lmdb++.h:295
static void txn_reset(MDB_txn *txn) noexcept
Definition lmdb++.h:601
static void env_set_userctx(MDB_env *env, void *ctx)
Definition lmdb++.h:500
static void dbi_close(MDB_env *env, MDB_dbi dbi) noexcept
Definition lmdb++.h:685
static void env_stat(MDB_env *env, MDB_stat *stat)
Definition lmdb++.h:334
static T * ptr_from_sv(std::string_view v)
Takes a std::string_view and casts its pointer as a pointer to the parameterized type.
Definition lmdb++.h:1670
static void env_sync(MDB_env *env, bool force)
Definition lmdb++.h:360
static void dbi_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Definition lmdb++.h:722
static void env_get_flags(MDB_env *env, unsigned int *flags)
Definition lmdb++.h:395
static void txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn)
Definition lmdb++.h:549
mdb_mode_t mode
Definition lmdb++.h:38
static std::string_view ptr_to_sv(T *v)
Creates a std::string_view that points to the memory pointed to by v.
Definition lmdb++.h:1650
static void dbi_set_relctx(MDB_txn *txn, MDB_dbi dbi, void *ctx)
Definition lmdb++.h:750