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')"
50 class key_exist_error;
51 class not_found_error;
52 class corrupted_error;
54 class version_mismatch_error;
72 [[noreturn]]
static inline void raise(
const char*
origin,
int rc);
78 const int rc) noexcept
85 int code() const noexcept {
92 const char*
origin() const noexcept {
99 virtual const char*
what() const noexcept {
100 static thread_local char buffer[1024];
101 std::snprintf(buffer,
sizeof(buffer),
138 using runtime_error::runtime_error;
148 using runtime_error::runtime_error;
158 using fatal_error::fatal_error;
168 using fatal_error::fatal_error;
178 using fatal_error::fatal_error;
188 using runtime_error::runtime_error;
199 using runtime_error::runtime_error;
232 static inline void env_open(MDB_env* env,
233 const char* path,
unsigned int flags,
mode mode);
234#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
235 static inline void env_copy(MDB_env* env,
const char* path,
unsigned int flags);
236 static inline void env_copy_fd(MDB_env* env, mdb_filehandle_t fd,
unsigned int flags);
238 static inline void env_copy(MDB_env* env,
const char* path);
239 static inline void env_copy_fd(MDB_env* env, mdb_filehandle_t fd);
241 static inline void env_stat(MDB_env* env, MDB_stat* stat);
242 static inline void env_info(MDB_env* env, MDB_envinfo* stat);
243 static inline void env_sync(MDB_env* env,
bool force);
244 static inline void env_close(MDB_env* env)
noexcept;
245 static inline void env_set_flags(MDB_env* env,
unsigned int flags,
bool onoff);
246 static inline void env_get_flags(MDB_env* env,
unsigned int* flags);
247 static inline void env_get_path(MDB_env* env,
const char** path);
248 static inline void env_get_fd(MDB_env* env, mdb_filehandle_t* fd);
254#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
260 static inline void reader_check(MDB_env *env,
int *dead);
269 const int rc = ::mdb_env_create(
env);
270 if (rc != MDB_SUCCESS) {
281 const char*
const path,
282 const unsigned int flags,
284 const int rc = ::mdb_env_open(
env, path, flags,
mode);
285 if (rc != MDB_SUCCESS) {
297#
if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
298 const char*
const path,
299 const unsigned int flags = 0) {
300 const int rc = ::mdb_env_copy2(
env, path, flags);
302 const char*
const path) {
303 const int rc = ::mdb_env_copy(
env, path);
305 if (rc != MDB_SUCCESS) {
317#
if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
318 const mdb_filehandle_t fd,
319 const unsigned int flags = 0) {
320 const int rc = ::mdb_env_copyfd2(
env, fd, flags);
322 const mdb_filehandle_t fd) {
323 const int rc = ::mdb_env_copyfd(
env, fd);
325 if (rc != MDB_SUCCESS) {
336 MDB_stat*
const stat) {
337 const int rc = ::mdb_env_stat(
env, stat);
338 if (rc != MDB_SUCCESS) {
349 MDB_envinfo*
const stat) {
350 const int rc = ::mdb_env_info(
env, stat);
351 if (rc != MDB_SUCCESS) {
362 const bool force =
true) {
363 const int rc = ::mdb_env_sync(
env, force);
364 if (rc != MDB_SUCCESS) {
374 ::mdb_env_close(
env);
383 const unsigned int flags,
384 const bool onoff =
true) {
385 const int rc = ::mdb_env_set_flags(
env, flags, onoff ? 1 : 0);
386 if (rc != MDB_SUCCESS) {
397 unsigned int*
const flags) {
398 const int rc = ::mdb_env_get_flags(
env, flags);
399 if (rc != MDB_SUCCESS) {
411 const int rc = ::mdb_env_get_path(
env, path);
412 if (rc != MDB_SUCCESS) {
423 mdb_filehandle_t*
const fd) {
424 const int rc = ::mdb_env_get_fd(
env, fd);
425 if (rc != MDB_SUCCESS) {
436 const std::size_t size) {
437 const int rc = ::mdb_env_set_mapsize(
env, size);
438 if (rc != MDB_SUCCESS) {
449 const unsigned int count) {
450 const int rc = ::mdb_env_set_maxreaders(
env, count);
451 if (rc != MDB_SUCCESS) {
462 unsigned int*
const count) {
463 const int rc = ::mdb_env_get_maxreaders(
env, count);
464 if (rc != MDB_SUCCESS) {
475 const MDB_dbi count) {
476 const int rc = ::mdb_env_set_maxdbs(
env, count);
477 if (rc != MDB_SUCCESS) {
485static inline unsigned int
487 const int rc = ::mdb_env_get_maxkeysize(
env);
491 return static_cast<unsigned int>(rc);
494#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
503 const int rc = ::mdb_env_set_userctx(
env, ctx);
504 if (rc != MDB_SUCCESS) {
510#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
517 return ::mdb_env_get_userctx(
env);
523 const int rc = ::mdb_reader_check(
env, dead);
524 if (rc != MDB_SUCCESS) {
534 MDB_env* env, MDB_txn* parent,
unsigned int flags, MDB_txn** txn);
535 static inline MDB_env*
txn_env(MDB_txn* txn)
noexcept;
537 static inline std::size_t txn_id(MDB_txn* txn)
noexcept;
540 static inline void txn_abort(MDB_txn* txn)
noexcept;
541 static inline void txn_reset(MDB_txn* txn)
noexcept;
542 static inline void txn_renew(MDB_txn* txn);
551 MDB_txn*
const parent,
552 const unsigned int flags,
554 const int rc = ::mdb_txn_begin(
env, parent, flags,
txn);
555 if (rc != MDB_SUCCESS) {
563static inline MDB_env*
565 return ::mdb_txn_env(
txn);
572static inline std::size_t
573lmdb::txn_id(MDB_txn*
const txn)
noexcept {
574 return ::mdb_txn_id(txn);
584 const int rc = ::mdb_txn_commit(
txn);
585 if (rc != MDB_SUCCESS) {
595 ::mdb_txn_abort(
txn);
603 ::mdb_txn_reset(
txn);
612 const int rc = ::mdb_txn_renew(
txn);
613 if (rc != MDB_SUCCESS) {
623 MDB_txn* txn,
const char* name,
unsigned int flags, MDB_dbi* dbi);
624 static inline void dbi_stat(MDB_txn* txn, MDB_dbi dbi, MDB_stat* stat);
625 static inline void dbi_flags(MDB_txn* txn, MDB_dbi dbi,
unsigned int* flags);
626 static inline void dbi_close(MDB_env* env, MDB_dbi dbi)
noexcept;
627 static inline void dbi_drop(MDB_txn* txn, MDB_dbi dbi,
bool del);
628 static inline void dbi_set_compare(MDB_txn* txn, MDB_dbi dbi, MDB_cmp_func* cmp);
629 static inline void dbi_set_dupsort(MDB_txn* txn, MDB_dbi dbi, MDB_cmp_func* cmp);
630 static inline void dbi_set_relfunc(MDB_txn* txn, MDB_dbi dbi, MDB_rel_func* rel);
631 static inline void dbi_set_relctx(MDB_txn* txn, MDB_dbi dbi,
void* ctx);
632 static inline bool dbi_get(MDB_txn* txn, MDB_dbi dbi,
const MDB_val* key, MDB_val* data);
633 static inline bool dbi_put(MDB_txn* txn, MDB_dbi dbi,
const MDB_val* key, MDB_val* data,
unsigned int flags);
634 static inline bool dbi_del(MDB_txn* txn, MDB_dbi dbi,
const MDB_val* key,
const MDB_val* data);
645 const char*
const name,
646 const unsigned int flags,
647 MDB_dbi*
const dbi) {
648 const int rc = ::mdb_dbi_open(
txn, name, flags,
dbi);
649 if (rc != MDB_SUCCESS) {
661 MDB_stat*
const result) {
662 const int rc = ::mdb_stat(
txn,
dbi, result);
663 if (rc != MDB_SUCCESS) {
675 unsigned int*
const flags) {
676 const int rc = ::mdb_dbi_flags(
txn,
dbi, flags);
677 if (rc != MDB_SUCCESS) {
687 const MDB_dbi
dbi)
noexcept {
688 ::mdb_dbi_close(
env,
dbi);
697 const bool del =
false) {
698 const int rc = ::mdb_drop(
txn,
dbi, del ? 1 : 0);
699 if (rc != MDB_SUCCESS) {
711 MDB_cmp_func*
const cmp =
nullptr) {
712 const int rc = ::mdb_set_compare(
txn,
dbi, cmp);
713 if (rc != MDB_SUCCESS) {
725 MDB_cmp_func*
const cmp =
nullptr) {
726 const int rc = ::mdb_set_dupsort(
txn,
dbi, cmp);
727 if (rc != MDB_SUCCESS) {
739 MDB_rel_func*
const rel) {
740 const int rc = ::mdb_set_relfunc(
txn,
dbi, rel);
741 if (rc != MDB_SUCCESS) {
754 const int rc = ::mdb_set_relctx(
txn,
dbi, ctx);
755 if (rc != MDB_SUCCESS) {
768 const MDB_val*
const key,
769 MDB_val*
const data) {
770 const int rc = ::mdb_get(
txn,
dbi,
const_cast<MDB_val*
>(key), data);
771 if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
774 return (rc == MDB_SUCCESS);
785 const MDB_val*
const key,
787 const unsigned int flags = 0) {
788 const int rc = ::mdb_put(
txn,
dbi,
const_cast<MDB_val*
>(key), data, flags);
789 if (rc != MDB_SUCCESS && rc != MDB_KEYEXIST) {
792 return (rc == MDB_SUCCESS);
803 const MDB_val*
const key,
804 const MDB_val*
const data =
nullptr) {
805 const int rc = ::mdb_del(
txn,
dbi,
const_cast<MDB_val*
>(key),
const_cast<MDB_val*
>(data));
806 if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
809 return (rc == MDB_SUCCESS);
816 static inline void cursor_open(MDB_txn* txn, MDB_dbi dbi, MDB_cursor** cursor);
817 static inline void cursor_close(MDB_cursor* cursor)
noexcept;
818 static inline void cursor_renew(MDB_txn* txn, MDB_cursor* cursor);
819 static inline MDB_txn*
cursor_txn(MDB_cursor* cursor)
noexcept;
820 static inline MDB_dbi
cursor_dbi(MDB_cursor* cursor)
noexcept;
821 static inline bool cursor_get(MDB_cursor* cursor, MDB_val* key, MDB_val* data, MDB_cursor_op op);
822 static inline bool cursor_put(MDB_cursor* cursor, MDB_val* key, MDB_val* data,
unsigned int flags);
823 static inline void cursor_del(MDB_cursor* cursor,
unsigned int flags);
824 static inline void cursor_count(MDB_cursor* cursor, std::size_t& count);
834 MDB_cursor**
const cursor) {
836 if (rc != MDB_SUCCESS) {
846 ::mdb_cursor_close(
cursor);
855 MDB_cursor*
const cursor) {
856 const int rc = ::mdb_cursor_renew(
txn,
cursor);
857 if (rc != MDB_SUCCESS) {
865static inline MDB_txn*
867 return ::mdb_cursor_txn(
cursor);
875 return ::mdb_cursor_dbi(
cursor);
886 const MDB_cursor_op op) {
887 const int rc = ::mdb_cursor_get(
cursor, key, data, op);
888 if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
891 return (rc == MDB_SUCCESS);
902 const unsigned int flags = 0) {
903 const int rc = ::mdb_cursor_put(
cursor, key, data, flags);
904 if (rc != MDB_SUCCESS && rc != MDB_KEYEXIST) {
907 return (rc == MDB_SUCCESS);
916 const unsigned int flags = 0) {
917 const int rc = ::mdb_cursor_del(
cursor, flags);
918 if (rc != MDB_SUCCESS) {
929 std::size_t& count) {
930 const int rc = ::mdb_cursor_count(
cursor, &count);
931 if (rc != MDB_SUCCESS) {
967 assert(
handle !=
nullptr);
993 std::swap(
_handle, other._handle);
1000 if (
this != &other) {
1001 std::swap(
_handle, other._handle);
1010 try {
close(); }
catch (...) {}
1016 operator MDB_env*()
const noexcept {
1033 void sync(
const bool force =
true) {
1077 const bool onoff =
true) {
1110 mdb_filehandle_t fd;
1119 if constexpr (
sizeof(int) != 4 ||
sizeof(long) != 8 ||
sizeof(
void*) != 8)
error::raise(
"get_internal_map: only LP64 supported", 0);
1124 char *me_map = *(
char**)(((
char*)
_handle) + 56);
1129 return std::string_view(me_map, arg.me_mapsize);
1162 MDB_txn*
const parent =
nullptr,
1164 MDB_txn*
handle{
nullptr};
1167 assert(
handle !=
nullptr);
1184 std::swap(
_handle, other._handle);
1191 if (
this != &other) {
1192 std::swap(
_handle, other._handle);
1202 try {
abort(); }
catch (...) {}
1210 operator MDB_txn*()
const noexcept {
1224 MDB_env*
env() const noexcept {
1282 MDB_dbi
_handle{(std::numeric_limits<MDB_dbi>::max)()};
1298 const char*
const name =
nullptr,
1314 std::string_view name,
1317 std::string nameStr(name);
1328 :
_handle{(std::numeric_limits<MDB_dbi>::max)()} {}
1350 operator MDB_dbi() const noexcept {
1380 unsigned int result{};
1401 const bool del =
false) {
1413 MDB_cmp_func*
const cmp =
nullptr) {
1428 const std::string_view key,
1429 std::string_view& data) {
1430 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1431 MDB_val dataV{data.size(),
const_cast<char*
>(data.data())};
1434 data = std::string_view(
static_cast<char*
>(dataV.mv_data), dataV.mv_size);
1449 const std::string_view key,
1450 std::string_view data,
1452 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1453 MDB_val dataV{data.size(),
const_cast<char*
>(data.data())};
1465 const std::string_view key) {
1466 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1479 const std::string_view key,
1480 const std::string_view val) {
1481 const MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1482 const MDB_val valV{val.size(),
const_cast<char*
>(val.data())};
1516 const MDB_dbi
dbi) {
1520 assert(
handle !=
nullptr);
1537 std::swap(
_handle, other._handle);
1544 if (
this != &other) {
1545 std::swap(
_handle, other._handle);
1554 try {
close(); }
catch (...) {}
1560 operator MDB_cursor*()
const noexcept {
1597 MDB_txn*
txn() const noexcept {
1604 MDB_dbi
dbi() const noexcept {
1615 bool get(std::string_view &key,
1616 const MDB_cursor_op op) {
1617 MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1620 key = std::string_view(
static_cast<char*
>(keyV.mv_data), keyV.mv_size);
1633 bool get(std::string_view &key,
1634 std::string_view &val,
1635 const MDB_cursor_op op) {
1636 MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1637 MDB_val valV{val.size(),
const_cast<char*
>(val.data())};
1640 key = std::string_view(
static_cast<char*
>(keyV.mv_data), keyV.mv_size);
1641 val = std::string_view(
static_cast<char*
>(valV.mv_data), valV.mv_size);
1656 bool put(
const std::string_view &key,
1657 const std::string_view &val,
1658 const unsigned int flags = 0) {
1659 MDB_val keyV{key.size(),
const_cast<char*
>(key.data())};
1660 MDB_val valV{val.size(),
const_cast<char*
>(val.data())};
1670 void del(
unsigned int flags = 0) {
1690 template<
typename T>
1692 return std::string_view(
reinterpret_cast<char*
>(v),
sizeof(*v));
1700 template<
typename T>
1701 static inline std::string_view
to_sv(
const T &v) {
1702 return std::string_view(
reinterpret_cast<const char*
>(std::addressof(v)),
sizeof(v));
1710 template<
typename T>
1712 if (v.size() !=
sizeof(T))
error::raise(
"ptr_from_sv", MDB_BAD_VALSIZE);
1713 return reinterpret_cast<T*
>(
const_cast<char*
>(v.data()));
1721 template<
typename T>
1723 if (v.size() !=
sizeof(T))
error::raise(
"from_sv", MDB_BAD_VALSIZE);
1725 std::memcpy(&ret,
const_cast<char*
>(v.data()),
sizeof(T));
Exception class for MDB_BAD_DBI errors.
Definition lmdb++.h:197
Exception class for MDB_CORRUPTED errors.
Definition lmdb++.h:156
Resource class for MDB_cursor* handles.
Definition lmdb++.h:1500
MDB_cursor * handle() const noexcept
Returns the underlying MDB_cursor* handle.
Definition lmdb++.h:1567
static constexpr unsigned int default_flags
Definition lmdb++.h:1505
MDB_cursor * _handle
Definition lmdb++.h:1502
void close() noexcept
Closes this cursor.
Definition lmdb++.h:1577
~cursor() noexcept
Destructor.
Definition lmdb++.h:1553
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:1656
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:1633
MDB_txn * txn() const noexcept
Returns the cursor's transaction handle.
Definition lmdb++.h:1597
size_t count()
Return count of duplicates for current key.
Definition lmdb++.h:1677
cursor(cursor &&other) noexcept
Move constructor.
Definition lmdb++.h:1536
MDB_dbi dbi() const noexcept
Returns the cursor's database handle.
Definition lmdb++.h:1604
static cursor open(MDB_txn *const txn, const MDB_dbi dbi)
Creates an LMDB cursor.
Definition lmdb++.h:1515
cursor & operator=(cursor &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1543
cursor(MDB_cursor *const handle) noexcept
Constructor.
Definition lmdb++.h:1530
void del(unsigned int flags=0)
Delete current key/data pair.
Definition lmdb++.h:1670
bool get(std::string_view &key, const MDB_cursor_op op)
Retrieves a key from the database.
Definition lmdb++.h:1615
void renew(MDB_txn *const txn)
Renews this cursor.
Definition lmdb++.h:1590
Resource class for MDB_dbi handles.
Definition lmdb++.h:1280
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:1448
std::size_t size(MDB_txn *const txn) const
Returns the number of records in this database.
Definition lmdb++.h:1391
static constexpr unsigned int default_put_flags
Definition lmdb++.h:1286
dbi(const MDB_dbi handle) noexcept
Constructor.
Definition lmdb++.h:1335
bool del(MDB_txn *const txn, const std::string_view key)
Removes a key from this database.
Definition lmdb++.h:1464
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:1412
~dbi() noexcept
Destructor.
Definition lmdb++.h:1341
static dbi open(MDB_txn *const txn, std::string_view name, const unsigned int flags=default_flags)
Definition lmdb++.h:1313
MDB_stat stat(MDB_txn *const txn) const
Returns statistics for this database.
Definition lmdb++.h:1367
unsigned int flags(MDB_txn *const txn) const
Retrieves the flags for this database handle.
Definition lmdb++.h:1379
dbi() noexcept
Constructor.
Definition lmdb++.h:1327
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:1297
static constexpr unsigned int default_flags
Definition lmdb++.h:1285
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:1478
void drop(MDB_txn *const txn, const bool del=false)
Definition lmdb++.h:1400
MDB_dbi _handle
Definition lmdb++.h:1282
MDB_dbi handle() const noexcept
Returns the underlying MDB_dbi handle.
Definition lmdb++.h:1357
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:1427
Resource class for MDB_env* handles.
Definition lmdb++.h:949
env & set_flags(const unsigned int flags, const bool onoff=true)
Definition lmdb++.h:1076
void close() noexcept
Closes this environment, releasing the memory map.
Definition lmdb++.h:1043
static constexpr mode default_mode
Definition lmdb++.h:955
env & set_mapsize(const std::size_t size)
Definition lmdb++.h:1086
env & set_max_dbs(const MDB_dbi count)
Definition lmdb++.h:1104
~env() noexcept
Destructor.
Definition lmdb++.h:1009
MDB_env * _handle
Definition lmdb++.h:951
env(MDB_env *const handle) noexcept
Constructor.
Definition lmdb++.h:986
env(env &&other) noexcept
Move constructor.
Definition lmdb++.h:992
void sync(const bool force=true)
Flushes data buffers to disk.
Definition lmdb++.h:1033
MDB_env * handle() const noexcept
Returns the underlying MDB_env* handle.
Definition lmdb++.h:1023
static constexpr unsigned int default_flags
Definition lmdb++.h:954
env & operator=(env &&other) noexcept
Move assignment operator.
Definition lmdb++.h:999
static env create(const unsigned int flags=default_flags)
Creates a new LMDB environment.
Definition lmdb++.h:963
env & open(const char *const path, const unsigned int flags=default_flags, const mode mode=default_mode)
Opens this environment.
Definition lmdb++.h:1064
int reader_check()
Definition lmdb++.h:1050
env & set_max_readers(const unsigned int count)
Definition lmdb++.h:1095
mdb_filehandle_t get_fd()
Definition lmdb++.h:1109
std::string_view get_internal_map()
@notice WARNING: This is a function to access LMDB's internal memory map, use at your own risk!
Definition lmdb++.h:1118
Base class for LMDB exception conditions.
Definition lmdb++.h:64
const char * origin() const noexcept
Returns the origin of the LMDB error.
Definition lmdb++.h:92
const int _code
Definition lmdb++.h:66
virtual const char * what() const noexcept
Returns the underlying LMDB error code.
Definition lmdb++.h:99
error(const char *const origin, const int rc) noexcept
Constructor.
Definition lmdb++.h:77
static void raise(const char *origin, int rc)
Throws an error based on the given LMDB return code.
Definition lmdb++.h:203
int code() const noexcept
Returns the underlying LMDB error code.
Definition lmdb++.h:85
Base class for fatal error conditions.
Definition lmdb++.h:118
Exception class for MDB_KEYEXIST errors.
Definition lmdb++.h:136
Base class for logic error conditions.
Definition lmdb++.h:110
Exception class for MDB_MAP_FULL errors.
Definition lmdb++.h:186
Exception class for MDB_NOTFOUND errors.
Definition lmdb++.h:146
Exception class for MDB_PANIC errors.
Definition lmdb++.h:166
Base class for runtime error conditions.
Definition lmdb++.h:126
Resource class for MDB_txn* handles.
Definition lmdb++.h:1146
MDB_txn * handle() const noexcept
Returns the underlying MDB_txn* handle.
Definition lmdb++.h:1217
void commit()
Commits this transaction.
Definition lmdb++.h:1234
MDB_env * env() const noexcept
Returns the transaction's MDB_env* handle.
Definition lmdb++.h:1224
void abort() noexcept
Aborts this transaction.
Definition lmdb++.h:1245
MDB_txn * _handle
Definition lmdb++.h:1148
void reset() noexcept
Resets this read-only transaction.
Definition lmdb++.h:1254
static constexpr unsigned int default_flags
Definition lmdb++.h:1151
txn & operator=(txn &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1190
~txn() noexcept
Destructor.
Definition lmdb++.h:1200
void renew()
Renews this read-only transaction.
Definition lmdb++.h:1263
txn(txn &&other) noexcept
Move constructor.
Definition lmdb++.h:1183
txn(MDB_txn *const handle) noexcept
Constructor.
Definition lmdb++.h:1177
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:1161
Exception class for MDB_VERSION_MISMATCH errors.
Definition lmdb++.h:176
<lmdb++.h> - C++17 wrapper for LMDB.
Definition lmdb++.h:38
static void env_info(MDB_env *env, MDB_envinfo *stat)
Definition lmdb++.h:348
static void * env_get_userctx(MDB_env *env)
Definition lmdb++.h:516
static void dbi_flags(MDB_txn *txn, MDB_dbi dbi, unsigned int *flags)
Definition lmdb++.h:673
static void cursor_renew(MDB_txn *txn, MDB_cursor *cursor)
Definition lmdb++.h:854
static void env_copy_fd(MDB_env *env, mdb_filehandle_t fd, unsigned int flags)
Definition lmdb++.h:316
static void txn_commit(MDB_txn *txn)
Definition lmdb++.h:583
static void env_open(MDB_env *env, const char *path, unsigned int flags, mode mode)
Definition lmdb++.h:280
static MDB_txn * cursor_txn(MDB_cursor *cursor) noexcept
Definition lmdb++.h:866
static void dbi_drop(MDB_txn *txn, MDB_dbi dbi, bool del)
Definition lmdb++.h:695
static bool dbi_put(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, MDB_val *data, unsigned int flags)
Definition lmdb++.h:783
static void env_create(MDB_env **env)
Definition lmdb++.h:268
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:1701
static unsigned int env_get_max_keysize(MDB_env *env)
Definition lmdb++.h:486
static void cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor)
Definition lmdb++.h:832
static void reader_check(MDB_env *env, int *dead)
Definition lmdb++.h:522
static void env_get_fd(MDB_env *env, mdb_filehandle_t *fd)
Definition lmdb++.h:422
static void cursor_del(MDB_cursor *cursor, unsigned int flags)
Definition lmdb++.h:915
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:1722
static void dbi_set_relfunc(MDB_txn *txn, MDB_dbi dbi, MDB_rel_func *rel)
Definition lmdb++.h:737
static void dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
Definition lmdb++.h:644
static void dbi_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Definition lmdb++.h:709
static void env_set_max_readers(MDB_env *env, unsigned int count)
Definition lmdb++.h:448
static MDB_env * txn_env(MDB_txn *txn) noexcept
Definition lmdb++.h:564
static void env_set_mapsize(MDB_env *env, std::size_t size)
Definition lmdb++.h:435
static void env_set_max_dbs(MDB_env *env, MDB_dbi count)
Definition lmdb++.h:474
static void env_close(MDB_env *env) noexcept
Definition lmdb++.h:373
static void env_set_flags(MDB_env *env, unsigned int flags, bool onoff)
Definition lmdb++.h:382
static void txn_renew(MDB_txn *txn)
Definition lmdb++.h:611
static bool cursor_put(MDB_cursor *cursor, MDB_val *key, MDB_val *data, unsigned int flags)
Definition lmdb++.h:899
static void cursor_close(MDB_cursor *cursor) noexcept
Definition lmdb++.h:845
static bool cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op)
Definition lmdb++.h:883
static void cursor_count(MDB_cursor *cursor, std::size_t &count)
Definition lmdb++.h:928
static void env_get_max_readers(MDB_env *env, unsigned int *count)
Definition lmdb++.h:461
static MDB_dbi cursor_dbi(MDB_cursor *cursor) noexcept
Definition lmdb++.h:874
static void txn_abort(MDB_txn *txn) noexcept
Definition lmdb++.h:594
static void env_get_path(MDB_env *env, const char **path)
Definition lmdb++.h:409
static void dbi_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat)
Definition lmdb++.h:659
static bool dbi_del(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, const MDB_val *data)
Definition lmdb++.h:801
static bool dbi_get(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, MDB_val *data)
Definition lmdb++.h:766
static void env_copy(MDB_env *env, const char *path, unsigned int flags)
Definition lmdb++.h:296
static void txn_reset(MDB_txn *txn) noexcept
Definition lmdb++.h:602
static void env_set_userctx(MDB_env *env, void *ctx)
Definition lmdb++.h:501
static void dbi_close(MDB_env *env, MDB_dbi dbi) noexcept
Definition lmdb++.h:686
static void env_stat(MDB_env *env, MDB_stat *stat)
Definition lmdb++.h:335
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:1711
static void env_sync(MDB_env *env, bool force)
Definition lmdb++.h:361
static void dbi_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Definition lmdb++.h:723
static void env_get_flags(MDB_env *env, unsigned int *flags)
Definition lmdb++.h:396
static void txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn)
Definition lmdb++.h:550
mdb_mode_t mode
Definition lmdb++.h:39
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:1691
static void dbi_set_relctx(MDB_txn *txn, MDB_dbi dbi, void *ctx)
Definition lmdb++.h:751