MDBX Containers
Loading...
Searching...
No Matches
mdbxc Namespace Reference

Classes

class  BaseTable
 Base class providing common functionality for MDBX database access. More...
 
class  Config
 Parameters used by Connection to create the MDBX environment. More...
 
class  Connection
 Manages a single MDBX environment and an optional read-only transaction. More...
 
struct  has_from_bytes
 Trait to check if a type provides a static from_bytes() method. More...
 
struct  has_to_bytes
 Trait to check if a type provides a to_bytes() member. More...
 
struct  has_value_type
 Trait indicating that a container defines value_type. More...
 
class  KeyValueTable
 Template class for managing key-value pairs in an MDBX database. More...
 
class  MdbxException
 Represents a specific exception for MDBX-related errors. More...
 
struct  PathComponents
 Structure to hold the root and components of a path. More...
 
class  Transaction
 Manages MDBX transactions with automatic cleanup and error handling. More...
 
class  TransactionTracker
 Associates MDBX transactions with threads. More...
 

Enumerations

enum class  TransactionMode { READ_ONLY , WRITABLE }
 Specifies the access mode of a transaction. More...
 

Functions

bool is_absolute_path (const std::string &path)
 Checks whether the given path is absolute (cross-platform).
 
std::string get_parent_path (const std::string &file_path)
 Extracts the parent directory from a full file path.
 
std::string get_exec_dir ()
 Retrieves the directory of the executable file.
 
std::string get_file_name (const std::string &file_path)
 Extracts the file name from a full file path.
 
PathComponents split_path (const std::string &path)
 Splits a path into its root and components.
 
std::string utf8_to_ansi (const std::string &utf8) noexcept
 Converts a UTF-8 string to an ANSI string (Windows-specific).
 
void create_directories (const std::string &path)
 Creates directories recursively for the given path.
 
void check_mdbx (int rc, const std::string &context)
 Throws an MdbxException if MDBX return code indicates an error.
 
template<typename T>
MDBX_db_flags_t get_mdbx_flags ()
 Returns MDBX flags for a given key type.
 
template<typename T>
size_t get_key_size (const T &key)
 Returns the size in bytes of a given key type.
 
template<typename T>
std::enable_if<!has_to_bytes< T >::value &&!std::is_same< T, std::string >::value &&!std::is_trivially_copyable< T >::value, MDBX_val >::type serialize_key (const T &key)
 Serializes a key into MDBX_val for database operations.
 
template<typename T>
std::enable_if< std::is_same< T, std::string >::value, MDBX_val >::type serialize_key (const T &key)
 Serializes a key of type std::string.
 
template<typename T>
std::enable_if< std::is_same< T, std::vector< uint8_t > >::value||std::is_same< T, std::vector< char > >::value||std::is_same< T, std::vector< unsignedchar > >::value, MDBX_val >::type serialize_key (const T &key)
 Serializes a key stored in a byte vector.
 
template<typename T>
std::enable_if< std::is_integral< T >::value &&(sizeof(T)<=2), MDBX_val >::type serialize_key (const T &key)
 Serializes a small integral key (<=16 bits).
 
template<typename T>
std::enable_if< std::is_same< T, int32_t >::value||std::is_same< T, uint32_t >::value||std::is_same< T, float >::value, MDBX_val >::type serialize_key (const T &key)
 Serializes a 32-bit integral or float key.
 
template<typename T>
std::enable_if< std::is_same< T, int64_t >::value||std::is_same< T, uint64_t >::value||std::is_same< T, double >::value, MDBX_val >::type serialize_key (const T &key)
 Serializes a 64-bit integral or double key.
 
template<typename T>
std::enable_if< std::is_trivially_copyable< T >::value &&!std::is_same< T, std::string >::value &&!(std::is_integral< T >::value &&sizeof(T)<=2)&&!std::is_same< T, int32_t >::value &&!std::is_same< T, uint32_t >::value &&!std::is_same< T, float >::value &&!std::is_same< T, int64_t >::value &&!std::is_same< T, uint64_t >::value &&!std::is_same< T, double >::value, MDBX_val >::type serialize_key (const T &key)
 Serializes any other trivially copyable key type.
 
template<size_t N>
MDBX_val serialize_key (const std::bitset< N > &data)
 Serializes a std::bitset as a key.
 
template<typename T>
std::enable_if<!has_value_type< T >::value &&!std::is_same< T, std::vector< typenameT::value_type > >::value &&!std::is_trivially_copyable< typenameT::value_type >::value &&!has_to_bytes< T >::value &&!std::is_same< T, std::string >::value &&!std::is_trivially_copyable< T >::value, MDBX_val >::type serialize_value (const T &value)
 Serializes a general value into MDBX_val.
 
template<typename T>
std::enable_if< std::is_same< T, std::string >::value, MDBX_val >::type serialize_value (const T &value)
 Serializes a std::string value.
 
template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_trivially_copyable< typenameT::value_type >::value &&(std::is_same< T, std::deque< typenameT::value_type > >::value||std::is_same< T, std::list< typenameT::value_type > >::value||std::is_same< T, std::set< typenameT::value_type > >::value), MDBX_val >::type serialize_value (const T &container)
 Serializes containers (vector, deque, list, set) of trivially copyable elements.
 
template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< T, std::vector< typenameT::value_type > >::value &&std::is_trivially_copyable< typenameT::value_type >::value, MDBX_val >::type serialize_value (const T &value)
 Serializes a vector of trivially copyable elements.
 
template<typename T>
std::enable_if< has_to_bytes< T >::value, MDBX_val >::type serialize_value (const T &value)
 Serializes a value using its to_bytes() method.
 
template<typename T>
std::enable_if<!has_to_bytes< T >::value &&std::is_trivially_copyable< T >::value, MDBX_val >::type serialize_value (const T &value)
 Serializes any trivially copyable value.
 
template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< typenameT::value_type, std::string >::value, MDBX_val >::type serialize_value (const T &container)
 Serializes a container of strings.
 
template<typename T>
std::enable_if<!has_from_bytes< T >::value &&!std::is_same< T, std::string >::value &&!std::is_trivially_copyable< T >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a value from MDBX_val into type T.
 
template<typename T>
std::enable_if< std::is_same< T, std::string >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a std::string value.
 
template<typename T>
std::enable_if< std::is_same< T, std::vector< uint8_t > >::value||std::is_same< T, std::vector< char > >::value||std::is_same< T, std::vector< unsignedchar > >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a vector of bytes.
 
template<typename T>
std::enable_if< std::is_same< T, std::deque< uint8_t > >::value||std::is_same< T, std::deque< char > >::value||std::is_same< T, std::deque< unsignedchar > >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a deque of bytes.
 
template<typename T>
std::enable_if< std::is_same< T, std::list< uint8_t > >::value||std::is_same< T, std::list< char > >::value||std::is_same< T, std::list< unsignedchar > >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a list of bytes.
 
template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< T, std::vector< typenameT::value_type > >::value &&std::is_trivially_copyable< typenameT::value_type >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a vector of trivially copyable elements.
 
template<typename T>
std::enable_if<(std::is_same< T, std::deque< typenameT::value_type > >::value||std::is_same< T, std::list< typenameT::value_type > >::value)&&std::is_trivially_copyable< typenameT::value_type >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a deque or list of trivially copyable elements.
 
template<typename T>
std::enable_if<!has_from_bytes< T >::value &&std::is_trivially_copyable< T >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a trivially copyable value.
 
template<typename T>
std::enable_if< has_from_bytes< T >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a value using its from_bytes() method.
 
template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< typenameT::value_type, std::string >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a container of strings.
 
template<typename T>
std::enable_if< std::is_same< T, std::set< std::string > >::value||std::is_same< T, std::unordered_set< std::string > >::value, T >::type deserialize_value (const MDBX_val &val)
 Deserializes a set of strings.
 

Enumeration Type Documentation

◆ TransactionMode

enum class mdbxc::TransactionMode
strong

Specifies the access mode of a transaction.

Defines whether the transaction is read-only or writable.

Enumerator
READ_ONLY 

Read-only transaction (no write operations allowed).

WRITABLE 

Writable transaction (allows inserts, updates, deletes).

Definition at line 14 of file Transaction.hpp.

Function Documentation

◆ check_mdbx()

void mdbxc::check_mdbx ( int rc,
const std::string & context )

Throws an MdbxException if MDBX return code indicates an error.

Parameters
rcReturn code from an MDBX function.
contextDescription of the calling context.

Definition at line 18 of file utils.hpp.

◆ create_directories()

void mdbxc::create_directories ( const std::string & path)

Creates directories recursively for the given path.

Parameters
pathThe directory path to create.
Exceptions
std::runtime_errorif the directories cannot be created.

Definition at line 261 of file path_utils.hpp.

◆ deserialize_value() [1/11]

template<typename T>
std::enable_if<!has_from_bytes< T >::value &&!std::is_same< T, std::string >::value &&!std::is_trivially_copyable< T >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a value from MDBX_val into type T.

Template Parameters
TDesired type.
Parameters
valMDBX_val containing raw data.
Returns
Deserialized T.

Definition at line 403 of file utils.hpp.

◆ deserialize_value() [2/11]

template<typename T>
std::enable_if< std::is_same< T, std::string >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a std::string value.

Template Parameters
TMust be std::string.

Definition at line 413 of file utils.hpp.

◆ deserialize_value() [3/11]

template<typename T>
std::enable_if< std::is_same< T, std::vector< uint8_t > >::value||std::is_same< T, std::vector< char > >::value||std::is_same< T, std::vector< unsignedchar > >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a vector of bytes.

Template Parameters
TVector type containing bytes.

Definition at line 427 of file utils.hpp.

◆ deserialize_value() [4/11]

template<typename T>
std::enable_if< std::is_same< T, std::deque< uint8_t > >::value||std::is_same< T, std::deque< char > >::value||std::is_same< T, std::deque< unsignedchar > >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a deque of bytes.

Template Parameters
TByte deque type.

Definition at line 442 of file utils.hpp.

◆ deserialize_value() [5/11]

template<typename T>
std::enable_if< std::is_same< T, std::list< uint8_t > >::value||std::is_same< T, std::list< char > >::value||std::is_same< T, std::list< unsignedchar > >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a list of bytes.

Template Parameters
TByte list type.

Definition at line 457 of file utils.hpp.

◆ deserialize_value() [6/11]

template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< T, std::vector< typenameT::value_type > >::value &&std::is_trivially_copyable< typenameT::value_type >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a vector of trivially copyable elements.

Template Parameters
TVector type.

Definition at line 469 of file utils.hpp.

◆ deserialize_value() [7/11]

template<typename T>
std::enable_if<(std::is_same< T, std::deque< typenameT::value_type > >::value||std::is_same< T, std::list< typenameT::value_type > >::value)&&std::is_trivially_copyable< typenameT::value_type >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a deque or list of trivially copyable elements.

Template Parameters
TContainer type.

Definition at line 485 of file utils.hpp.

◆ deserialize_value() [8/11]

template<typename T>
std::enable_if<!has_from_bytes< T >::value &&std::is_trivially_copyable< T >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a trivially copyable value.

Template Parameters
TTrivially copyable type.

Definition at line 499 of file utils.hpp.

◆ deserialize_value() [9/11]

template<typename T>
std::enable_if< has_from_bytes< T >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a value using its from_bytes() method.

Template Parameters
TType providing from_bytes.

Definition at line 511 of file utils.hpp.

◆ deserialize_value() [10/11]

template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< typenameT::value_type, std::string >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a container of strings.

Template Parameters
TContainer type with std::string elements.

Definition at line 522 of file utils.hpp.

◆ deserialize_value() [11/11]

template<typename T>
std::enable_if< std::is_same< T, std::set< std::string > >::value||std::is_same< T, std::unordered_set< std::string > >::value, T >::type mdbxc::deserialize_value ( const MDBX_val & val)

Deserializes a set of strings.

Template Parameters
TEither std::set<std::string> or std::unordered_set<std::string>.

Definition at line 552 of file utils.hpp.

◆ get_exec_dir()

std::string mdbxc::get_exec_dir ( )

Retrieves the directory of the executable file.

Returns
A string containing the directory path of the executable.

Definition at line 75 of file path_utils.hpp.

◆ get_file_name()

std::string mdbxc::get_file_name ( const std::string & file_path)

Extracts the file name from a full file path.

Parameters
file_pathThe full file path as a string.
Returns
The extracted file name, or the full string if no directory separator is found.

Definition at line 133 of file path_utils.hpp.

◆ get_key_size()

template<typename T>
size_t mdbxc::get_key_size ( const T & key)

Returns the size in bytes of a given key type.

Template Parameters
TKey type.
Parameters
keyThe key value.
Returns
Size in bytes suitable for filling MDBX_val.

Definition at line 88 of file utils.hpp.

◆ get_mdbx_flags()

template<typename T>
MDBX_db_flags_t mdbxc::get_mdbx_flags ( )
inline

Returns MDBX flags for a given key type.

Template Parameters
TKey type.
Returns
MDBX_INTEGERKEY if T is an integer-like type; 0 otherwise.

Definition at line 71 of file utils.hpp.

◆ get_parent_path()

std::string mdbxc::get_parent_path ( const std::string & file_path)
inline

Extracts the parent directory from a full file path.

Parameters
file_pathPath to a file (e.g., "data/testdb").
Returns
Directory path (e.g., "data")

Definition at line 62 of file path_utils.hpp.

◆ is_absolute_path()

bool mdbxc::is_absolute_path ( const std::string & path)
inline

Checks whether the given path is absolute (cross-platform).

Parameters
pathFile or directory path.
Returns
True if path is absolute, false otherwise.

Definition at line 43 of file path_utils.hpp.

◆ serialize_key() [1/8]

template<size_t N>
MDBX_val mdbxc::serialize_key ( const std::bitset< N > & data)
inline

Serializes a std::bitset as a key.

Template Parameters
NNumber of bits in the bitset.
Parameters
dataBitset value to serialize.

Definition at line 253 of file utils.hpp.

◆ serialize_key() [2/8]

template<typename T>
std::enable_if<!has_to_bytes< T >::value &&!std::is_same< T, std::string >::value &&!std::is_trivially_copyable< T >::value, MDBX_val >::type mdbxc::serialize_key ( const T & key)

Serializes a key into MDBX_val for database operations.

Template Parameters
TKey type.
Parameters
keyThe key to convert.
Returns
MDBX_val representing the key.

Definition at line 132 of file utils.hpp.

◆ serialize_key() [3/8]

template<typename T>
std::enable_if< std::is_same< T, std::string >::value, MDBX_val >::type mdbxc::serialize_key ( const T & key)

Serializes a key of type std::string.

Template Parameters
TMust be std::string.

Definition at line 144 of file utils.hpp.

◆ serialize_key() [4/8]

template<typename T>
std::enable_if< std::is_same< T, std::vector< uint8_t > >::value||std::is_same< T, std::vector< char > >::value||std::is_same< T, std::vector< unsignedchar > >::value, MDBX_val >::type mdbxc::serialize_key ( const T & key)

Serializes a key stored in a byte vector.

Template Parameters
TVector type containing bytes.

Definition at line 161 of file utils.hpp.

◆ serialize_key() [5/8]

template<typename T>
std::enable_if< std::is_integral< T >::value &&(sizeof(T)<=2), MDBX_val >::type mdbxc::serialize_key ( const T & key)

Serializes a small integral key (<=16 bits).

Template Parameters
TIntegral type.

Definition at line 174 of file utils.hpp.

◆ serialize_key() [6/8]

template<typename T>
std::enable_if< std::is_same< T, int32_t >::value||std::is_same< T, uint32_t >::value||std::is_same< T, float >::value, MDBX_val >::type mdbxc::serialize_key ( const T & key)

Serializes a 32-bit integral or float key.

Template Parameters
TSupported 32-bit type.

Definition at line 192 of file utils.hpp.

◆ serialize_key() [7/8]

template<typename T>
std::enable_if< std::is_same< T, int64_t >::value||std::is_same< T, uint64_t >::value||std::is_same< T, double >::value, MDBX_val >::type mdbxc::serialize_key ( const T & key)

Serializes a 64-bit integral or double key.

Template Parameters
TSupported 64-bit type.

Definition at line 214 of file utils.hpp.

◆ serialize_key() [8/8]

template<typename T>
std::enable_if< std::is_trivially_copyable< T >::value &&!std::is_same< T, std::string >::value &&!(std::is_integral< T >::value &&sizeof(T)<=2)&&!std::is_same< T, int32_t >::value &&!std::is_same< T, uint32_t >::value &&!std::is_same< T, float >::value &&!std::is_same< T, int64_t >::value &&!std::is_same< T, uint64_t >::value &&!std::is_same< T, double >::value, MDBX_val >::type mdbxc::serialize_key ( const T & key)

Serializes any other trivially copyable key type.

Template Parameters
TTrivially copyable type.

Definition at line 242 of file utils.hpp.

◆ serialize_value() [1/7]

template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_trivially_copyable< typenameT::value_type >::value &&(std::is_same< T, std::deque< typenameT::value_type > >::value||std::is_same< T, std::list< typenameT::value_type > >::value||std::is_same< T, std::set< typenameT::value_type > >::value), MDBX_val >::type mdbxc::serialize_value ( const T & container)

Serializes containers (vector, deque, list, set) of trivially copyable elements.

Template Parameters
TContainer type with value_type.
Parameters
containerThe container to serialize.

Definition at line 313 of file utils.hpp.

◆ serialize_value() [2/7]

template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< typenameT::value_type, std::string >::value, MDBX_val >::type mdbxc::serialize_value ( const T & container)

Serializes a container of strings.

Template Parameters
TContainer type with std::string elements.

Definition at line 374 of file utils.hpp.

◆ serialize_value() [3/7]

template<typename T>
std::enable_if<!has_value_type< T >::value &&!std::is_same< T, std::vector< typenameT::value_type > >::value &&!std::is_trivially_copyable< typenameT::value_type >::value &&!has_to_bytes< T >::value &&!std::is_same< T, std::string >::value &&!std::is_trivially_copyable< T >::value, MDBX_val >::type mdbxc::serialize_value ( const T & value)

Serializes a general value into MDBX_val.

Template Parameters
TType of the value.
Parameters
valueThe value to serialize.
Returns
MDBX_val structure with binary representation of the value.

Definition at line 280 of file utils.hpp.

◆ serialize_value() [4/7]

template<typename T>
std::enable_if< std::is_same< T, std::string >::value, MDBX_val >::type mdbxc::serialize_value ( const T & value)

Serializes a std::string value.

Template Parameters
TMust be std::string.

Definition at line 292 of file utils.hpp.

◆ serialize_value() [5/7]

template<typename T>
std::enable_if< has_value_type< T >::value &&std::is_same< T, std::vector< typenameT::value_type > >::value &&std::is_trivially_copyable< typenameT::value_type >::value, MDBX_val >::type mdbxc::serialize_value ( const T & value)

Serializes a vector of trivially copyable elements.

Template Parameters
TVector type.

Definition at line 332 of file utils.hpp.

◆ serialize_value() [6/7]

template<typename T>
std::enable_if< has_to_bytes< T >::value, MDBX_val >::type mdbxc::serialize_value ( const T & value)

Serializes a value using its to_bytes() method.

Template Parameters
TType providing to_bytes.

Definition at line 344 of file utils.hpp.

◆ serialize_value() [7/7]

template<typename T>
std::enable_if<!has_to_bytes< T >::value &&std::is_trivially_copyable< T >::value, MDBX_val >::type mdbxc::serialize_value ( const T & value)

Serializes any trivially copyable value.

Template Parameters
TTrivially copyable type.

Definition at line 360 of file utils.hpp.

◆ split_path()

PathComponents mdbxc::split_path ( const std::string & path)

Splits a path into its root and components.

Parameters
pathThe path to split.
Returns
A PathComponents object containing the root and components of the path.

Definition at line 200 of file path_utils.hpp.

◆ utf8_to_ansi()

std::string mdbxc::utf8_to_ansi ( const std::string & utf8)
noexcept

Converts a UTF-8 string to an ANSI string (Windows-specific).

Parameters
utf8The UTF-8 encoded string.
Returns
The converted ANSI string.

Definition at line 243 of file path_utils.hpp.