26 template<
typename K,
typename V>
54 template<
typename U,
typename F = U, std::
size_t offset = 0>
57 static_assert(std::is_same<U, V>(),
"bad ELECTRONEUM_FIELD?");
58 static_assert(std::is_pod<F>(),
"F must be POD");
59 static_assert(
sizeof(
F) + offset <=
sizeof(U),
"bad field type and/or offset");
61 if (
value.mv_size !=
sizeof(U))
65 std::memcpy(std::addressof(out), static_cast<char*>(
value.mv_data) + offset,
sizeof(out));
MDB_cmp_func *const key_cmp
static constexpr unsigned compute_flags(const unsigned flags) noexcept
int() MDB_cmp_func(const MDB_val *a, const MDB_val *b)
A callback function used to compare two keys in a database.
std::unique_ptr< MDB_txn, abort_write_txn > write_txn
MDB_cmp_func *const value_cmp
static expect< F > get_value(MDB_val value) noexcept
struct MDB_txn MDB_txn
Opaque structure for a transaction handle.
static expect< key_stream< K, V, D > > get_key_stream(std::unique_ptr< MDB_cursor, D > cur) noexcept
constexpr basic_table(const char *name, unsigned flags=0, MDB_cmp_func value_cmp=nullptr) noexcept
Helper for grouping typical LMDB DBI options when key and value are fixed types.
int mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op)
Retrieve by cursor.
Generic structure used for passing keys and data in and out of the database.
const T & move(const T &t)
const GenericPointer< typename T::ValueType > T2 value
void * memcpy(void *a, const void *b, size_t c)
#define ELECTRONEUM_PRECOND(...)
If precondition fails, return ::error::kInvalidArgument in current scope.
MDB_val to_val(T &&value) noexcept
Helper for grouping typical LMDB DBI options.
static expect< value_stream< V, D > > get_value_stream(K const &key, std::unique_ptr< MDB_cursor, D > cur) noexcept
error
Tracks LMDB error codes.
expect< MDB_dbi > open(MDB_txn &write_txn) const noexcept