Loading...
Searching...
No Matches
lmdb++.h
Go to the documentation of this file.
/* This is free and unencumbered software released into the public domain. */
#ifndef LMDBXX_H
#define LMDBXX_H
#ifndef __cplusplus
#error "<lmdb++.h> requires a C++ compiler"
#endif
#if __cplusplus < 201103L
#if !defined(_MSC_VER) || _MSC_VER < 1900
#error "<lmdb++.h> requires a C++11 compiler (CXXFLAGS='-std=c++11')"
#endif // _MSC_VER check
#endif
#include <lmdb.h> /* for MDB_*, mdb_*() */
#ifdef LMDBXX_DEBUG
#include <cassert> /* for assert() */
#endif
#include <cstddef> /* for std::size_t */
#include <cstdio> /* for std::snprintf() */
#include <cstring> /* for std::strlen() */
#include <stdexcept> /* for std::runtime_error */
#include <string> /* for std::string */
#include <type_traits> /* for std::is_pod<> */
namespace lmdb {
using mode = mdb_mode_t;
}
/* Error Handling */
namespace lmdb {
class error;
class logic_error;
class fatal_error;
class runtime_error;
class key_exist_error;
class not_found_error;
class corrupted_error;
class panic_error;
class version_mismatch_error;
class map_full_error;
class bad_dbi_error;
}
class lmdb::error : public std::runtime_error {
protected:
const int _code;
public:
[[noreturn]] static inline void raise(const char* origin, int rc);
error(const char* const origin,
const int rc) noexcept
: runtime_error{origin},
_code{rc} {}
int code() const noexcept {
return _code;
}
const char* origin() const noexcept {
return runtime_error::what();
}
virtual const char* what() const noexcept {
static thread_local char buffer[1024];
std::snprintf(buffer, sizeof(buffer),
"%s: %s", origin(), ::mdb_strerror(code()));
return buffer;
}
};
class lmdb::logic_error : public lmdb::error {
public:
using error::error;
};
class lmdb::fatal_error : public lmdb::error {
public:
using error::error;
};
class lmdb::runtime_error : public lmdb::error {
public:
using error::error;
};
class lmdb::key_exist_error final : public lmdb::runtime_error {
public:
using runtime_error::runtime_error;
};
class lmdb::not_found_error final : public lmdb::runtime_error {
public:
using runtime_error::runtime_error;
};
class lmdb::corrupted_error final : public lmdb::fatal_error {
public:
using fatal_error::fatal_error;
};
class lmdb::panic_error final : public lmdb::fatal_error {
public:
using fatal_error::fatal_error;
};
class lmdb::version_mismatch_error final : public lmdb::fatal_error {
public:
using fatal_error::fatal_error;
};
class lmdb::map_full_error final : public lmdb::runtime_error {
public:
using runtime_error::runtime_error;
};
class lmdb::bad_dbi_error final : public lmdb::runtime_error {
public:
using runtime_error::runtime_error;
};
inline void
lmdb::error::raise(const char* const origin,
const int rc) {
switch (rc) {
case MDB_KEYEXIST: throw key_exist_error{origin, rc};
case MDB_NOTFOUND: throw not_found_error{origin, rc};
case MDB_CORRUPTED: throw corrupted_error{origin, rc};
case MDB_PANIC: throw panic_error{origin, rc};
case MDB_VERSION_MISMATCH: throw version_mismatch_error{origin, rc};
case MDB_MAP_FULL: throw map_full_error{origin, rc};
#ifdef MDB_BAD_DBI
case MDB_BAD_DBI: throw bad_dbi_error{origin, rc};
#endif
default: throw lmdb::runtime_error{origin, rc};
}
}
/* Procedural Interface: Metadata */
namespace lmdb {
// TODO: mdb_version()
// TODO: mdb_strerror()
}
/* Procedural Interface: Environment */
namespace lmdb {
static inline void env_create(MDB_env** env);
static inline void env_open(MDB_env* env,
const char* path, unsigned int flags, mode mode);
#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
static inline void env_copy(MDB_env* env, const char* path, unsigned int flags);
static inline void env_copy_fd(MDB_env* env, mdb_filehandle_t fd, unsigned int flags);
#else
static inline void env_copy(MDB_env* env, const char* path);
static inline void env_copy_fd(MDB_env* env, mdb_filehandle_t fd);
#endif
static inline void env_stat(MDB_env* env, MDB_stat* stat);
static inline void env_info(MDB_env* env, MDB_envinfo* stat);
static inline void env_sync(MDB_env* env, bool force);
static inline void env_close(MDB_env* env) noexcept;
static inline void env_set_flags(MDB_env* env, unsigned int flags, bool onoff);
static inline void env_get_flags(MDB_env* env, unsigned int* flags);
static inline void env_get_path(MDB_env* env, const char** path);
static inline void env_get_fd(MDB_env* env, mdb_filehandle_t* fd);
static inline void env_set_mapsize(MDB_env* env, std::size_t size);
static inline void env_set_max_readers(MDB_env* env, unsigned int count);
static inline void env_get_max_readers(MDB_env* env, unsigned int* count);
static inline void env_set_max_dbs(MDB_env* env, MDB_dbi count);
static inline unsigned int env_get_max_keysize(MDB_env* env);
#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
static inline void env_set_userctx(MDB_env* env, void* ctx);
static inline void* env_get_userctx(MDB_env* env);
#endif
// TODO: mdb_env_set_assert()
// TODO: mdb_reader_list()
// TODO: mdb_reader_check()
}
static inline void
lmdb::env_create(MDB_env** env) {
const int rc = ::mdb_env_create(env);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_create", rc);
}
}
static inline void
lmdb::env_open(MDB_env* const env,
const char* const path,
const unsigned int flags,
const mode mode) {
const int rc = ::mdb_env_open(env, path, flags, mode);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_open", rc);
}
}
static inline void
lmdb::env_copy(MDB_env* const env,
#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
const char* const path,
const unsigned int flags = 0) {
const int rc = ::mdb_env_copy2(env, path, flags);
#else
const char* const path) {
const int rc = ::mdb_env_copy(env, path);
#endif
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_copy2", rc);
}
}
static inline void
lmdb::env_copy_fd(MDB_env* const env,
#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 14)
const mdb_filehandle_t fd,
const unsigned int flags = 0) {
const int rc = ::mdb_env_copyfd2(env, fd, flags);
#else
const mdb_filehandle_t fd) {
const int rc = ::mdb_env_copyfd(env, fd);
#endif
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_copyfd2", rc);
}
}
static inline void
lmdb::env_stat(MDB_env* const env,
MDB_stat* const stat) {
const int rc = ::mdb_env_stat(env, stat);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_stat", rc);
}
}
static inline void
lmdb::env_info(MDB_env* const env,
MDB_envinfo* const stat) {
const int rc = ::mdb_env_info(env, stat);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_info", rc);
}
}
static inline void
lmdb::env_sync(MDB_env* const env,
const bool force = true) {
const int rc = ::mdb_env_sync(env, force);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_sync", rc);
}
}
static inline void
lmdb::env_close(MDB_env* const env) noexcept {
::mdb_env_close(env);
}
static inline void
lmdb::env_set_flags(MDB_env* const env,
const unsigned int flags,
const bool onoff = true) {
const int rc = ::mdb_env_set_flags(env, flags, onoff ? 1 : 0);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_set_flags", rc);
}
}
static inline void
lmdb::env_get_flags(MDB_env* const env,
unsigned int* const flags) {
const int rc = ::mdb_env_get_flags(env, flags);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_get_flags", rc);
}
}
static inline void
lmdb::env_get_path(MDB_env* const env,
const char** path) {
const int rc = ::mdb_env_get_path(env, path);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_get_path", rc);
}
}
static inline void
lmdb::env_get_fd(MDB_env* const env,
mdb_filehandle_t* const fd) {
const int rc = ::mdb_env_get_fd(env, fd);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_get_fd", rc);
}
}
static inline void
lmdb::env_set_mapsize(MDB_env* const env,
const std::size_t size) {
const int rc = ::mdb_env_set_mapsize(env, size);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_set_mapsize", rc);
}
}
static inline void
lmdb::env_set_max_readers(MDB_env* const env,
const unsigned int count) {
const int rc = ::mdb_env_set_maxreaders(env, count);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_set_maxreaders", rc);
}
}
static inline void
lmdb::env_get_max_readers(MDB_env* const env,
unsigned int* const count) {
const int rc = ::mdb_env_get_maxreaders(env, count);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_get_maxreaders", rc);
}
}
static inline void
lmdb::env_set_max_dbs(MDB_env* const env,
const MDB_dbi count) {
const int rc = ::mdb_env_set_maxdbs(env, count);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_set_maxdbs", rc);
}
}
static inline unsigned int
lmdb::env_get_max_keysize(MDB_env* const env) {
const int rc = ::mdb_env_get_maxkeysize(env);
#ifdef LMDBXX_DEBUG
assert(rc >= 0);
#endif
return static_cast<unsigned int>(rc);
}
#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
static inline void
lmdb::env_set_userctx(MDB_env* const env,
void* const ctx) {
const int rc = ::mdb_env_set_userctx(env, ctx);
if (rc != MDB_SUCCESS) {
error::raise("mdb_env_set_userctx", rc);
}
}
#endif
#if MDB_VERSION_FULL >= MDB_VERINT(0, 9, 11)
static inline void*
lmdb::env_get_userctx(MDB_env* const env) {
return ::mdb_env_get_userctx(env);
}
#endif
/* Procedural Interface: Transactions */
namespace lmdb {
static inline void txn_begin(
MDB_env* env, MDB_txn* parent, unsigned int flags, MDB_txn** txn);
static inline MDB_env* txn_env(MDB_txn* txn) noexcept;
#ifdef LMDBXX_TXN_ID
static inline std::size_t txn_id(MDB_txn* txn) noexcept;
#endif
static inline void txn_commit(MDB_txn* txn);
static inline void txn_abort(MDB_txn* txn) noexcept;
static inline void txn_reset(MDB_txn* txn) noexcept;
static inline void txn_renew(MDB_txn* txn);
}
static inline void
lmdb::txn_begin(MDB_env* const env,
MDB_txn* const parent,
const unsigned int flags,
MDB_txn** txn) {
const int rc = ::mdb_txn_begin(env, parent, flags, txn);
if (rc != MDB_SUCCESS) {
error::raise("mdb_txn_begin", rc);
}
}
static inline MDB_env*
lmdb::txn_env(MDB_txn* const txn) noexcept {
return ::mdb_txn_env(txn);
}
#ifdef LMDBXX_TXN_ID
static inline std::size_t
lmdb::txn_id(MDB_txn* const txn) noexcept {
return ::mdb_txn_id(txn);
}
#endif
static inline void
lmdb::txn_commit(MDB_txn* const txn) {
const int rc = ::mdb_txn_commit(txn);
if (rc != MDB_SUCCESS) {
error::raise("mdb_txn_commit", rc);
}
}
static inline void
lmdb::txn_abort(MDB_txn* const txn) noexcept {
::mdb_txn_abort(txn);
}
static inline void
lmdb::txn_reset(MDB_txn* const txn) noexcept {
::mdb_txn_reset(txn);
}
static inline void
lmdb::txn_renew(MDB_txn* const txn) {
const int rc = ::mdb_txn_renew(txn);
if (rc != MDB_SUCCESS) {
error::raise("mdb_txn_renew", rc);
}
}
/* Procedural Interface: Databases */
namespace lmdb {
static inline void dbi_open(
MDB_txn* txn, const char* name, unsigned int flags, MDB_dbi* dbi);
static inline void dbi_stat(MDB_txn* txn, MDB_dbi dbi, MDB_stat* stat);
static inline void dbi_flags(MDB_txn* txn, MDB_dbi dbi, unsigned int* flags);
static inline void dbi_close(MDB_env* env, MDB_dbi dbi) noexcept;
static inline void dbi_drop(MDB_txn* txn, MDB_dbi dbi, bool del);
static inline void dbi_set_compare(MDB_txn* txn, MDB_dbi dbi, MDB_cmp_func* cmp);
static inline void dbi_set_dupsort(MDB_txn* txn, MDB_dbi dbi, MDB_cmp_func* cmp);
static inline void dbi_set_relfunc(MDB_txn* txn, MDB_dbi dbi, MDB_rel_func* rel);
static inline void dbi_set_relctx(MDB_txn* txn, MDB_dbi dbi, void* ctx);
static inline bool dbi_get(MDB_txn* txn, MDB_dbi dbi, const MDB_val* key, MDB_val* data);
static inline bool dbi_put(MDB_txn* txn, MDB_dbi dbi, const MDB_val* key, MDB_val* data, unsigned int flags);
static inline bool dbi_del(MDB_txn* txn, MDB_dbi dbi, const MDB_val* key, const MDB_val* data);
// TODO: mdb_cmp()
// TODO: mdb_dcmp()
}
static inline void
lmdb::dbi_open(MDB_txn* const txn,
const char* const name,
const unsigned int flags,
MDB_dbi* const dbi) {
const int rc = ::mdb_dbi_open(txn, name, flags, dbi);
if (rc != MDB_SUCCESS) {
error::raise("mdb_dbi_open", rc);
}
}
static inline void
lmdb::dbi_stat(MDB_txn* const txn,
const MDB_dbi dbi,
MDB_stat* const result) {
const int rc = ::mdb_stat(txn, dbi, result);
if (rc != MDB_SUCCESS) {
error::raise("mdb_stat", rc);
}
}
static inline void
lmdb::dbi_flags(MDB_txn* const txn,
const MDB_dbi dbi,
unsigned int* const flags) {
const int rc = ::mdb_dbi_flags(txn, dbi, flags);
if (rc != MDB_SUCCESS) {
error::raise("mdb_dbi_flags", rc);
}
}
static inline void
lmdb::dbi_close(MDB_env* const env,
const MDB_dbi dbi) noexcept {
::mdb_dbi_close(env, dbi);
}
static inline void
lmdb::dbi_drop(MDB_txn* const txn,
const MDB_dbi dbi,
const bool del = false) {
const int rc = ::mdb_drop(txn, dbi, del ? 1 : 0);
if (rc != MDB_SUCCESS) {
error::raise("mdb_drop", rc);
}
}
static inline void
lmdb::dbi_set_compare(MDB_txn* const txn,
const MDB_dbi dbi,
MDB_cmp_func* const cmp = nullptr) {
const int rc = ::mdb_set_compare(txn, dbi, cmp);
if (rc != MDB_SUCCESS) {
error::raise("mdb_set_compare", rc);
}
}
static inline void
lmdb::dbi_set_dupsort(MDB_txn* const txn,
const MDB_dbi dbi,
MDB_cmp_func* const cmp = nullptr) {
const int rc = ::mdb_set_dupsort(txn, dbi, cmp);
if (rc != MDB_SUCCESS) {
error::raise("mdb_set_dupsort", rc);
}
}
static inline void
lmdb::dbi_set_relfunc(MDB_txn* const txn,
const MDB_dbi dbi,
MDB_rel_func* const rel) {
const int rc = ::mdb_set_relfunc(txn, dbi, rel);
if (rc != MDB_SUCCESS) {
error::raise("mdb_set_relfunc", rc);
}
}
static inline void
lmdb::dbi_set_relctx(MDB_txn* const txn,
const MDB_dbi dbi,
void* const ctx) {
const int rc = ::mdb_set_relctx(txn, dbi, ctx);
if (rc != MDB_SUCCESS) {
error::raise("mdb_set_relctx", rc);
}
}
static inline bool
lmdb::dbi_get(MDB_txn* const txn,
const MDB_dbi dbi,
const MDB_val* const key,
MDB_val* const data) {
const int rc = ::mdb_get(txn, dbi, const_cast<MDB_val*>(key), data);
if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
error::raise("mdb_get", rc);
}
return (rc == MDB_SUCCESS);
}
static inline bool
lmdb::dbi_put(MDB_txn* const txn,
const MDB_dbi dbi,
const MDB_val* const key,
MDB_val* const data,
const unsigned int flags = 0) {
const int rc = ::mdb_put(txn, dbi, const_cast<MDB_val*>(key), data, flags);
if (rc != MDB_SUCCESS && rc != MDB_KEYEXIST) {
error::raise("mdb_put", rc);
}
return (rc == MDB_SUCCESS);
}
static inline bool
lmdb::dbi_del(MDB_txn* const txn,
const MDB_dbi dbi,
const MDB_val* const key,
const MDB_val* const data = nullptr) {
const int rc = ::mdb_del(txn, dbi, const_cast<MDB_val*>(key), const_cast<MDB_val*>(data));
if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
error::raise("mdb_del", rc);
}
return (rc == MDB_SUCCESS);
}
/* Procedural Interface: Cursors */
namespace lmdb {
static inline void cursor_open(MDB_txn* txn, MDB_dbi dbi, MDB_cursor** cursor);
static inline void cursor_close(MDB_cursor* cursor) noexcept;
static inline void cursor_renew(MDB_txn* txn, MDB_cursor* cursor);
static inline MDB_txn* cursor_txn(MDB_cursor* cursor) noexcept;
static inline MDB_dbi cursor_dbi(MDB_cursor* cursor) noexcept;
static inline bool cursor_get(MDB_cursor* cursor, MDB_val* key, MDB_val* data, MDB_cursor_op op);
static inline void cursor_put(MDB_cursor* cursor, MDB_val* key, MDB_val* data, unsigned int flags);
static inline void cursor_del(MDB_cursor* cursor, unsigned int flags);
static inline void cursor_count(MDB_cursor* cursor, std::size_t& count);
}
static inline void
lmdb::cursor_open(MDB_txn* const txn,
const MDB_dbi dbi,
MDB_cursor** const cursor) {
const int rc = ::mdb_cursor_open(txn, dbi, cursor);
if (rc != MDB_SUCCESS) {
error::raise("mdb_cursor_open", rc);
}
}
static inline void
lmdb::cursor_close(MDB_cursor* const cursor) noexcept {
::mdb_cursor_close(cursor);
}
static inline void
lmdb::cursor_renew(MDB_txn* const txn,
MDB_cursor* const cursor) {
const int rc = ::mdb_cursor_renew(txn, cursor);
if (rc != MDB_SUCCESS) {
error::raise("mdb_cursor_renew", rc);
}
}
static inline MDB_txn*
lmdb::cursor_txn(MDB_cursor* const cursor) noexcept {
return ::mdb_cursor_txn(cursor);
}
static inline MDB_dbi
lmdb::cursor_dbi(MDB_cursor* const cursor) noexcept {
return ::mdb_cursor_dbi(cursor);
}
static inline bool
lmdb::cursor_get(MDB_cursor* const cursor,
MDB_val* const key,
MDB_val* const data,
const MDB_cursor_op op) {
const int rc = ::mdb_cursor_get(cursor, key, data, op);
if (rc != MDB_SUCCESS && rc != MDB_NOTFOUND) {
error::raise("mdb_cursor_get", rc);
}
return (rc == MDB_SUCCESS);
}
static inline void
lmdb::cursor_put(MDB_cursor* const cursor,
MDB_val* const key,
MDB_val* const data,
const unsigned int flags = 0) {
const int rc = ::mdb_cursor_put(cursor, key, data, flags);
if (rc != MDB_SUCCESS) {
error::raise("mdb_cursor_put", rc);
}
}
static inline void
lmdb::cursor_del(MDB_cursor* const cursor,
const unsigned int flags = 0) {
const int rc = ::mdb_cursor_del(cursor, flags);
if (rc != MDB_SUCCESS) {
error::raise("mdb_cursor_del", rc);
}
}
static inline void
lmdb::cursor_count(MDB_cursor* const cursor,
std::size_t& count) {
const int rc = ::mdb_cursor_count(cursor, &count);
if (rc != MDB_SUCCESS) {
error::raise("mdb_cursor_count", rc);
}
}
/* Resource Interface: Values */
namespace lmdb {
class val;
}
class lmdb::val {
protected:
MDB_val _val;
public:
val() noexcept = default;
val(const std::string& data) noexcept
: val{data.data(), data.size()} {}
val(const char* const data) noexcept
: val{data, std::strlen(data)} {}
val(const void* const data,
const std::size_t size) noexcept
: _val{size, const_cast<void*>(data)} {}
val(val&& other) noexcept = default;
val& operator=(val&& other) noexcept = default;
~val() noexcept = default;
operator MDB_val*() noexcept {
return &_val;
}
operator const MDB_val*() const noexcept {
return &_val;
}
bool empty() const noexcept {
return size() == 0;
}
std::size_t size() const noexcept {
return _val.mv_size;
}
template<typename T>
T* data() noexcept {
return reinterpret_cast<T*>(_val.mv_data);
}
template<typename T>
const T* data() const noexcept {
return reinterpret_cast<T*>(_val.mv_data);
}
char* data() noexcept {
return reinterpret_cast<char*>(_val.mv_data);
}
const char* data() const noexcept {
return reinterpret_cast<char*>(_val.mv_data);
}
template<typename T>
val& assign(const T* const data,
const std::size_t size) noexcept {
_val.mv_size = size;
_val.mv_data = const_cast<void*>(reinterpret_cast<const void*>(data));
return *this;
}
val& assign(const char* const data) noexcept {
return assign(data, std::strlen(data));
}
val& assign(const std::string& data) noexcept {
return assign(data.data(), data.size());
}
};
#if !(defined(__COVERITY__) || defined(_MSC_VER))
static_assert(std::is_pod<lmdb::val>::value, "lmdb::val must be a POD type");
static_assert(sizeof(lmdb::val) == sizeof(MDB_val), "sizeof(lmdb::val) != sizeof(MDB_val)");
#endif
/* Resource Interface: Environment */
namespace lmdb {
class env;
}
class lmdb::env {
protected:
MDB_env* _handle{nullptr};
public:
static constexpr unsigned int default_flags = 0;
static constexpr mode default_mode = 0644; /* -rw-r--r-- */
static env create(const unsigned int flags = default_flags) {
MDB_env* handle{nullptr};
lmdb::env_create(&handle);
#ifdef LMDBXX_DEBUG
assert(handle != nullptr);
#endif
if (flags) {
try {
lmdb::env_set_flags(handle, flags);
}
catch (const lmdb::error&) {
lmdb::env_close(handle);
throw;
}
}
return env{handle};
}
env(MDB_env* const handle) noexcept
: _handle{handle} {}
env(env&& other) noexcept {
std::swap(_handle, other._handle);
}
env& operator=(env&& other) noexcept {
if (this != &other) {
std::swap(_handle, other._handle);
}
return *this;
}
~env() noexcept {
try { close(); } catch (...) {}
}
operator MDB_env*() const noexcept {
return _handle;
}
MDB_env* handle() const noexcept {
return _handle;
}
void sync(const bool force = true) {
lmdb::env_sync(handle(), force);
}
void close() noexcept {
if (handle()) {
lmdb::env_close(handle());
_handle = nullptr;
}
}
env& open(const char* const path,
const unsigned int flags = default_flags,
const mode mode = default_mode) {
lmdb::env_open(handle(), path, flags, mode);
return *this;
}
env& set_flags(const unsigned int flags,
const bool onoff = true) {
lmdb::env_set_flags(handle(), flags, onoff);
return *this;
}
env& set_mapsize(const std::size_t size) {
lmdb::env_set_mapsize(handle(), size);
return *this;
}
env& set_max_readers(const unsigned int count) {
lmdb::env_set_max_readers(handle(), count);
return *this;
}
env& set_max_dbs(const MDB_dbi count) {
lmdb::env_set_max_dbs(handle(), count);
return *this;
}
};
/* Resource Interface: Transactions */
namespace lmdb {
class txn;
}
class lmdb::txn {
protected:
MDB_txn* _handle{nullptr};
public:
static constexpr unsigned int default_flags = 0;
static txn begin(MDB_env* const env,
MDB_txn* const parent = nullptr,
const unsigned int flags = default_flags) {
MDB_txn* handle{nullptr};
lmdb::txn_begin(env, parent, flags, &handle);
#ifdef LMDBXX_DEBUG
assert(handle != nullptr);
#endif
return txn{handle};
}
txn(MDB_txn* const handle) noexcept
: _handle{handle} {}
txn(txn&& other) noexcept {
std::swap(_handle, other._handle);
}
txn& operator=(txn&& other) noexcept {
if (this != &other) {
std::swap(_handle, other._handle);
}
return *this;
}
~txn() noexcept {
if (_handle) {
try { abort(); } catch (...) {}
_handle = nullptr;
}
}
operator MDB_txn*() const noexcept {
return _handle;
}
MDB_txn* handle() const noexcept {
return _handle;
}
MDB_env* env() const noexcept {
return lmdb::txn_env(handle());
}
void commit() {
lmdb::txn_commit(_handle);
_handle = nullptr;
}
void abort() noexcept {
lmdb::txn_abort(_handle);
_handle = nullptr;
}
void reset() noexcept {
lmdb::txn_reset(_handle);
}
void renew() {
lmdb::txn_renew(_handle);
}
};
/* Resource Interface: Databases */
namespace lmdb {
class dbi;
}
class lmdb::dbi {
protected:
MDB_dbi _handle{0};
public:
static constexpr unsigned int default_flags = 0;
static constexpr unsigned int default_put_flags = 0;
static dbi
open(MDB_txn* const txn,
const char* const name = nullptr,
const unsigned int flags = default_flags) {
MDB_dbi handle{};
lmdb::dbi_open(txn, name, flags, &handle);
return dbi{handle};
}
dbi(const MDB_dbi handle) noexcept
: _handle{handle} {}
dbi(dbi&& other) noexcept {
std::swap(_handle, other._handle);
}
dbi& operator=(dbi&& other) noexcept {
if (this != &other) {
std::swap(_handle, other._handle);
}
return *this;
}
~dbi() noexcept {
if (_handle) {
/* No need to call close() here. */
}
}
operator MDB_dbi() const noexcept {
return _handle;
}
MDB_dbi handle() const noexcept {
return _handle;
}
MDB_stat stat(MDB_txn* const txn) const {
MDB_stat result;
lmdb::dbi_stat(txn, handle(), &result);
return result;
}
unsigned int flags(MDB_txn* const txn) const {
unsigned int result{};
lmdb::dbi_flags(txn, handle(), &result);
return result;
}
std::size_t size(MDB_txn* const txn) const {
return stat(txn).ms_entries;
}
void drop(MDB_txn* const txn,
const bool del = false) {
lmdb::dbi_drop(txn, handle(), del);
}
dbi& set_compare(MDB_txn* const txn,
MDB_cmp_func* const cmp = nullptr) {
lmdb::dbi_set_compare(txn, handle(), cmp);
return *this;
}
bool get(MDB_txn* const txn,
const val& key,
val& data) {
return lmdb::dbi_get(txn, handle(), key, data);
}
template<typename K>
bool get(MDB_txn* const txn,
const K& key) const {
const lmdb::val k{&key, sizeof(K)};
lmdb::val v{};
return lmdb::dbi_get(txn, handle(), k, v);
}
template<typename K, typename V>
bool get(MDB_txn* const txn,
const K& key,
V& val) const {
const lmdb::val k{&key, sizeof(K)};
lmdb::val v{};
const bool result = lmdb::dbi_get(txn, handle(), k, v);
if (result) {
val = *v.data<const V>();
}
return result;
}
template<typename V>
bool get(MDB_txn* const txn,
const char* const key,
V& val) const {
const lmdb::val k{key, std::strlen(key)};
lmdb::val v{};
const bool result = lmdb::dbi_get(txn, handle(), k, v);
if (result) {
val = *v.data<const V>();
}
return result;
}
bool put(MDB_txn* const txn,
const val& key,
val& data,
const unsigned int flags = default_put_flags) {
return lmdb::dbi_put(txn, handle(), key, data, flags);
}
template<typename K>
bool put(MDB_txn* const txn,
const K& key,
const unsigned int flags = default_put_flags) {
const lmdb::val k{&key, sizeof(K)};
lmdb::val v{};
return lmdb::dbi_put(txn, handle(), k, v, flags);
}
template<typename K, typename V>
bool put(MDB_txn* const txn,
const K& key,
const V& val,
const unsigned int flags = default_put_flags) {
const lmdb::val k{&key, sizeof(K)};
lmdb::val v{&val, sizeof(V)};
return lmdb::dbi_put(txn, handle(), k, v, flags);
}
template<typename V>
bool put(MDB_txn* const txn,
const char* const key,
const V& val,
const unsigned int flags = default_put_flags) {
const lmdb::val k{key, std::strlen(key)};
lmdb::val v{&val, sizeof(V)};
return lmdb::dbi_put(txn, handle(), k, v, flags);
}
bool put(MDB_txn* const txn,
const char* const key,
const char* const val,
const unsigned int flags = default_put_flags) {
const lmdb::val k{key, std::strlen(key)};
lmdb::val v{val, std::strlen(val)};
return lmdb::dbi_put(txn, handle(), k, v, flags);
}
bool del(MDB_txn* const txn,
const val& key) {
return lmdb::dbi_del(txn, handle(), key);
}
template<typename K>
bool del(MDB_txn* const txn,
const K& key) {
const lmdb::val k{&key, sizeof(K)};
return lmdb::dbi_del(txn, handle(), k);
}
};
/* Resource Interface: Cursors */
namespace lmdb {
class cursor;
}
class lmdb::cursor {
protected:
MDB_cursor* _handle{nullptr};
public:
static constexpr unsigned int default_flags = 0;
static cursor
open(MDB_txn* const txn,
const MDB_dbi dbi) {
MDB_cursor* handle{};
lmdb::cursor_open(txn, dbi, &handle);
#ifdef LMDBXX_DEBUG
assert(handle != nullptr);
#endif
return cursor{handle};
}
cursor(MDB_cursor* const handle) noexcept
: _handle{handle} {}
cursor(cursor&& other) noexcept {
std::swap(_handle, other._handle);
}
cursor& operator=(cursor&& other) noexcept {
if (this != &other) {
std::swap(_handle, other._handle);
}
return *this;
}
~cursor() noexcept {
try { close(); } catch (...) {}
}
operator MDB_cursor*() const noexcept {
return _handle;
}
MDB_cursor* handle() const noexcept {
return _handle;
}
void close() noexcept {
if (_handle) {
lmdb::cursor_close(_handle);
_handle = nullptr;
}
}
void renew(MDB_txn* const txn) {
lmdb::cursor_renew(txn, handle());
}
MDB_txn* txn() const noexcept {
return lmdb::cursor_txn(handle());
}
MDB_dbi dbi() const noexcept {
return lmdb::cursor_dbi(handle());
}
bool get(MDB_val* const key,
const MDB_cursor_op op) {
return get(key, nullptr, op);
}
bool get(lmdb::val& key,
const MDB_cursor_op op) {
return get(key, nullptr, op);
}
bool get(MDB_val* const key,
MDB_val* const val,
const MDB_cursor_op op) {
return lmdb::cursor_get(handle(), key, val, op);
}
bool get(lmdb::val& key,
lmdb::val& val,
const MDB_cursor_op op) {
return lmdb::cursor_get(handle(), key, val, op);
}
bool get(std::string& key,
std::string& val,
const MDB_cursor_op op) {
lmdb::val k{}, v{};
const bool found = get(k, v, op);
if (found) {
key.assign(k.data(), k.size());
val.assign(v.data(), v.size());
}
return found;
}
template<typename K>
bool find(const K& key,
const MDB_cursor_op op = MDB_SET) {
lmdb::val k{&key, sizeof(K)};
return get(k, nullptr, op);
}
};
#endif /* LMDBXX_H */
lmdb::bad_dbi_error
Exception class for MDB_BAD_DBI errors.
Definition lmdb++.h:196
lmdb::corrupted_error
Exception class for MDB_CORRUPTED errors.
Definition lmdb++.h:155
lmdb::cursor
Resource class for MDB_cursor* handles.
Definition lmdb++.h:1716
lmdb::cursor::get
bool get(lmdb::val &key, const MDB_cursor_op op)
Retrieves a key from the database.
Definition lmdb++.h:1843
lmdb::cursor::handle
MDB_cursor * handle() const noexcept
Returns the underlying MDB_cursor* handle.
Definition lmdb++.h:1783
lmdb::cursor::default_flags
static constexpr unsigned int default_flags
Definition lmdb++.h:1721
lmdb::cursor::_handle
MDB_cursor * _handle
Definition lmdb++.h:1718
lmdb::cursor::get
bool get(lmdb::val &key, lmdb::val &val, const MDB_cursor_op op)
Retrieves a key/value pair from the database.
Definition lmdb++.h:1870
lmdb::cursor::close
void close() noexcept
Closes this cursor.
Definition lmdb++.h:1793
lmdb::cursor::~cursor
~cursor() noexcept
Destructor.
Definition lmdb++.h:1769
lmdb::cursor::get
bool get(MDB_val *const key, const MDB_cursor_op op)
Retrieves a key from the database.
Definition lmdb++.h:1831
lmdb::cursor::find
bool find(const K &key, const MDB_cursor_op op=MDB_SET)
Positions this cursor at the given key.
Definition lmdb++.h:1904
lmdb::cursor::txn
MDB_txn * txn() const noexcept
Returns the cursor's transaction handle.
Definition lmdb++.h:1813
lmdb::cursor::get
bool get(std::string &key, std::string &val, const MDB_cursor_op op)
Retrieves a key/value pair from the database.
Definition lmdb++.h:1884
lmdb::cursor::cursor
cursor(cursor &&other) noexcept
Move constructor.
Definition lmdb++.h:1752
lmdb::cursor::dbi
MDB_dbi dbi() const noexcept
Returns the cursor's database handle.
Definition lmdb++.h:1820
lmdb::cursor::open
static cursor open(MDB_txn *const txn, const MDB_dbi dbi)
Creates an LMDB cursor.
Definition lmdb++.h:1731
lmdb::cursor::operator=
cursor & operator=(cursor &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1759
lmdb::cursor::cursor
cursor(MDB_cursor *const handle) noexcept
Constructor.
Definition lmdb++.h:1746
lmdb::cursor::get
bool get(MDB_val *const key, MDB_val *const val, const MDB_cursor_op op)
Retrieves a key/value pair from the database.
Definition lmdb++.h:1856
lmdb::cursor::renew
void renew(MDB_txn *const txn)
Renews this cursor.
Definition lmdb++.h:1806
lmdb::dbi
Resource class for MDB_dbi handles.
Definition lmdb++.h:1386
lmdb::dbi::size
std::size_t size(MDB_txn *const txn) const
Returns the number of records in this database.
Definition lmdb++.h:1489
lmdb::dbi::default_put_flags
static constexpr unsigned int default_put_flags
Definition lmdb++.h:1392
lmdb::dbi::put
bool put(MDB_txn *const txn, const K &key, const V &val, const unsigned int flags=default_put_flags)
Stores a key/value pair into this database.
Definition lmdb++.h:1630
lmdb::dbi::put
bool put(MDB_txn *const txn, const val &key, val &data, const unsigned int flags=default_put_flags)
Stores a key/value pair into this database.
Definition lmdb++.h:1596
lmdb::dbi::dbi
dbi(const MDB_dbi handle) noexcept
Constructor.
Definition lmdb++.h:1416
lmdb::dbi::del
bool del(MDB_txn *const txn, const val &key)
Removes a key/value pair from this database.
Definition lmdb++.h:1683
lmdb::dbi::set_compare
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:1510
lmdb::dbi::~dbi
~dbi() noexcept
Destructor.
Definition lmdb++.h:1439
lmdb::dbi::get
bool get(MDB_txn *const txn, const val &key, val &data)
Retrieves a key/value pair from this database.
Definition lmdb++.h:1524
lmdb::dbi::stat
MDB_stat stat(MDB_txn *const txn) const
Returns statistics for this database.
Definition lmdb++.h:1465
lmdb::dbi::put
bool put(MDB_txn *const txn, const char *const key, const V &val, const unsigned int flags=default_put_flags)
Stores a key/value pair into this database.
Definition lmdb++.h:1649
lmdb::dbi::flags
unsigned int flags(MDB_txn *const txn) const
Retrieves the flags for this database handle.
Definition lmdb++.h:1477
lmdb::dbi::del
bool del(MDB_txn *const txn, const K &key)
Removes a key/value pair from this database.
Definition lmdb++.h:1696
lmdb::dbi::open
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:1403
lmdb::dbi::default_flags
static constexpr unsigned int default_flags
Definition lmdb++.h:1391
lmdb::dbi::get
bool get(MDB_txn *const txn, const K &key, V &val) const
Retrieves a key/value pair from this database.
Definition lmdb++.h:1554
lmdb::dbi::drop
void drop(MDB_txn *const txn, const bool del=false)
Definition lmdb++.h:1498
lmdb::dbi::put
bool put(MDB_txn *const txn, const char *const key, const char *const val, const unsigned int flags=default_put_flags)
Stores a key/value pair into this database.
Definition lmdb++.h:1667
lmdb::dbi::get
bool get(MDB_txn *const txn, const char *const key, V &val) const
Retrieves a key/value pair from this database.
Definition lmdb++.h:1575
lmdb::dbi::dbi
dbi(dbi &&other) noexcept
Move constructor.
Definition lmdb++.h:1422
lmdb::dbi::_handle
MDB_dbi _handle
Definition lmdb++.h:1388
lmdb::dbi::get
bool get(MDB_txn *const txn, const K &key) const
Retrieves a key from this database.
Definition lmdb++.h:1538
lmdb::dbi::handle
MDB_dbi handle() const noexcept
Returns the underlying MDB_dbi handle.
Definition lmdb++.h:1455
lmdb::dbi::put
bool put(MDB_txn *const txn, const K &key, const unsigned int flags=default_put_flags)
Stores a key into this database.
Definition lmdb++.h:1612
lmdb::dbi::operator=
dbi & operator=(dbi &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1429
lmdb::env
Resource class for MDB_env* handles.
Definition lmdb++.h:1085
lmdb::env::set_flags
env & set_flags(const unsigned int flags, const bool onoff=true)
Definition lmdb++.h:1206
lmdb::env::close
void close() noexcept
Closes this environment, releasing the memory map.
Definition lmdb++.h:1179
lmdb::env::default_mode
static constexpr mode default_mode
Definition lmdb++.h:1091
lmdb::env::set_mapsize
env & set_mapsize(const std::size_t size)
Definition lmdb++.h:1216
lmdb::env::set_max_dbs
env & set_max_dbs(const MDB_dbi count)
Definition lmdb++.h:1234
lmdb::env::~env
~env() noexcept
Destructor.
Definition lmdb++.h:1145
lmdb::env::_handle
MDB_env * _handle
Definition lmdb++.h:1087
lmdb::env::env
env(MDB_env *const handle) noexcept
Constructor.
Definition lmdb++.h:1122
lmdb::env::env
env(env &&other) noexcept
Move constructor.
Definition lmdb++.h:1128
lmdb::env::sync
void sync(const bool force=true)
Flushes data buffers to disk.
Definition lmdb++.h:1169
lmdb::env::handle
MDB_env * handle() const noexcept
Returns the underlying MDB_env* handle.
Definition lmdb++.h:1159
lmdb::env::default_flags
static constexpr unsigned int default_flags
Definition lmdb++.h:1090
lmdb::env::operator=
env & operator=(env &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1135
lmdb::env::create
static env create(const unsigned int flags=default_flags)
Creates a new LMDB environment.
Definition lmdb++.h:1099
lmdb::env::open
env & open(const char *const path, const unsigned int flags=default_flags, const mode mode=default_mode)
Opens this environment.
Definition lmdb++.h:1194
lmdb::env::set_max_readers
env & set_max_readers(const unsigned int count)
Definition lmdb++.h:1225
lmdb::error
Base class for LMDB exception conditions.
Definition lmdb++.h:63
lmdb::error::origin
const char * origin() const noexcept
Returns the origin of the LMDB error.
Definition lmdb++.h:91
lmdb::error::_code
const int _code
Definition lmdb++.h:65
lmdb::error::what
virtual const char * what() const noexcept
Returns the underlying LMDB error code.
Definition lmdb++.h:98
lmdb::error::error
error(const char *const origin, const int rc) noexcept
Constructor.
Definition lmdb++.h:76
lmdb::error::raise
static void raise(const char *origin, int rc)
Throws an error based on the given LMDB return code.
Definition lmdb++.h:202
lmdb::error::code
int code() const noexcept
Returns the underlying LMDB error code.
Definition lmdb++.h:84
lmdb::fatal_error
Base class for fatal error conditions.
Definition lmdb++.h:117
lmdb::key_exist_error
Exception class for MDB_KEYEXIST errors.
Definition lmdb++.h:135
lmdb::logic_error
Base class for logic error conditions.
Definition lmdb++.h:109
lmdb::map_full_error
Exception class for MDB_MAP_FULL errors.
Definition lmdb++.h:185
lmdb::not_found_error
Exception class for MDB_NOTFOUND errors.
Definition lmdb++.h:145
lmdb::panic_error
Exception class for MDB_PANIC errors.
Definition lmdb++.h:165
lmdb::runtime_error
Base class for runtime error conditions.
Definition lmdb++.h:125
lmdb::txn
Resource class for MDB_txn* handles.
Definition lmdb++.h:1253
lmdb::txn::handle
MDB_txn * handle() const noexcept
Returns the underlying MDB_txn* handle.
Definition lmdb++.h:1324
lmdb::txn::commit
void commit()
Commits this transaction.
Definition lmdb++.h:1341
lmdb::txn::env
MDB_env * env() const noexcept
Returns the transaction's MDB_env* handle.
Definition lmdb++.h:1331
lmdb::txn::abort
void abort() noexcept
Aborts this transaction.
Definition lmdb++.h:1351
lmdb::txn::_handle
MDB_txn * _handle
Definition lmdb++.h:1255
lmdb::txn::reset
void reset() noexcept
Resets this read-only transaction.
Definition lmdb++.h:1359
lmdb::txn::default_flags
static constexpr unsigned int default_flags
Definition lmdb++.h:1258
lmdb::txn::operator=
txn & operator=(txn &&other) noexcept
Move assignment operator.
Definition lmdb++.h:1297
lmdb::txn::~txn
~txn() noexcept
Destructor.
Definition lmdb++.h:1307
lmdb::txn::renew
void renew()
Renews this read-only transaction.
Definition lmdb++.h:1368
lmdb::txn::txn
txn(txn &&other) noexcept
Move constructor.
Definition lmdb++.h:1290
lmdb::txn::txn
txn(MDB_txn *const handle) noexcept
Constructor.
Definition lmdb++.h:1284
lmdb::txn::begin
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:1268
lmdb::val
Wrapper class for MDB_val structures.
Definition lmdb++.h:939
lmdb::val::data
char * data() noexcept
Returns a pointer to the data.
Definition lmdb++.h:1030
lmdb::val::val
val(const char *const data) noexcept
Constructor.
Definition lmdb++.h:958
lmdb::val::assign
val & assign(const std::string &data) noexcept
Assigns the value.
Definition lmdb++.h:1062
lmdb::val::_val
MDB_val _val
Definition lmdb++.h:941
lmdb::val::val
val(const void *const data, const std::size_t size) noexcept
Constructor.
Definition lmdb++.h:964
lmdb::val::empty
bool empty() const noexcept
Determines whether this value is empty.
Definition lmdb++.h:1000
lmdb::val::data
const char * data() const noexcept
Returns a pointer to the data.
Definition lmdb++.h:1037
lmdb::val::operator=
val & operator=(val &&other) noexcept=default
Move assignment operator.
lmdb::val::data
const T * data() const noexcept
Returns a pointer to the data.
Definition lmdb++.h:1023
lmdb::val::val
val(val &&other) noexcept=default
Move constructor.
lmdb::val::val
val() noexcept=default
Default constructor.
lmdb::val::data
T * data() noexcept
Returns a pointer to the data.
Definition lmdb++.h:1015
lmdb::val::~val
~val() noexcept=default
Destructor.
lmdb::val::assign
val & assign(const char *const data) noexcept
Assigns the value.
Definition lmdb++.h:1055
lmdb::val::size
std::size_t size() const noexcept
Returns the size of the data.
Definition lmdb++.h:1007
lmdb::val::assign
val & assign(const T *const data, const std::size_t size) noexcept
Assigns the value.
Definition lmdb++.h:1045
lmdb::version_mismatch_error
Exception class for MDB_VERSION_MISMATCH errors.
Definition lmdb++.h:175
lmdb
<lmdb++.h> - C++11 wrapper for LMDB.
Definition lmdb++.h:37
lmdb::env_info
static void env_info(MDB_env *env, MDB_envinfo *stat)
Definition lmdb++.h:347
lmdb::env_get_userctx
static void * env_get_userctx(MDB_env *env)
Definition lmdb++.h:515
lmdb::dbi_flags
static void dbi_flags(MDB_txn *txn, MDB_dbi dbi, unsigned int *flags)
Definition lmdb++.h:664
lmdb::cursor_renew
static void cursor_renew(MDB_txn *txn, MDB_cursor *cursor)
Definition lmdb++.h:845
lmdb::mode
mdb_mode_t mode
Definition lmdb++.h:38
lmdb::env_copy_fd
static void env_copy_fd(MDB_env *env, mdb_filehandle_t fd, unsigned int flags)
Definition lmdb++.h:315
lmdb::txn_commit
static void txn_commit(MDB_txn *txn)
Definition lmdb++.h:574
lmdb::env_open
static void env_open(MDB_env *env, const char *path, unsigned int flags, mode mode)
Definition lmdb++.h:279
lmdb::cursor_txn
static MDB_txn * cursor_txn(MDB_cursor *cursor) noexcept
Definition lmdb++.h:857
lmdb::dbi_drop
static void dbi_drop(MDB_txn *txn, MDB_dbi dbi, bool del)
Definition lmdb++.h:686
lmdb::dbi_put
static bool dbi_put(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, MDB_val *data, unsigned int flags)
Definition lmdb++.h:774
lmdb::env_create
static void env_create(MDB_env **env)
Definition lmdb++.h:267
lmdb::env_get_max_keysize
static unsigned int env_get_max_keysize(MDB_env *env)
Definition lmdb++.h:485
lmdb::cursor_open
static void cursor_open(MDB_txn *txn, MDB_dbi dbi, MDB_cursor **cursor)
Definition lmdb++.h:823
lmdb::cursor_put
static void cursor_put(MDB_cursor *cursor, MDB_val *key, MDB_val *data, unsigned int flags)
Definition lmdb++.h:890
lmdb::env_get_fd
static void env_get_fd(MDB_env *env, mdb_filehandle_t *fd)
Definition lmdb++.h:421
lmdb::cursor_del
static void cursor_del(MDB_cursor *cursor, unsigned int flags)
Definition lmdb++.h:905
lmdb::dbi_set_relfunc
static void dbi_set_relfunc(MDB_txn *txn, MDB_dbi dbi, MDB_rel_func *rel)
Definition lmdb++.h:728
lmdb::dbi_open
static void dbi_open(MDB_txn *txn, const char *name, unsigned int flags, MDB_dbi *dbi)
Definition lmdb++.h:635
lmdb::dbi_set_compare
static void dbi_set_compare(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Definition lmdb++.h:700
lmdb::env_set_max_readers
static void env_set_max_readers(MDB_env *env, unsigned int count)
Definition lmdb++.h:447
lmdb::txn_env
static MDB_env * txn_env(MDB_txn *txn) noexcept
Definition lmdb++.h:555
lmdb::env_set_mapsize
static void env_set_mapsize(MDB_env *env, std::size_t size)
Definition lmdb++.h:434
lmdb::env_set_max_dbs
static void env_set_max_dbs(MDB_env *env, MDB_dbi count)
Definition lmdb++.h:473
lmdb::env_close
static void env_close(MDB_env *env) noexcept
Definition lmdb++.h:372
lmdb::env_set_flags
static void env_set_flags(MDB_env *env, unsigned int flags, bool onoff)
Definition lmdb++.h:381
lmdb::txn_renew
static void txn_renew(MDB_txn *txn)
Definition lmdb++.h:602
lmdb::cursor_close
static void cursor_close(MDB_cursor *cursor) noexcept
Definition lmdb++.h:836
lmdb::cursor_get
static bool cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op)
Definition lmdb++.h:874
lmdb::cursor_count
static void cursor_count(MDB_cursor *cursor, std::size_t &count)
Definition lmdb++.h:918
lmdb::env_get_max_readers
static void env_get_max_readers(MDB_env *env, unsigned int *count)
Definition lmdb++.h:460
lmdb::cursor_dbi
static MDB_dbi cursor_dbi(MDB_cursor *cursor) noexcept
Definition lmdb++.h:865
lmdb::txn_abort
static void txn_abort(MDB_txn *txn) noexcept
Definition lmdb++.h:585
lmdb::env_get_path
static void env_get_path(MDB_env *env, const char **path)
Definition lmdb++.h:408
lmdb::dbi_stat
static void dbi_stat(MDB_txn *txn, MDB_dbi dbi, MDB_stat *stat)
Definition lmdb++.h:650
lmdb::dbi_del
static bool dbi_del(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, const MDB_val *data)
Definition lmdb++.h:792
lmdb::dbi_get
static bool dbi_get(MDB_txn *txn, MDB_dbi dbi, const MDB_val *key, MDB_val *data)
Definition lmdb++.h:757
lmdb::env_copy
static void env_copy(MDB_env *env, const char *path, unsigned int flags)
Definition lmdb++.h:295
lmdb::txn_reset
static void txn_reset(MDB_txn *txn) noexcept
Definition lmdb++.h:593
lmdb::env_set_userctx
static void env_set_userctx(MDB_env *env, void *ctx)
Definition lmdb++.h:500
lmdb::dbi_close
static void dbi_close(MDB_env *env, MDB_dbi dbi) noexcept
Definition lmdb++.h:677
lmdb::env_stat
static void env_stat(MDB_env *env, MDB_stat *stat)
Definition lmdb++.h:334
lmdb::env_sync
static void env_sync(MDB_env *env, bool force)
Definition lmdb++.h:360
lmdb::dbi_set_dupsort
static void dbi_set_dupsort(MDB_txn *txn, MDB_dbi dbi, MDB_cmp_func *cmp)
Definition lmdb++.h:714
lmdb::env_get_flags
static void env_get_flags(MDB_env *env, unsigned int *flags)
Definition lmdb++.h:395
lmdb::txn_begin
static void txn_begin(MDB_env *env, MDB_txn *parent, unsigned int flags, MDB_txn **txn)
Definition lmdb++.h:541
lmdb::dbi_set_relctx
static void dbi_set_relctx(MDB_txn *txn, MDB_dbi dbi, void *ctx)
Definition lmdb++.h:742