Skip to content

Group cxx_api

Modules > cxx_api

Modules

Type Name
module Environment, Transactions, Cursors, Key-value tables and map handles
module Slices and Buffers
module Exceptions and Errors

Namespaces

Type Name
namespace mdbx
The libmdbx C++ API namespace.
namespace std
STL namespace.

Classes

Type Name
class mdbx::buffer <class ALLOCATOR, typename CAPACITY_POLICY>
The chunk of data stored inside the buffer or located outside it.

Public Types

Type Name
typedef buffer_pair_spec< typename BUFFER::allocator_type, typename BUFFER::reservation_policy > buffer_pair
Combines pair of buffers for key and value to hold an operands for certain operations.
typedef ::MDBX_build_info build_info
libmdbx build information
typedef char8_t byte
The byte-like type that don't presumes aliases for pointers as does the char .
typedef polymorphic_allocator default_allocator
The default allocator for buffer andstring ; resolves topolymorphic_allocator when the latter is available, otherwise tolegacy_allocator .
typedef buffer< default_allocator, default_capacity_policy > default_buffer
Default buffer.
typedef buffer_pair< default_buffer > default_buffer_pair
Default pair of buffers.
typedef ::std::chrono::duration< unsigned, ::std::ratio< 1, 65536 > > duration
Duration in 1/65536 units of second.
typedef ::mdbx_filehandle_t filehandle
The platform-dependent file handle type, i.e. an alias for mdbx_filehandle_t .
typedef ::std::string::allocator_type legacy_allocator
Legacy allocator but it is recommended to use polymorphic_allocator .
typedef ::mdbx::filesystem::path path
The default path type for opening environments; resolves to mdbx::filesystem::path when the filesystem library is available, otherwise tostd::wstring on Windows andstd::string elsewhere.
typedef path_string::value_type path_char
The character type of path_string , i.e.wchar_t on Windows andchar elsewhere.
typedef ::mdbx::filesystem::path::string_type path_string
The string type used by path , i.e.std::wstring on Windows andstd::string elsewhere (orpath::string_type for the filesystem library).
typedef ::std::pmr::string::allocator_type polymorphic_allocator
Default polymorphic allocator for modern code.
typedef ::std::basic_string< char, ::std::char_traits< char >, ALLOCATOR > string
Default single-byte string.
typedef uint64_t txnid
Transaction ID and MVCC-snapshot number.
typedef ::MDBX_version_info version_info
libmdbx version information,

Public Static Attributes

Type Name
const MDBX_chk_callbacks_t silent_chk_callbacks = {}

Public Functions

Type Name
env & alter_flags (MDBX_env_flags_t flags, bool on_off)
Alter environment flags.
void append (map_handle map, const slice & key, const slice & value, bool multivalue_order_preserved=true)
Adding a key-value pair, provided that ascending order of the keys and (optionally) values are preserved.
string< ALLOCATOR > as_base58_string (unsigned wrap_width=0, const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a string with a Base58 dump of the slice content.
string< ALLOCATOR > as_base64_string (unsigned wrap_width=0, const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a string with a Base64 dump of the slice content.
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a buffer with a hexadecimal dump of a passed slice.
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a buffer with a Base58 dump of a passed slice.
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a buffer with a Base64 dump of a passed slice.
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned buffer.
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned buffer.
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned buffer.
string< ALLOCATOR > as_hex_string (bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a string with a hexadecimal dump of the slice content.
string< ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a string with a hexadecimal dump of a passed slice.
string< ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a string with a Base58 dump of a passed slice.
string< ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a string with a Base64 dump of a passed slice.
string< ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned string.
string< ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned string.
string< ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned string.
slice & assign (const void * ptr, size_t bytes)
Assigns the slice to reference [0,bytes-1] of memory pointed by ptr.
slice & assign (const slice & src) noexcept
Assigns the slice to reference the same data as the source slice.
slice & assign (const ::MDBX_val & src)
Assigns the slice to reference the contents of the given MDBX_val .
slice & assign (slice && src) noexcept
Moves the source slice into this one, invalidating the source.
slice & assign (::MDBX_val && src)
Takes over a temporary MDBX_val instance.
slice & assign (const void * begin, const void * end)
Assigns the slice to reference the [begin,end) memory range.
slice & assign (const char * c_str)
Assigns the slice to reference a null-terminated string.
cursor & assign (const cursor & src)
Assigns this cursor to refer to the same handle as the source.
byte at (size_t n) const
Returns the nth byte in the referenced data with bounds checking.
buffer< ALLOCATOR, CAPACITY_POLICY > base58_decode (bool ignore_spaces=false, const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes Base58 dump from the slice content to returned buffer.
buffer< ALLOCATOR, CAPACITY_POLICY > base64_decode (bool ignore_spaces=false, const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes Base64 dump from the slice content to returned buffer.
const byte * begin () noexcept const
Returns an iterator to the beginning of the referenced data.
byte * begin () noexcept
Returns an iterator to the beginning of the referenced data.
void bind (::mdbx::txn & txn, ::mdbx::map_handle map_handle)
Bind/renew a cursor with a new transaction and specified key-value map handle.
constexpr buffer (const struct slice & src, bool make_reference, const allocator_type & alloc=allocator_type())
Constructs a buffer from the given slice, either copying or referencing it.
buffer (const txn & transaction, const struct slice & src, const allocator_type & alloc)
Constructs a buffer owning a clone of the given slice when its data is dirty within the given transaction, otherwise a reference to it.
const byte * byte_ptr () noexcept const
Returns casted to pointer to byte an address of data.
byte * byte_ptr () noexcept
Returns casted to pointer to byte an address of data.
void capture () noexcept
Captures the currently thrown exception, if any.
const char * char_ptr () noexcept const
Returns casted to pointer to char an address of data.
char * char_ptr () noexcept
Returns casted to pointer to char an address of data.
unsigned check_readers ()
Checks for stale readers in the lock table and return number of cleared slots.
MDBX_NODISCARD MDBX_chk_context_t & chk (MDBX_chk_context_t & ctx, const MDBX_chk_callbacks_t * cb=nullptr, MDBX_chk_flags_t flags=MDBX_CHK_DEFAULTS, MDBX_chk_severity_t verbosity=MDBX_chk_info, unsigned timeout_seconds_16dot16=0) const
Checks the integrity of the environment (database).
void clear () noexcept
Makes the slice empty and referencing to nothing.
void clear_map (map_handle map)
Clear key-value map.
bool clear_map (const ::std::string & name, bool throw_if_absent=false)
Clear key-value map by name.
txn_managed clone (void * context=nullptr) const
Clone read transaction.
void clone (txn_managed & txn_for_renew_into_clone, void * context=nullptr) const
Renew given read transaction into clone.
void close_map (const map_handle & map)
Close a key-value map (aka table) handle. Normally unnecessary.
MDBX_error_t code () noexcept const
Returns error code.
int compare_keys (map_handle map, const slice & a, const slice & b) noexcept const
Compare two keys according to a particular key-value map (aka table).
int compare_keys (map_handle map, const pair & a, const pair & b) noexcept const
Compare keys of two pairs according to a particular key-value map (aka table).
int compare_position (const cursor & left, const cursor & right, bool ignore_nested=false)
Compares the positions of two cursors.
int compare_position_nothrow (const cursor & left, const cursor & right, bool ignore_nested=false)
Compares the positions of two cursors without throwing.
int compare_values (map_handle map, const slice & a, const slice & b) noexcept const
Compare two values according to a particular key-value map (aka table).
int compare_values (map_handle map, const pair & a, const pair & b) noexcept const
Compare values of two pairs according to a particular key-value map(aka table).
void copy (const char * destination, bool compactify, bool force_dynamic_size=false)
Copy an MVCC-snapshot of the database to the destination path.
void copy (const ::std::string & destination, bool compactify, bool force_dynamic_size=false)
Copy an MVCC-snapshot of the database to the destination path.
void copy (const ::mdbx::filesystem::path & destination, bool compactify, bool force_dynamic_size=false)
Copy an MVCC-snapshot of the database to the destination path.
void copy (filehandle fd, bool compactify, bool force_dynamic_size=false)
Copy an MVCC-snapshot of the database to the given file handle.
size_t count_multivalue () const
Return count of duplicates for current key.
size_t count_multivalue (MDBX_stat * stat) const
Return count of duplicates for current key, along with basic statistics of the table.
map_handle create_map (const slice & name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
Create new or open existing key-value map.
map_handle create_map (const char * name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
Create new or open existing key-value map.
map_handle create_map (const ::std::string & name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single)
Create new or open existing key-value map.
constexpr cursor (MDBX_cursor * ptr) noexcept
Constructs a non-owning cursor wrapping the given C handle.
cursor (cursor && other) noexcept
Move constructor: the source cursor is nullified.
const void * data () noexcept const
Return a pointer to the beginning of the referenced data.
void * data () noexcept
Return a pointer to the beginning of the referenced data.
defrag_result defrag (VISITOR & visitor, size_t defrag_atleast=0, size_t time_atleast_dot16=0, size_t defrag_enough=0, size_t time_limit_dot16=0, intptr_t acceptable_backlash=-1, intptr_t preferred_batch=0)
Performs database defragmentation.
defrag_result defrag (size_t defrag_atleast=0, size_t time_atleast_dot16=0, size_t defrag_enough=0, size_t time_limit_dot16=0, intptr_t acceptable_backlash=-1, intptr_t preferred_batch=0)
Performs database defragmentation without a progress visitor.
operate_parameters & disable_clear_memory (bool value=true) noexcept
Sets the clear-memory disable mode, i.e. operate_options::disable_clear_memory .
operate_parameters & disable_readahead (bool value=true) noexcept
Sets the readahead disable mode, i.e. operate_options::disable_readahead .
void drop_map (map_handle map)
Drops key-value map using handle.
bool drop_map (const ::std::string & name, bool throw_if_absent=false)
Drop key-value map.
bool empty () noexcept const
Checks whether the slice is empty.
operate_parameters & enable_validation (bool value=true) noexcept
Sets the validation enable mode, i.e. operate_options::enable_validation .
buffer< ALLOCATOR, CAPACITY_POLICY > encode_base58 (unsigned wrap_width=0, const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a buffer with a Base58 dump of the slice content.
buffer< ALLOCATOR, CAPACITY_POLICY > encode_base64 (unsigned wrap_width=0, const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a buffer with a Base64 dump of the slice content.
buffer< ALLOCATOR, CAPACITY_POLICY > encode_hex (bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR & alloc=ALLOCATOR()) const
Returns a buffer with a hexadecimal dump of the slice content.
const byte * end () noexcept const
Return a pointer to the end of the referenced data.
byte * end () noexcept
Return a pointer to the end of the referenced data.
const byte * end_byte_ptr () noexcept const
Returns casted to pointer to byte an end of data.
byte * end_byte_ptr () noexcept
Returns casted to pointer to byte an end of data.
const char * end_char_ptr () noexcept const
Returns casted to pointer to char an end of data.
char * end_char_ptr () noexcept
Returns casted to pointer to char an end of data.
bool ends_with (const slice & suffix) noexcept const
Checks if the data ends with the given suffix.
int enumerate_readers (VISITOR & visitor)
Enumerate readers.
int enumerate_tables (VISITOR & visitor) const
Enumerates user's named tables in a database.
env (env && other) noexcept
Move constructor: the source environment is nullified.
inline ::mdbx::env env () noexcept const
Returns the transaction's environment.
bool eof () const
Checks whether the cursor is at the end-of-table (not positioned).
bool erase (map_handle map, const slice & key)
Removes all values for given key.
bool erase (map_handle map, const slice & key, const slice & value)
Removes the particular multi-value entry of the key.
bool erase (bool whole_multivalue=false)
Removes single key-value pair or all multi-values at the current cursor position.
bool erase (const slice & key, bool whole_multivalue=true)
Seeks and removes first value or whole multi-value of the given key.
bool erase (const slice & key, const slice & value)
Seeks and removes the particular multi-value entry of the key.
size_t erase_bunch (bunch_delete action)
Quickly removes bunches of neighboring items much faster by cutting out entire pages and branches from the B+ tree structure.
size_t erase_range (const cursor & end, bool end_including)
Quickly removes a range of items between the current cursor position and the position of end much faster by cutting out entire pages and branches from the B+ tree structure.
constexpr error (MDBX_error_t error_code) noexcept
Constructs an error instance from the given code.
ptrdiff_t estimate (const cursor & from, const cursor & to)
Estimates the distance (number of items) between two cursor positions.
ptrdiff_t estimate (map_handle map, const pair & from, const pair & to) const
Estimates the number of items between two key-value pairs.
ptrdiff_t estimate (map_handle map, const slice & from, const slice & to) const
Estimates the number of items between two keys.
estimate_result estimate (const slice & key, const slice & value) const
Estimates the number of items between the current position and the given key-value pair.
estimate_result estimate (const slice & key) const
Estimates the number of items between the current position and the given key.
estimate_result estimate (move_operation operation) const
Estimates the number of items up to the boundary defined by the operation.
estimate_result estimate (move_operation operation, const slice & key) const
Estimates the number of items up to the boundary defined by the operation and key.
ptrdiff_t estimate_from_first (map_handle map, const slice & to) const
Estimates the number of items from the first one up to the given key.
estimate_result (const cursor & cursor, move_operation operation, const slice & key, const slice & value)
Estimates the number of items from the given key-value pair per the given operation.
ptrdiff_t estimate_to_last (map_handle map, const slice & from) const
Estimates the number of items from the given key up to the last one.
operate_parameters & exclusive (bool value=true) noexcept
Sets the exclusive mode, i.e. operate_options::exclusive .
uint64_t extra_option (extra_runtime_option option) const
Gets the value of extra runtime options from an environment.
BUFFER extract (map_handle map, const slice & key, const ALLOCATOR & alloc=ALLOCATOR())
Removes and return a value of the key.
size_t find (const slice & needle, size_t pos=0) noexcept const
Finds the first occurrence of needle starting atpos .
size_t find (byte c, size_t pos=0) noexcept const
Finds the first occurrence of the byte c starting atpos .
move_result find (const slice & key, bool throw_notfound=true)
Finds the exact key.
size_t find_first_not_of (const slice & chars, size_t pos=0) noexcept const
Finds the first byte not matching any byte of chars starting atpos .
size_t find_first_not_of (byte c, size_t pos=0) noexcept const
Finds the first byte not equal to c starting atpos .
size_t find_first_of (const slice & chars, size_t pos=0) noexcept const
Finds the first byte matching any byte of chars starting atpos .
size_t find_first_of (byte c, size_t pos=0) noexcept const
Finds the first occurrence of the byte c starting atpos .
size_t find_last_not_of (const slice & chars, size_t pos=npos) noexcept const
Finds the last byte not matching any byte of chars not afterpos .
size_t find_last_not_of (byte c, size_t pos=npos) noexcept const
Finds the last byte not equal to c not afterpos .
size_t find_last_of (const slice & chars, size_t pos=npos) noexcept const
Finds the last byte matching any byte of chars not afterpos .
size_t find_last_of (byte c, size_t pos=npos) noexcept const
Finds the last occurrence of the byte c not afterpos .
move_result find_multivalue (const slice & key, const slice & value, bool throw_notfound=true)
Finds the exact key-value pair in a dupsort table.
MDBX_txn_flags_t flags () const
Returns transaction's flags.
slice get (map_handle map, const slice & key) const
Get value by key from a key-value map (aka table).
slice get (map_handle map, slice key, size_t & values_count) const
Get first of multi-value and values count by key from a key-value multimap (aka table).
slice get (map_handle map, const slice & key, const slice & value_at_absence) const
Get value by key from a key-value map (aka table).
slice get (map_handle map, slice key, size_t & values_count, const slice & value_at_absence) const
Get first of multi-value and values count by key from a key-value multimap (aka table).
MDBX_hsr_func get_HandleSlowReaders () noexcept const
Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled.
inline ::std::vector< pair > get_batch (size_t max_pairs, move_operation op, bool * is_last=nullptr) const
Reads a batch of key-value pairs.
const build_info & get_build () noexcept
Returns libmdbx build information.
MDBX_NODISCARD cache_result get_cached (map_handle map, const slice & key, slice * data, cache_entry & entry) const
Gets a value by key using the transparent read-your-writes cache.
MDBX_NODISCARD slice get_cached (map_handle map, const slice & key, cache_entry & entry, cache_status * status=nullptr) const
Gets a value by key using the transparent read-your-writes cache, throwing exceptions on errors.
canary get_canary () const
Returns the four integer markers (aka "canary") associated with the environment.
void * get_context () noexcept const
Returns the application context associated with the environment.
void * get_context () noexcept const
Returns the application context associated with the transaction.
void * get_context () noexcept const
Returns the application context associated with the cursor.
MDBX_NODISCARD env::durability get_durability () const
Returns current durability mode.
pair_result get_equal_or_great (map_handle map, const slice & key) const
Gets the value for an equal or greater key from a table.
pair_result get_equal_or_great (map_handle map, const slice & key, const slice & value_at_absence) const
Gets the value for an equal or greater key from a table.
filehandle get_filehandle () const
Returns the file descriptor for the DXB file of MDBX environment.
MDBX_env_flags_t get_flags () const
Returns environment flags.
gc_info get_gc_info (VISITOR & visitor) const
Provides information of Garbage Collection and page usage.
gc_info get_gc_info () const
Returns information about garbage collection and page usage.
info get_info () const
Return snapshot information about the MDBX environment.
info get_info (const txn & txn) const
Return information about the MDBX environment accordingly to the specified transaction.
info get_info (bool scan_reader_lock_table=false) const
Returns information about the MDBX transaction.
map_handle::info get_map_flags (map_handle map) const
Returns information about key-value map (aka table) handle.
map_stat get_map_stat (map_handle map) const
Returns statistics for a table.
MDBX_NODISCARD env::mode get_mode () const
Returns current operation mode.
MDBX_NODISCARD env::operate_parameters get_operation_parameters () const
Returns current operation parameters.
MDBX_NODISCARD env::operate_options get_options () const
Returns current operate options.
MDBX_NODISCARD env::reclaiming_options get_reclaiming () const
Returns current reclaiming options.
stat get_stat () const
Returns snapshot statistics about the MDBX environment.
stat get_stat (const txn & txn) const
Return statistics about the MDBX environment accordingly to the specified transaction.
uint32_t get_tree_deepmask (map_handle map) const
Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given table.
const version_info & get_version () noexcept
Returns libmdbx version information.
operate_parameters & half_synchronous_weak_last () noexcept
Sets the durability level to env::durability::half_synchronous_weak_last .
size_t hash_value () noexcept const
Returns the hash value of referenced data.
slice head (size_t n) noexcept const
Returns the first "n" bytes of the slice.
buffer< ALLOCATOR, CAPACITY_POLICY > hex_decode (bool ignore_spaces=false, const ALLOCATOR & alloc=ALLOCATOR()) const
Decodes hexadecimal dump from the slice content to returned buffer.
uint64_t id () const
Return the transaction's ID.
void ignore_key_order ()
Disables the control of the order of keys when reading database pages for this cursor.
constexpr info (map_handle::flags flags, map_handle::state state) noexcept
Constructs the info from the given flags and state.
void insert (map_handle map, const slice & key, slice value)
Inserts a new key-value pair; fails if the key already exists.
void insert (const slice & key, slice value)
Inserts a new key-value pair; fails if the key already exists.
slice insert_reserve (map_handle map, const slice & key, size_t value_length)
Reserves space for a value of the given length for a new key.
slice insert_reserve (const slice & key, size_t value_length)
Reserves space for a value of the given length for a new key.
void invalidate () noexcept
Invalidates the slice by nullifying the data pointer while preserving the length; makes is_valid() returnfalse unless the slice was already of zero length.
bool is_base58 (bool ignore_spaces=false) noexcept const
Checks whether the content of the slice is a Base58 dump.
bool is_base64 (bool ignore_spaces=false) noexcept const
Checks whether the content of the slice is a Base64 dump.
bool is_clean () noexcept const
Checks whether no exception is captured.
bool is_dirty (const void * ptr) const
Checks whether the given data is on a dirty page.
bool is_failure () noexcept const
Checks the error is a failure.
bool is_hex (bool ignore_spaces=false) noexcept const
Checks whether the content of the slice is a hexadecimal dump.
bool is_mdbx_error () noexcept const
Returns true for MDBX's errors.
bool is_null () noexcept const
Checks whether the slice data pointer is nullptr.
bool is_result_false () noexcept const
Checks the error is the "false" result of a MDBX_RESULT_FALSE .
bool is_result_true () noexcept const
Checks the error is the "true" result of a MDBX_RESULT_TRUE .
bool is_success () noexcept const
Checks the error is a success.
MDBX_CXX11_CONSTEXPR_ENUM mdbx::key_mode key_mode () noexcept const
Returns the key comparison mode implied by the flags.
operate_parameters & lazy_weak_tail () noexcept
Sets the durability level to env::durability::lazy_weak_tail .
size_t length () noexcept const
Returns the number of bytes.
operate_parameters & lifo (bool value=true) noexcept
Sets the LIFO reclaiming mode, i.e. reclaiming_options::lifo .
move_result lower_bound (const slice & key, bool throw_notfound=false)
Finds the exact key or the first one greater than it.
move_result lower_bound_multivalue (const slice & key, const slice & value, bool throw_notfound=false)
Finds the exact key and the first multi-value greater-or-equal to the given one.
void make_broken ()
Marks transaction as broken to prevent further operations.
buffer< ALLOCATOR, CAPACITY_POLICY > make_buffer (PRODUCER & producer, const ALLOCATOR & alloc)
Produces a buffer from a mutable byte-producer (see the MutableByteProducer concept).
buffer< ALLOCATOR, CAPACITY_POLICY > make_buffer (const PRODUCER & producer, const ALLOCATOR & alloc)
Produces a buffer from an immutable byte-producer (see the ImmutableByteProducer concept).
geometry & make_dynamic (intptr_t lower=default_value, intptr_t upper=default_value) noexcept
Makes a dynamic-size geometry with the given bounds.
geometry & make_fixed (intptr_t size) noexcept
Makes a fixed-size geometry, i.e. with disabled growing and shrinking.
string< ALLOCATOR > make_string (PRODUCER & producer, const ALLOCATOR & alloc)
Produces a string from a mutable byte-producer (see the MutableByteProducer concept).
string< ALLOCATOR > make_string (const PRODUCER & producer, const ALLOCATOR & alloc)
Produces a string from an immutable byte-producer (see the ImmutableByteProducer concept).
map_handle map () const
Returns the cursor's table (map) handle.
unsigned max_maps () const
Returns the maximum number of named tables for the environment.
unsigned max_readers () const
Returns the maximum number of threads/reader slots for the environment.
slice middle (size_t from, size_t n) noexcept const
Returns the middle "n" bytes of the slice.
move_result (const cursor & cursor, bool throw_notfound)
Reads the current position of the given cursor.
move_result (cursor & cursor, move_operation operation, const slice & key, const slice & value, bool throw_notfound)
Performs the given positioning operation at the specified key-value pair.
operate_parameters & nested_transactions (bool value=true) noexcept
Sets the nested transactions mode, i.e. operate_options::nested_transactions .
operate_parameters & no_sticky_threads (bool value=true) noexcept
Sets the "no sticky threads" mode, i.e. operate_options::no_sticky_threads .
bool on_first () const
Checks whether the cursor is on the first item of the table.
bool on_first_multival () const
Checks whether the cursor is on the first multi-value of the current key.
bool on_last () const
Checks whether the cursor is on the last item of the table.
bool on_last_multival () const
Checks whether the cursor is on the last multi-value of the current key.
cursor_managed open_cursor (map_handle map) const
Opens cursor for specified key-value map handle.
map_handle open_map (const slice & name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
Open existing key-value map.
map_handle open_map (const char * name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
Open existing key-value map.
map_handle open_map (const ::std::string & name, const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual, const ::mdbx::value_mode value_mode=::mdbx::value_mode::single) const
Open existing key-value map.
map_handle open_map_accede (const slice & name) const
Open existing key-value map.
map_handle open_map_accede (const char * name) const
Open existing key-value map.
map_handle open_map_accede (const ::std::string & name) const
Open existing key-value map.
bool operator!= (const error & a, const error & b)
bool operator!= (const slice & a, const slice & b)
bool operator!= (const pair & a, const pair & b)
bool operator< (const slice & a, const slice & b)
bool operator< (const pair & a, const pair & b)
inline ::std::ostream & operator<< (::std::ostream & out, const buffer< ALLOCATOR, CAPACITY_POLICY > & it)
inline ::std::ostream & operator<< (::std::ostream & out, const to_hex & wrapper)
inline ::std::ostream & operator<< (::std::ostream & out, const to_base58 & wrapper)
inline ::std::ostream & operator<< (::std::ostream & out, const to_base64 & wrapper)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const slice &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const pair &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const pair_result &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env::geometry::size &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env::geometry &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env::operate_parameters &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env::mode &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env::durability &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env::reclaiming_options &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env::operate_options &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const env_managed::create_parameters &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const MDBX_log_level_t &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const MDBX_debug_flags_t &)
LIBMDBX_API::std::ostream & operator<< (::std::ostream &, const error &)
inline ::std::ostream & operator<< (::std::ostream & out, const MDBX_error_t & errcode)
bool operator<= (const slice & a, const slice & b)
bool operator<= (const pair & a, const pair & b)
slice & operator= (slice && src) noexcept
Move assignment: the source slice is invalidated.
slice & operator= (::MDBX_val && src)
Takes over a temporary MDBX_val instance.
env & operator= (env && other) noexcept
Move assignment operator.
txn & operator= (txn && other) noexcept
Move assignment operator.
cursor & operator= (cursor && other) noexcept
Move assignment operator.
bool operator== (const error & a, const error & b)
bool operator== (const slice & a, const slice & b)
bool operator== (const pair & a, const pair & b)
bool operator> (const slice & a, const slice & b)
bool operator> (const pair & a, const pair & b)
bool operator>= (const slice & a, const slice & b)
bool operator>= (const pair & a, const pair & b)
byte operator[] (size_t n) noexcept const
Returns the nth byte in the referenced data.
void park_reading (bool autounpark=true)
Park read-only transaction.
txn_managed prepare_read () const
Creates but not start read transaction.
MDBX_error_t put (map_handle map, const slice & key, slice * value, MDBX_put_flags_t flags) noexcept
Stores a key-value pair using the given low-level flags.
void put (map_handle map, const slice & key, slice value, put_mode mode)
Stores a key-value pair in the given mode.
MDBX_error_t put (const slice & key, slice * value, MDBX_put_flags_t flags) noexcept
Stores a key-value pair using the given low-level flags.
void put (const slice & key, slice value, put_mode mode)
Stores a key-value pair in the given mode.
txn & put_canary (const canary & canary)
Set integers markers (aka "canary") associated with the environment.
size_t put_multiple_samelength (map_handle map, const slice & key, const size_t value_length, const void * values_array, size_t values_count, put_mode mode, bool allow_partial=false)
Stores a bunch of same-length multi-values for the given key.
size_t put_multiple_samelength (const slice & key, const size_t value_length, const void * values_array, size_t values_count, put_mode mode, bool allow_partial=false)
Stores a bunch of same-length multi-values for the given key.
constexpr reader_info (int slot, mdbx_pid_t pid, mdbx_tid_t thread, uint64_t txnid, uint64_t lag, size_t used, size_t retained) noexcept
Constructs the reader information.
operate_parameters & readonly () noexcept
Sets the operation mode to env::mode::readonly .
bool refresh ()
Refresh the read-only transaction to the most recent snapshot.
size_t release_all_cursors (bool unbind) const
Unbind or close all cursors.
void remove_prefix (size_t n) noexcept
Drops the first "n" bytes from this slice.
void remove_suffix (size_t n) noexcept
Drops the last "n" bytes from this slice.
void rename_map (map_handle map, const char * new_name)
Переименовывает таблицу ключ-значение.
void rename_map (map_handle map, const slice & new_name)
Переименовывает таблицу ключ-значение.
void rename_map (map_handle map, const ::std::string & new_name)
Переименовывает таблицу ключ-значение.
void renew (::mdbx::txn & txn)
Renew/bind a cursor with a new transaction and previously used key-value map handle.
void renew_reading ()
Renew read-only transaction.
void replace (map_handle map, const slice & key, slice & old_value, const slice & new_value)
Replaces the particular multi-value of the key with a new value.
BUFFER replace (map_handle map, const slice & key, const slice & new_value, const ALLOCATOR & alloc=ALLOCATOR())
Replaces and returns a value of the key with new one.
BUFFER replace_reserve (map_handle map, const slice & key, size_t length, slice & new_value_reservation, const ALLOCATOR & alloc=ALLOCATOR())
Replaces the value of the key reserving space for the new one, and returns the old value as a buffer.
void reset ()
Resets the cursor state.
void reset_reading ()
Reset read-only transaction.
void resurrect_after_fork ()
Restores the environment after fork() , dropping all read-write locks and reader slots of the parent process.
void rethrow_captured () const
Re-throws the captured exception, if any.
size_t rfind (const slice & needle, size_t pos=npos) noexcept const
Finds the last occurrence of needle not afterpos .
size_t rfind (byte c, size_t pos=npos) noexcept const
Finds the last occurrence of the byte c not afterpos .
operate_parameters & robust_synchronous () noexcept
Sets the durability level to env::durability::robust_synchronous .
slice safe_head (size_t n) const
Returns the first "n" bytes of the slice.
slice safe_middle (size_t from, size_t n) const
Returns the middle "n" bytes of the slice.
void safe_remove_prefix (size_t n)
Drops the first "n" bytes from this slice.
void safe_remove_suffix (size_t n)
Drops the last "n" bytes from this slice.
slice safe_tail (size_t n) const
Returns the last "n" bytes of the slice.
bool scroll (intptr_t distable, unsigned deepness=42, bool throw_notfound=true)
Scrolls the cursor to the given distance from the current position.
bool seek (const slice & key)
Seeks the cursor to the exact key.
uint64_t sequence (map_handle map) const
Reads sequence generator associated with a key-value map (aka table).
uint64_t sequence (map_handle map, uint64_t increment)
Reads and increment sequence generator associated with a key-value map (aka table).
env & set_HandleSlowReaders (MDBX_hsr_func cb)
Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled.
env & set_context (void * your_context)
Sets the application context associated with the environment.
txn & set_context (void * your_context)
Sets the application context associated with the transaction.
cursor & set_context (void * your_context)
Sets the application context associated with the cursor.
operate_options & set_disable_clear_memory (bool value=true) noexcept
Sets the clear-memory disable mode.
operate_options & set_disable_readahead (bool value=true) noexcept
Sets the readahead disable mode.
operate_parameters & set_durability (env::durability value) noexcept
Sets the durability level.
operate_options & set_enable_validation (bool value=true) noexcept
Sets the validation enable mode.
slice & set_end (const void * ptr)
Sets the length by specifying the end of the slice data.
operate_options & set_exclusive (bool value=true) noexcept
Sets the exclusive mode.
env & set_extra_option (extra_runtime_option option, uint64_t value)
Sets the value of a extra runtime options for an environment.
create_parameters & set_file_mode_bits (mdbx_mode_t value) noexcept
Sets the file mode bits used for creation of the DB files.
create_parameters & set_geometry (const env::geometry & value) noexcept
Sets the database geometry for size management.
env & set_geometry (const geometry & size)
Set all size-related parameters of environment.
geometry & set_growth_step (intptr_t step) noexcept
Sets the growth step in bytes.
slice & set_length (size_t bytes)
Set slice length.
reclaiming_options & set_lifo (bool value=true) noexcept
Sets the LIFO reclaiming mode.
operate_parameters & set_max_maps (unsigned value) noexcept
Sets the maximum number of named tables/maps for the environment. Zero means default value.
operate_parameters & set_max_readers (unsigned value) noexcept
Sets the maximum number of threads/reader slots for the environment. Zero means default value.
operate_parameters & set_mode (env::mode value) noexcept
Sets the operation mode.
operate_options & set_nested_transactions (bool value=true) noexcept
Sets the nested transactions mode.
operate_options & set_no_sticky_threads (bool value=true) noexcept
Sets the "no sticky threads" mode.
operate_parameters & set_options (const env::operate_options & value) noexcept
Sets the operate options.
geometry & set_pagesize (intptr_t size) noexcept
Sets the database page size for new database creation.
operate_parameters & set_reclaiming (const env::reclaiming_options & value) noexcept
Sets the garbage reclaiming options.
geometry & set_shrink_threshold (intptr_t threshold) noexcept
Sets the shrink threshold in bytes.
geometry & set_size_lower (intptr_t size) noexcept
Sets the lower bound of database size in bytes.
geometry & set_size_now (intptr_t size) noexcept
Sets the size in bytes to setup the database size for now.
geometry & set_size_upper (intptr_t size) noexcept
Sets the upper bound of database size in bytes.
env & set_sync_period__seconds_16dot16 (unsigned seconds_16dot16)
Sets the flush period in 1/65536 of second units; the same as set_sync_period() with the correspondingduration .
env & set_sync_period__seconds_double (double seconds)
Sets the flush period in seconds; the same as set_sync_period() with the correspondingduration .
env & set_sync_threshold (size_t bytes)
Sets threshold to force flush the data buffers to disk, for non-sync durability modes.
create_parameters & set_use_subdirectory (bool value=true) noexcept
Sets whether to use a subdirectory to place the DB files.
size_t size () noexcept const
Returns the number of bytes.
constexpr slice () noexcept
Create an empty slice.
constexpr slice (const void * ptr, size_t bytes)
Create a slice that refers to [0,bytes-1] of memory bytes pointed by ptr.
constexpr slice (const void * begin, const void * end)
Create a slice that refers to [begin,end] of memory bytes.
constexpr slice (const char * c_str)
Create a slice that refers to c_str[0,strlen(c_str)-1].
constexpr slice (const MDBX_val & src)
Create a slice that refers to the contents of the given MDBX_val .
constexpr slice (MDBX_val && src)
Takes over a temporary MDBX_val instance: the slice refers to its bytes and the moved-fromsrc.iov_base is set to null, whilesrc.iov_len is kept (matching the library's own moved-from state); the slice does not own the bytes.
constexpr slice (slice && src) noexcept
Move constructor: the source slice is invalidated.
txn_managed start_read () const
Starts read (read-only) transaction.
txn_managed start_write (bool dont_wait=false)
Starts write (read-write) transaction.
txn_managed start_write (txn & parent)
Starts write (read-write) transaction.
bool starts_with (const slice & prefix) noexcept const
Checks if the data starts with the given prefix.
void success_or_throw () const
Throws the corresponding exception if this error is a failure.
void success_or_throw (const exception_thunk & thunk) const
Throws the corresponding exception, or the captured one if any.
unsigned sync_period__seconds_16dot16 () const
Gets the flush period in 1/65536 of second units.
double sync_period__seconds_double () const
Gets the flush period in seconds.
size_t sync_threshold () const
Gets threshold used to force flush the data buffers to disk, for non-sync durability modes.
bool sync_to_disk (bool force=true, bool nonblock=false)
Flush the environment data buffers.
slice tail (size_t n) noexcept const
Returns the last "n" bytes of the slice.
bool thread_register ()
Registers the current thread as a reader for the environment, i.e. assigns a reader slot.
bool thread_unregister ()
Unregisters the current thread, i.e. releases its reader slot.
void throw_on_failure () const
Throws the corresponding exception if this error is a failure.
value_result try_insert (map_handle map, const slice & key, slice value)
Tries to insert a new key-value pair without throwing on a duplicate.
value_result try_insert (const slice & key, slice value)
Tries to insert a new key-value pair without throwing on a duplicate.
value_result try_insert_reserve (map_handle map, const slice & key, size_t value_length)
Tries to reserve space for a value of the given length for a new key.
value_result try_insert_reserve (const slice & key, size_t value_length)
Tries to reserve space for a value of the given length for a new key.
txn_managed try_start_write ()
Tries to start write (read-write) transaction without blocking.
bool try_update (map_handle map, const slice & key, const slice & value)
Tries to update the value for an existing key without throwing.
bool try_update (const slice & key, const slice & value)
Tries to update the value for an existing key without throwing.
value_result try_update_reserve (map_handle map, const slice & key, size_t value_length)
Tries to reserve space for a value of the given length for an existing key.
value_result try_update_reserve (const slice & key, size_t value_length)
Tries to reserve space for a value of the given length for an existing key.
void turn_for_recovery (unsigned target_meta)
Turns the database to the specified meta-page.
txn (txn && other) noexcept
Move constructor: the source transaction is nullified.
inline ::mdbx::txn txn () const
Returns the cursor's transaction.
bool txn_lock (bool dont_wait=false)
Acquires write-transaction lock.
void txn_unlock ()
Releases write-transaction lock acquired by txn_lock() .
void unbind ()
Unbind cursor from a transaction.
bool unpark_reading (bool restart_if_ousted=true)
Resume parked read-only transaction.
void update (map_handle map, const slice & key, const slice & value)
Updates the value for an existing key; fails if the key is absent.
void update (const slice & key, const slice & value)
Updates the value for an existing key; fails if the key is absent.
slice update_reserve (map_handle map, const slice & key, size_t value_length)
Reserves space for a value of the given length for an existing key.
slice update_reserve (const slice & key, size_t value_length)
Reserves space for a value of the given length for an existing key.
move_result upper_bound (const slice & key, bool throw_notfound=false)
Finds the first key greater than the given one.
move_result upper_bound_multivalue (const slice & key, const slice & value, bool throw_notfound=false)
Finds the exact key and the first multi-value greater than the given one.
void upsert (map_handle map, const slice & key, const slice & value)
Inserts or updates the value for the given key.
void upsert (const slice & key, const slice & value)
Inserts or updates the value for the given key.
slice upsert_reserve (map_handle map, const slice & key, size_t value_length)
Reserves space for a value of the given length, inserting or updating the key.
slice upsert_reserve (const slice & key, size_t value_length)
Reserves space for a value of the given length, inserting or updating the key.
MDBX_CXX11_CONSTEXPR_ENUM mdbx::value_mode value_mode () noexcept const
Returns the value comparison mode implied by the flags.
MDBX_NODISCARD int warmup (MDBX_warmup_flags_t flags, unsigned timeout_seconds_16dot16, const MDBX_txn * txn=nullptr) const
Loads into memory the given pages of the database and their on-disk neighbours in advance.
operate_parameters & whole_fragile () noexcept
Sets the durability level to env::durability::whole_fragile .
operate_parameters & write_file_io () noexcept
Sets the operation mode to env::mode::write_file_io .
operate_parameters & write_mapped_io () noexcept
Sets the operation mode to env::mode::write_mapped_io .
~cursor () noexcept
Destroys the wrapper; the underlying object is NOT closed since the cursor is non-owning.
~env () noexcept
Destroys the wrapper; the underlying object is NOT closed since the environment is non-owning.
~txn () noexcept
Destroys the wrapper; the underlying object is NOT finished since the transaction is non-owning.

Public Static Functions

Type Name
bool boolean_or_throw (int error_code)
Throws the corresponding exception if the code is a failure.
bool boolean_or_throw (int error_code, const exception_thunk & thunk)
Throws the corresponding exception, or the captured one if any.
intptr_t compare_fast (const slice & a, const slice & b) noexcept
Three-way fast non-lexicographically length-based comparison.
intptr_t compare_fast (const pair & a, const pair & b) noexcept
Three-way fast non-lexicographically length-based comparison.
intptr_t compare_lexicographically (const slice & a, const slice & b) noexcept
Three-way lexicographically comparison.
intptr_t compare_lexicographically (const pair & a, const pair & b) noexcept
Three-way lexicographically comparison.
size_t dbsize_max (intptr_t pagesize)
Returns the maximal database size in bytes for specified page size.
size_t dbsize_min (intptr_t pagesize)
Returns the minimal database size in bytes for specified page size.
ptrdiff_t distance_between (const cursor from, const cursor to, unsigned deepness=42)
Estimates the distance (number of items) between two cursor positions.
bool distribute (const cursor from, const cursor to, cursor * cursors_array, intptr_t cursors_array_size, unsigned deepness=42)
Distributes cursors evenly over the range between two positions.
bool distribute (const cursor from, const cursor to, const std::vector< cursor > & cursors, unsigned deepness=42)
Distributes cursors evenly over the range between two positions.
bool distribute (const cursor from, const cursor to, const std::vector< cursor_managed > & cursors, unsigned deepness=42)
Distributes cursors evenly over the range between two positions.
operate_parameters fragile_write () noexcept
Constructs parameters for a writable environment with env::durability::whole_fragile durability and_env::mode::write_mapped_io ._
MDBX_NODISCARD info get_preopen_snapinfo (const ::std::string & pathname, MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY)
Provides information about a database, including meta-page and geometry, without opening it.
MDBX_NODISCARD info get_preopen_snapinfo (const char * pathname, MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY)
Provides information about a database, including meta-page and geometry, without opening it.
MDBX_NODISCARD info get_preopen_snapinfo (const ::mdbx::filesystem::path & pathname, MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY)
Provides information about a database, including meta-page and geometry, without opening it.
MDBX_NODISCARD sysraminfo get_sysraminfo ()
Returns information about the system RAM.
size_t key_max (intptr_t pagesize, MDBX_db_flags_t flags)
Returns the maximal key size in bytes for specified page size and table flags.
size_t key_max (intptr_t pagesize, key_mode mode)
Returns the maximal key size in bytes for specified page size and keys mode.
size_t key_max (const env & env, MDBX_db_flags_t flags)
Returns the maximal key size in bytes for given environment and table flags.
size_t key_max (const env & env, key_mode mode)
Returns the maximal key size in bytes for given environment and keys mode.
size_t key_min (MDBX_db_flags_t flags) noexcept
Returns the minimal key size in bytes for specified table flags.
size_t key_min (key_mode mode) noexcept
Returns the minimal key size in bytes for specified keys mode.
operate_parameters lazy_write () noexcept
Constructs parameters for a writable environment with env::durability::lazy_weak_tail durability and_env::mode::write_mapped_io ._
size_t max_map_handles (void)
Returns the maximum opened map handles, aka DBI-handles.
int memcmp (const void * a, const void * b, size_t bytes) noexcept
constexpr-enabled memcmp().
void * memcpy (void * dest, const void * src, size_t bytes) noexcept
constexpr-enabled memcpy().
MDBX_NODISCARD env::operate_options options_from_flags (MDBX_env_flags_t flags) noexcept
Extracts the other options from environment flags.
size_t pagesize_max () noexcept
Returns the maximal database page size in bytes.
size_t pagesize_min () noexcept
Returns the minimal database page size in bytes.
size_t pairsize4page_max (intptr_t pagesize, MDBX_db_flags_t flags)
Returns maximal size of key-value pair to fit in a single page for specified page size and table flags.
size_t pairsize4page_max (intptr_t pagesize, value_mode mode)
Returns maximal size of key-value pair to fit in a single page for specified page size and values mode.
size_t pairsize4page_max (const env & env, MDBX_db_flags_t flags)
Returns maximal size of key-value pair to fit in a single page for given environment and table flags.
size_t pairsize4page_max (const env & env, value_mode mode)
Returns maximal size of key-value pair to fit in a single page for given environment and values mode.
operate_parameters read_only () noexcept
Constructs parameters for a read-only environment.
MDBX_NODISCARD env::reclaiming_options reclaiming_from_flags (MDBX_env_flags_t flags) noexcept
Extracts the reclaiming options from environment flags.
operate_parameters safe_write () noexcept
Constructs parameters for a writable environment with env::durability::robust_synchronous durability and_env::mode::write_mapped_io ._
size_t strlen (const char * c_str) noexcept
constexpr-enabled strlen().
void success_or_throw (MDBX_error_t error_code)
Throws the corresponding exception if the code is a failure.
void success_or_throw (int error_code, const exception_thunk & thunk)
Throws the corresponding exception, or the captured one if any.
void throw_exception (int error_code)
Panics on unrecoverable errors inside destructors etc.
void throw_on_failure (int error_code)
Throws the corresponding exception if the code is a failure.
void throw_on_nullptr (const void * ptr, MDBX_error_t error_code)
Throws the corresponding exception if the pointer is null.
size_t transaction_size_max (intptr_t pagesize)
Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for specified page size.
size_t valsize4page_max (intptr_t pagesize, MDBX_db_flags_t flags)
Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified size and table flags.
size_t valsize4page_max (intptr_t pagesize, value_mode mode)
Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified page size and values mode.
size_t valsize4page_max (const env & env, MDBX_db_flags_t flags)
Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for given environment and table flags.
size_t valsize4page_max (const env & env, value_mode mode)
Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for given environment and values mode.
size_t value_max (intptr_t pagesize, MDBX_db_flags_t flags)
Returns the maximal value size in bytes for specified page size and table flags.
size_t value_max (intptr_t pagesize, value_mode mode)
Returns the maximal value size in bytes for specified page size and values mode.
size_t value_max (const env & env, MDBX_db_flags_t flags)
Returns the maximal value size in bytes for given environment and table flags.
size_t value_max (const env & env, value_mode mode)
Returns the maximal value size in bytes for given environment and values mode.
size_t value_min (MDBX_db_flags_t flags) noexcept
Returns the minimal values size in bytes for specified table flags.
size_t value_min (value_mode mode) noexcept
Returns the minimal values size in bytes for specified values mode.

Protected Functions

Type Name
constexpr env (MDBX_env * ptr) noexcept
Constructs a non-owning environment wrapping the given C handle.
ptrdiff_t estimate (move_operation operation, MDBX_val * key, MDBX_val * value) const
The low-level range estimation primitive.
bool move (move_operation operation, MDBX_val * key, MDBX_val * value, bool throw_notfound) const
The low-level positioning primitive.
constexpr txn (MDBX_txn * ptr) noexcept
Constructs a non-owning transaction wrapping the given C handle.

Macros

Type Name
define MDBX_CXX_HAS_POLYMORPHIC_ALLOCATOR 1
Defined as 1 if themdbx::polymorphic_allocator is available.
define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path
Defined if mdbx::filesystem::path is available.

Public Types Documentation

typedef buffer_pair

Combines pair of buffers for key and value to hold an operands for certain operations.

using mdbx::buffer_pair = buffer_pair_spec<typename BUFFER::allocator_type, typename BUFFER::reservation_policy>;

typedef build_info

libmdbx build information

using mdbx::build_info = ::MDBX_build_info;

Attention:

Some strings could be NULL in case no corresponding information was provided at build time (i.e. flags).


typedef byte

The byte-like type that don't presumes aliases for pointers as does the char .

using mdbx::byte = char8_t;

Essentially, to enable all kinds of an compiler optimization, we need just the unsigned char * restrict type in C99 terms, i.e. the non-aliasing pointer to unsigned char. However, C++ still doesn't have restrict keyword not non-aliases type attribute, but a char-pointers may be aliased.

On the other hand, while uint8_t is provided and CHAR_BIT = 8 the char8_t * actually act the same as the C99 unsigned char * restrict. So using char8_t should not be an issue, since both the CHAR_BIT = 8 and uint8_tare required.

At the same time, the approach of using char8_t has several advantages: * the restrict attribute is defined on level of the base type and is inherited by any derived pointer type; * some compilers treat __restrict as an attribute of an instance of a type (i.e. a variable, a specific pointer), but not a type attribute.

Nonetheless, I should think about switching to the uint8_t * __restrict__ for byte pointers.

Note:

Functions whose signature depends on the mdbx::byte type must be strictly defined as inline!


typedef default_allocator

The default allocator for buffer andstring ; resolves topolymorphic_allocator when the latter is available, otherwise tolegacy_allocator .

using mdbx::default_allocator = polymorphic_allocator;

typedef default_buffer

Default buffer.

using mdbx::default_buffer = buffer<default_allocator, default_capacity_policy>;

typedef default_buffer_pair

Default pair of buffers.

using mdbx::default_buffer_pair = buffer_pair<default_buffer>;

typedef duration

Duration in 1/65536 units of second.

using mdbx::duration = ::std::chrono::duration<unsigned, ::std::ratio<1, 65536>>;

typedef filehandle

The platform-dependent file handle type, i.e. an alias for mdbx_filehandle_t .

using mdbx::filehandle = ::mdbx_filehandle_t;

typedef legacy_allocator

Legacy allocator but it is recommended to use polymorphic_allocator .

using mdbx::legacy_allocator = ::std::string::allocator_type;

typedef path

The default path type for opening environments; resolves to mdbx::filesystem::path when the filesystem library is available, otherwise tostd::wstring on Windows andstd::string elsewhere.

using mdbx::path = ::mdbx::filesystem::path;

typedef path_char

The character type of path_string , i.e.wchar_t on Windows andchar elsewhere.

using mdbx::path_char = path_string::value_type;

typedef path_string

The string type used by path , i.e.std::wstring on Windows andstd::string elsewhere (orpath::string_type for the filesystem library).

using mdbx::path_string = ::mdbx::filesystem::path::string_type;

typedef polymorphic_allocator

Default polymorphic allocator for modern code.

using mdbx::polymorphic_allocator = ::std::pmr::string::allocator_type;

typedef string

Default single-byte string.

using mdbx::string = ::std::basic_string<char, ::std::char_traits<char>, ALLOCATOR>;

typedef txnid

Transaction ID and MVCC-snapshot number.

using mdbx::txnid = uint64_t;

typedef version_info

libmdbx version information,

using mdbx::version_info = ::MDBX_version_info;

See also: https://semver.org/


Public Static Attributes Documentation

variable silent_chk_callbacks

const MDBX_chk_callbacks_t mdbx::silent_chk_callbacks;

Zeroed set of check callbacks for a "silent" integrity check.


Public Functions Documentation

function alter_flags

Alter environment flags.

inline env & alter_flags (
    MDBX_env_flags_t flags,
    bool on_off
) 

Parameters:

  • flags The flags.
  • on_off The on_off argument.

Returns:

The environment instance.


function append

Adding a key-value pair, provided that ascending order of the keys and (optionally) values are preserved.

inline void append (
    map_handle map,
    const slice & key,
    const slice & value,
    bool multivalue_order_preserved=true
) 

Instead of splitting the full b+tree pages, the data will be placed on new ones. Thus appending is about two times faster than insertion, and the pages will be filled in completely mostly but not half as after splitting ones. On the other hand, any subsequent insertion or update with an increase in the length of the value will be twice as slow, since it will require splitting already filled pages.

Parameters:

  • map A map handle to append
  • key A key to be append
  • value A value to store with the key
  • multivalue_order_preserved If multivalue_order_preserved == true then the same rules applied for to pages of nested b+tree of multimap's values.

function as_base58_string

Returns a string with a Base58 dump of the slice content.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_base58_string (
    unsigned wrap_width=0,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the resulting string.

Returns:

The string with the Base58 dump.


function as_base64_string

Returns a string with a Base64 dump of the slice content.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_base64_string (
    unsigned wrap_width=0,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the resulting string.

Returns:

The string with the Base64 dump.


function as_buffer

Returns a buffer with a hexadecimal dump of a passed slice.

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the hexadecimal dump.


function as_buffer

Returns a buffer with a Base58 dump of a passed slice.

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the Base58 dump.


function as_buffer

Returns a buffer with a Base64 dump of a passed slice.

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the Base64 dump.


function as_buffer

Decodes hexadecimal dump from a passed slice to returned buffer.

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the decoded data.


function as_buffer

Decodes Base58 dump from a passed slice to returned buffer.

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the decoded data.


function as_buffer

Decodes Base64 dump from a passed slice to returned buffer.

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the decoded data.


function as_hex_string

Returns a string with a hexadecimal dump of the slice content.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_hex_string (
    bool uppercase=false,
    unsigned wrap_width=0,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • uppercase Use uppercase letters for hexadecimal digits.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the resulting string.

Returns:

The string with the hexadecimal dump.


function as_string

Returns a string with a hexadecimal dump of a passed slice.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_string (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting string.

Returns:

The string with the hexadecimal dump.


function as_string

Returns a string with a Base58 dump of a passed slice.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_string (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting string.

Returns:

The string with the Base58 dump.


function as_string

Returns a string with a Base64 dump of a passed slice.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_string (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting string.

Returns:

The string with the Base64 dump.


function as_string

Decodes hexadecimal dump from a passed slice to returned string.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_string (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting string.

Returns:

The string with the decoded data.


function as_string

Decodes Base58 dump from a passed slice to returned string.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_string (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting string.

Returns:

The string with the decoded data.


function as_string

Decodes Base64 dump from a passed slice to returned string.

template<class ALLOCATOR>
inline string< ALLOCATOR > as_string (
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • alloc The allocator for the resulting string.

Returns:

The string with the decoded data.


function assign

Assigns the slice to reference [0,bytes-1] of memory pointed by ptr.

inline slice & assign (
    const void * ptr,
    size_t bytes
) 

Parameters:

  • ptr The address of the data to be referenced.
  • bytes The number of bytes to be referenced.

Returns:

A reference to this instance.


function assign

Assigns the slice to reference the same data as the source slice.

inline slice & assign (
    const slice & src
) noexcept

Parameters:

  • src The source slice.

Returns:

A reference to this instance.


function assign

Assigns the slice to reference the contents of the given MDBX_val .

inline slice & assign (
    const ::MDBX_val & src
) 

Parameters:

  • src The source MDBX_val instance.

Returns:

A reference to this instance.


function assign

Moves the source slice into this one, invalidating the source.

inline slice & assign (
    slice && src
) noexcept

Parameters:

  • src The source slice to be moved from.

Returns:

A reference to this instance.


function assign

Takes over a temporary MDBX_val instance.

inline slice & assign (
    ::MDBX_val && src
) 

Parameters:

  • src The source MDBX_val to be moved from.

Returns:

A reference to this instance.


function assign

Assigns the slice to reference the [begin,end) memory range.

inline slice & assign (
    const void * begin,
    const void * end
) 

Parameters:

  • begin The address of the first byte to be referenced.
  • end The address just after the last byte to be referenced.

Returns:

A reference to this instance.


function assign

Assigns the slice to reference a null-terminated string.

inline slice & assign (
    const char * c_str
) 

Parameters:

  • c_str The source null-terminated string.

Returns:

A reference to this instance.


function assign

Assigns this cursor to refer to the same handle as the source.

inline cursor & assign (
    const cursor & src
) 

Parameters:

  • src The source cursor.

Returns:

A reference to this instance.


function at

Returns the nth byte in the referenced data with bounds checking.

byte at (
    size_t n
) const

Parameters:

  • n The index of the byte.

Returns:

The nth byte.

Exception:

  • std::out_of_range if n >= size()

function base58_decode

Decodes Base58 dump from the slice content to returned buffer.

template<class ALLOCATOR, class CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > base58_decode (
    bool ignore_spaces=false,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the decoded data.


function base64_decode

Decodes Base64 dump from the slice content to returned buffer.

template<class ALLOCATOR, class CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > base64_decode (
    bool ignore_spaces=false,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the decoded data.


function begin

Returns an iterator to the beginning of the referenced data.

const byte * begin () noexcept const

Returns:

The read-only pointer to the first byte.


function begin

Returns an iterator to the beginning of the referenced data.

byte * begin () noexcept

Returns:

The read-only pointer to the first byte.


function bind

Bind/renew a cursor with a new transaction and specified key-value map handle.

inline void bind (
    ::mdbx::txn & txn,
    ::mdbx::map_handle map_handle
) 

Parameters:

  • txn The new transaction to attach the cursor to.
  • map_handle The key-value map (table) handle.

Exception:


function buffer

Constructs a buffer from the given slice, either copying or referencing it.

constexpr buffer (
    const struct slice & src,
    bool make_reference,
    const allocator_type & alloc=allocator_type()
) 

Parameters:

  • src The source slice.
  • make_reference Make the buffer a reference to the source data instead of copying it.
  • alloc The allocator for the buffer storage.

function buffer

Constructs a buffer owning a clone of the given slice when its data is dirty within the given transaction, otherwise a reference to it.

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline buffer (
    const txn & transaction,
    const struct slice & src,
    const allocator_type & alloc
) 

Parameters:

  • transaction The transaction to check the data dirtiness against.
  • src The source slice.
  • alloc The allocator for the owned storage.

function byte_ptr

Returns casted to pointer to byte an address of data.

const byte * byte_ptr () noexcept const

Returns:

The read-only pointer to the first byte.


function byte_ptr

Returns casted to pointer to byte an address of data.

byte * byte_ptr () noexcept

Returns:

The mutable pointer to the first byte.


function capture

Captures the currently thrown exception, if any.

inline void capture () noexcept

function char_ptr

Returns casted to pointer to char an address of data.

const char * char_ptr () noexcept const

Returns:

The read-only pointer to the first byte.


function char_ptr

Returns casted to pointer to char an address of data.

char * char_ptr () noexcept

Returns:

The mutable pointer to the first byte.


function check_readers

Checks for stale readers in the lock table and return number of cleared slots.

inline unsigned check_readers () 

Returns:

The number of cleared stale reader slots.


function chk

Checks the integrity of the environment (database).

inline MDBX_NODISCARD  MDBX_chk_context_t & chk (
    MDBX_chk_context_t & ctx,
    const MDBX_chk_callbacks_t * cb=nullptr,
    MDBX_chk_flags_t flags=MDBX_CHK_DEFAULTS,
    MDBX_chk_severity_t verbosity=MDBX_chk_info,
    unsigned timeout_seconds_16dot16=0
) const

Performs a full consistency check of the database with interactive callbacks, see mdbx_env_chk(). The caller provides an MDBX_chk_context_t context where the results of the check are generated (ctx.result), and optionally a set of callbacks (cb, all fields may be nullptr).

Note:

The API is not frozen yet and may be improved in future versions.

Parameters:

  • ctx A zero-initialized context of the check, where the results are generated. ctx.result.tables is valid only inside the callbacks and is nullptr once the check returns.
  • cb A set of callback functions, all optional. nullptr means no callbacks.
  • flags Flags/options of the check, MDBX_chk_flags_t.
  • verbosity The required detail level of progress and results.
  • timeout_seconds_16dot16 Duration limit of the check in 1/65536 fractions of a second, zero means no limit.

Returns:

The reference to the ctx for chaining.

Exception:

See also: mdbx_env_chk()


function clear

Makes the slice empty and referencing to nothing.

void clear () noexcept

function clear_map

Clear key-value map.

inline void clear_map (
    map_handle map
) 

Parameters:

  • map The table (map) handle.

Exception:


function clear_map

Clear key-value map by name.

inline bool clear_map (
    const ::std::string & name,
    bool throw_if_absent=false
) 

Parameters:

  • name The table name.
  • throw_if_absent Throw mdbx::not_found if the table does not exist.

Returns:

True if the key-value map existed and was cleared, either false if the key-value map did not exist and there is nothing to clear.


function clone

Clone read transaction.

inline txn_managed clone (
    void * context=nullptr
) const

Parameters:

  • context The application context.

Returns:

The managed transaction instance.


function clone

Renew given read transaction into clone.

inline void clone (
    txn_managed & txn_for_renew_into_clone,
    void * context=nullptr
) const

Parameters:

  • txn_for_renew_into_clone The txn_for_renew_into_clone argument.
  • context The application context.

function close_map

Close a key-value map (aka table) handle. Normally unnecessary.

inline void close_map (
    const map_handle & map
) 

Closing a table handle is not necessary, but lets txn::open_map() reuse the handle value. Usually it's better to set a bigger env::operate_parameters::max_maps, unless that value would be large.

Note:

Use with care. This call is synchronized via mutex with other calls close_map(), but NOT with other transactions running by other threads. The "next" version of libmdbx (MithrilDB) will solve this issue.

Handles should only be closed if no other threads are going to reference the table handle or one of its cursors any further. Do not close a handle if an existing transaction has modified its table. Doing so can cause misbehavior from database corruption to errors like MDBX_BAD_DBI (since the DB name is gone).

Parameters:

  • map The table (map) handle to be closed.

function code

Returns error code.

MDBX_error_t code () noexcept const

Returns:

The stored MDBX_error_t code.


function compare_keys

Compare two keys according to a particular key-value map (aka table).

inline int compare_keys (
    map_handle map,
    const slice & a,
    const slice & b
) noexcept const

Parameters:

  • map The table (map) handle.
  • a The left-hand operand.
  • b The right-hand operand.

Returns:

The resulting value.


function compare_keys

Compare keys of two pairs according to a particular key-value map (aka table).

inline int compare_keys (
    map_handle map,
    const pair & a,
    const pair & b
) noexcept const

Parameters:

  • map The table (map) handle.
  • a The left-hand operand.
  • b The right-hand operand.

Returns:

The resulting value.


function compare_position

Compares the positions of two cursors.

inline int compare_position (
    const cursor & left,
    const cursor & right,
    bool ignore_nested=false
) 

Parameters:

  • left The left-hand cursor.
  • right The right-hand cursor.
  • ignore_nested Ignore the position within a nested (dupsort) tree.

Returns:

A negative value if left is before right, a positive value if after, zero if at the same position.

Exception:

  • std::logic_error if the cursors are incomparable.

function compare_position_nothrow

Compares the positions of two cursors without throwing.

inline int compare_position_nothrow (
    const cursor & left,
    const cursor & right,
    bool ignore_nested=false
) 

Parameters:

  • left The left-hand cursor.
  • right The right-hand cursor.
  • ignore_nested Ignore the position within a nested (dupsort) tree.

Returns:

A negative value if left is before right, a positive value if after, zero if at the same position, or MDBX_RESULT_TRUE when the cursors are incomparable.


function compare_values

Compare two values according to a particular key-value map (aka table).

inline int compare_values (
    map_handle map,
    const slice & a,
    const slice & b
) noexcept const

Parameters:

  • map The table (map) handle.
  • a The left-hand operand.
  • b The right-hand operand.

Returns:

The resulting value.


function compare_values

Compare values of two pairs according to a particular key-value map(aka table).

inline int compare_values (
    map_handle map,
    const pair & a,
    const pair & b
) noexcept const

Parameters:

  • map The table (map) handle.
  • a The left-hand operand.
  • b The right-hand operand.

Returns:

The resulting value.


function copy

Copy an MVCC-snapshot of the database to the destination path.

inline void copy (
    const char * destination,
    bool compactify,
    bool force_dynamic_size=false
) 

Copies the consistent state as seen by this transaction, see mdbx_txn_copy2pathname().

See also: env::copy()

Parameters:

  • destination The destination argument.
  • compactify The compactify argument.
  • force_dynamic_size The force_dynamic_size argument.

function copy

Copy an MVCC-snapshot of the database to the destination path.

inline void copy (
    const ::std::string & destination,
    bool compactify,
    bool force_dynamic_size=false
) 

Copies the consistent state as seen by this transaction, see mdbx_txn_copy2pathname().

See also: env::copy()

Parameters:

  • destination The destination argument.
  • compactify The compactify argument.
  • force_dynamic_size The force_dynamic_size argument.

function copy

Copy an MVCC-snapshot of the database to the destination path.

inline void copy (
    const ::mdbx::filesystem::path & destination,
    bool compactify,
    bool force_dynamic_size=false
) 

Copies the consistent state as seen by this transaction, see mdbx_txn_copy2pathname().

See also: env::copy()

Parameters:

  • destination The destination argument.
  • compactify The compactify argument.
  • force_dynamic_size The force_dynamic_size argument.

function copy

Copy an MVCC-snapshot of the database to the given file handle.

inline void copy (
    filehandle fd,
    bool compactify,
    bool force_dynamic_size=false
) 

See also: mdbx_txn_copy2fd()

Parameters:

  • fd The file descriptor.
  • compactify The compactify argument.
  • force_dynamic_size The force_dynamic_size argument.

function count_multivalue

Return count of duplicates for current key.

inline size_t count_multivalue () const

Returns:

The number of multi-values at the current key.


function count_multivalue

Return count of duplicates for current key, along with basic statistics of the table.

inline size_t count_multivalue (
    MDBX_stat * stat
) const

See also: mdbx_cursor_count_ex()

Parameters:

  • stat Optional address of an MDBX_stat structure to be filled.

Returns:

The number of multi-values at the current key.


function create_map

Create new or open existing key-value map.

inline map_handle create_map (
    const slice & name,
    const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual,
    const ::mdbx::value_mode value_mode=::mdbx::value_mode::single
) 

Parameters:

Returns:

The table (map) handle.


function create_map

Create new or open existing key-value map.

inline map_handle create_map (
    const char * name,
    const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual,
    const ::mdbx::value_mode value_mode=::mdbx::value_mode::single
) 

Parameters:

Returns:

The table (map) handle.


function create_map

Create new or open existing key-value map.

inline map_handle create_map (
    const ::std::string & name,
    const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual,
    const ::mdbx::value_mode value_mode=::mdbx::value_mode::single
) 

Parameters:

Returns:

The table (map) handle.


function cursor

Constructs a non-owning cursor wrapping the given C handle.

constexpr cursor (
    MDBX_cursor * ptr
) noexcept

Parameters:

  • ptr The pointer to the underlying MDBX_cursor object.

function cursor

Move constructor: the source cursor is nullified.

inline cursor (
    cursor && other
) noexcept

Parameters:

  • other The source cursor to be moved from.

function data

Return a pointer to the beginning of the referenced data.

const void * data () noexcept const

Returns:

The read-only pointer to the data.


function data

Return a pointer to the beginning of the referenced data.

void * data () noexcept

Returns:

The mutable pointer to the data.


function defrag

Performs database defragmentation.

template<typename VISITOR>
inline defrag_result defrag (
    VISITOR & visitor,
    size_t defrag_atleast=0,
    size_t time_atleast_dot16=0,
    size_t defrag_enough=0,
    size_t time_limit_dot16=0,
    intptr_t acceptable_backlash=-1,
    intptr_t preferred_batch=0
) 

Defragmentation is the transfer of data from pages located at the end of the database to free pages closer to the beginning, so the freed tail can be cut off while reducing the size of the database file, see mdbx_env_defrag(). It is almost always performed in several cycles, each of which ends with committing an internal transaction.

Note:

No transactions nor cursors must be open while defragmenting.

The visitor functor (if provided) is called time-to-time with a reference to the current defrag_result and must return defrag_control::proceed to continue, defrag_control::abort to abort immediately, or defrag_control::discontinue to stop after completing scheduled operations.

Returns:

The final defrag_result. Stopping reasons are reported via its stopping_reasons field and are not treated as errors (the same for MDBX_RESULT_TRUE and MDBX_LAGGARD_READER).

Parameters:

  • visitor An optional functor with the signature defrag_control visitor(const defrag_result &progress).
  • defrag_atleast The required at least number of pages by which the database must be reduced, zero means no lower bound.
  • time_atleast_dot16 The minimum time in 1/65536 fractions of a second that should be spent to defragment more even if goals reached, zero means no lower bound.
  • defrag_enough The number of pages by which it will be enough to shrink the database to finish, zero means no limit.
  • time_limit_dot16 The time limit in 1/65536 fractions of a second that could be spent to defragment, zero means no limit.
  • acceptable_backlash Stop if the next cycle will be unable to shrink the database by more pages than this value, -1 means autopilot.
  • preferred_batch The preferred maximum number of pages to be moved per defragmentation cycle, zero means no limit.

Exception:

  • mdbx::error on failure (other than stopping reasons above).

See also: mdbx_env_defrag()


function defrag

Performs database defragmentation without a progress visitor.

inline defrag_result defrag (
    size_t defrag_atleast=0,
    size_t time_atleast_dot16=0,
    size_t defrag_enough=0,
    size_t time_limit_dot16=0,
    intptr_t acceptable_backlash=-1,
    intptr_t preferred_batch=0
) 

The same defragmentation as in the overload accepting a visitor functor, but without progress callbacks.

Parameters:

  • defrag_atleast The required at least number of pages by which the database must be reduced, zero means no lower bound.
  • time_atleast_dot16 The minimum time in 1/65536 fractions of a second that should be spent to defragment more even if goals reached, zero means no lower bound.
  • defrag_enough The number of pages by which it will be enough to shrink the database to finish, zero means no limit.
  • time_limit_dot16 The time limit in 1/65536 fractions of a second that could be spent to defragment, zero means no limit.
  • acceptable_backlash Stop if the next cycle will be unable to shrink the database by more pages than this value, -1 means autopilot.
  • preferred_batch The preferred maximum number of pages to be moved per defragmentation cycle, zero means no limit.

Returns:

The final defrag_result.

Exception:

  • mdbx::error on failure (other than stopping reasons above).

See also: mdbx_env_defrag()


function disable_clear_memory

Sets the clear-memory disable mode, i.e. operate_options::disable_clear_memory .

operate_parameters & disable_clear_memory (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function disable_readahead

Sets the readahead disable mode, i.e. operate_options::disable_readahead .

operate_parameters & disable_readahead (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function drop_map

Drops key-value map using handle.

inline void drop_map (
    map_handle map
) 

Parameters:

  • map The table (map) handle.

function drop_map

Drop key-value map.

inline bool drop_map (
    const ::std::string & name,
    bool throw_if_absent=false
) 

Returns:

True if the key-value map existed and was deleted, either false if the key-value map did not exist and there is nothing to delete.

Parameters:

  • name The table name.
  • throw_if_absent The throw_if_absent argument.

function empty

Checks whether the slice is empty.

bool empty () noexcept const

Returns:

true if the slice length is zero.


function enable_validation

Sets the validation enable mode, i.e. operate_options::enable_validation .

operate_parameters & enable_validation (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function encode_base58

Returns a buffer with a Base58 dump of the slice content.

template<class ALLOCATOR, class CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > encode_base58 (
    unsigned wrap_width=0,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the Base58 dump.


function encode_base64

Returns a buffer with a Base64 dump of the slice content.

template<class ALLOCATOR, class CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > encode_base64 (
    unsigned wrap_width=0,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the Base64 dump.


function encode_hex

Returns a buffer with a hexadecimal dump of the slice content.

template<class ALLOCATOR, class CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > encode_hex (
    bool uppercase=false,
    unsigned wrap_width=0,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • uppercase Use uppercase letters for hexadecimal digits.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the hexadecimal dump.


function end

Return a pointer to the end of the referenced data.

const byte * end () noexcept const

An iterator-style pointer (one past the last byte).

Returns:

The read-only pointer just after the last byte.


function end

Return a pointer to the end of the referenced data.

byte * end () noexcept

An iterator-style pointer (one past the last byte).

Returns:

The read-only pointer just after the last byte.


function end_byte_ptr

Returns casted to pointer to byte an end of data.

const byte * end_byte_ptr () noexcept const

Returns:

The read-only pointer just after the last byte.


function end_byte_ptr

Returns casted to pointer to byte an end of data.

byte * end_byte_ptr () noexcept

Returns:

The mutable pointer just after the last byte.


function end_char_ptr

Returns casted to pointer to char an end of data.

const char * end_char_ptr () noexcept const

Returns:

The read-only pointer just after the last byte.


function end_char_ptr

Returns casted to pointer to char an end of data.

char * end_char_ptr () noexcept

Returns:

The mutable pointer just after the last byte.


function ends_with

Checks if the data ends with the given suffix.

bool ends_with (
    const slice & suffix
) noexcept const

Parameters:

  • suffix The expected suffix.

Returns:

true if the slice ends with the given suffix.


function enumerate_readers

Enumerate readers.

template<typename VISITOR>
inline int enumerate_readers (
    VISITOR & visitor
) 

The VISITOR class must have int operator()(const reader_info &, int serial) which should return continue_loop (zero) to continue enumeration, or any non-zero value to exit.

Parameters:

  • visitor The visitor functor, see the description above.

Returns:

The last value returned from visitor' functor.


function enumerate_tables

Enumerates user's named tables in a database.

template<typename VISITOR>
inline int enumerate_tables (
    VISITOR & visitor
) const

Calls the visitor functor for each user-created named table until the named tables are exhausted, or until the visitor returns exit_loop (which will be returned as a result).

Parameters:

  • visitor A functor with the signature int visitor(const slice &name, MDBX_db_flags_t flags , const MDBX_stat &stat, MDBX_dbi dbi), which will be called for each table.

Returns:

The last value returned by the visitor's functor.

See also: mdbx_enumerate_tables()


function env

Move constructor: the source environment is nullified.

inline env (
    env && other
) noexcept

Parameters:

  • other The source environment to be moved from.

function env

Returns the transaction's environment.

inline inline ::mdbx::env env () noexcept const

Returns:

The env instance the transaction belongs to.


function eof

Checks whether the cursor is at the end-of-table (not positioned).

inline bool eof () const

Returns:

true if the cursor is not positioned on any item.


function erase

Removes all values for given key.

inline bool erase (
    map_handle map,
    const slice & key
) 

Parameters:

  • map The table (map) handle.
  • key The key.

Returns:

true on success, false otherwise.


function erase

Removes the particular multi-value entry of the key.

inline bool erase (
    map_handle map,
    const slice & key,
    const slice & value
) 

Parameters:

  • map The table (map) handle.
  • key The key.
  • value The value.

Returns:

true on success, false otherwise.


function erase

Removes single key-value pair or all multi-values at the current cursor position.

inline bool erase (
    bool whole_multivalue=false
) 

Parameters:

  • whole_multivalue Remove all multi-values of the current key.

Returns:

true if something was removed.


function erase

Seeks and removes first value or whole multi-value of the given key.

inline bool erase (
    const slice & key,
    bool whole_multivalue=true
) 

Parameters:

  • key The key to remove.
  • whole_multivalue Remove all multi-values of the key.

Returns:

True if the key is found and a value(s) is removed.


function erase

Seeks and removes the particular multi-value entry of the key.

inline bool erase (
    const slice & key,
    const slice & value
) 

Parameters:

  • key The key of the entry.
  • value The multi-value to remove.

Returns:

True if the given key-value pair is found and removed.


function erase_bunch

Quickly removes bunches of neighboring items much faster by cutting out entire pages and branches from the B+ tree structure.

inline size_t erase_bunch (
    bunch_delete action
) 

Parameters:

Returns:

The number of removed items.

See also: erase_range()

See also: mdbx_cursor_bunch_delete()


function erase_range

Quickly removes a range of items between the current cursor position and the position of end much faster by cutting out entire pages and branches from the B+ tree structure.

inline size_t erase_range (
    const cursor & end,
    bool end_including
) 

Parameters:

  • end A positioned cursor defining the end of the range.
  • end_including Whether the end position itself should be included in the range to be deleted.

Returns:

The number of removed items.

See also: erase_bunch()

See also: mdbx_cursor_delete_range()


function error

Constructs an error instance from the given code.

constexpr error (
    MDBX_error_t error_code
) noexcept

Parameters:

  • error_code The error code.

function estimate

Estimates the distance (number of items) between two cursor positions.

inline ptrdiff_t estimate (
    const cursor & from,
    const cursor & to
) 

Parameters:

  • from The cursor at the "from" position.
  • to The cursor at the "to" position.

Returns:

The approximate distance; a negative value means the to position is before the from one.

Exception:


function estimate

Estimates the number of items between two key-value pairs.

inline ptrdiff_t estimate (
    map_handle map,
    const pair & from,
    const pair & to
) const

Parameters:

  • map The table (map) handle.
  • from The "from" boundary pair.
  • to The "to" boundary pair.

Returns:

The approximate distance; a negative value means to is before from.


function estimate

Estimates the number of items between two keys.

inline ptrdiff_t estimate (
    map_handle map,
    const slice & from,
    const slice & to
) const

Parameters:

  • map The table (map) handle.
  • from The "from" boundary key.
  • to The "to" boundary key.

Returns:

The approximate distance; a negative value means to is before from.


function estimate

Estimates the number of items between the current position and the given key-value pair.

inline estimate_result estimate (
    const slice & key,
    const slice & value
) const

Parameters:

  • key The boundary key.
  • value The boundary value.

Returns:

The estimate_result with the approximate quantity.


function estimate

Estimates the number of items between the current position and the given key.

inline estimate_result estimate (
    const slice & key
) const

Parameters:

  • key The boundary key.

Returns:

The estimate_result with the approximate quantity.


function estimate

Estimates the number of items up to the boundary defined by the operation.

inline estimate_result estimate (
    move_operation operation
) const

Parameters:

  • operation The positioning operation defining the boundary.

Returns:

The estimate_result with the approximate quantity.


function estimate

Estimates the number of items up to the boundary defined by the operation and key.

inline estimate_result estimate (
    move_operation operation,
    const slice & key
) const

Parameters:

  • operation The positioning operation defining the boundary.
  • key The boundary key.

Returns:

The estimate_result with the approximate quantity.


function estimate_from_first

Estimates the number of items from the first one up to the given key.

inline ptrdiff_t estimate_from_first (
    map_handle map,
    const slice & to
) const

Parameters:

  • map The table (map) handle.
  • to The "to" boundary key.

Returns:

The approximate distance.


function estimate_result

Estimates the number of items from the given key-value pair per the given operation.

inline estimate_result (
    const cursor & cursor,
    move_operation operation,
    const slice & key,
    const slice & value
) 

Parameters:

  • cursor The positioned cursor.
  • operation The positioning operation.
  • key The boundary key.
  • value The boundary value (for dupsort tables).

function estimate_to_last

Estimates the number of items from the given key up to the last one.

inline ptrdiff_t estimate_to_last (
    map_handle map,
    const slice & from
) const

Parameters:

  • map The table (map) handle.
  • from The "from" boundary key.

Returns:

The approximate distance.


function exclusive

Sets the exclusive mode, i.e. operate_options::exclusive .

operate_parameters & exclusive (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function extra_option

Gets the value of extra runtime options from an environment.

inline uint64_t extra_option (
    extra_runtime_option option
) const

Parameters:

  • option The option argument.

Returns:

The resulting value.


function extract

Removes and return a value of the key.

template<class BUFFER, class ALLOCATOR>
inline BUFFER extract (
    map_handle map,
    const slice & key,
    const ALLOCATOR & alloc=ALLOCATOR()
) 

Parameters:

  • map The table (map) handle.
  • key The key.
  • alloc The allocator for the buffer storage.

Returns:

The result.


function find

Finds the first occurrence of needle starting atpos .

size_t find (
    const slice & needle,
    size_t pos=0
) noexcept const

Parameters:

  • needle The sub-slice to search for.
  • pos The position to start the search from.

Returns:

The position of the first match or npos.


function find

Finds the first occurrence of the byte c starting atpos .

size_t find (
    byte c,
    size_t pos=0
) noexcept const

Parameters:

  • c The byte to search for.
  • pos The position to start the search from.

Returns:

The position of the first match or npos.


function find

Finds the exact key.

inline move_result find (
    const slice & key,
    bool throw_notfound=true
) 

Parameters:

  • key The key to find.
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

Returns:

The move_result with the found pair and the success flag.


function find_first_not_of

Finds the first byte not matching any byte of chars starting atpos .

size_t find_first_not_of (
    const slice & chars,
    size_t pos=0
) noexcept const

Parameters:

  • chars The set of bytes to avoid.
  • pos The position to start the search from.

Returns:

The position of the first match or npos.


function find_first_not_of

Finds the first byte not equal to c starting atpos .

size_t find_first_not_of (
    byte c,
    size_t pos=0
) noexcept const

Parameters:

  • c The byte to avoid.
  • pos The position to start the search from.

Returns:

The position of the first match or npos.


function find_first_of

Finds the first byte matching any byte of chars starting atpos .

size_t find_first_of (
    const slice & chars,
    size_t pos=0
) noexcept const

Parameters:

  • chars The set of bytes to search for.
  • pos The position to start the search from.

Returns:

The position of the first match or npos.


function find_first_of

Finds the first occurrence of the byte c starting atpos .

size_t find_first_of (
    byte c,
    size_t pos=0
) noexcept const

Parameters:

  • c The byte to search for.
  • pos The position to start the search from.

Returns:

The position of the first match or npos.


function find_last_not_of

Finds the last byte not matching any byte of chars not afterpos .

size_t find_last_not_of (
    const slice & chars,
    size_t pos=npos
) noexcept const

Parameters:

  • chars The set of bytes to avoid.
  • pos The position to search backwards from, npos means the end.

Returns:

The position of the last match or npos.


function find_last_not_of

Finds the last byte not equal to c not afterpos .

size_t find_last_not_of (
    byte c,
    size_t pos=npos
) noexcept const

Parameters:

  • c The byte to avoid.
  • pos The position to search backwards from, npos means the end.

Returns:

The position of the last match or npos.


function find_last_of

Finds the last byte matching any byte of chars not afterpos .

size_t find_last_of (
    const slice & chars,
    size_t pos=npos
) noexcept const

Parameters:

  • chars The set of bytes to search for.
  • pos The position to search backwards from, npos means the end.

Returns:

The position of the last match or npos.


function find_last_of

Finds the last occurrence of the byte c not afterpos .

size_t find_last_of (
    byte c,
    size_t pos=npos
) noexcept const

Parameters:

  • c The byte to search for.
  • pos The position to search backwards from, npos means the end.

Returns:

The position of the last match or npos.


function find_multivalue

Finds the exact key-value pair in a dupsort table.

inline move_result find_multivalue (
    const slice & key,
    const slice & value,
    bool throw_notfound=true
) 

Parameters:

  • key The key to find.
  • value The multi-value to find.
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

Returns:

The move_result with the found pair and the success flag.


function flags

Returns transaction's flags.

inline MDBX_txn_flags_t flags () const

Returns:

The MDBX_txn_flags_t combination.


function get

Get value by key from a key-value map (aka table).

inline slice get (
    map_handle map,
    const slice & key
) const

Parameters:

  • map The table (map) handle.
  • key The key.

Returns:

The resulting slice.


function get

Get first of multi-value and values count by key from a key-value multimap (aka table).

inline slice get (
    map_handle map,
    slice key,
    size_t & values_count
) const

Parameters:

  • map The table (map) handle.
  • key The key.
  • values_count The number of values in the array.

Returns:

The resulting slice.


function get

Get value by key from a key-value map (aka table).

inline slice get (
    map_handle map,
    const slice & key,
    const slice & value_at_absence
) const

Parameters:

  • map The table (map) handle.
  • key The key.
  • value_at_absence The value_at_absence argument.

Returns:

The resulting slice.


function get

Get first of multi-value and values count by key from a key-value multimap (aka table).

inline slice get (
    map_handle map,
    slice key,
    size_t & values_count,
    const slice & value_at_absence
) const

Parameters:

  • map The table (map) handle.
  • key The key.
  • values_count The number of values in the array.
  • value_at_absence The value_at_absence argument.

Returns:

The resulting slice.


function get_HandleSlowReaders

Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled.

inline MDBX_hsr_func get_HandleSlowReaders () noexcept const

Returns:

The current MDBX_hsr_func callback, or nullptr.

See also: set_HandleSlowReaders()


function get_batch

Reads a batch of key-value pairs.

inline inline ::std::vector< pair > get_batch (
    size_t max_pairs,
    move_operation op,
    bool * is_last=nullptr
) const

Fetches up to max_pairs key-value pairs starting from the current cursor position, advancing the cursor. The returned slices reference database-owned memory and remain valid while the transaction and cursor are alive.

Parameters:

  • max_pairs The maximum number of key-value pairs to fetch.
  • op The positioning operation, either move_operation::first or move_operation::next.
  • is_last Optional flag set to true when the returned chunk is the last one (no pairs left after it).

Returns:

The vector of fetched key-value pairs.

See also: mdbx_cursor_get_batch()


function get_build

Returns libmdbx build information.

const build_info & get_build () noexcept

Returns:

A reference to the constant build_info instance.


function get_cached

Gets a value by key using the transparent read-your-writes cache.

inline MDBX_NODISCARD cache_result get_cached (
    map_handle map,
    const slice & key,
    slice * data,
    cache_entry & entry
) const

Uses the cached information to check as quickly as possible whether the data has changed or not, with early exit when searching through the DB. Supports multithreaded cases and resolves collisions in a lockfree way; the MDBX_NOSTICKYTHREADS mode is required to use it from different threads.

Parameters:

  • map The table handle.
  • key The key to search for.
  • data The resulting value; points into database-owned memory and remains valid until the transaction end.
  • entry The cache entry corresponding to the key, must be initialized (cache_entry::reset()) before use.

Returns:

The cache_result with the pair of error code and cache status. The caller inspects errcode and status explicitly.

See also: mdbx_cache_get()


function get_cached

Gets a value by key using the transparent read-your-writes cache, throwing exceptions on errors.

inline MDBX_NODISCARD slice get_cached (
    map_handle map,
    const slice & key,
    cache_entry & entry,
    cache_status * status=nullptr
) const

Parameters:

  • map The table handle.
  • key The key to search for.
  • entry The cache entry corresponding to the key.
  • status Optional address to receive the cache_status.

Returns:

The resulting value, or throws mdbx::not_found if the key is absent (like get()).

See also: mdbx_cache_get()


function get_canary

Returns the four integer markers (aka "canary") associated with the environment.

inline canary get_canary () const

Returns:

The canary markers.


function get_context

Returns the application context associated with the environment.

inline void * get_context () noexcept const

Returns:

The application context pointer.


function get_context

Returns the application context associated with the transaction.

inline void * get_context () noexcept const

Returns:

The application context pointer.


function get_context

Returns the application context associated with the cursor.

inline void * get_context () noexcept const

Returns:

The application context pointer.


function get_durability

Returns current durability mode.

inline MDBX_NODISCARD env::durability get_durability () const

Returns:

The env::durability of the environment.


function get_equal_or_great

Gets the value for an equal or greater key from a table.

inline pair_result get_equal_or_great (
    map_handle map,
    const slice & key
) const

Returns:

Bundle of key-value pair and boolean flag, which will be true if the exact key was found and false otherwise.

Parameters:

  • map The table (map) handle.
  • key The key.

function get_equal_or_great

Gets the value for an equal or greater key from a table.

inline pair_result get_equal_or_great (
    map_handle map,
    const slice & key,
    const slice & value_at_absence
) const

Returns:

Bundle of key-value pair and boolean flag, which will be true if the exact key was found and false otherwise.

Parameters:

  • map The table (map) handle.
  • key The key.
  • value_at_absence The value_at_absence argument.

function get_filehandle

Returns the file descriptor for the DXB file of MDBX environment.

inline filehandle get_filehandle () const

Returns:

The filehandle of the DXB file.


function get_flags

Returns environment flags.

inline MDBX_env_flags_t get_flags () const

Returns:

The MDBX_env_flags_t combination.


function get_gc_info

Provides information of Garbage Collection and page usage.

template<typename VISITOR>
inline gc_info get_gc_info (
    VISITOR & visitor
) const

Scans the whole GC to summarise the GC state and page usage for the given transaction, optionally iterating GC entries by calling the visitor functor for each span of pages inside GC (excepting the pages forming the B-tree structure of GC itself).

Parameters:

  • visitor An optional functor with the signature int visitor(uint64_t span_txnid, size_t span_pgno, size_t span_length, bool span_is_reclaimable) returning continue_loop to proceed or any other value to stop enumeration.

Returns:

The gc_info of the database. An empty (zeroed) info is returned when the GC is empty (MDBX_NOTFOUND).

Note:

This API has not been frozen yet.

See also: mdbx_gc_info()


function get_gc_info

Returns information about garbage collection and page usage.

inline gc_info get_gc_info () const

Returns:

The gc_info for the current transaction.


function get_info

Return snapshot information about the MDBX environment.

inline info get_info () const

Returns:

The info snapshot of the environment.


function get_info

Return information about the MDBX environment accordingly to the specified transaction.

inline info get_info (
    const txn & txn
) const

Parameters:

  • txn The transaction for the snapshot.

Returns:

The info accordingly to the given transaction.


function get_info

Returns information about the MDBX transaction.

inline info get_info (
    bool scan_reader_lock_table=false
) const

Parameters:

  • scan_reader_lock_table The scan_reader_lock_table argument.

Returns:

Information about the MDBX transaction.


function get_map_flags

Returns information about key-value map (aka table) handle.

inline map_handle::info get_map_flags (
    map_handle map
) const

Parameters:

  • map The table (map) handle.

Returns:

Information about key-value map (aka table) handle.


function get_map_stat

Returns statistics for a table.

inline map_stat get_map_stat (
    map_handle map
) const

Parameters:

  • map The table (map) handle.

Returns:

Statistics for a table.


function get_mode

Returns current operation mode.

inline MDBX_NODISCARD env::mode get_mode () const

Returns:

The env::mode of the environment.


function get_operation_parameters

Returns current operation parameters.

inline MDBX_NODISCARD env::operate_parameters get_operation_parameters () const

Returns:

The operate_parameters the environment was opened with.


function get_options

Returns current operate options.

inline MDBX_NODISCARD env::operate_options get_options () const

Returns:

The operate_options of the environment.


function get_reclaiming

Returns current reclaiming options.

inline MDBX_NODISCARD env::reclaiming_options get_reclaiming () const

Returns:

The reclaiming_options of the environment.


function get_stat

Returns snapshot statistics about the MDBX environment.

inline stat get_stat () const

Returns:

The stat snapshot of the environment.


function get_stat

Return statistics about the MDBX environment accordingly to the specified transaction.

inline stat get_stat (
    const txn & txn
) const

Parameters:

  • txn The transaction for the snapshot.

Returns:

The stat accordingly to the given transaction.


function get_tree_deepmask

Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given table.

inline uint32_t get_tree_deepmask (
    map_handle map
) const

Parameters:

  • map The table (map) handle.

Returns:

Depth (bitmask) information of nested dupsort (multi-value) B+trees for given table.


function get_version

Returns libmdbx version information.

const version_info & get_version () noexcept

Returns:

A reference to the constant version_info instance.


function half_synchronous_weak_last

Sets the durability level to env::durability::half_synchronous_weak_last .

operate_parameters & half_synchronous_weak_last () noexcept

Returns:

A reference to this instance.


function hash_value

Returns the hash value of referenced data.

size_t hash_value () noexcept const

Attention:

Function implementation and returned hash values may change from version to version, and in future the t1ha3 will be used here. Therefore values obtained from this function shouldn't be persisted anywhere.

Returns:

The hash value of the referenced data.


function head

Returns the first "n" bytes of the slice.

slice head (
    size_t n
) noexcept const

Parameters:

  • n The number of bytes.

Returns:

The sub-slice of the first n bytes.

Precondition:

REQUIRES: n <= size()


function hex_decode

Decodes hexadecimal dump from the slice content to returned buffer.

template<class ALLOCATOR, class CAPACITY_POLICY>
inline buffer< ALLOCATOR, CAPACITY_POLICY > hex_decode (
    bool ignore_spaces=false,
    const ALLOCATOR & alloc=ALLOCATOR()
) const

Parameters:

  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the resulting buffer.

Returns:

The buffer with the decoded data.


function id

Return the transaction's ID.

inline uint64_t id () const

Returns:

The transaction/MVCC-snapshot ID.


function ignore_key_order

Disables the control of the order of keys when reading database pages for this cursor.

inline void ignore_key_order () 

Useful when reading a database whose user-defined comparison functions are unavailable, otherwise such reads return MDBX_CORRUPTED.

See also: mdbx_cursor_ignord()


function info

Constructs the info from the given flags and state.

constexpr info (
    map_handle::flags flags,
    map_handle::state state
) noexcept

Parameters:

  • flags The table flags.
  • state The table state.

function insert

Inserts a new key-value pair; fails if the key already exists.

inline void insert (
    map_handle map,
    const slice & key,
    slice value
) 

Parameters:

  • map The table (map) handle.
  • key The key to insert.
  • value The value to insert.

Exception:


function insert

Inserts a new key-value pair; fails if the key already exists.

inline void insert (
    const slice & key,
    slice value
) 

Parameters:

  • key The key to insert.
  • value The value to insert.

Exception:


function insert_reserve

Reserves space for a value of the given length for a new key.

inline slice insert_reserve (
    map_handle map,
    const slice & key,
    size_t value_length
) 

Parameters:

  • map The table (map) handle.
  • key The key to insert.
  • value_length The length of the value to reserve.

Returns:

The writable slice for the reserved value.

Exception:


function insert_reserve

Reserves space for a value of the given length for a new key.

inline slice insert_reserve (
    const slice & key,
    size_t value_length
) 

Parameters:

  • key The key to insert.
  • value_length The length of the value to reserve.

Returns:

The writable slice for the reserved value.

Exception:


function invalidate

Invalidates the slice by nullifying the data pointer while preserving the length; makes is_valid() returnfalse unless the slice was already of zero length.

void invalidate () noexcept

function is_base58

Checks whether the content of the slice is a Base58 dump.

inline bool is_base58 (
    bool ignore_spaces=false
) noexcept const

Parameters:

  • ignore_spaces If true function will skips spaces surrounding (before, between and after) a encoded bytes. However, spaces should not break a code group of characters.

Returns:

true if the content is a valid Base58 dump.


function is_base64

Checks whether the content of the slice is a Base64 dump.

inline bool is_base64 (
    bool ignore_spaces=false
) noexcept const

Parameters:

  • ignore_spaces If true function will skips spaces surrounding (before, between and after) a encoded bytes. However, spaces should not break a code group of characters.

Returns:

true if the content is a valid Base64 dump.


function is_clean

Checks whether no exception is captured.

inline bool is_clean () noexcept const

Returns:

true if the thunk is empty, false otherwise.


function is_dirty

Checks whether the given data is on a dirty page.

inline bool is_dirty (
    const void * ptr
) const

Parameters:

  • ptr The address of the source data.

Returns:

true on success, false otherwise.


function is_failure

Checks the error is a failure.

bool is_failure () noexcept const

Returns:

true if the error code is neither a success nor a boolean result, false otherwise.


function is_hex

Checks whether the content of the slice is a hexadecimal dump.

inline bool is_hex (
    bool ignore_spaces=false
) noexcept const

Parameters:

  • ignore_spaces If true function will skips spaces surrounding (before, between and after) a encoded bytes. However, spaces should not break a pair of characters encoding a single byte.

Returns:

true if the content is a valid hexadecimal dump.


function is_mdbx_error

Returns true for MDBX's errors.

bool is_mdbx_error () noexcept const

Returns:

true if the error code belongs to libmdbx, false otherwise.


function is_null

Checks whether the slice data pointer is nullptr.

bool is_null () noexcept const

Returns:

true if the slice refers to nothing.


function is_result_false

Checks the error is the "false" result of a MDBX_RESULT_FALSE .

bool is_result_false () noexcept const

Returns:

true if the error code is MDBX_RESULT_FALSE, false otherwise.


function is_result_true

Checks the error is the "true" result of a MDBX_RESULT_TRUE .

bool is_result_true () noexcept const

Returns:

true if the error code is MDBX_RESULT_TRUE, false otherwise.


function is_success

Checks the error is a success.

bool is_success () noexcept const

Returns:

true if the error code is MDBX_SUCCESS, false otherwise.


function key_mode

Returns the key comparison mode implied by the flags.

MDBX_CXX11_CONSTEXPR_ENUM  mdbx::key_mode key_mode () noexcept const

Returns:

The mdbx::key_mode of the table.


function lazy_weak_tail

Sets the durability level to env::durability::lazy_weak_tail .

operate_parameters & lazy_weak_tail () noexcept

Returns:

A reference to this instance.


function length

Returns the number of bytes.

size_t length () noexcept const

Returns:

The length of the referenced data in bytes.


function lifo

Sets the LIFO reclaiming mode, i.e. reclaiming_options::lifo .

operate_parameters & lifo (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function lower_bound

Finds the exact key or the first one greater than it.

inline move_result lower_bound (
    const slice & key,
    bool throw_notfound=false
) 

Parameters:

  • key The key to find.
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

Returns:

The move_result with the found pair and the success flag.


function lower_bound_multivalue

Finds the exact key and the first multi-value greater-or-equal to the given one.

inline move_result lower_bound_multivalue (
    const slice & key,
    const slice & value,
    bool throw_notfound=false
) 

Parameters:

  • key The key to find.
  • value The multi-value lower bound.
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

Returns:

The move_result with the found pair and the success flag.


function make_broken

Marks transaction as broken to prevent further operations.

inline void make_broken () 

function make_buffer

Produces a buffer from a mutable byte-producer (see the MutableByteProducer concept).

template<class ALLOCATOR, class CAPACITY_POLICY, MutableByteProducer PRODUCER>
inline buffer< ALLOCATOR, CAPACITY_POLICY > make_buffer (
    PRODUCER & producer,
    const ALLOCATOR & alloc
) 

Parameters:

  • producer The producer of bytes.
  • alloc The allocator for the resulting buffer.

Returns:

The produced buffer.


function make_buffer

Produces a buffer from an immutable byte-producer (see the ImmutableByteProducer concept).

template<class ALLOCATOR, class CAPACITY_POLICY, ImmutableByteProducer PRODUCER>
inline buffer< ALLOCATOR, CAPACITY_POLICY > make_buffer (
    const PRODUCER & producer,
    const ALLOCATOR & alloc
) 

Parameters:

  • producer The producer of bytes.
  • alloc The allocator for the resulting buffer.

Returns:

The produced buffer.


function make_dynamic

Makes a dynamic-size geometry with the given bounds.

geometry & make_dynamic (
    intptr_t lower=default_value,
    intptr_t upper=default_value
) noexcept

Parameters:

  • lower The lower bound of database size in bytes.
  • upper The upper bound of database size in bytes.

Returns:

A reference to this instance.


function make_fixed

Makes a fixed-size geometry, i.e. with disabled growing and shrinking.

geometry & make_fixed (
    intptr_t size
) noexcept

Parameters:

  • size The fixed database size in bytes.

Returns:

A reference to this instance.


function make_string

Produces a string from a mutable byte-producer (see the MutableByteProducer concept).

template<class ALLOCATOR, MutableByteProducer PRODUCER>
inline string< ALLOCATOR > make_string (
    PRODUCER & producer,
    const ALLOCATOR & alloc
) 

Parameters:

  • producer The producer of bytes.
  • alloc The allocator for the resulting string.

Returns:

The produced string.


function make_string

Produces a string from an immutable byte-producer (see the ImmutableByteProducer concept).

template<class ALLOCATOR, ImmutableByteProducer PRODUCER>
inline string< ALLOCATOR > make_string (
    const PRODUCER & producer,
    const ALLOCATOR & alloc
) 

Parameters:

  • producer The producer of bytes.
  • alloc The allocator for the resulting string.

Returns:

The produced string.


function map

Returns the cursor's table (map) handle.

inline map_handle map () const

Returns:

The map_handle the cursor is associated with.


function max_maps

Returns the maximum number of named tables for the environment.

inline unsigned max_maps () const

Returns:

The maximum number of named tables.

See also: extra_runtime_option::max_maps


function max_readers

Returns the maximum number of threads/reader slots for the environment.

inline unsigned max_readers () const

Returns:

The maximum number of readers.

See also: extra_runtime_option::max_readers


function middle

Returns the middle "n" bytes of the slice.

slice middle (
    size_t from,
    size_t n
) noexcept const

Parameters:

  • from The offset of the first byte.
  • n The number of bytes.

Returns:

The sub-slice of n bytes starting at from.

Precondition:

REQUIRES: from + n <= size()


function move_result

Reads the current position of the given cursor.

inline move_result (
    const cursor & cursor,
    bool throw_notfound
) 

Parameters:

  • cursor The cursor to read the position from.
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

function move_result

Performs the given positioning operation at the specified key-value pair.

inline move_result (
    cursor & cursor,
    move_operation operation,
    const slice & key,
    const slice & value,
    bool throw_notfound
) 

Parameters:

  • cursor The cursor to be moved.
  • operation The positioning operation.
  • key The key to position at.
  • value The value to position at (for dupsort tables).
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

function nested_transactions

Sets the nested transactions mode, i.e. operate_options::nested_transactions .

operate_parameters & nested_transactions (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function no_sticky_threads

Sets the "no sticky threads" mode, i.e. operate_options::no_sticky_threads .

operate_parameters & no_sticky_threads (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function on_first

Checks whether the cursor is on the first item of the table.

inline bool on_first () const

Returns:

true if the cursor is on the first item.


function on_first_multival

Checks whether the cursor is on the first multi-value of the current key.

inline bool on_first_multival () const

Returns:

true if the cursor is on the first multi-value.


function on_last

Checks whether the cursor is on the last item of the table.

inline bool on_last () const

Returns:

true if the cursor is on the last item.


function on_last_multival

Checks whether the cursor is on the last multi-value of the current key.

inline bool on_last_multival () const

Returns:

true if the cursor is on the last multi-value.


function open_cursor

Opens cursor for specified key-value map handle.

inline cursor_managed open_cursor (
    map_handle map
) const

Parameters:

  • map The table (map) handle.

Returns:

The managed cursor instance.


function open_map

Open existing key-value map.

inline map_handle open_map (
    const slice & name,
    const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual,
    const ::mdbx::value_mode value_mode=::mdbx::value_mode::single
) const

Parameters:

Returns:

The table (map) handle.


function open_map

Open existing key-value map.

inline map_handle open_map (
    const char * name,
    const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual,
    const ::mdbx::value_mode value_mode=::mdbx::value_mode::single
) const

Parameters:

Returns:

The table (map) handle.


function open_map

Open existing key-value map.

inline map_handle open_map (
    const ::std::string & name,
    const ::mdbx::key_mode key_mode=::mdbx::key_mode::usual,
    const ::mdbx::value_mode value_mode=::mdbx::value_mode::single
) const

Parameters:

Returns:

The table (map) handle.


function open_map_accede

Open existing key-value map.

inline map_handle open_map_accede (
    const slice & name
) const

Parameters:

  • name The table name.

Returns:

The table (map) handle.


function open_map_accede

Open existing key-value map.

inline map_handle open_map_accede (
    const char * name
) const

Parameters:

  • name The table name.

Returns:

The table (map) handle.


function open_map_accede

Open existing key-value map.

inline map_handle open_map_accede (
    const ::std::string & name
) const

Parameters:

  • name The table name.

Returns:

The table (map) handle.


function operator!=

bool operator!= (
    const error & a,
    const error & b
) 

Parameters:

  • a The left-hand error.
  • b The right-hand error.

Returns:

true if the error codes are not equal, false otherwise.


function operator!=

bool operator!= (
    const slice & a,
    const slice & b
) 

function operator!=

bool operator!= (
    const pair & a,
    const pair & b
) 

function operator<

bool operator< (
    const slice & a,
    const slice & b
) 

function operator<

bool operator< (
    const pair & a,
    const pair & b
) 

function operator<<

template<class ALLOCATOR, typename CAPACITY_POLICY>
inline ::std::ostream & operator<< (
    ::std::ostream & out,
    const buffer< ALLOCATOR, CAPACITY_POLICY > & it
) 

function operator<<

inline ::std::ostream & operator<< (
    ::std::ostream & out,
    const to_hex & wrapper
) 

function operator<<

inline ::std::ostream & operator<< (
    ::std::ostream & out,
    const to_base58 & wrapper
) 

function operator<<

inline ::std::ostream & operator<< (
    ::std::ostream & out,
    const to_base64 & wrapper
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const slice &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const pair &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const pair_result &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env::geometry::size &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env::geometry &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env::operate_parameters &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env::mode &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env::durability &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env::reclaiming_options &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env::operate_options &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const env_managed::create_parameters &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const MDBX_log_level_t &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const MDBX_debug_flags_t &
) 

function operator<<

LIBMDBX_API::std::ostream & operator<< (
    ::std::ostream &,
    const error &
) 

function operator<<

inline ::std::ostream & operator<< (
    ::std::ostream & out,
    const MDBX_error_t & errcode
) 

function operator<=

bool operator<= (
    const slice & a,
    const slice & b
) 

function operator<=

bool operator<= (
    const pair & a,
    const pair & b
) 

function operator=

Move assignment: the source slice is invalidated.

inline slice & operator= (
    slice && src
) noexcept

Parameters:

  • src The source slice to be moved from.

Returns:

A reference to this instance.


function operator=

Takes over a temporary MDBX_val instance.

inline slice & operator= (
    ::MDBX_val && src
) 

Parameters:

  • src The source MDBX_val to be moved from.

Returns:

A reference to this instance.


function operator=

Move assignment operator.

inline env & operator= (
    env && other
) noexcept

Parameters:

  • other The source environment to be moved from.

Returns:

A reference to this instance.


function operator=

Move assignment operator.

inline txn & operator= (
    txn && other
) noexcept

Parameters:

  • other The source transaction to be moved from.

Returns:

A reference to this instance.


function operator=

Move assignment operator.

inline cursor & operator= (
    cursor && other
) noexcept

Parameters:

  • other The source cursor to be moved from.

Returns:

A reference to this instance.


function operator==

bool operator== (
    const error & a,
    const error & b
) 

Parameters:

  • a The left-hand error.
  • b The right-hand error.

Returns:

true if the error codes are equal, false otherwise.


function operator==

bool operator== (
    const slice & a,
    const slice & b
) 

function operator==

bool operator== (
    const pair & a,
    const pair & b
) 

function operator>

bool operator> (
    const slice & a,
    const slice & b
) 

function operator>

bool operator> (
    const pair & a,
    const pair & b
) 

function operator>=

bool operator>= (
    const slice & a,
    const slice & b
) 

function operator>=

bool operator>= (
    const pair & a,
    const pair & b
) 

function operator[]

Returns the nth byte in the referenced data.

byte operator[] (
    size_t n
) noexcept const

Parameters:

  • n The index of the byte.

Returns:

The nth byte.

Precondition:

REQUIRES: n < size()


function park_reading

Park read-only transaction.

inline void park_reading (
    bool autounpark=true
) 

Parameters:

  • autounpark The autounpark argument.

function prepare_read

Creates but not start read transaction.

inline txn_managed prepare_read () const

Returns:

The created (not started) managed read transaction.

Exception:


function put

Stores a key-value pair using the given low-level flags.

inline MDBX_error_t put (
    map_handle map,
    const slice & key,
    slice * value,
    MDBX_put_flags_t flags
) noexcept

Parameters:

  • map The table (map) handle.
  • key The key to store.
  • value The value to store (in/out for some flags).
  • flags The MDBX_put_flags_t combination.

Returns:

An error code, zero on success (does not throw).


function put

Stores a key-value pair in the given mode.

inline void put (
    map_handle map,
    const slice & key,
    slice value,
    put_mode mode
) 

Parameters:

  • map The table (map) handle.
  • key The key to store.
  • value The value to store.
  • mode The put_mode (insert/upsert/update).

Exception:


function put

Stores a key-value pair using the given low-level flags.

inline MDBX_error_t put (
    const slice & key,
    slice * value,
    MDBX_put_flags_t flags
) noexcept

Parameters:

  • key The key to store.
  • value The value to store (in/out for some flags).
  • flags The MDBX_put_flags_t combination.

Returns:

An error code, zero on success (does not throw).


function put

Stores a key-value pair in the given mode.

inline void put (
    const slice & key,
    slice value,
    put_mode mode
) 

Parameters:

  • key The key to store.
  • value The value to store.
  • mode The put_mode (insert/upsert/update).

Exception:


function put_canary

Set integers markers (aka "canary") associated with the environment.

inline txn & put_canary (
    const canary & canary
) 

Parameters:

  • canary The canary markers to set.

Returns:

A reference to this transaction.


function put_multiple_samelength

Stores a bunch of same-length multi-values for the given key.

inline size_t put_multiple_samelength (
    map_handle map,
    const slice & key,
    const size_t value_length,
    const void * values_array,
    size_t values_count,
    put_mode mode,
    bool allow_partial=false
) 

Parameters:

  • map The table (map) handle.
  • key The key of the multi-value hive.
  • value_length The length of each value in bytes.
  • values_array The array of values.
  • values_count The number of values in the array.
  • mode The put_mode.
  • allow_partial Allow a partial store when some values are rejected.

Returns:

The number of stored values.


function put_multiple_samelength

Stores a bunch of same-length multi-values for the given key.

inline size_t put_multiple_samelength (
    const slice & key,
    const size_t value_length,
    const void * values_array,
    size_t values_count,
    put_mode mode,
    bool allow_partial=false
) 

Parameters:

  • key The key of the multi-value hive.
  • value_length The length of each value in bytes.
  • values_array The array of values.
  • values_count The number of values in the array.
  • mode The put_mode.
  • allow_partial Allow partial store when some values are rejected.

Returns:

The number of stored values.


function reader_info

Constructs the reader information.

constexpr reader_info (
    int slot,
    mdbx_pid_t pid,
    mdbx_tid_t thread,
    uint64_t txnid,
    uint64_t lag,
    size_t used,
    size_t retained
) noexcept

Parameters:

  • slot The reader lock table slot number.
  • pid The reader process ID.
  • thread The reader thread ID.
  • txnid The ID of the transaction being read.
  • lag The lag from a recent MVCC-snapshot.
  • used The number of last used page in the MVCC-snapshot.
  • retained The total size of retained pages in bytes.

function readonly

Sets the operation mode to env::mode::readonly .

operate_parameters & readonly () noexcept

Returns:

A reference to this instance.


function refresh

Refresh the read-only transaction to the most recent snapshot.

inline bool refresh () 

Replaces the MVCC-snapshot of the given read-only transaction with the most recent committed one, see mdbx_txn_refresh().

Returns:

True if the transaction was already reading the most recent version and no actions were performed, or false if it was refreshed (i.e. advanced to a newer snapshot).

See also: reset_reading()

See also: renew_reading()


function release_all_cursors

Unbind or close all cursors.

inline size_t release_all_cursors (
    bool unbind
) const

Warning:

With unbind=false it must NOT be used while any cursor of the transaction is owned by a cursor_managed instance: the cursor is closed behind the wrapper's back, which is left owning a freed handle.

Note:

With unbind=true the wrappers are left alive but detached (see unbind_all_cursors()).

Parameters:

  • unbind Unbind the cursor from the transaction.

Returns:

The size in bytes.


function remove_prefix

Drops the first "n" bytes from this slice.

inline void remove_prefix (
    size_t n
) noexcept

Parameters:

  • n The number of bytes to drop.

Precondition:

REQUIRES: n <= size()


function remove_suffix

Drops the last "n" bytes from this slice.

inline void remove_suffix (
    size_t n
) noexcept

Parameters:

  • n The number of bytes to drop.

Precondition:

REQUIRES: n <= size()


function rename_map

Переименовывает таблицу ключ-значение.

inline void rename_map (
    map_handle map,
    const char * new_name
) 

Parameters:

  • map The table (map) handle.
  • new_name The new table name.

function rename_map

Переименовывает таблицу ключ-значение.

inline void rename_map (
    map_handle map,
    const slice & new_name
) 

Parameters:

  • map The table (map) handle.
  • new_name The new table name.

function rename_map

Переименовывает таблицу ключ-значение.

inline void rename_map (
    map_handle map,
    const ::std::string & new_name
) 

Parameters:

  • map The table (map) handle.
  • new_name The new table name.

function renew

Renew/bind a cursor with a new transaction and previously used key-value map handle.

inline void renew (
    ::mdbx::txn & txn
) 

Parameters:

  • txn The new transaction to attach the cursor to.

Exception:

  • mdbx::error on failure. After unbind() or after txn::unbind_all_cursors() this is how the cursor becomes usable again.

function renew_reading

Renew read-only transaction.

inline void renew_reading () 

function replace

Replaces the particular multi-value of the key with a new value.

inline void replace (
    map_handle map,
    const slice & key,
    slice & old_value,
    const slice & new_value
) 

Parameters:

  • map The table (map) handle.
  • key The key.
  • old_value The old_value argument.
  • new_value The new_value argument.

function replace

Replaces and returns a value of the key with new one.

template<class BUFFER, class ALLOCATOR>
inline BUFFER replace (
    map_handle map,
    const slice & key,
    const slice & new_value,
    const ALLOCATOR & alloc=ALLOCATOR()
) 

Parameters:

  • map The table (map) handle.
  • key The key.
  • new_value The new_value argument.
  • alloc The allocator for the buffer storage.

Returns:

The result.


function replace_reserve

Replaces the value of the key reserving space for the new one, and returns the old value as a buffer.

template<class BUFFER, class ALLOCATOR>
inline BUFFER replace_reserve (
    map_handle map,
    const slice & key,
    size_t length,
    slice & new_value_reservation,
    const ALLOCATOR & alloc=ALLOCATOR()
) 

Parameters:

  • map The table (map) handle.
  • key The key to replace.
  • length The length of the new value to reserve.
  • new_value_reservation Out: the writable slice for the reserved new value.
  • alloc The allocator for the returned buffer.

Returns:

The buffer with the old value (empty if the key was absent).


function reset

Resets the cursor state.

inline void reset () 

As a result of the reset, the cursor becomes unpositioned and does not allow relative positioning operations, getting or changing data until the cursor is set to a position independent of the current one.

See also: mdbx_cursor_reset()


function reset_reading

Reset read-only transaction.

inline void reset_reading () 

function resurrect_after_fork

Restores the environment after fork() , dropping all read-write locks and reader slots of the parent process.

inline void resurrect_after_fork () 

function rethrow_captured

Re-throws the captured exception, if any.

inline void rethrow_captured () const

Exception:

  • The captured exception.

function rfind

Finds the last occurrence of needle not afterpos .

size_t rfind (
    const slice & needle,
    size_t pos=npos
) noexcept const

Parameters:

  • needle The sub-slice to search for.
  • pos The position to search backwards from, npos means the end.

Returns:

The position of the last match or npos.


function rfind

Finds the last occurrence of the byte c not afterpos .

size_t rfind (
    byte c,
    size_t pos=npos
) noexcept const

Parameters:

  • c The byte to search for.
  • pos The position to search backwards from, npos means the end.

Returns:

The position of the last match or npos.


function robust_synchronous

Sets the durability level to env::durability::robust_synchronous .

operate_parameters & robust_synchronous () noexcept

Returns:

A reference to this instance.


function safe_head

Returns the first "n" bytes of the slice.

slice safe_head (
    size_t n
) const

Parameters:

  • n The number of bytes.

Returns:

The sub-slice of the first n bytes.

Exception:

  • std::out_of_range if n > size()

function safe_middle

Returns the middle "n" bytes of the slice.

slice safe_middle (
    size_t from,
    size_t n
) const

Parameters:

  • from The offset of the first byte.
  • n The number of bytes.

Returns:

The sub-slice of n bytes starting at from.

Exception:

  • std::out_of_range if from + n > size()

function safe_remove_prefix

Drops the first "n" bytes from this slice.

inline void safe_remove_prefix (
    size_t n
) 

Parameters:

  • n The number of bytes to drop.

Exception:

  • std::out_of_range if n > size()

function safe_remove_suffix

Drops the last "n" bytes from this slice.

inline void safe_remove_suffix (
    size_t n
) 

Parameters:

  • n The number of bytes to drop.

Exception:

  • std::out_of_range if n > size()

function safe_tail

Returns the last "n" bytes of the slice.

slice safe_tail (
    size_t n
) const

Parameters:

  • n The number of bytes.

Returns:

The sub-slice of the last n bytes.

Exception:

  • std::out_of_range if n > size()

function scroll

Scrolls the cursor to the given distance from the current position.

inline bool scroll (
    intptr_t distable,
    unsigned deepness=42,
    bool throw_notfound=true
) 

Parameters:

  • distable The signed number of items to scroll by.
  • deepness The maximum depth of the B+tree inspection.
  • throw_notfound Throw mdbx::not_found instead of returning false.

Returns:

true if the cursor was positioned successfully.


function seek

Seeks the cursor to the exact key.

inline bool seek (
    const slice & key
) 

Parameters:

  • key The key to seek.

Returns:

true if the exact key was found.


function sequence

Reads sequence generator associated with a key-value map (aka table).

inline uint64_t sequence (
    map_handle map
) const

Parameters:

  • map The table (map) handle.

Returns:

The current sequence value.


function sequence

Reads and increment sequence generator associated with a key-value map (aka table).

inline uint64_t sequence (
    map_handle map,
    uint64_t increment
) 

Parameters:

  • map The table (map) handle.
  • increment The increment of the sequence.

Returns:

The resulting value.


function set_HandleSlowReaders

Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which prevents the old data from being recycled.

inline env & set_HandleSlowReaders (
    MDBX_hsr_func cb
) 

Such callback will be triggered in a case where there is not enough free space in the database due to long read transaction(s) which impedes reusing the pages of an old MVCC snapshot(s).

Using this callback you can choose how to resolve the situation: * abort the write transaction with an error; * wait for the read transaction(s) to complete; * notify a thread performing a long-lived read transaction and wait for an effect; * kill the thread or whole process that performs the long-lived read transaction;

See also: long-lived-read

Parameters:

  • cb The callback function, or nullptr to disable.

Returns:

A reference to this environment instance.


function set_context

Sets the application context associated with the environment.

inline env & set_context (
    void * your_context
) 

Parameters:

  • your_context The application context pointer.

Returns:

The environment instance.


function set_context

Sets the application context associated with the transaction.

inline txn & set_context (
    void * your_context
) 

Parameters:

  • your_context The application context pointer.

Returns:

The transaction instance.


function set_context

Sets the application context associated with the cursor.

inline cursor & set_context (
    void * your_context
) 

Parameters:

  • your_context The application context pointer.

Returns:

A reference to this instance.


function set_disable_clear_memory

Sets the clear-memory disable mode.

operate_options & set_disable_clear_memory (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_disable_readahead

Sets the readahead disable mode.

operate_options & set_disable_readahead (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_durability

Sets the durability level.

operate_parameters & set_durability (
    env::durability value
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_enable_validation

Sets the validation enable mode.

operate_options & set_enable_validation (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_end

Sets the length by specifying the end of the slice data.

slice & set_end (
    const void * ptr
) 

Parameters:

  • ptr The address just after the last byte of the slice.

Returns:

A reference to this instance.


function set_exclusive

Sets the exclusive mode.

operate_options & set_exclusive (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_extra_option

Sets the value of a extra runtime options for an environment.

inline env & set_extra_option (
    extra_runtime_option option,
    uint64_t value
) 

Parameters:

  • option The option argument.
  • value The value.

Returns:

The environment instance.


function set_file_mode_bits

Sets the file mode bits used for creation of the DB files.

create_parameters & set_file_mode_bits (
    mdbx_mode_t value
) noexcept

Parameters:

  • value The file mode bits to set.

Returns:

A reference to this instance.


function set_geometry

Sets the database geometry for size management.

create_parameters & set_geometry (
    const env::geometry & value
) noexcept

Parameters:

  • value The geometry to set.

Returns:

A reference to this instance.


function set_geometry

Set all size-related parameters of environment.

inline env & set_geometry (
    const geometry & size
) 

Exception:

  • mdbx::error on invalid or inapplicable values (e.g. a size below the current file size or a late call after the environment was opened).

Parameters:

  • size The new length of the data.

Returns:

The environment instance.


function set_growth_step

Sets the growth step in bytes.

geometry & set_growth_step (
    intptr_t step
) noexcept

Parameters:

  • step The growth step in bytes.

Returns:

A reference to this instance.


function set_length

Set slice length.

slice & set_length (
    size_t bytes
) 

Parameters:

  • bytes The new length of the slice.

Returns:

A reference to this instance.


function set_lifo

Sets the LIFO reclaiming mode.

reclaiming_options & set_lifo (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_max_maps

Sets the maximum number of named tables/maps for the environment. Zero means default value.

operate_parameters & set_max_maps (
    unsigned value
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_max_readers

Sets the maximum number of threads/reader slots for the environment. Zero means default value.

operate_parameters & set_max_readers (
    unsigned value
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_mode

Sets the operation mode.

operate_parameters & set_mode (
    env::mode value
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_nested_transactions

Sets the nested transactions mode.

operate_options & set_nested_transactions (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_no_sticky_threads

Sets the "no sticky threads" mode.

operate_options & set_no_sticky_threads (
    bool value=true
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_options

Sets the operate options.

operate_parameters & set_options (
    const env::operate_options & value
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_pagesize

Sets the database page size for new database creation.

geometry & set_pagesize (
    intptr_t size
) noexcept

Parameters:

  • size The page size in bytes.

Returns:

A reference to this instance.


function set_reclaiming

Sets the garbage reclaiming options.

operate_parameters & set_reclaiming (
    const env::reclaiming_options & value
) noexcept

Parameters:

  • value The value.

Returns:

The result.


function set_shrink_threshold

Sets the shrink threshold in bytes.

geometry & set_shrink_threshold (
    intptr_t threshold
) noexcept

Parameters:

  • threshold The shrink threshold in bytes.

Returns:

A reference to this instance.


function set_size_lower

Sets the lower bound of database size in bytes.

geometry & set_size_lower (
    intptr_t size
) noexcept

Parameters:

  • size The lower bound in bytes.

Returns:

A reference to this instance.


function set_size_now

Sets the size in bytes to setup the database size for now.

geometry & set_size_now (
    intptr_t size
) noexcept

Parameters:

  • size The size in bytes to setup for now.

Returns:

A reference to this instance.


function set_size_upper

Sets the upper bound of database size in bytes.

geometry & set_size_upper (
    intptr_t size
) noexcept

Parameters:

  • size The upper bound in bytes.

Returns:

A reference to this instance.


function set_sync_period__seconds_16dot16

Sets the flush period in 1/65536 of second units; the same as set_sync_period() with the correspondingduration .

inline env & set_sync_period__seconds_16dot16 (
    unsigned seconds_16dot16
) 

Parameters:

  • seconds_16dot16 The period in 1/65536 of second when a synchronous flush would be made since the last unsteady commit.

Returns:

A reference to this environment instance.


function set_sync_period__seconds_double

Sets the flush period in seconds; the same as set_sync_period() with the correspondingduration .

inline env & set_sync_period__seconds_double (
    double seconds
) 

Parameters:

  • seconds The period in second when a synchronous flush would be made since the last unsteady commit.

Returns:

A reference to this environment instance.


function set_sync_threshold

Sets threshold to force flush the data buffers to disk, for non-sync durability modes.

inline env & set_sync_threshold (
    size_t bytes
) 

The threshold value affects all processes which operates with given environment until the last process close environment or a new value will be settled. Data is always written to disk when txn_managed::commit() is called, but the operating system may keep it buffered. MDBX always flushes the OS buffers upon commit as well, unless the environment was opened with env::durability::whole_fragile, env::durability::lazy_weak_tail or in part env::durability::half_synchronous_weak_last.

The default is 0, which means that no threshold is checked and no additional flush will be made.

See also: extra_runtime_option::sync_bytes

Parameters:

  • bytes The number of bytes of the source data.

Returns:

The environment instance.


function set_use_subdirectory

Sets whether to use a subdirectory to place the DB files.

create_parameters & set_use_subdirectory (
    bool value=true
) noexcept

Parameters:

  • value true to use a subdirectory.

Returns:

A reference to this instance.


function size

Returns the number of bytes.

size_t size () noexcept const

Returns:

The length of the referenced data in bytes.


function slice

Create an empty slice.

constexpr slice () noexcept

function slice

Create a slice that refers to [0,bytes-1] of memory bytes pointed by ptr.

constexpr slice (
    const void * ptr,
    size_t bytes
) 

Parameters:

  • ptr The address of the data to be referenced.
  • bytes The number of bytes to be referenced.

function slice

Create a slice that refers to [begin,end] of memory bytes.

constexpr slice (
    const void * begin,
    const void * end
) 

Parameters:

  • begin The address of the first byte to be referenced.
  • end The address just after the last byte to be referenced.

function slice

Create a slice that refers to c_str[0,strlen(c_str)-1].

explicit constexpr slice (
    const char * c_str
) 

Parameters:

  • c_str The null-terminated string to be referenced.

function slice

Create a slice that refers to the contents of the given MDBX_val .

constexpr slice (
    const MDBX_val & src
) 

Parameters:

  • src The source MDBX_val instance.

function slice

Takes over a temporary MDBX_val instance: the slice refers to its bytes and the moved-fromsrc.iov_base is set to null, whilesrc.iov_len is kept (matching the library's own moved-from state); the slice does not own the bytes.

constexpr slice (
    MDBX_val && src
) 

Parameters:

  • src The source MDBX_val to be moved from.

function slice

Move constructor: the source slice is invalidated.

constexpr slice (
    slice && src
) noexcept

Parameters:

  • src The source slice to be moved from.

function start_read

Starts read (read-only) transaction.

inline txn_managed start_read () const

Returns:

The started managed read transaction.

Exception:


function start_write

Starts write (read-write) transaction.

inline txn_managed start_write (
    bool dont_wait=false
) 

Parameters:

  • dont_wait Don't wait if the resource is locked by another thread.

Returns:

The managed transaction instance.


function start_write

Starts write (read-write) transaction.

inline txn_managed start_write (
    txn & parent
) 

Parameters:

  • parent The parent transaction.

Returns:

The managed transaction instance.


function starts_with

Checks if the data starts with the given prefix.

bool starts_with (
    const slice & prefix
) noexcept const

Parameters:

  • prefix The expected prefix.

Returns:

true if the slice starts with the given prefix.


function success_or_throw

Throws the corresponding exception if this error is a failure.

inline void success_or_throw () const

Exception:


function success_or_throw

Throws the corresponding exception, or the captured one if any.

inline void success_or_throw (
    const exception_thunk & thunk
) const

Parameters:

Exception:


function sync_period__seconds_16dot16

Gets the flush period in 1/65536 of second units.

inline unsigned sync_period__seconds_16dot16 () const

Returns:

The period in 1/65536 of second units.

See also: sync_period__seconds_16dot16(unsigned)


function sync_period__seconds_double

Gets the flush period in seconds.

inline double sync_period__seconds_double () const

Returns:

The period in seconds.

See also: set_sync_period__seconds_double(double)


function sync_threshold

Gets threshold used to force flush the data buffers to disk, for non-sync durability modes.

inline size_t sync_threshold () const

See set_sync_threshold() for the description of the threshold.

Returns:

The threshold in bytes.

See also: extra_runtime_option::sync_bytes


function sync_to_disk

Flush the environment data buffers.

inline bool sync_to_disk (
    bool force=true,
    bool nonblock=false
) 

Returns:

True if sync done or no data to sync; false if the environment is busy by another thread and nonblock=true is used.

Parameters:

  • force Force the operation even when it is not required.
  • nonblock Don't wait if a write transaction is running by another thread.

function tail

Returns the last "n" bytes of the slice.

slice tail (
    size_t n
) noexcept const

Parameters:

  • n The number of bytes.

Returns:

The sub-slice of the last n bytes.

Precondition:

REQUIRES: n <= size()


function thread_register

Registers the current thread as a reader for the environment, i.e. assigns a reader slot.

inline bool thread_register () 

Returns:

false if the thread was already registered.


function thread_unregister

Unregisters the current thread, i.e. releases its reader slot.

inline bool thread_unregister () 

Returns:

false if the thread was not registered.


function throw_on_failure

Throws the corresponding exception if this error is a failure.

inline void throw_on_failure () const

Exception:


function try_insert

Tries to insert a new key-value pair without throwing on a duplicate.

inline value_result try_insert (
    map_handle map,
    const slice & key,
    slice value
) 

Parameters:

  • map The table (map) handle.
  • key The key to insert.
  • value The value to insert.

Returns:

The value_result with the success flag.


function try_insert

Tries to insert a new key-value pair without throwing on a duplicate.

inline value_result try_insert (
    const slice & key,
    slice value
) 

Parameters:

  • key The key to insert.
  • value The value to insert.

Returns:

The value_result with the success flag.


function try_insert_reserve

Tries to reserve space for a value of the given length for a new key.

inline value_result try_insert_reserve (
    map_handle map,
    const slice & key,
    size_t value_length
) 

Parameters:

  • map The table (map) handle.
  • key The key to insert.
  • value_length The length of the value to reserve.

Returns:

The value_result with the reserved slice and the success flag.


function try_insert_reserve

Tries to reserve space for a value of the given length for a new key.

inline value_result try_insert_reserve (
    const slice & key,
    size_t value_length
) 

Parameters:

  • key The key to insert.
  • value_length The length of the value to reserve.

Returns:

The value_result with the reserved slice and the success flag.


function try_start_write

Tries to start write (read-write) transaction without blocking.

inline txn_managed try_start_write () 

Returns:

The started managed write transaction.

Exception:

  • mdbx::error on failure, including MDBX_BUSY when the write lock is held by another thread.

function try_update

Tries to update the value for an existing key without throwing.

inline bool try_update (
    map_handle map,
    const slice & key,
    const slice & value
) 

Parameters:

  • map The table (map) handle.
  • key The key to update.
  • value The new value.

Returns:

true if the key was found and updated.


function try_update

Tries to update the value for an existing key without throwing.

inline bool try_update (
    const slice & key,
    const slice & value
) 

Parameters:

  • key The key to update.
  • value The new value.

Returns:

true if the key was found and updated.


function try_update_reserve

Tries to reserve space for a value of the given length for an existing key.

inline value_result try_update_reserve (
    map_handle map,
    const slice & key,
    size_t value_length
) 

Parameters:

  • map The table (map) handle.
  • key The key to update.
  • value_length The length of the value to reserve.

Returns:

The value_result with the reserved slice and the success flag.


function try_update_reserve

Tries to reserve space for a value of the given length for an existing key.

inline value_result try_update_reserve (
    const slice & key,
    size_t value_length
) 

Parameters:

  • key The key to update.
  • value_length The length of the value to reserve.

Returns:

The value_result with the reserved slice and the success flag.


function turn_for_recovery

Turns the database to the specified meta-page.

inline void turn_for_recovery (
    unsigned target_meta
) 

Mostly an internal API for the mdbx_chk utility and subject to change; use only when you know what you are doing. See env_managed::open_for_recovery().

See also: mdbx_env_turn_for_recovery()

Parameters:

  • target_meta The index of the meta-page.

function txn

Move constructor: the source transaction is nullified.

inline txn (
    txn && other
) noexcept

Parameters:

  • other The source transaction to be moved from.

function txn

Returns the cursor's transaction.

inline inline ::mdbx::txn txn () const

Returns:

The transaction the cursor belongs to.


function txn_lock

Acquires write-transaction lock.

inline bool txn_lock (
    bool dont_wait=false
) 

Provided for custom and/or complex locking scenarios, see mdbx_txn_lock(). Callers MUST NOT hold any write transaction while holding the lock.

Parameters:

  • dont_wait If true, does not block and returns false immediately when the lock is held by another thread or process.

Returns:

True if the lock was acquired, false otherwise.

See also: txn_unlock()

See also: mdbx_txn_lock()


function txn_unlock

Releases write-transaction lock acquired by txn_lock() .

inline void txn_unlock () 

See also: txn_lock()

See also: mdbx_txn_unlock()


function unbind

Unbind cursor from a transaction.

inline void unbind () 

Detaches the cursor from its transaction without closing the underlying C object: the wrapper keeps the handle and the destructor still closes it. While unbound, any seek/move/read operation fails with MDBX_EBADSIGN or MDBX_EINVAL; call renew() / bind() to attach the cursor to a transaction again (issue #146).


function unpark_reading

Resume parked read-only transaction.

inline bool unpark_reading (
    bool restart_if_ousted=true
) 

Returns:

True if transaction was restarted while restart_if_ousted=true.

Parameters:

  • restart_if_ousted The restart_if_ousted argument.

function update

Updates the value for an existing key; fails if the key is absent.

inline void update (
    map_handle map,
    const slice & key,
    const slice & value
) 

Parameters:

  • map The table (map) handle.
  • key The key to update.
  • value The new value.

Exception:


function update

Updates the value for an existing key; fails if the key is absent.

inline void update (
    const slice & key,
    const slice & value
) 

Parameters:

  • key The key to update.
  • value The new value.

Exception:


function update_reserve

Reserves space for a value of the given length for an existing key.

inline slice update_reserve (
    map_handle map,
    const slice & key,
    size_t value_length
) 

Parameters:

  • map The table (map) handle.
  • key The key to update.
  • value_length The length of the value to reserve.

Returns:

The writable slice for the reserved value.

Exception:


function update_reserve

Reserves space for a value of the given length for an existing key.

inline slice update_reserve (
    const slice & key,
    size_t value_length
) 

Parameters:

  • key The key to update.
  • value_length The length of the value to reserve.

Returns:

The writable slice for the reserved value.

Exception:


function upper_bound

Finds the first key greater than the given one.

inline move_result upper_bound (
    const slice & key,
    bool throw_notfound=false
) 

Parameters:

  • key The key to find the upper bound for.
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

Returns:

The move_result with the found pair and the success flag.


function upper_bound_multivalue

Finds the exact key and the first multi-value greater than the given one.

inline move_result upper_bound_multivalue (
    const slice & key,
    const slice & value,
    bool throw_notfound=false
) 

Parameters:

  • key The key to find.
  • value The multi-value to find the upper bound for.
  • throw_notfound Throw mdbx::not_found instead of returning an unsuccessful result.

Returns:

The move_result with the found pair and the success flag.


function upsert

Inserts or updates the value for the given key.

inline void upsert (
    map_handle map,
    const slice & key,
    const slice & value
) 

Parameters:

  • map The table (map) handle.
  • key The key to store.
  • value The value to store.

Exception:


function upsert

Inserts or updates the value for the given key.

inline void upsert (
    const slice & key,
    const slice & value
) 

Parameters:

  • key The key to store.
  • value The value to store.

Exception:


function upsert_reserve

Reserves space for a value of the given length, inserting or updating the key.

inline slice upsert_reserve (
    map_handle map,
    const slice & key,
    size_t value_length
) 

Parameters:

  • map The table (map) handle.
  • key The key to store.
  • value_length The length of the value to reserve.

Returns:

The writable slice for the reserved value.


function upsert_reserve

Reserves space for a value of the given length, inserting or updating the key.

inline slice upsert_reserve (
    const slice & key,
    size_t value_length
) 

Parameters:

  • key The key to store.
  • value_length The length of the value to reserve.

Returns:

The writable slice for the reserved value.


function value_mode

Returns the value comparison mode implied by the flags.

MDBX_CXX11_CONSTEXPR_ENUM  mdbx::value_mode value_mode () noexcept const

Returns:

The mdbx::value_mode of the table.


function warmup

Loads into memory the given pages of the database and their on-disk neighbours in advance.

inline MDBX_NODISCARD int warmup (
    MDBX_warmup_flags_t flags,
    unsigned timeout_seconds_16dot16,
    const MDBX_txn * txn=nullptr
) const

Returns:

MDBX_RESULT_TRUE if the specified timeout is reached during loading data into memory, MDBX_SUCCESS on success.

See also: mdbx_env_warmup()

Parameters:

  • flags The flags.
  • timeout_seconds_16dot16 The timeout in 1/65536 of second units.
  • txn The transaction handle.

function whole_fragile

Sets the durability level to env::durability::whole_fragile .

operate_parameters & whole_fragile () noexcept

Returns:

A reference to this instance.


function write_file_io

Sets the operation mode to env::mode::write_file_io .

operate_parameters & write_file_io () noexcept

Returns:

A reference to this instance.


function write_mapped_io

Sets the operation mode to env::mode::write_mapped_io .

operate_parameters & write_mapped_io () noexcept

Returns:

A reference to this instance.


function ~cursor

Destroys the wrapper; the underlying object is NOT closed since the cursor is non-owning.

inline ~cursor () noexcept

function ~env

Destroys the wrapper; the underlying object is NOT closed since the environment is non-owning.

inline ~env () noexcept

function ~txn

Destroys the wrapper; the underlying object is NOT finished since the transaction is non-owning.

inline ~txn () noexcept

Public Static Functions Documentation

function boolean_or_throw

Throws the corresponding exception if the code is a failure.

static inline bool boolean_or_throw (
    int error_code
) 

Parameters:

  • error_code The error code to be checked.

Returns:

true if the code is MDBX_RESULT_TRUE, false otherwise.

Exception:


function boolean_or_throw

Throws the corresponding exception, or the captured one if any.

static inline bool boolean_or_throw (
    int error_code,
    const exception_thunk & thunk
) 

Parameters:

Returns:

true if the code is MDBX_RESULT_TRUE, false otherwise.

Exception:


function compare_fast

Three-way fast non-lexicographically length-based comparison.

static intptr_t compare_fast (
    const slice & a,
    const slice & b
) noexcept

Firstly compares length and if it equal then compare content lexicographically.

Returns:

value: == 0 if a the same as b; < 0 if a shorter than b, or the same length and lexicographically less than b; > 0 if a longer than b, or the same length and lexicographically greater than b.

Parameters:

  • a The left-hand slice.
  • b The right-hand slice.

Returns:

The three-way comparison result.


function compare_fast

Three-way fast non-lexicographically length-based comparison.

static intptr_t compare_fast (
    const pair & a,
    const pair & b
) noexcept

Parameters:

  • a The left-hand pair.
  • b The right-hand pair.

Returns:

The three-way comparison result.


function compare_lexicographically

Three-way lexicographically comparison.

static intptr_t compare_lexicographically (
    const slice & a,
    const slice & b
) noexcept

Returns:

value: == 0 if a lexicographically equal b; < 0 if a lexicographically less than b; > 0 if a lexicographically greater than b.

Parameters:

  • a The left-hand slice.
  • b The right-hand slice.

Returns:

The three-way comparison result.


function compare_lexicographically

Three-way lexicographically comparison.

static intptr_t compare_lexicographically (
    const pair & a,
    const pair & b
) noexcept

Parameters:

  • a The left-hand pair.
  • b The right-hand pair.

Returns:

The three-way comparison result.


function dbsize_max

Returns the maximal database size in bytes for specified page size.

static inline size_t dbsize_max (
    intptr_t pagesize
) 

Parameters:

  • pagesize The database page size in bytes.

Returns:

The maximal database size in bytes for specified page size.


function dbsize_min

Returns the minimal database size in bytes for specified page size.

static inline size_t dbsize_min (
    intptr_t pagesize
) 

Parameters:

  • pagesize The database page size in bytes.

Returns:

The minimal database size in bytes for specified page size.


function distance_between

Estimates the distance (number of items) between two cursor positions.

static inline ptrdiff_t distance_between (
    const cursor from,
    const cursor to,
    unsigned deepness=42
) 

Parameters:

  • from The cursor at the "from" position, null means the table start.
  • to The cursor at the "to" position, null means the table end.
  • deepness The maximum depth of the B+tree inspection.

Returns:

The approximate distance; a negative value means to is before from.


function distribute

Distributes cursors evenly over the range between two positions.

static inline bool distribute (
    const cursor from,
    const cursor to,
    cursor * cursors_array,
    intptr_t cursors_array_size,
    unsigned deepness=42
) 

Parameters:

  • from The cursor at the start of the range, null means the table start.
  • to The cursor at the end of the range, null means the table end.
  • cursors_array The array of cursors to be positioned.
  • cursors_array_size The number of cursors in the array.
  • deepness The maximum depth of the B+tree inspection.

Returns:

true on success.


function distribute

Distributes cursors evenly over the range between two positions.

static inline bool distribute (
    const cursor from,
    const cursor to,
    const std::vector< cursor > & cursors,
    unsigned deepness=42
) 

Parameters:

  • from The cursor at the start of the range, null means the table start.
  • to The cursor at the end of the range, null means the table end.
  • cursors The vector of cursors to be positioned.
  • deepness The maximum depth of the B+tree inspection.

Returns:

true on success.


function distribute

Distributes cursors evenly over the range between two positions.

static inline bool distribute (
    const cursor from,
    const cursor to,
    const std::vector< cursor_managed > & cursors,
    unsigned deepness=42
) 

Parameters:

  • from The cursor at the start of the range, null means the table start.
  • to The cursor at the end of the range, null means the table end.
  • cursors The vector of managed cursors to be positioned.
  • deepness The maximum depth of the B+tree inspection.

Returns:

true on success.


function fragile_write

Constructs parameters for a writable environment with env::durability::whole_fragile durability and_env::mode::write_mapped_io ._

static operate_parameters fragile_write () noexcept

Returns:

The constructed operate_parameters instance.


function get_preopen_snapinfo

Provides information about a database, including meta-page and geometry, without opening it.

static inline MDBX_NODISCARD info get_preopen_snapinfo (
    const ::std::string & pathname,
    MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY
) 

Parameters:

  • pathname The path to the directory or database file.
  • mode The mode of processing weak checkpoints, see MDBX_preopen_flags. Defaults to MDBX_PREOPEN_PROPERLY (same as the legacy get_preopen_snapinfo()).

Returns:

The info of the database. Errors are thrown as mdbx::error.

See also: mdbx_preopen_snapinfo_ex()


function get_preopen_snapinfo

Provides information about a database, including meta-page and geometry, without opening it.

static inline MDBX_NODISCARD info get_preopen_snapinfo (
    const char * pathname,
    MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY
) 

Parameters:

  • pathname The path to the directory or database file.
  • mode The mode of processing weak checkpoints, see MDBX_preopen_flags. Defaults to MDBX_PREOPEN_PROPERLY (same as the legacy get_preopen_snapinfo()).

Returns:

The info of the database. Errors are thrown as mdbx::error.

See also: mdbx_preopen_snapinfo_ex()


function get_preopen_snapinfo

Provides information about a database, including meta-page and geometry, without opening it.

static inline MDBX_NODISCARD info get_preopen_snapinfo (
    const ::mdbx::filesystem::path & pathname,
    MDBX_preopen_flags mode=MDBX_PREOPEN_PROPERLY
) 

Parameters:

  • pathname The path to the directory or database file.
  • mode The mode of processing weak checkpoints, see MDBX_preopen_flags. Defaults to MDBX_PREOPEN_PROPERLY (same as the legacy get_preopen_snapinfo()).

Returns:

The info of the database. Errors are thrown as mdbx::error.

See also: mdbx_preopen_snapinfo_ex()


function get_sysraminfo

Returns information about the system RAM.

static inline MDBX_NODISCARD sysraminfo get_sysraminfo () 

Returns:

The sysraminfo of the system.


function key_max

Returns the maximal key size in bytes for specified page size and table flags.

static inline size_t key_max (
    intptr_t pagesize,
    MDBX_db_flags_t flags
) 

Parameters:

  • pagesize The database page size in bytes.
  • flags The table flags.

Returns:

The maximal key size in bytes for specified page size and table flags.


function key_max

Returns the maximal key size in bytes for specified page size and keys mode.

static inline size_t key_max (
    intptr_t pagesize,
    key_mode mode
) 

Parameters:

  • pagesize The database page size in bytes.
  • mode The key comparison mode, see mdbx::key_mode.

Returns:

The maximal key size in bytes for specified page size and keys mode.


function key_max

Returns the maximal key size in bytes for given environment and table flags.

static inline size_t key_max (
    const env & env,
    MDBX_db_flags_t flags
) 

Parameters:

  • env The environment.
  • flags The table flags.

Returns:

The maximal key size in bytes for given environment and table flags.


function key_max

Returns the maximal key size in bytes for given environment and keys mode.

static inline size_t key_max (
    const env & env,
    key_mode mode
) 

Parameters:

  • env The environment.
  • mode The key comparison mode, see mdbx::key_mode.

Returns:

The maximal key size in bytes for given environment and keys mode.


function key_min

Returns the minimal key size in bytes for specified table flags.

static inline size_t key_min (
    MDBX_db_flags_t flags
) noexcept

Parameters:

  • flags The table flags.

Returns:

The minimal key size in bytes for specified table flags.


function key_min

Returns the minimal key size in bytes for specified keys mode.

static inline size_t key_min (
    key_mode mode
) noexcept

Parameters:

Returns:

The minimal key size in bytes for specified keys mode.


function lazy_write

Constructs parameters for a writable environment with env::durability::lazy_weak_tail durability and_env::mode::write_mapped_io ._

static operate_parameters lazy_write () noexcept

Returns:

The constructed operate_parameters instance.


function max_map_handles

Returns the maximum opened map handles, aka DBI-handles.

static inline size_t max_map_handles (
    void
) 

Returns:

The maximum number of map (DBI) handles.


function memcmp

constexpr-enabled memcmp().

static int memcmp (
    const void * a,
    const void * b,
    size_t bytes
) noexcept

function memcpy

constexpr-enabled memcpy().

static void * memcpy (
    void * dest,
    const void * src,
    size_t bytes
) noexcept

function options_from_flags

Extracts the other options from environment flags.

static inline MDBX_NODISCARD env::operate_options options_from_flags (
    MDBX_env_flags_t flags
) noexcept

Parameters:

Returns:

The corresponding env::operate_options.


function pagesize_max

Returns the maximal database page size in bytes.

static inline size_t pagesize_max () noexcept

Returns:

The maximal page size in bytes.


function pagesize_min

Returns the minimal database page size in bytes.

static inline size_t pagesize_min () noexcept

Returns:

The minimal page size in bytes.


function pairsize4page_max

Returns maximal size of key-value pair to fit in a single page for specified page size and table flags.

static inline size_t pairsize4page_max (
    intptr_t pagesize,
    MDBX_db_flags_t flags
) 

Parameters:

  • pagesize The database page size in bytes.
  • flags The table flags.

Returns:

Maximal size of key-value pair to fit in a single page for specified page size and table flags.


function pairsize4page_max

Returns maximal size of key-value pair to fit in a single page for specified page size and values mode.

static inline size_t pairsize4page_max (
    intptr_t pagesize,
    value_mode mode
) 

Parameters:

  • pagesize The database page size in bytes.
  • mode The value comparison mode, see mdbx::value_mode.

Returns:

Maximal size of key-value pair to fit in a single page for specified page size and values mode.


function pairsize4page_max

Returns maximal size of key-value pair to fit in a single page for given environment and table flags.

static inline size_t pairsize4page_max (
    const env & env,
    MDBX_db_flags_t flags
) 

Parameters:

  • env The environment.
  • flags The table flags.

Returns:

Maximal size of key-value pair to fit in a single page for given environment and table flags.


function pairsize4page_max

Returns maximal size of key-value pair to fit in a single page for given environment and values mode.

static inline size_t pairsize4page_max (
    const env & env,
    value_mode mode
) 

Parameters:

Returns:

Maximal size of key-value pair to fit in a single page for given environment and values mode.


function read_only

Constructs parameters for a read-only environment.

static operate_parameters read_only () noexcept

Returns:

The constructed operate_parameters instance.


function reclaiming_from_flags

Extracts the reclaiming options from environment flags.

static inline MDBX_NODISCARD env::reclaiming_options reclaiming_from_flags (
    MDBX_env_flags_t flags
) noexcept

Parameters:

Returns:

The corresponding env::reclaiming_options.


function safe_write

Constructs parameters for a writable environment with env::durability::robust_synchronous durability and_env::mode::write_mapped_io ._

static operate_parameters safe_write () noexcept

Returns:

The constructed operate_parameters instance.


function strlen

constexpr-enabled strlen().

static size_t strlen (
    const char * c_str
) noexcept

function success_or_throw

Throws the corresponding exception if the code is a failure.

static inline void success_or_throw (
    MDBX_error_t error_code
) 

Parameters:

  • error_code The error code to be checked.

Exception:


function success_or_throw

Throws the corresponding exception, or the captured one if any.

static inline void success_or_throw (
    int error_code,
    const exception_thunk & thunk
) 

Parameters:

Exception:


function throw_exception

Panics on unrecoverable errors inside destructors etc.

static inline void throw_exception (
    int error_code
) 

Parameters:

  • error_code The error code to be checked.

Exception:


function throw_on_failure

Throws the corresponding exception if the code is a failure.

static inline void throw_on_failure (
    int error_code
) 

Parameters:

  • error_code The error code to be checked.

Exception:


function throw_on_nullptr

Throws the corresponding exception if the pointer is null.

static inline void throw_on_nullptr (
    const void * ptr,
    MDBX_error_t error_code
) 

Parameters:

  • ptr The pointer to be checked.
  • error_code The error code to be thrown on a null pointer.

Exception:


function transaction_size_max

Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for specified page size.

static inline size_t transaction_size_max (
    intptr_t pagesize
) 

Parameters:

  • pagesize The database page size in bytes.

Returns:

The maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for specified page size.


function valsize4page_max

Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified size and table flags.

static inline size_t valsize4page_max (
    intptr_t pagesize,
    MDBX_db_flags_t flags
) 

Parameters:

  • pagesize The database page size in bytes.
  • flags The table flags.

Returns:

Maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified size and table flags.


function valsize4page_max

Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified page size and values mode.

static inline size_t valsize4page_max (
    intptr_t pagesize,
    value_mode mode
) 

Parameters:

  • pagesize The database page size in bytes.
  • mode The value comparison mode, see mdbx::value_mode.

Returns:

Maximal data size in bytes to fit in a leaf-page or single large/overflow-page for specified page size and values mode.


function valsize4page_max

Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for given environment and table flags.

static inline size_t valsize4page_max (
    const env & env,
    MDBX_db_flags_t flags
) 

Parameters:

  • env The environment.
  • flags The table flags.

Returns:

Maximal data size in bytes to fit in a leaf-page or single large/overflow-page for given environment and table flags.


function valsize4page_max

Returns maximal data size in bytes to fit in a leaf-page or single large/overflow-page for given environment and values mode.

static inline size_t valsize4page_max (
    const env & env,
    value_mode mode
) 

Parameters:

Returns:

Maximal data size in bytes to fit in a leaf-page or single large/overflow-page for given environment and values mode.


function value_max

Returns the maximal value size in bytes for specified page size and table flags.

static inline size_t value_max (
    intptr_t pagesize,
    MDBX_db_flags_t flags
) 

Parameters:

  • pagesize The database page size in bytes.
  • flags The table flags.

Returns:

The maximal value size in bytes for specified page size and table flags.


function value_max

Returns the maximal value size in bytes for specified page size and values mode.

static inline size_t value_max (
    intptr_t pagesize,
    value_mode mode
) 

Parameters:

  • pagesize The database page size in bytes.
  • mode The value comparison mode, see mdbx::value_mode.

Returns:

The maximal value size in bytes for specified page size and values mode.


function value_max

Returns the maximal value size in bytes for given environment and table flags.

static inline size_t value_max (
    const env & env,
    MDBX_db_flags_t flags
) 

Parameters:

  • env The environment.
  • flags The table flags.

Returns:

The maximal value size in bytes for given environment and table flags.


function value_max

Returns the maximal value size in bytes for given environment and values mode.

static inline size_t value_max (
    const env & env,
    value_mode mode
) 

Parameters:

Returns:

The maximal value size in bytes for given environment and values mode.


function value_min

Returns the minimal values size in bytes for specified table flags.

static inline size_t value_min (
    MDBX_db_flags_t flags
) noexcept

Parameters:

  • flags The table flags.

Returns:

The minimal values size in bytes for specified table flags.


function value_min

Returns the minimal values size in bytes for specified values mode.

static inline size_t value_min (
    value_mode mode
) noexcept

Parameters:

Returns:

The minimal values size in bytes for specified values mode.


Protected Functions Documentation

function env

Constructs a non-owning environment wrapping the given C handle.

constexpr env (
    MDBX_env * ptr
) noexcept

Parameters:

  • ptr The pointer to the underlying MDBX_env object.

function estimate

The low-level range estimation primitive.

inline ptrdiff_t estimate (
    move_operation operation,
    MDBX_val * key,
    MDBX_val * value
) const

Parameters:

  • operation The positioning operation.
  • key The boundary key (in/out).
  • value The boundary value (in/out).

Returns:

The approximate number of items in the range.

Exception:


function move

The low-level positioning primitive.

inline bool move (
    move_operation operation,
    MDBX_val * key,
    MDBX_val * value,
    bool throw_notfound
) const

Parameters:

  • operation The positioning operation.
  • key The key argument (in/out).
  • value The value argument (in/out).
  • throw_notfound Throw mdbx::not_found instead of returning false.

Returns:

true if the cursor was positioned successfully.

Exception:


function txn

Constructs a non-owning transaction wrapping the given C handle.

constexpr txn (
    MDBX_txn * ptr
) noexcept

Parameters:

  • ptr The pointer to the underlying MDBX_txn object.

Macro Definition Documentation

define MDBX_CXX_HAS_POLYMORPHIC_ALLOCATOR

Defined as 1 if themdbx::polymorphic_allocator is available.

#define MDBX_CXX_HAS_POLYMORPHIC_ALLOCATOR `1`

See also: The <memory_resource> Standard C++17 library header


define MDBX_STD_FILESYSTEM_PATH

Defined if mdbx::filesystem::path is available.

#define MDBX_STD_FILESYSTEM_PATH `::mdbx::filesystem::path`

If defined, it is always mdbx::filesystem::path, which in turn can refer to std::filesystem::path or std::experimental::filesystem::path. Nonetheless MDBX_STD_FILESYSTEM_PATH is not defined if the mdbx::path falls back to a plain std::string or std::wstring.