libmdbx  0.12.1.0 (2022-08-24T16:24:22+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
mdbx.h++ File Reference

The libmdbx C++ API header file. More...

#include <algorithm>
#include <cassert>
#include <climits>
#include <cstring>
#include <exception>
#include <ostream>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <utility>
#include <vector>
#include "mdbx.h"
#include <concepts>

Go to the source code of this file.

Classes

class  mdbx::exception_thunk
 Transfers C++ exceptions thru C callbacks. More...
 
class  mdbx::error
 Implements error information and throwing corresponding exceptions. More...
 
class  mdbx::exception
 Base class for all libmdbx's exceptions that are corresponds to libmdbx errors. More...
 
class  mdbx::fatal
 Fatal exception that lead termination anyway in dangerous unrecoverable cases. More...
 
struct  mdbx::slice
 References a data located outside the slice. More...
 
struct  mdbx::default_capacity_policy
 
struct  mdbx::to_hex
 Hexadecimal encoder which satisfy SliceTranscoder concept. More...
 
struct  mdbx::to_base58
 Base58 encoder which satisfy SliceTranscoder concept. More...
 
struct  mdbx::to_base64
 Base64 encoder which satisfy SliceTranscoder concept. More...
 
struct  mdbx::from_hex
 Hexadecimal decoder which satisfy SliceTranscoder concept. More...
 
struct  mdbx::from_base58
 Base58 decoder which satisfy SliceTranscoder concept. More...
 
struct  mdbx::from_base64
 Base64 decoder which satisfy SliceTranscoder concept. More...
 
class  mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >
 The chunk of data stored inside the buffer or located outside it. More...
 
union  mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::silo::bin
 
struct  mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::silo::bin::allocated
 
struct  mdbx::value_result
 Combines data slice with boolean flag to represent result of certain operations. More...
 
struct  mdbx::pair
 Combines pair of slices for key and value to represent result of certain operations. More...
 
struct  mdbx::pair_result
 Combines pair of slices for key and value with boolean flag to represent result of certain operations. More...
 
struct  mdbx::map_handle
 A handle for an individual database (key-value spaces) in the environment. More...
 
struct  mdbx::map_handle::info
 
class  mdbx::env
 Unmanaged database environment. More...
 
struct  mdbx::env::geometry
 Database geometry for size management. More...
 
struct  mdbx::env::geometry::size
 Tagged type for output to std::ostream. More...
 
struct  mdbx::env::reclaiming_options
 Garbage reclaiming options. More...
 
struct  mdbx::env::operate_options
 Operate options. More...
 
struct  mdbx::env::operate_parameters
 Operate parameters. More...
 
struct  mdbx::env::limits
 
struct  mdbx::env::reader_info
 Reader information. More...
 
class  mdbx::env_managed
 Managed database environment. More...
 
struct  mdbx::env_managed::create_parameters
 Additional parameters for creating a new database. More...
 
class  mdbx::txn
 Unmanaged database transaction. More...
 
class  mdbx::txn_managed
 Managed database transaction. More...
 
class  mdbx::cursor
 Unmanaged cursor. More...
 
struct  mdbx::cursor::move_result
 
class  mdbx::cursor_managed
 Managed cursor. More...
 
struct  std::hash<::mdbx::slice >
 

Namespaces

 mdbx
 The libmdbx C++ API namespace.
 
 mdbx::allocation_aware_details
 

Macros

#define MDBX_CXX17_CONSTEXPR   constexpr
 
#define MDBX_CXX20_CONSTEXPR   constexpr
 
#define MDBX_CONSTEXPR_ASSERT(expr)    ((expr) ? void(0) : [] { assert(!#expr); }())
 
#define MDBX_LIKELY(cond)   __builtin_expect(!!(cond), 1)
 
#define MDBX_UNLIKELY(cond)   __builtin_expect(!!(cond), 0)
 
#define MDBX_IF_CONSTEXPR   constexpr
 
#define MDBX_CXX17_FALLTHROUGH   [[fallthrough]]
 
#define MDBX_CXX20_LIKELY   [[likely]]
 
#define MDBX_CXX20_UNLIKELY   [[unlikely]]
 
#define MDBX_CXX20_CONCEPT(CONCEPT, NAME)   CONCEPT NAME
 
#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE)    static_assert(CONCEPT<TYPE>)
 
#define MDBX_STD_FILESYSTEM_PATH   ::mdbx::filesystem::path
 Defined if mdbx::filesystem::path is available. More...
 
#define MDBX_DECLARE_EXCEPTION(NAME)
 

Typedefs

using mdbx::byte = char8_t
 
using mdbx::version_info = ::MDBX_version_info
 libmdbx version information More...
 
using mdbx::build_info = ::MDBX_build_info
 libmdbx build information More...
 
using mdbx::legacy_allocator = ::std::string::allocator_type
 Legacy default allocator but it is recommended to use polymorphic_allocator. More...
 
using mdbx::polymorphic_allocator = ::std::pmr::string::allocator_type
 Default polymorphic allocator for modern code. More...
 
template<class ALLOCATOR = legacy_allocator>
using mdbx::string = ::std::basic_string< char, ::std::char_traits< char >, ALLOCATOR >
 Default singe-byte string. More...
 
using mdbx::filehandle = ::mdbx_filehandle_t
 
using mdbx::path = MDBX_STD_FILESYSTEM_PATH
 

Enumerations

enum  mdbx::loop_control { mdbx::continue_loop = 0 , mdbx::exit_loop = INT32_MIN }
 Loop control constants for readers enumeration functor and other cases. More...
 
enum class  mdbx::key_mode { mdbx::usual = MDBX_DB_DEFAULTS , mdbx::reverse = MDBX_REVERSEKEY , mdbx::ordinal = MDBX_INTEGERKEY , mdbx::msgpack = -1 }
 Kinds of the keys and corresponding modes of comparing it. More...
 
enum class  mdbx::value_mode {
  mdbx::single = MDBX_DB_DEFAULTS , mdbx::multi , mdbx::multi_reverse , mdbx::multi_samelength ,
  mdbx::multi_ordinal , mdbx::multi_reverse_samelength , mdbx::msgpack = -1
}
 Kind of the values and sorted multi-values with corresponding comparison. More...
 
enum  mdbx::put_mode { mdbx::insert_unique = MDBX_NOOVERWRITE , mdbx::upsert = MDBX_UPSERT , mdbx::update = MDBX_CURRENT }
 Key-value pairs put mode. More...
 

Functions

const version_info & mdbx::get_version () noexcept
 Returns libmdbx version information. More...
 
const build_info & mdbx::get_build () noexcept
 Returns libmdbx build information. More...
 
LIBMDBX_API void mdbx::throw_too_small_target_buffer ()
 
LIBMDBX_API void mdbx::throw_max_length_exceeded ()
 
LIBMDBX_API void mdbx::throw_out_range ()
 
LIBMDBX_API void mdbx::throw_allocators_mismatch ()
 
template<class ALLOCATOR = legacy_allocator, typename CAPACITY_POLICY = default_capacity_policy, MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER) >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::make_buffer (PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
 
template<class ALLOCATOR = legacy_allocator, typename CAPACITY_POLICY = default_capacity_policy, MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER) >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::make_buffer (const PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
 
template<class ALLOCATOR = legacy_allocator, MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER) >
string< ALLOCATOR > mdbx::make_string (PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
 
template<class ALLOCATOR = legacy_allocator, MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER) >
string< ALLOCATOR > mdbx::make_string (const PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
 
template<typename A >
constexpr bool mdbx::allocation_aware_details::allocator_is_always_equal () noexcept
 
inline ::std::ostream & mdbx::operator<< (::std::ostream &out, const to_hex &wrapper)
 
inline ::std::ostream & mdbx::operator<< (::std::ostream &out, const to_base58 &wrapper)
 
inline ::std::ostream & mdbx::operator<< (::std::ostream &out, const to_base64 &wrapper)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const slice &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const pair &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const pair_result &)
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
inline ::std::ostream & mdbx::operator<< (::std::ostream &out, const buffer< ALLOCATOR, CAPACITY_POLICY > &it)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::geometry::size &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::geometry &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::operate_parameters &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::mode &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::durability &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::reclaiming_options &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env::operate_options &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const env_managed::create_parameters &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const MDBX_log_level_t &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const MDBX_debug_flags_t &)
 
LIBMDBX_API ::std::ostream & mdbx::operator<< (::std::ostream &, const error &)
 
inline ::std::ostream & mdbx::operator<< (::std::ostream &out, const MDBX_error_t &errcode)
 
bool mdbx::operator== (const error &a, const error &b) noexcept
 
bool mdbx::operator!= (const error &a, const error &b) noexcept
 
bool mdbx::operator== (const slice &a, const slice &b) noexcept
 
bool mdbx::operator< (const slice &a, const slice &b) noexcept
 
bool mdbx::operator> (const slice &a, const slice &b) noexcept
 
bool mdbx::operator<= (const slice &a, const slice &b) noexcept
 
bool mdbx::operator>= (const slice &a, const slice &b) noexcept
 
bool mdbx::operator!= (const slice &a, const slice &b) noexcept
 
bool mdbx::operator== (const env &a, const env &b) noexcept
 
bool mdbx::operator!= (const env &a, const env &b) noexcept
 
bool mdbx::operator== (const txn &a, const txn &b) noexcept
 
bool mdbx::operator!= (const txn &a, const txn &b) noexcept
 
bool mdbx::operator== (const cursor &a, const cursor &b) noexcept
 
bool mdbx::operator!= (const cursor &a, const cursor &b) noexcept
 
ptrdiff_t mdbx::estimate (const cursor &from, const cursor &to)
 
string std::to_string (const ::mdbx::slice &value)
 
template<class ALLOCATOR , typename CAPACITY_POLICY >
string std::to_string (const ::mdbx::buffer< ALLOCATOR, CAPACITY_POLICY > &buffer)
 
string std::to_string (const ::mdbx::pair &value)
 
string std::to_string (const ::mdbx::env::geometry &value)
 
string std::to_string (const ::mdbx::env::operate_parameters &value)
 
string std::to_string (const ::mdbx::env::mode &value)
 
string std::to_string (const ::mdbx::env::durability &value)
 
string std::to_string (const ::mdbx::env::reclaiming_options &value)
 
string std::to_string (const ::mdbx::env::operate_options &value)
 
string std::to_string (const ::mdbx::env_managed::create_parameters &value)
 
string std::to_string (const ::MDBX_log_level_t &value)
 
string std::to_string (const ::MDBX_debug_flags_t &value)
 
string std::to_string (const ::mdbx::error &value)
 
string std::to_string (const ::MDBX_error_t &errcode)
 

Variables

 mdbx::bad_map_id
 
 mdbx::bad_transaction
 
 mdbx::bad_value_size
 
 mdbx::db_corrupted
 
 mdbx::db_full
 
 mdbx::db_invalid
 
 mdbx::db_too_large
 
 mdbx::db_unable_extend
 
 mdbx::db_version_mismatch
 
 mdbx::db_wanna_write_for_recovery
 
 mdbx::incompatible_operation
 
 mdbx::internal_page_full
 
 mdbx::internal_problem
 
 mdbx::key_exists
 
 mdbx::key_mismatch
 
 mdbx::max_maps_reached
 
 mdbx::max_readers_reached
 
 mdbx::multivalue
 
 mdbx::no_data
 
 mdbx::not_found
 
 mdbx::operation_not_permitted
 
 mdbx::permission_denied_or_not_writeable
 
 mdbx::reader_slot_busy
 
 mdbx::remote_media
 
 mdbx::something_busy
 
 mdbx::thread_mismatch
 
 mdbx::transaction_full
 
 mdbx::transaction_overlapping
 
template<typename T >
concept mdbx::MutableByteProducer
 
template<typename T >
concept mdbx::ImmutableByteProducer
 
template<typename T >
concept mdbx::SliceTranscoder
 

Detailed Description

The libmdbx C++ API header file.

Author
Copyright (c) 2020-2022, Leonid Yuriev leo@y.nosp@m.urie.nosp@m.v.ru.

Tested with:

  • Elbrus LCC >= 1.23 (http://www.mcst.ru/lcc);
  • GNU C++ >= 4.8;
  • clang >= 3.9;
  • MSVC >= 14.0 (Visual Studio 2015), but 19.2x could hang due optimizer bug;
  • AppleClang, but without C++20 concepts.

Macro Definition Documentation

◆ MDBX_ASSERT_CXX20_CONCEPT_SATISFIED

#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED (   CONCEPT,
  TYPE 
)     static_assert(CONCEPT<TYPE>)

◆ MDBX_CONSTEXPR_ASSERT

#define MDBX_CONSTEXPR_ASSERT (   expr)     ((expr) ? void(0) : [] { assert(!#expr); }())

Workaround for old compilers without support assertion inside constexpr functions.

◆ MDBX_CXX17_CONSTEXPR

#define MDBX_CXX17_CONSTEXPR   constexpr

Workaround for old compilers without properly support for C++17 constexpr.

◆ MDBX_CXX17_FALLTHROUGH

#define MDBX_CXX17_FALLTHROUGH   [[fallthrough]]

◆ MDBX_CXX20_CONCEPT

#define MDBX_CXX20_CONCEPT (   CONCEPT,
  NAME 
)    CONCEPT NAME

◆ MDBX_CXX20_CONSTEXPR

#define MDBX_CXX20_CONSTEXPR   constexpr

Workaround for old compilers without properly support for C++20 constexpr.

◆ MDBX_CXX20_LIKELY

#define MDBX_CXX20_LIKELY   [[likely]]

◆ MDBX_CXX20_UNLIKELY

#define MDBX_CXX20_UNLIKELY   [[unlikely]]

◆ MDBX_IF_CONSTEXPR

#define MDBX_IF_CONSTEXPR   constexpr

Workaround for old compilers without properly support for C++20 if constexpr.

◆ MDBX_LIKELY

#define MDBX_LIKELY (   cond)    __builtin_expect(!!(cond), 1)

◆ MDBX_UNLIKELY

#define MDBX_UNLIKELY (   cond)    __builtin_expect(!!(cond), 0)