![]() |
MDBX Containers
|
Utility helper functions for serializing values to and from MDBX. More...
Go to the source code of this file.
Classes | |
| struct | mdbxc::has_to_bytes< T > |
Trait to check if a type provides a to_bytes() member. More... | |
| struct | mdbxc::has_from_bytes< T > |
Trait to check if a type provides a static from_bytes() method. More... | |
| struct | mdbxc::has_value_type< T > |
Trait indicating that a container defines value_type. More... | |
| class | mdbxc::SerializeScratch |
Per-call scratch buffer to produce MDBX_val without using thread_local. More... | |
Namespaces | |
| namespace | mdbxc |
Macros | |
| #define | _MDBX_CONTAINERS_UTILS_HPP_INCLUDED |
| #define | MDBXC_NODISCARD |
Functions | |
| void | mdbxc::check_mdbx (int rc, const std::string &context) |
| Throws an MdbxException if MDBX return code indicates an error. | |
| uint32_t | mdbxc::sortable_key_from_float (float f) |
| Convert IEEE754 float to monotonic sortable unsigned int key. | |
| uint64_t | mdbxc::sortable_key_from_double (double d) |
| Convert IEEE754 double to monotonic sortable unsigned int key. | |
| template<typename T> | |
| MDBX_db_flags_t | mdbxc::get_mdbx_flags () |
| Returns MDBX flags for a given key type. | |
| template<typename T> | |
| size_t | mdbxc::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 | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| 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 | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| 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 | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| 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 | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| 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, MDBX_val >::type | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| Serializes a 32-bit integral key. | |
| template<typename T> | |
| std::enable_if< std::is_same< T, float >::value, MDBX_val >::type | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| Serializes a 32-bit float key. | |
| template<typename T> | |
| std::enable_if< std::is_same< T, int64_t >::value||std::is_same< T, uint64_t >::value, MDBX_val >::type | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| Serializes a 64-bit integral key. | |
| template<typename T> | |
| std::enable_if< std::is_same< T, double >::value, MDBX_val >::type | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| Serializes a 64-bit 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 | mdbxc::serialize_key (const T &key, SerializeScratch &sc) |
| Serializes any other trivially copyable key type. | |
| template<size_t N> | |
| MDBX_val | mdbxc::serialize_key (const std::bitset< N > &data, SerializeScratch &sc) |
| 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 | mdbxc::serialize_value (const T &value, SerializeScratch &sc) |
| Serializes a general value into MDBX_val. | |
| template<typename T> | |
| std::enable_if< std::is_same< T, std::string >::value, MDBX_val >::type | mdbxc::serialize_value (const T &value, SerializeScratch &sc) |
| 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||std::is_same< T, std::unordered_set< typenameT::value_type > >::value), MDBX_val >::type | mdbxc::serialize_value (const T &container, SerializeScratch &sc) |
| Serializes containers (vector, deque, list, set, unordered_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 | mdbxc::serialize_value (const T &container, SerializeScratch &sc) |
| Serializes a vector of trivially copyable elements. | |
| template<typename T> | |
| std::enable_if< has_to_bytes< T >::value, MDBX_val >::type | mdbxc::serialize_value (const T &value, SerializeScratch &sc) |
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 | mdbxc::serialize_value (const T &value, SerializeScratch &sc) |
| 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 | mdbxc::serialize_value (const T &container, SerializeScratch &sc) |
| Serializes a container of strings. | |
| template<typename T> | |
| std::enable_if<!has_value_type< T >::value &&!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<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<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<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<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<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 &&!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 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 | mdbxc::deserialize_value (const MDBX_val &val) |
| Deserializes a deque or list of trivially copyable elements. | |
| template<typename T> | |
| std::enable_if<(std::is_same< T, std::set< typenameT::value_type > >::value||std::is_same< T, std::unordered_set< typenameT::value_type > >::value)&&std::is_trivially_copyable< typenameT::value_type >::value, T >::type | mdbxc::deserialize_value (const MDBX_val &val) |
| Deserializes a set or unordered_set of trivially copyable elements. | |
| 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<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<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<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. | |
Utility helper functions for serializing values to and from MDBX.
See: https://libmdbx.dqdkfa.ru/
Definition in file utils.hpp.