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));
#define ELECTRONEUM_PRECOND(...)
If precondition fails, return ::error::kInvalidArgument in current scope.
void * memcpy(void *a, const void *b, size_t c)
int mdb_cursor_get(MDB_cursor *cursor, MDB_val *key, MDB_val *data, MDB_cursor_op op)
Retrieve by cursor.
struct MDB_txn MDB_txn
Opaque structure for a transaction handle.
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_val to_val(T &&value) noexcept
error
Tracks LMDB error codes.
const T & move(const T &t)
const GenericPointer< typename T::ValueType > T2 value
Generic structure used for passing keys and data in and out of the database.
Helper for grouping typical LMDB DBI options when key and value are fixed types.
constexpr basic_table(const char *name, unsigned flags=0, MDB_cmp_func value_cmp=nullptr) noexcept
static expect< value_stream< V, D > > get_value_stream(K const &key, std::unique_ptr< MDB_cursor, D > cur) noexcept
static expect< key_stream< K, V, D > > get_key_stream(std::unique_ptr< MDB_cursor, D > cur) noexcept
static constexpr unsigned compute_flags(const unsigned flags) noexcept
static expect< F > get_value(MDB_val value) noexcept
Helper for grouping typical LMDB DBI options.
expect< MDB_dbi > open(MDB_txn &write_txn) const noexcept
MDB_cmp_func *const value_cmp
MDB_cmp_func *const key_cmp