17 std::vector<uint8_t> out(
sizeof(
MyStruct));
18 std::memcpy(out.data(),
this,
sizeof(
MyStruct));
25 std::memcpy(&out, data,
sizeof(
MyStruct));
37 auto txn = conn->transaction();
42# if __cplusplus >= 201703L
43 auto result = table.
find(1, txn);
44 std::cout <<
"Key 1: " << result.value_or(
"not found") << std::endl;
48 std::cout <<
"Key 1: " << result.second << std::endl;
50 std::cout <<
"Key 1: not found" << std::endl;
55 std::cin.ignore(std::numeric_limits<std::streamsize>::max(),
'\n');
Declaration of the KeyValueTable class for managing key-value pairs in an MDBX database.
Parameters used by Connection to create the MDBX environment.
std::string pathname
Path to the database file or directory containing the database.
static std::shared_ptr< Connection > create(const Config &config)
Creates and connects a new shared Connection instance.
Template class for managing key-value pairs in an MDBX database.
void insert_or_assign(const KeyT &key, const ValueT &value, MDBX_txn *txn=nullptr)
Inserts or replaces key-value pair.
std::pair< bool, ValueT > find_compat(const KeyT &key, MDBX_txn *txn=nullptr) const
Finds value by key.
std::pair< bool, ValueT > find(const KeyT &key, MDBX_txn *txn=nullptr) const
Finds value by key.
void clear(MDBX_txn *txn=nullptr)
Clears all key-value pairs from the database.
Demonstrates storing values of arbitrary types using AnyValueTable.
static MyStruct from_bytes(const void *data, size_t size)
std::vector< uint8_t > to_bytes() const