27#if defined(__SIZEOF_INT128__) && !defined(__GLIBCXX_TYPE_INT_N_0) && \
28 defined(__clang__) && __clang_major__ < 4
29#define __GLIBCXX_BITSIZE_INT_N_0 128
30#define __GLIBCXX_TYPE_INT_N_0 __int128
33#if !defined(__cplusplus) || __cplusplus < 201103L
34#if !defined(_MSC_VER) || _MSC_VER < 1900
35#error "C++11 compiler or better is required"
38 "Please add `/Zc:__cplusplus` to MSVC compiler options to enforce it conform ISO C++"
42#if (defined(_WIN32) || defined(_WIN64)) && MDBX_WITHOUT_MSVC_CRT
44 "CRT is required for C++ API, the MDBX_WITHOUT_MSVC_CRT option must be disabled"
48#define __has_include(header) (0)
51#if __has_include(<version>)
73#if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L
74#include <memory_resource>
77#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
81#ifndef MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM
82#ifdef INCLUDE_STD_FILESYSTEM_EXPERIMENTAL
83#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 1
84#elif defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \
85 __cplusplus >= 201703L
86#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 0
87#elif (!defined(_MSC_VER) || __cplusplus >= 201403L || \
88 (defined(_MSC_VER) && \
89 defined(_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING) && \
90 __cplusplus >= 201403L))
91#if defined(__cpp_lib_experimental_filesystem) && \
92 __cpp_lib_experimental_filesystem >= 201406L
93#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 1
94#elif defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L && \
95 __has_include(<experimental/filesystem>)
96#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 1
98#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 0
101#define MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM 0
105#if MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM
106#include <experimental/filesystem>
107#elif defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L
111#if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L
115#if __cplusplus >= 201103L
122#if (defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L) || \
123 (defined(__cpp_lib_endian) && __cpp_lib_endian >= 201907L) || \
124 (defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L) || \
125 (defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L)
127#elif !(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
128 defined(__ORDER_BIG_ENDIAN__))
129#if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
130#define __ORDER_LITTLE_ENDIAN__ __LITTLE_ENDIAN
131#define __ORDER_BIG_ENDIAN__ __BIG_ENDIAN
132#define __BYTE_ORDER__ __BYTE_ORDER
133#elif defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
134#define __ORDER_LITTLE_ENDIAN__ _LITTLE_ENDIAN
135#define __ORDER_BIG_ENDIAN__ _BIG_ENDIAN
136#define __BYTE_ORDER__ _BYTE_ORDER
138#define __ORDER_LITTLE_ENDIAN__ 1234
139#define __ORDER_BIG_ENDIAN__ 4321
140#if defined(__LITTLE_ENDIAN__) || \
141 (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) || \
142 defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
143 defined(__MIPSEL__) || defined(_MIPSEL) || defined(__MIPSEL) || \
144 defined(_M_ARM) || defined(_M_ARM64) || defined(__e2k__) || \
145 defined(__elbrus_4c__) || defined(__elbrus_8c__) || defined(__bfin__) || \
146 defined(__BFIN__) || defined(__ia64__) || defined(_IA64) || \
147 defined(__IA64__) || defined(__ia64) || defined(_M_IA64) || \
148 defined(__itanium__) || defined(__ia32__) || defined(__CYGWIN__) || \
149 defined(_WIN64) || defined(_WIN32) || defined(__TOS_WIN__) || \
151#define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
152#elif defined(__BIG_ENDIAN__) || \
153 (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)) || \
154 defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
155 defined(__MIPSEB__) || defined(_MIPSEB) || defined(__MIPSEB) || \
156 defined(__m68k__) || defined(M68000) || defined(__hppa__) || \
157 defined(__hppa) || defined(__HPPA__) || defined(__sparc__) || \
158 defined(__sparc) || defined(__370__) || defined(__THW_370__) || \
159 defined(__s390__) || defined(__s390x__) || defined(__SYSC_ZARCH__)
160#define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
168#define MDBX_CXX17_CONSTEXPR constexpr
169#elif defined(__cpp_constexpr) && __cpp_constexpr >= 201603L && \
170 ((defined(_MSC_VER) && _MSC_VER >= 1915) || \
171 (defined(__clang__) && __clang_major__ > 5) || \
172 (defined(__GNUC__) && __GNUC__ > 7) || \
173 (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
174#define MDBX_CXX17_CONSTEXPR constexpr
176#define MDBX_CXX17_CONSTEXPR inline
182#define MDBX_CXX20_CONSTEXPR constexpr
183#elif defined(__cpp_lib_is_constant_evaluated) && \
184 __cpp_lib_is_constant_evaluated >= 201811L && \
185 defined(__cpp_lib_constexpr_string) && \
186 __cpp_lib_constexpr_string >= 201907L
187#define MDBX_CXX20_CONSTEXPR constexpr
189#define MDBX_CXX20_CONSTEXPR inline
192#if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
193#define MDBX_CXX01_CONSTEXPR_ENUM MDBX_CXX01_CONSTEXPR
194#define MDBX_CXX11_CONSTEXPR_ENUM MDBX_CXX11_CONSTEXPR
195#define MDBX_CXX14_CONSTEXPR_ENUM MDBX_CXX14_CONSTEXPR
196#define MDBX_CXX17_CONSTEXPR_ENUM MDBX_CXX17_CONSTEXPR
197#define MDBX_CXX20_CONSTEXPR_ENUM MDBX_CXX20_CONSTEXPR
199#define MDBX_CXX01_CONSTEXPR_ENUM inline
200#define MDBX_CXX11_CONSTEXPR_ENUM inline
201#define MDBX_CXX14_CONSTEXPR_ENUM inline
202#define MDBX_CXX17_CONSTEXPR_ENUM inline
203#define MDBX_CXX20_CONSTEXPR_ENUM inline
208#if defined(CONSTEXPR_ASSERT)
209#define MDBX_CONSTEXPR_ASSERT(expr) CONSTEXPR_ASSERT(expr)
211#define MDBX_CONSTEXPR_ASSERT(expr) void(0)
213#define MDBX_CONSTEXPR_ASSERT(expr) \
214 ((expr) ? void(0) : [] { assert(!#expr); }())
218#if defined(DOXYGEN) || \
219 (defined(__GNUC__) || __has_builtin(__builtin_expect)) && \
220 !defined(__COVERITY__)
221#define MDBX_LIKELY(cond) __builtin_expect(!!(cond), 1)
223#define MDBX_LIKELY(x) (x)
228#if defined(DOXYGEN) || \
229 (defined(__GNUC__) || __has_builtin(__builtin_expect)) && \
230 !defined(__COVERITY__)
231#define MDBX_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
233#define MDBX_UNLIKELY(x) (x)
240#define MDBX_IF_CONSTEXPR constexpr
241#elif defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606L
242#define MDBX_IF_CONSTEXPR constexpr
244#define MDBX_IF_CONSTEXPR
247#if defined(DOXYGEN) || \
248 (__has_cpp_attribute(fallthrough) && \
249 (!defined(__clang__) || __clang__ > 4)) || \
250 __cplusplus >= 201703L
251#define MDBX_CXX17_FALLTHROUGH [[fallthrough]]
253#define MDBX_CXX17_FALLTHROUGH
256#if defined(DOXYGEN) || (__has_cpp_attribute(likely) >= 201803L && \
257 (!defined(__GNUC__) || __GNUC__ > 9))
258#define MDBX_CXX20_LIKELY [[likely]]
260#define MDBX_CXX20_LIKELY
263#ifndef MDBX_CXX20_UNLIKELY
264#if defined(DOXYGEN) || (__has_cpp_attribute(unlikely) >= 201803L && \
265 (!defined(__GNUC__) || __GNUC__ > 9))
266#define MDBX_CXX20_UNLIKELY [[unlikely]]
268#define MDBX_CXX20_UNLIKELY
272#ifndef MDBX_HAVE_CXX20_CONCEPTS
273#if defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L
275#define MDBX_HAVE_CXX20_CONCEPTS 1
276#elif defined(DOXYGEN)
277#define MDBX_HAVE_CXX20_CONCEPTS 1
279#define MDBX_HAVE_CXX20_CONCEPTS 0
283#ifndef MDBX_CXX20_CONCEPT
284#if MDBX_HAVE_CXX20_CONCEPTS || defined(DOXYGEN)
285#define MDBX_CXX20_CONCEPT(CONCEPT, NAME) CONCEPT NAME
287#define MDBX_CXX20_CONCEPT(CONCEPT, NAME) typename NAME
291#ifndef MDBX_ASSERT_CXX20_CONCEPT_SATISFIED
292#if MDBX_HAVE_CXX20_CONCEPTS || defined(DOXYGEN)
293#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE) \
294 static_assert(CONCEPT<TYPE>)
296#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, NAME) \
297 static_assert(true, MDBX_STRINGIFY(CONCEPT) "<" MDBX_STRINGIFY(TYPE) ">")
302#pragma warning(push, 4)
303#pragma warning(disable : 4127)
304#pragma warning(disable : 4251)
306#pragma warning(disable : 4275)
311#pragma warning(disable : 4702)
314#if defined(__LCC__) && __LCC__ >= 126
315#pragma diagnostic push
317#pragma diag_suppress 3058
319#pragma diag_suppress 3060
334#if defined(DOXYGEN) || (defined(__cpp_char8_t) && __cpp_char8_t >= 201811)
344using byte =
unsigned char;
347#if defined(__cpp_lib_endian) && __cpp_lib_endian >= 201907L
348using endian = ::std::endian;
349#elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
350 defined(__ORDER_BIG_ENDIAN__)
352 little = __ORDER_LITTLE_ENDIAN__,
353 big = __ORDER_BIG_ENDIAN__,
354 native = __BYTE_ORDER__
358 "Please use a C++ compiler provides byte order information or C++20 support"
375 size_t bytes) noexcept;
378 size_t bytes) noexcept;
384#if defined(DOXYGEN) || \
385 (defined(__cpp_lib_memory_resource) && \
386 __cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI)
410template <
class ALLOCATOR = default_allocator>
411using string = ::std::basic_string<char, ::std::char_traits<char>, ALLOCATOR>;
414#if MDBX_USING_CXX_EXPERIMETAL_FILESYSTEM
416namespace filesystem = ::std::experimental::filesystem::v1;
418namespace filesystem = ::std::experimental::filesystem;
420#define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path
421#elif defined(DOXYGEN) || \
422 (defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \
423 defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L && \
424 (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || \
425 __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) && \
426 (!defined(__IPHONE_OS_VERSION_MIN_REQUIRED) || \
427 __IPHONE_OS_VERSION_MIN_REQUIRED >= 130100)) && \
428 (!defined(_MSC_VER) || __cplusplus >= 201703L)
429namespace filesystem = ::std::filesystem;
436#define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path
439#ifdef MDBX_STD_FILESYSTEM_PATH
441#elif defined(_WIN32) || defined(_WIN64)
442using path = ::std::wstring;
444using path = ::std::string;
447#if defined(__SIZEOF_INT128__) || \
448 (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 128)
449#ifndef MDBX_U128_TYPE
450#define MDBX_U128_TYPE __uint128_t
452#ifndef MDBX_I128_TYPE
453#define MDBX_I128_TYPE __int128_t
457#if __cplusplus >= 201103L || defined(DOXYGEN)
459using duration = ::std::chrono::duration<unsigned, ::std::ratio<1, 65536>>;
470 ::std::exception_ptr captured_;
478 inline
bool is_clean() const noexcept;
479 inline
void capture() noexcept;
480 inline
void rethrow_captured() const;
496 const error &b)
noexcept;
498 const error &b)
noexcept;
509 const
char *what() const noexcept;
512 ::
std::
string message() const;
517 [[noreturn]]
void panic(const
char *context_where_when,
518 const
char *func_who_what) const noexcept;
519 [[noreturn]]
void throw_exception() const;
520 [[noreturn]] static inline
void throw_exception(
int error_code);
521 inline
void throw_on_failure() const;
522 inline
void success_or_throw() const;
524 inline
void panic_on_failure(const
char *context_where,
525 const
char *func_who) const noexcept;
526 inline
void success_or_panic(const
char *context_where,
527 const
char *func_who) const noexcept;
528 static inline
void throw_on_nullptr(const
void *ptr,
MDBX_error_t error_code);
529 static inline
void success_or_throw(
MDBX_error_t error_code);
530 static
void success_or_throw(
int error_code) {
531 success_or_throw(
static_cast<MDBX_error_t>(error_code));
533 static inline void throw_on_failure(
int error_code);
534 static inline bool boolean_or_throw(
int error_code);
535 static inline void success_or_throw(
int error_code,
const exception_thunk &);
536 static inline bool boolean_or_throw(
int error_code,
const exception_thunk &);
537 static inline void panic_on_failure(
int error_code,
const char *context_where,
538 const char *func_who)
noexcept;
539 static inline void success_or_panic(
int error_code,
const char *context_where,
540 const char *func_who)
noexcept;
548 using base = ::std::runtime_error;
567 fatal(const ::mdbx::error &)
noexcept;
577#define MDBX_DECLARE_EXCEPTION(NAME) \
578 struct LIBMDBX_API_TYPE NAME : public exception { \
579 NAME(const ::mdbx::error &); \
580 virtual ~NAME() noexcept; \
614#undef MDBX_DECLARE_EXCEPTION
635#if MDBX_HAVE_CXX20_CONCEPTS || defined(DOXYGEN)
642 { a.is_empty() } -> std::same_as<bool>;
643 { a.envisage_result_length() } -> std::same_as<size_t>;
644 { a.write_bytes(&array[0],
size_t(42)) } -> std::same_as<char *>;
652 { a.is_empty() } -> std::same_as<bool>;
653 { a.envisage_result_length() } -> std::same_as<size_t>;
654 { a.write_bytes(&array[0],
size_t(42)) } -> std::same_as<char *>;
664 { a.is_erroneous() } -> std::same_as<bool>;
673make_buffer(PRODUCER &producer,
const ALLOCATOR &allocator = ALLOCATOR());
679make_buffer(
const PRODUCER &producer,
const ALLOCATOR &allocator = ALLOCATOR());
684 const ALLOCATOR &allocator = ALLOCATOR());
689 const ALLOCATOR &allocator = ALLOCATOR());
716 template <
size_t SIZE>
725 template <
class CHAR,
class T,
class A>
727 slice(const ::std::basic_string<CHAR, T, A> &str)
728 :
slice(str.data(), str.length() * sizeof(CHAR)) {}
735#if defined(DOXYGEN) || (defined(__cpp_lib_span) && __cpp_lib_span >= 202002L)
736 template <
typename POD>
738 :
slice(span.begin(), span.end()) {
739 static_assert(::std::is_standard_layout<POD>::value &&
740 !::std::is_pointer<POD>::value,
741 "Must be a standard layout type!");
744 template <
typename POD>
745 MDBX_CXX14_CONSTEXPR ::std::span<const POD>
as_span()
const {
746 static_assert(::std::is_standard_layout<POD>::value &&
747 !::std::is_pointer<POD>::value,
748 "Must be a standard layout type!");
751 return ::std::span<const POD>(
static_cast<const POD *
>(data()),
752 size() /
sizeof(POD));
756 template <
typename POD> MDBX_CXX14_CONSTEXPR ::std::span<POD>
as_span() {
757 static_assert(::std::is_standard_layout<POD>::value &&
758 !::std::is_pointer<POD>::value,
759 "Must be a standard layout type!");
762 return ::std::span<POD>(
static_cast<POD *
>(data()), size() /
sizeof(POD));
766 MDBX_CXX14_CONSTEXPR ::std::span<const byte>
bytes()
const {
767 return as_span<const byte>();
769 MDBX_CXX14_CONSTEXPR ::std::span<byte>
bytes() {
return as_span<byte>(); }
770 MDBX_CXX14_CONSTEXPR ::std::span<const char>
chars()
const {
771 return as_span<const char>();
773 MDBX_CXX14_CONSTEXPR ::std::span<char>
chars() {
return as_span<char>(); }
776#if defined(DOXYGEN) || \
777 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
779 template <
class CHAR,
class T>
781 :
slice(sv.data(), sv.data() + sv.length()) {}
783 template <
class CHAR,
class T>
789 template <
size_t SIZE>
794 template <
typename POD>
796 static_assert(::std::is_standard_layout<POD>::value &&
797 !::std::is_pointer<POD>::value,
798 "Must be a standard layout type!");
799 return slice(&pod,
sizeof(pod));
802 inline slice &assign(
const void *ptr,
size_t bytes);
803 inline slice &assign(
const slice &src)
noexcept;
804 inline slice &assign(const ::MDBX_val &src);
807 inline slice &assign(
const void *begin,
const void *end);
808 template <
class CHAR,
class T,
class ALLOCATOR>
809 slice &
assign(const ::std::basic_string<CHAR, T, ALLOCATOR> &str) {
810 return assign(str.data(), str.length() *
sizeof(CHAR));
812 inline slice &assign(
const char *c_str);
813#if defined(DOXYGEN) || \
814 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
815 template <
class CHAR,
class T>
817 return assign(view.begin(), view.end());
819 template <
class CHAR,
class T>
828 inline slice &operator=(
slice &&src)
noexcept;
831 operator const MDBX_val *()
const noexcept {
return this; }
833#if defined(DOXYGEN) || \
834 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
835 template <
class CHAR,
class T>
840 template <
class CHAR,
class T>
846 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>>
847 MDBX_CXX11_CONSTEXPR ::std::basic_string_view<CHAR, T>
849 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
850 return ::std::basic_string_view<CHAR, T>(char_ptr(), length());
854 template <
class CHAR,
class T>
856 operator ::std::basic_string_view<CHAR, T>() const noexcept {
857 return this->string_view<CHAR, T>();
861 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>,
862 class ALLOCATOR = default_allocator>
863 MDBX_CXX20_CONSTEXPR ::std::basic_string<CHAR, T, ALLOCATOR>
864 as_string(
const ALLOCATOR &allocator = ALLOCATOR())
const {
865 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
866 return ::std::basic_string<CHAR, T, ALLOCATOR>(char_ptr(), length(),
870 template <
class CHAR,
class T,
class ALLOCATOR>
872 operator ::std::basic_string<CHAR, T, ALLOCATOR>()
const {
873 return as_string<CHAR, T, ALLOCATOR>();
877 template <
class ALLOCATOR = default_allocator>
879 as_hex_string(
bool uppercase =
false,
unsigned wrap_width = 0,
880 const ALLOCATOR &allocator = ALLOCATOR())
const;
884 template <
class ALLOCATOR = default_allocator>
886 as_base58_string(
unsigned wrap_width = 0,
887 const ALLOCATOR &allocator = ALLOCATOR())
const;
891 template <
class ALLOCATOR = default_allocator>
893 as_base64_string(
unsigned wrap_width = 0,
894 const ALLOCATOR &allocator = ALLOCATOR())
const;
900 encode_hex(
bool uppercase =
false,
unsigned wrap_width = 0,
901 const ALLOCATOR &allocator = ALLOCATOR())
const;
908 encode_base58(
unsigned wrap_width = 0,
909 const ALLOCATOR &allocator = ALLOCATOR())
const;
916 encode_base64(
unsigned wrap_width = 0,
917 const ALLOCATOR &allocator = ALLOCATOR())
const;
923 hex_decode(
bool ignore_spaces =
false,
924 const ALLOCATOR &allocator = ALLOCATOR())
const;
931 base58_decode(
bool ignore_spaces =
false,
932 const ALLOCATOR &allocator = ALLOCATOR())
const;
939 base64_decode(
bool ignore_spaces =
false,
940 const ALLOCATOR &allocator = ALLOCATOR())
const;
955 is_hex(
bool ignore_spaces = false) const noexcept;
963 is_base58(
bool ignore_spaces = false) const noexcept;
971 is_base64(
bool ignore_spaces = false) const noexcept;
973 inline
void swap(
slice &other) noexcept;
975#if defined(DOXYGEN) || \
976 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
977 template <
class CHAR,
class T>
978 void swap(::std::basic_string_view<CHAR, T> &view)
noexcept {
979 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
980 const auto temp = ::std::basic_string_view<CHAR, T>(*
this);
1039 inline
void remove_prefix(
size_t n) noexcept;
1043 inline
void remove_suffix(
size_t n) noexcept;
1047 inline
void safe_remove_prefix(
size_t n);
1051 inline
void safe_remove_suffix(
size_t n);
1055 starts_with(const
slice &prefix) const noexcept;
1059 ends_with(const
slice &suffix) const noexcept;
1098 hash_value() const noexcept;
1109 compare_fast(const
slice &a, const
slice &b) noexcept;
1117 compare_lexicographically(const
slice &a, const
slice &b) noexcept;
1119 const
slice &b) noexcept;
1121 const
slice &b) noexcept;
1123 const
slice &b) noexcept;
1125 const
slice &b) noexcept;
1127 const
slice &b) noexcept;
1129 const
slice &b) noexcept;
1133 return !(iov_base ==
nullptr && iov_len != 0);
1139 return slice(
size_t(-1));
1143 static_assert(::std::is_standard_layout<POD>::value &&
1144 !::std::is_pointer<POD>::value,
1145 "Must be a standard layout type!");
1149 memcpy(&r, data(),
sizeof(r));
1155#ifdef MDBX_U128_TYPE
1157 return as_pod<MDBX_U128_TYPE>();
1165#ifdef MDBX_I128_TYPE
1167 return as_pod<MDBX_I128_TYPE>();
1175#ifdef MDBX_U128_TYPE
1183#ifdef MDBX_I128_TYPE
1198namespace allocation_aware_details {
1201#if defined(__cpp_lib_allocator_traits_is_always_equal) && \
1202 __cpp_lib_allocator_traits_is_always_equal >= 201411L
1203 return ::std::allocator_traits<A>::is_always_equal::value;
1205 return ::std::is_empty<A>::value;
1209template <
typename T,
typename A =
typename T::allocator_type,
1210 bool PoCMA = ::std::allocator_traits<
1211 A>::propagate_on_container_move_assignment::value>
1215 static constexpr bool is_nothrow() noexcept {
1216 return allocator_is_always_equal<A>();
1219 return allocator_is_always_equal<A>() ||
1220 target->get_allocator() == source.get_allocator();
1223 assert(target->get_allocator() != source.get_allocator());
1229template <
typename T,
typename A>
struct move_assign_alloc<T, A, true> {
1230 static constexpr bool is_nothrow() noexcept {
1231 return allocator_is_always_equal<A>() ||
1232 ::std::is_nothrow_move_assignable<A>::value;
1234 static constexpr bool is_moveable(T *, T &)
noexcept {
return true; }
1236 assert(target->get_allocator() != source.get_allocator());
1237 target->get_allocator() = ::std::move(source.get_allocator());
1241template <
typename T,
typename A =
typename T::allocator_type,
1242 bool PoCCA = ::std::allocator_traits<
1243 A>::propagate_on_container_copy_assignment::value>
1247 static constexpr bool is_nothrow() noexcept {
return false; }
1249 const T &source)
noexcept {
1250 assert(target->get_allocator() != source.get_allocator());
1256template <
typename T,
typename A>
struct copy_assign_alloc<T, A, true> {
1257 static constexpr bool is_nothrow() noexcept {
1258 return allocator_is_always_equal<A>() ||
1259 ::std::is_nothrow_copy_assignable<A>::value;
1262 propagate(T *target,
const T &source)
noexcept(is_nothrow()) {
1264 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1265 MDBX_CXX20_UNLIKELY target->get_allocator() =
1266 ::std::allocator_traits<A>::select_on_container_copy_construction(
1267 source.get_allocator());
1276template <
typename T,
typename A =
typename T::allocator_type,
1278 ::std::allocator_traits<A>::propagate_on_container_swap::value>
1281template <
typename T,
typename A>
struct swap_alloc<T, A, false> {
1282 static constexpr bool is_nothrow() noexcept {
1283 return allocator_is_always_equal<A>();
1286 T &source)
noexcept(is_nothrow()) {
1288 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1298template <
typename T,
typename A>
struct swap_alloc<T, A, true> {
1299 static constexpr bool is_nothrow() noexcept {
1300 return allocator_is_always_equal<A>() ||
1301#if defined(__cpp_lib_is_swappable) && __cpp_lib_is_swappable >= 201603L
1302 ::std::is_nothrow_swappable<A>() ||
1304 (::std::is_nothrow_move_constructible<A>::value &&
1305 ::std::is_nothrow_move_assignable<A>::value);
1308 T &source)
noexcept(is_nothrow()) {
1310 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1311 MDBX_CXX20_UNLIKELY ::std::swap(*target, source);
1324 extra_inplace_storage = 0,
1325 pettiness_threshold = 64,
1330 static_assert((pettiness_threshold & (pettiness_threshold - 1)) == 0,
1331 "pettiness_threshold must be a power of 2");
1332 static_assert(pettiness_threshold % 2 == 0,
1333 "pettiness_threshold must be even");
1334 static_assert(pettiness_threshold >=
sizeof(uint64_t),
1335 "pettiness_threshold must be > 7");
1336 constexpr const auto pettiness_mask = ~size_t(pettiness_threshold - 1);
1337 return (value + pettiness_threshold - 1) & pettiness_mask;
1341 const size_t wanna) {
1342 static_assert(max_reserve % pettiness_threshold == 0,
1343 "max_reserve must be a multiple of pettiness_threshold");
1344 static_assert(max_reserve / 3 > pettiness_threshold,
1345 "max_reserve must be > pettiness_threshold * 3");
1346 if (wanna > current)
1348 return round(wanna + ::std::min(
size_t(max_reserve), current));
1350 if (current - wanna >
1353 ::std::min(wanna + pettiness_threshold,
size_t(max_reserve)))
1354 return round(wanna);
1364 const bool uppercase =
false;
1365 const unsigned wrap_width = 0;
1367 unsigned wrap_width = 0) noexcept
1368 : source(source), uppercase(uppercase), wrap_width(wrap_width) {
1373 template <
class ALLOCATOR = default_allocator>
1375 return make_string<ALLOCATOR>(*
this, allocator);
1383 return make_buffer<ALLOCATOR>(*
this, allocator);
1389 const size_t bytes = source.
length() << 1;
1390 return wrap_width ? bytes + bytes / wrap_width : bytes;
1400 ::std::ostream &
output(::std::ostream &out)
const;
1415 const unsigned wrap_width = 0;
1418 : source(source), wrap_width(wrap_width) {
1424 template <
class ALLOCATOR = default_allocator>
1426 return make_string<ALLOCATOR>(*
this, allocator);
1435 return make_buffer<ALLOCATOR>(*
this, allocator);
1441 const size_t bytes = (source.
length() * 11 + 7) / 8;
1442 return wrap_width ? bytes + bytes / wrap_width : bytes;
1454 ::std::ostream &
output(::std::ostream &out)
const;
1469 const unsigned wrap_width = 0;
1472 : source(source), wrap_width(wrap_width) {
1478 template <
class ALLOCATOR = default_allocator>
1480 return make_string<ALLOCATOR>(*
this, allocator);
1489 return make_buffer<ALLOCATOR>(*
this, allocator);
1495 const size_t bytes = (source.
length() + 2) / 3 * 4;
1496 return wrap_width ? bytes + bytes / wrap_width : bytes;
1508 ::std::ostream &
output(::std::ostream &out)
const;
1520 return wrapper.
output(out);
1524 return wrapper.
output(out);
1528 return wrapper.
output(out);
1534 const bool ignore_spaces =
false;
1536 bool ignore_spaces =
false) noexcept
1537 : source(source), ignore_spaces(ignore_spaces) {
1542 template <
class ALLOCATOR = default_allocator>
1544 return make_string<ALLOCATOR>(*
this, allocator);
1552 return make_buffer<ALLOCATOR>(*
this, allocator);
1558 return source.
length() >> 1;
1579 const bool ignore_spaces =
false;
1581 bool ignore_spaces =
false) noexcept
1582 : source(source), ignore_spaces(ignore_spaces) {
1588 template <
class ALLOCATOR = default_allocator>
1590 return make_string<ALLOCATOR>(*
this, allocator);
1599 return make_buffer<ALLOCATOR>(*
this, allocator);
1628 const bool ignore_spaces =
false;
1630 bool ignore_spaces =
false) noexcept
1631 : source(source), ignore_spaces(ignore_spaces) {
1637 template <
class ALLOCATOR = default_allocator>
1639 return make_string<ALLOCATOR>(*
this, allocator);
1648 return make_buffer<ALLOCATOR>(*
this, allocator);
1655 return (source.
length() + 3) / 4 * 3;
1674template <class ALLOCATOR, typename CAPACITY_POLICY> class
buffer {
1676#if !defined(_MSC_VER) || _MSC_VER > 1900
1678 ALLOCATOR>::template rebind_alloc<uint64_t>;
1680 using allocator_type =
typename ALLOCATOR::template rebind<uint64_t>::other;
1686 max_capacity = (max_length / 3u * 4u + 1023u) & ~
size_t(1023),
1687 extra_inplace_storage = reservation_policy::extra_inplace_storage,
1688 pettiness_threshold = reservation_policy::pettiness_threshold
1703 using allocator_pointer =
typename allocator_traits::pointer;
1704 using allocator_const_pointer =
typename allocator_traits::const_pointer;
1706 MDBX_CXX20_CONSTEXPR ::std::pair<allocator_pointer, size_t>
1707 allocate_storage(
size_t bytes) {
1708 assert(bytes >=
sizeof(bin));
1709 constexpr size_t unit =
sizeof(
typename allocator_type::value_type);
1710 static_assert((unit & (unit - 1)) == 0,
1711 "size of ALLOCATOR::value_type should be a power of 2");
1712 static_assert(unit > 0,
"size of ALLOCATOR::value_type must be > 0");
1713 const size_t n = (bytes + unit - 1) / unit;
1714 return ::std::make_pair(allocator_traits::allocate(get_allocator(), n),
1719 constexpr size_t unit =
sizeof(
typename allocator_type::value_type);
1720 assert(ptr && bytes >=
sizeof(bin) && bytes >= unit && bytes % unit == 0);
1721 allocator_traits::deallocate(get_allocator(), ptr, bytes / unit);
1725 to_address(allocator_pointer ptr)
noexcept {
1726#if defined(__cpp_lib_to_address) && __cpp_lib_to_address >= 201711L
1727 return static_cast<void *
>(::std::to_address(ptr));
1729 return static_cast<void *
>(::std::addressof(*ptr));
1733 to_address(allocator_const_pointer ptr)
noexcept {
1734#if defined(__cpp_lib_to_address) && __cpp_lib_to_address >= 201711L
1735 return static_cast<const void *
>(::std::to_address(ptr));
1737 return static_cast<const void *
>(::std::addressof(*ptr));
1745 constexpr allocated(allocator_pointer ptr,
size_t bytes) noexcept
1746 : ptr_(ptr), capacity_bytes_(bytes) {}
1756 uint64_t align_hint_;
1757 byte inplace_[(sizeof(
allocated) + extra_inplace_storage + 7u) &
1760 static constexpr
bool
1761 is_suitable_for_inplace(
size_t capacity_bytes) noexcept {
1762 static_assert(
sizeof(
bin) ==
sizeof(inplace_),
"WTF?");
1763 return capacity_bytes <
sizeof(
bin);
1766 enum :
byte { lastbyte_inplace_signature =
byte(~
byte(0)) };
1768 inplace_signature_limit =
1769 size_t(lastbyte_inplace_signature)
1770 << (
sizeof(
size_t ) - 1) * CHAR_BIT
1774 return inplace_[
sizeof(
bin) - 1];
1777 return inplace_[
sizeof(
bin) - 1];
1781 static_assert(size_t(inplace_signature_limit) > size_t(max_capacity),
1784 std::numeric_limits<size_t>::max() -
1785 (std::numeric_limits<size_t>::max() >> CHAR_BIT) ==
1786 inplace_signature_limit,
1788 return inplace_lastbyte() == lastbyte_inplace_signature;
1792 template <
bool destroy_ptr>
1797 allocated_.~allocated();
1799 if (::std::is_trivial<allocator_pointer>::value)
1801 memset(&allocated_.ptr_, 0,
sizeof(allocated_.ptr_));
1802 inplace_lastbyte() = lastbyte_inplace_signature;
1804 is_suitable_for_inplace(capacity()));
1808 template <
bool construct_ptr>
1814 new (&allocated_)
allocated(ptr, capacity_bytes);
1817 allocated_.ptr_ = ptr;
1818 allocated_.capacity_bytes_ = capacity_bytes;
1821 capacity() == capacity_bytes);
1827 make_inplace<false>();
1828 (void)capacity_bytes;
1831 size_t capacity_bytes)
noexcept {
1833 make_allocated<true>(ptr, capacity_bytes);
1838 allocated_.~allocated();
1841 if (ditto.is_inplace()) {
1844 memcpy(inplace_, ditto.inplace_,
sizeof(inplace_));
1847 new (&allocated_)
allocated(::std::move(ditto.allocated_));
1848 ditto.make_inplace<
true>();
1854 if (ditto.is_inplace()) {
1859 allocated_.~allocated();
1860 memcpy(inplace_, ditto.inplace_,
sizeof(inplace_));
1862 }
else if (is_inplace())
1863 make_allocated<true>(ditto.allocated_.ptr_,
1864 ditto.allocated_.capacity_bytes_);
1866 make_allocated<false>(ditto.allocated_.ptr_,
1867 ditto.allocated_.capacity_bytes_);
1872 operator=(
const_cast<const bin &
>(ditto));
1873 if (ditto.is_allocated())
1874 ditto.make_inplace<
true>();
1879 const size_t wanna) {
1883 const size_t advised = reservation_policy::advise(current, wanna);
1884 assert(advised >= wanna);
1885 return ::std::min(
size_t(max_capacity),
1886 ::std::max(
sizeof(
bin) - 1, advised));
1892 :
static_cast<const byte *
>(to_address(allocated_.ptr_));
1895 return is_inplace() ? inplace_
1896 :
static_cast<byte *
>(to_address(allocated_.ptr_));
1899 return is_inplace() ?
sizeof(
bin) - 1 : allocated_.capacity_bytes_;
1904 capacity = bin::advise_capacity(0, capacity);
1905 if (bin_.is_suitable_for_inplace(capacity))
1908 const auto pair = allocate_storage(capacity);
1909 assert(
pair.second >= capacity);
1910 new (&bin_) bin(
pair.first,
pair.second);
1912 return bin_.address();
1916 if (bin_.is_allocated()) {
1917 deallocate_storage(bin_.allocated_.ptr_,
1918 bin_.allocated_.capacity_bytes_);
1919 bin_.template make_inplace<true>();
1923 template <
bool external_content>
1925 reshape(
const size_t wanna_capacity,
const size_t wanna_headroom,
1926 const void *
const content,
const size_t length) {
1927 assert(wanna_capacity >= wanna_headroom + length);
1928 const size_t old_capacity = bin_.capacity();
1929 const size_t new_capacity =
1930 bin::advise_capacity(old_capacity, wanna_capacity);
1933 assert(bin_.is_inplace() ==
1934 bin::is_suitable_for_inplace(new_capacity));
1935 byte *
const new_place = bin_.address() + wanna_headroom;
1938 if (external_content)
1939 memcpy(new_place, content, length);
1941 const size_t old_headroom =
1942 bin_.address() -
static_cast<const byte *
>(content);
1943 assert(old_capacity >= old_headroom + length);
1945 MDBX_CXX20_UNLIKELY ::std::memmove(new_place, content,
1952 if (bin::is_suitable_for_inplace(new_capacity)) {
1953 assert(bin_.is_allocated());
1954 const auto old_allocated = ::std::move(bin_.allocated_.ptr_);
1955 byte *
const new_place =
1956 bin_.template make_inplace<true>() + wanna_headroom;
1959 deallocate_storage(old_allocated, old_capacity);
1963 if (!bin_.is_allocated()) {
1964 const auto pair = allocate_storage(new_capacity);
1965 assert(pair.second >= new_capacity);
1966 byte *
const new_place =
1967 static_cast<byte *
>(to_address(pair.first)) + wanna_headroom;
1970 bin_.template make_allocated<true>(pair.first, pair.second);
1974 const auto old_allocated = ::std::move(bin_.allocated_.ptr_);
1975 if (external_content)
1976 deallocate_storage(old_allocated, old_capacity);
1977 const auto pair = allocate_storage(new_capacity);
1978 assert(pair.second >= new_capacity);
1979 byte *
const new_place =
1980 bin_.template make_allocated<false>(pair.first, pair.second) +
1984 if (!external_content)
1985 deallocate_storage(old_allocated, old_capacity);
1990 assert(capacity() >= offset);
1991 return bin_.address() + offset;
1994 assert(capacity() >= offset);
1995 return bin_.address() + offset;
1999 assert(capacity() >= offset + length);
2000 return static_cast<byte *
>(memcpy(get(offset), ptr, length));
2006 silo() noexcept : allocator_type() { init(0); }
2008 silo(
const allocator_type &alloc) noexcept : allocator_type(alloc) {
2018 ::std::is_nothrow_move_constructible<allocator_type>::value)
2019 : allocator_type(::
std::move(ditto.get_allocator())),
2020 bin_(::
std::move(ditto.bin_)) {}
2025 assert(capacity >= headroom + length);
2027 put(headroom, ptr, length);
2032 size_t length,
const allocator_type &alloc)
2033 : silo(capacity, alloc) {
2034 assert(capacity >= headroom + length);
2036 put(headroom, ptr, length);
2040 : silo(length, 0, ptr, length) {}
2042 const allocator_type &alloc)
2043 : silo(length, 0, ptr, length, alloc) {}
2045 ~silo() { release(); }
2050 size_t length,
size_t tailroom) {
2051 return reshape<true>(headroom + length + tailroom, headroom, ptr, length);
2054 return assign(0, ptr, length, 0);
2059 assert(ditto.get() + headroom == content.byte_ptr());
2062 if (
MDBX_UNLIKELY(get_allocator() != ditto.get_allocator()))
2063 MDBX_CXX20_UNLIKELY {
2065 allocation_aware_details::copy_assign_alloc<
2066 silo, allocator_type>::propagate(
this, ditto);
2069 content.iov_base = reshape<true>(ditto.capacity(), headroom,
2070 content.data(), content.length());
2075 assign(silo &&ditto,
size_t headroom, slice &content)
noexcept(
2076 allocation_aware_details::move_assign_alloc<
2077 silo, allocator_type>::is_nothrow()) {
2078 assert(ditto.get() + headroom == content.byte_ptr());
2079 if (allocation_aware_details::move_assign_alloc<
2080 silo, allocator_type>::is_moveable(
this, ditto)) {
2082 allocation_aware_details::move_assign_alloc<
2083 silo, allocator_type>::propagate(
this, ditto);
2085 bin_ = ::std::move(ditto.bin_);
2086 assert(get() + headroom == content.byte_ptr());
2089 content.iov_base = reshape<true>(ditto.capacity(), headroom,
2090 content.data(), content.length());
2097 return reshape<true>(0, 0,
nullptr, 0);
2101 return reshape<false>(whole_capacity, headroom,
nullptr, 0);
2106 reshape<false>(capacity, headroom, content.iov_base, content.iov_len);
2109 allocation_aware_details::swap_alloc<silo,
2110 allocator_type>::is_nothrow()) {
2111 allocation_aware_details::swap_alloc<silo, allocator_type>::propagate(
2113 ::std::swap(bin_, ditto.bin_);
2119 capacity() const noexcept {
2120 return bin_.capacity();
2123 data(
size_t offset = 0) const noexcept {
2127 data(
size_t offset = 0) noexcept {
2136 assert(is_reference());
2138 slice_.iov_base = silo_.data();
2142 silo_begin() const noexcept {
2143 return static_cast<const byte *
>(silo_.data());
2147 silo_end() const noexcept {
2148 return silo_begin() + silo_.capacity();
2151 struct data_preserver :
public exception_thunk {
2153 data_preserver(allocator_type &allocator) : data(allocator) {}
2154 static int callback(
void *context,
MDBX_val *target,
const void *src,
2155 size_t bytes)
noexcept {
2156 auto self =
static_cast<data_preserver *
>(context);
2157 assert(self->is_clean());
2158 assert(&self->data.slice_ == target);
2161 self->data.assign(src, bytes,
false);
2189 return silo_.get_allocator();
2196 static_assert(size_t(-
long(max_length)) > max_length,
"WTF?");
2197 return size_t(byte_ptr() - silo_begin()) < silo_.capacity();
2204 return !is_freestanding();
2211 return is_freestanding() ? silo_.capacity() : 0;
2218 return is_freestanding() ? slice_.
byte_ptr() - silo_begin() : 0;
2225 return is_freestanding() ? capacity() - headroom() - slice_.
length() : 0;
2243 return const_cast<byte *
>(slice_.
byte_ptr());
2269 return const_cast<char *
>(slice_.
char_ptr());
2282 return slice_.
data();
2293 return const_cast<void *
>(slice_.
data());
2301 return const_cast<void *
>(slice_.
end());
2308 slice_.
length() + headroom() <=
2316 bytes + headroom() <= silo_.capacity());
2324 return set_length(
static_cast<const char *
>(ptr) - char_ptr());
2337 : silo_(allocator) {}
2341 : silo_(allocator), slice_(src) {
2342 if (!make_reference)
2348 :
buffer(src.slice_, make_reference, allocator) {}
2350 buffer(
const void *ptr,
size_t bytes,
bool make_reference,
2354 template <
class CHAR,
class T,
class A>
2355 buffer(const ::std::basic_string<CHAR, T, A> &) =
delete;
2356 template <
class CHAR,
class T,
class A>
2357 buffer(const ::std::basic_string<CHAR, T, A> &&) =
delete;
2359 buffer(
const char *c_str,
bool make_reference,
2363#if defined(DOXYGEN) || \
2364 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2365 template <
class CHAR,
class T>
2366 buffer(const ::std::basic_string_view<CHAR, T> &view,
2367 bool make_reference,
2376 : silo_(src.data(), src.length(), allocator),
2377 slice_(silo_.data(), src.length()) {}
2381 :
buffer(src.slice_, allocator) {}
2388 template <
class CHAR,
class T,
class A>
2390 buffer(const ::std::basic_string<CHAR, T, A> &str,
2398#if defined(DOXYGEN) || \
2399 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2400 template <
class CHAR,
class T>
2402 buffer(const ::std::basic_string_view<CHAR, T> &view,
2410 : silo_(allocator) {
2411 slice_.iov_base = silo_.init(check_length(head_room, tail_room));
2412 assert(slice_.iov_len == 0);
2416 : silo_(allocator) {
2417 slice_.iov_base = silo_.init(check_length(capacity));
2418 assert(slice_.iov_len == 0);
2423 : silo_(allocator) {
2425 silo_.init(check_length(head_room, src.
length(), tail_room));
2426 slice_.iov_len = src.
length();
2427 memcpy(slice_.iov_base, src.
data(), src.
length());
2432 :
buffer(head_room, src.slice_, tail_room, allocator) {}
2438 : silo_(::
std::move(src.silo_)), slice_(::
std::move(src.slice_)) {}
2448#if defined(DOXYGEN) || (defined(__cpp_lib_span) && __cpp_lib_span >= 202002L)
2449 template <
typename POD>
2451 :
buffer(span.begin(), span.end()) {
2452 static_assert(::std::is_standard_layout<POD>::value &&
2453 !::std::is_pointer<POD>::value,
2454 "Must be a standard layout type!");
2457 template <
typename POD>
2458 MDBX_CXX14_CONSTEXPR ::std::span<const POD>
as_span()
const {
2459 return slice_.template as_span<const POD>();
2461 template <
typename POD> MDBX_CXX14_CONSTEXPR ::std::span<POD>
as_span() {
2462 return slice_.template as_span<POD>();
2465 MDBX_CXX14_CONSTEXPR ::std::span<const byte>
bytes()
const {
2466 return as_span<const byte>();
2468 MDBX_CXX14_CONSTEXPR ::std::span<byte>
bytes() {
return as_span<byte>(); }
2469 MDBX_CXX14_CONSTEXPR ::std::span<const char>
chars()
const {
2470 return as_span<const char>();
2472 MDBX_CXX14_CONSTEXPR ::std::span<char>
chars() {
return as_span<char>(); }
2475 template <
typename POD>
2482 return slice_.
as_pod<POD>();
2485#ifdef MDBX_U128_TYPE
2501#ifdef MDBX_I128_TYPE
2511#ifdef MDBX_U128_TYPE
2519#ifdef MDBX_I128_TYPE
2528 static buffer hex(const ::mdbx::slice &source,
bool uppercase =
false,
2529 unsigned wrap_width = 0,
2531 return source.template encode_hex<ALLOCATOR, CAPACITY_POLICY>(
2532 uppercase, wrap_width, allocator);
2539 return source.template encode_base58<ALLOCATOR, CAPACITY_POLICY>(wrap_width,
2546 return source.template encode_base64<ALLOCATOR, CAPACITY_POLICY>(wrap_width,
2551 template <
typename POD>
2553 unsigned wrap_width = 0,
2560 template <
typename POD>
2568 template <
typename POD>
2577 return slice().template encode_hex<ALLOCATOR, CAPACITY_POLICY>(
2578 uppercase, wrap_width, allocator);
2586 return slice().template encode_base58<ALLOCATOR, CAPACITY_POLICY>(
2587 wrap_width, allocator);
2594 return slice().template encode_base64<ALLOCATOR, CAPACITY_POLICY>(
2595 wrap_width, allocator);
2600 bool ignore_spaces =
false,
2602 return source.template hex_decode<ALLOCATOR, CAPACITY_POLICY>(ignore_spaces,
2611 return source.template base58_decode<ALLOCATOR, CAPACITY_POLICY>(
2612 ignore_spaces, allocator);
2620 return source.template base64_decode<ALLOCATOR, CAPACITY_POLICY>(
2621 ignore_spaces, allocator);
2628 return hex_decode(
slice(), ignore_spaces, allocator);
2636 return base58_decode(
slice(), ignore_spaces, allocator);
2644 return base64_decode(
slice(), ignore_spaces, allocator);
2648 void reserve(
size_t wanna_headroom,
size_t wanna_tailroom) {
2649 wanna_headroom = ::std::min(::std::max(headroom(), wanna_headroom),
2650 wanna_headroom + pettiness_threshold);
2651 wanna_tailroom = ::std::min(::std::max(tailroom(), wanna_tailroom),
2652 wanna_tailroom + pettiness_threshold);
2653 const size_t wanna_capacity =
2654 check_length(wanna_headroom, slice_.
length(), wanna_tailroom);
2655 silo_.resize(wanna_capacity, wanna_headroom, slice_);
2656 assert(headroom() >= wanna_headroom &&
2657 headroom() <= wanna_headroom + pettiness_threshold);
2658 assert(tailroom() >= wanna_tailroom &&
2659 tailroom() <= wanna_tailroom + pettiness_threshold);
2670 slice_.
assign(ptr, bytes);
2675 silo_.assign(
static_cast<const typename silo::value_type *
>(ptr),
2676 check_length(bytes));
2677 slice_.
assign(silo_.data(), bytes);
2683 silo_.swap(other.silo_);
2684 slice_.
swap(other.slice_);
2693 return assign(src.slice_, make_reference);
2696 buffer &
assign(
const void *ptr,
size_t bytes,
bool make_reference =
false) {
2697 return make_reference ? assign_reference(ptr, bytes)
2698 : assign_freestanding(ptr, bytes);
2702 return assign(src.
data(), src.
length(), make_reference);
2706 return assign(src.iov_base, src.iov_len, make_reference);
2710 assign(src.
data(), src.
length(), make_reference);
2716 assign(src.iov_base, src.iov_len, make_reference);
2717 src.iov_base =
nullptr;
2722 bool make_reference =
false) {
2723 return assign(begin,
2724 static_cast<const byte *
>(end) -
2725 static_cast<const byte *
>(begin),
2729 template <
class CHAR,
class T,
class A>
2731 bool make_reference =
false) {
2732 return assign(str.data(), str.length(), make_reference);
2736 return assign(c_str, ::mdbx::strlen(c_str), make_reference);
2739#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
2740 template <
class CHAR,
class T>
2741 buffer &assign(const ::std::basic_string_view<CHAR, T> &view,
2742 bool make_reference =
false) {
2743 return assign(view.data(), view.length(), make_reference);
2746 template <
class CHAR,
class T>
2747 buffer &assign(::std::basic_string_view<CHAR, T> &&view,
2748 bool make_reference =
false) {
2749 assign(view.data(), view.length(), make_reference);
2758 return assign(::std::move(src));
2765#if defined(DOXYGEN) || \
2766 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2767 template <
class CHAR,
class T>
2769 return assign(view);
2773 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>>
2774 ::std::basic_string_view<CHAR, T> string_view() const noexcept {
2779 template <
class CHAR,
class T>
2780 operator ::std::basic_string_view<CHAR, T>() const noexcept {
2781 return string_view<CHAR, T>();
2787 return length() == 0;
2792 return data() ==
nullptr;
2809 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>,
2810 class A = legacy_allocator>
2811 MDBX_CXX20_CONSTEXPR ::std::basic_string<CHAR, T, A>
2813 return slice_.
as_string<CHAR, T, A>(allocator);
2816 template <
class CHAR,
class T,
class A>
2818 operator ::std::basic_string<CHAR, T, A>()
const {
2819 return as_string<CHAR, T, A>();
2839 slice_.
assign(silo_.clear_and_reserve(whole_capacity, headroom),
size_t(0));
2872 return byte_ptr()[n];
2884 return byte_ptr()[n];
2890 return slice_.
head(n);
2896 return slice_.
tail(n);
2902 size_t n) const noexcept {
2903 return slice_.
middle(from, n);
2926 MDBX_CXX20_UNLIKELY reserve_tailroom(bytes);
2927 memcpy(end_byte_ptr(), src, bytes);
2928 slice_.iov_len += bytes;
2933 return append(chunk.
data(), chunk.
size());
2938 MDBX_CXX20_UNLIKELY reserve_headroom(bytes);
2940 memcpy(
static_cast<char *
>(slice_.iov_base) - bytes, src, bytes);
2941 slice_.iov_len += bytes;
2946 return add_header(chunk.
data(), chunk.
size());
2949 template <MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER)>
2951 const size_t wanna_bytes = producer.envisage_result_length();
2953 MDBX_CXX20_UNLIKELY reserve_tailroom(wanna_bytes);
2954 return set_end(producer.write_bytes(end_char_ptr(), tailroom()));
2957 template <MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER)>
2959 const size_t wanna_bytes = producer.envisage_result_length();
2961 MDBX_CXX20_UNLIKELY reserve_tailroom(wanna_bytes);
2962 return set_end(producer.write_bytes(end_char_ptr(), tailroom()));
2966 unsigned wrap_width = 0) {
2967 return append_producer(
to_hex(data, uppercase, wrap_width));
2971 return append_producer(
to_base58(data, wrap_width));
2975 return append_producer(
to_base64(data, wrap_width));
2979 bool ignore_spaces =
false) {
2980 return append_producer(
from_hex(data, ignore_spaces));
2984 bool ignore_spaces =
false) {
2985 return append_producer(
from_base58(data, ignore_spaces));
2989 bool ignore_spaces =
false) {
2990 return append_producer(
from_base64(data, ignore_spaces));
2995 MDBX_CXX20_UNLIKELY reserve_tailroom(1);
2997 slice_.iov_len += 1;
3005 MDBX_CXX20_UNLIKELY reserve_tailroom(2);
3007 ptr[0] = uint8_t(u16);
3008 ptr[1] = uint8_t(u16 >> 8);
3009 slice_.iov_len += 2;
3015 MDBX_CXX20_UNLIKELY reserve_tailroom(3);
3017 ptr[0] = uint8_t(u24);
3018 ptr[1] = uint8_t(u24 >> 8);
3019 ptr[2] = uint8_t(u24 >> 16);
3020 slice_.iov_len += 3;
3026 MDBX_CXX20_UNLIKELY reserve_tailroom(4);
3028 ptr[0] = uint8_t(u32);
3029 ptr[1] = uint8_t(u32 >> 8);
3030 ptr[2] = uint8_t(u32 >> 16);
3031 ptr[3] = uint8_t(u32 >> 24);
3032 slice_.iov_len += 4;
3038 MDBX_CXX20_UNLIKELY reserve_tailroom(6);
3040 ptr[0] = uint8_t(u48);
3041 ptr[1] = uint8_t(u48 >> 8);
3042 ptr[2] = uint8_t(u48 >> 16);
3043 ptr[3] = uint8_t(u48 >> 24);
3044 ptr[4] = uint8_t(u48 >> 32);
3045 ptr[5] = uint8_t(u48 >> 40);
3046 slice_.iov_len += 6;
3052 MDBX_CXX20_UNLIKELY reserve_tailroom(8);
3054 ptr[0] = uint8_t(u64);
3055 ptr[1] = uint8_t(u64 >> 8);
3056 ptr[2] = uint8_t(u64 >> 16);
3057 ptr[3] = uint8_t(u64 >> 24);
3058 ptr[4] = uint8_t(u64 >> 32);
3059 ptr[5] = uint8_t(u64 >> 40);
3060 ptr[6] = uint8_t(u64 >> 48);
3061 ptr[7] = uint8_t(u64 >> 56);
3062 slice_.iov_len += 8;
3068 template <
size_t SIZE>
3073#if defined(DOXYGEN) || \
3074 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
3075 template <
class CHAR,
class T>
3077 bool make_reference =
false) {
3078 return buffer(src, make_reference);
3083 return buffer(src, make_reference);
3086 template <
class CHAR,
class T,
class A>
3088 bool make_reference =
false) {
3089 return buffer(src, make_reference);
3093 return buffer(::std::move(src));
3101 return key_from_double(ieee754_64bit);
3109 return wrap(unsigned_int64);
3113 return key_from_u64(unsigned_int64);
3121 return key_from_i64(signed_int64);
3133 return key_from_float(ieee754_32bit);
3141 return wrap(unsigned_int32);
3145 return key_from_u32(unsigned_int32);
3153 return key_from_i32(signed_int32);
3157template <
class ALLOCATOR,
class CAPACITY_POLICY,
3159inline buffer<ALLOCATOR, CAPACITY_POLICY>
3164 producer.envisage_result_length(), allocator);
3172template <
class ALLOCATOR,
class CAPACITY_POLICY,
3174inline buffer<ALLOCATOR, CAPACITY_POLICY>
3179 producer.envisage_result_length(), allocator);
3187template <
class ALLOCATOR, MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER)>
3189 const ALLOCATOR &allocator) {
3193 result.resize(producer.envisage_result_length());
3194 result.resize(producer.write_bytes(
const_cast<char *
>(result.data()),
3195 result.capacity()) -
3201template <
class ALLOCATOR, MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER)>
3203 const ALLOCATOR &allocator) {
3207 result.resize(producer.envisage_result_length());
3208 result.resize(producer.write_bytes(
const_cast<char *
>(result.data()),
3209 result.capacity()) -
3221 : value(value), done(done) {}
3225 assert(!done ||
bool(value));
3236 : key(key), value(value) {}
3238 : key(couple.first), value(couple.second) {}
3245 assert(
bool(key) ==
bool(value));
3249 return pair(slice::invalid(), slice::invalid());
3254 compare_fast(
const pair &a,
const pair &b)
noexcept;
3258 compare_lexicographically(
const pair &a,
const pair &b)
noexcept;
3260 const pair &b)
noexcept;
3262 const pair &b)
noexcept;
3264 const pair &b)
noexcept;
3266 const pair &b)
noexcept;
3268 const pair &b)
noexcept;
3270 const pair &b)
noexcept;
3278 :
pair(
pair::invalid()), done(false) {}
3281 :
pair(key, value), done(done) {}
3285 assert(!done || (
bool(key) &&
bool(value)));
3290template <
typename ALLOCATOR,
typename CAPACITY_POLICY>
3296 using stl_pair = ::std::pair<buffer_type, buffer_type>;
3302 : key(allocator), value(allocator) {}
3306 : key(key, allocator), value(value, allocator) {}
3308 bool make_reference,
3310 : key(key, make_reference, allocator),
3311 value(value, make_reference, allocator) {}
3322 : key(key, allocator), value(value, allocator) {}
3325 : key(key, make_reference, allocator),
3326 value(value, make_reference, allocator) {}
3337 : key(
txn, key, allocator), value(
txn, value, allocator) {}
3343 buffer_type::move_assign_alloc::is_nothrow())
3344 : key(::
std::move(key)), value(::
std::move(value)) {}
3346 buffer_type::move_assign_alloc::is_nothrow())
3353 return key.is_freestanding() && value.is_freestanding();
3359 return key.is_reference() || value.is_reference();
3365 key.make_freestanding();
3366 value.make_freestanding();
3369 operator pair() const noexcept {
return pair(key, value); }
3372template <
typename BUFFER>
3374 typename BUFFER::reservation_policy>;
3418 return mode == key_mode::msgpack;
3433#if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
3513 return mode == value_mode::msgpack;
3529 operator bool() const noexcept {
return dbi != 0; }
3580 inline
env &operator=(
env &&other) noexcept;
3581 inline
env(
env &&other) noexcept;
3582 inline ~
env() noexcept;
3588 const
env &b) noexcept;
3590 const
env &b) noexcept;
3603 maximal_value = INTPTR_MAX,
3607#if INTPTR_MAX > 0x7fffFFFFl
3615#if INTPTR_MAX > 0x7fffFFFFl
3630 intptr_t size_lower{minimal_value};
3635 intptr_t size_now{default_value};
3647 intptr_t size_upper{maximal_value};
3651 intptr_t growth_step{default_value};
3655 intptr_t shrink_threshold{default_value};
3661 intptr_t pagesize{default_value};
3663 inline geometry &make_fixed(intptr_t size)
noexcept;
3664 inline geometry &make_dynamic(intptr_t lower = minimal_value,
3665 intptr_t upper = maximal_value)
noexcept;
3670 intptr_t size_now = default_value,
3671 intptr_t size_upper = maximal_value,
3672 intptr_t growth_step = default_value,
3673 intptr_t shrink_threshold = default_value,
3674 intptr_t pagesize = default_value) noexcept
3675 : size_lower(size_lower), size_now(size_now), size_upper(size_upper),
3676 growth_step(growth_step), shrink_threshold(shrink_threshold),
3677 pagesize(pagesize) {}
3685 nested_transactions = write_file_io
3701 bool coalesce{
false};
3713 bool no_sticky_threads{
false};
3716 bool nested_write_transactions{
false};
3718 bool exclusive{
false};
3720 bool disable_readahead{
false};
3722 bool disable_clear_memory{
false};
3724 bool enable_validation{
false};
3737 unsigned max_maps{0};
3740 unsigned max_readers{0};
3749 const unsigned max_maps,
const unsigned max_readers = 0,
3754 : max_maps(max_maps), max_readers(max_readers),
mode(
mode),
3764 bool use_subdirectory =
3795 return ::mdbx_default_pagesize();
3801 static inline size_t pagesize_min() noexcept;
3803 static inline
size_t pagesize_max() noexcept;
3806 static inline
size_t dbsize_min(intptr_t pagesize);
3809 static inline
size_t dbsize_max(intptr_t pagesize);
3817 static inline
size_t key_max(intptr_t pagesize,
MDBX_db_flags_t flags);
3820 static inline
size_t key_max(intptr_t pagesize,
key_mode mode);
3832 static inline
size_t value_min(
value_mode) noexcept;
3836 static inline
size_t value_max(intptr_t pagesize,
MDBX_db_flags_t flags);
3839 static inline
size_t value_max(intptr_t pagesize,
value_mode);
3849 static inline
size_t pairsize4page_max(intptr_t pagesize,
3853 static inline
size_t pairsize4page_max(intptr_t pagesize,
value_mode);
3859 static inline
size_t pairsize4page_max(const
env &,
value_mode);
3863 static inline
size_t valsize4page_max(intptr_t pagesize,
3867 static inline
size_t valsize4page_max(intptr_t pagesize,
value_mode);
3873 static inline
size_t valsize4page_max(const
env &,
value_mode);
3877 static inline
size_t transaction_size_max(intptr_t pagesize);
3880 static inline
size_t max_map_handles(
void);
3884 size_t dbsize_min()
const {
return limits::dbsize_min(this->get_pagesize()); }
3886 size_t dbsize_max()
const {
return limits::dbsize_max(this->get_pagesize()); }
3893 return limits::value_min(
mode);
3897 return limits::value_max(*
this,
mode);
3902 return limits::transaction_size_max(this->get_pagesize());
3907#ifdef MDBX_STD_FILESYSTEM_PATH
3909 bool force_dynamic_size =
false);
3911#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3912 env &
copy(const ::std::wstring &destination,
bool compactify,
3913 bool force_dynamic_size =
false);
3914 env &
copy(
const wchar_t *destination,
bool compactify,
3915 bool force_dynamic_size =
false);
3917 env &
copy(const ::std::string &destination,
bool compactify,
3918 bool force_dynamic_size =
false);
3919 env &
copy(
const char *destination,
bool compactify,
3920 bool force_dynamic_size =
false);
3944#ifdef MDBX_STD_FILESYSTEM_PATH
3948#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3949 static bool remove(const ::std::wstring &pathname,
3954 static bool remove(const ::std::string &pathname,
3966 inline stat get_stat()
const;
3972 inline info get_info()
const;
3976 inline stat get_stat(
const txn &)
const;
3980 inline info get_info(
const txn &)
const;
3994 inline unsigned max_readers()
const;
3998 inline unsigned max_maps()
const;
4001 inline void *get_context() const noexcept;
4004 inline
env &set_context(
void *your_context);
4020 inline
env &set_sync_threshold(
size_t bytes);
4027 inline
size_t sync_threshold() const;
4029#if __cplusplus >= 201103L || defined(DOXYGEN)
4062 inline env &set_sync_period__seconds_16dot16(
unsigned seconds_16dot16);
4066 inline unsigned sync_period__seconds_16dot16()
const;
4071 inline env &set_sync_period__seconds_double(
double seconds);
4075 inline double sync_period__seconds_double()
const;
4116 inline env &set_extra_option(extra_runtime_option option, uint64_t value);
4119 inline uint64_t extra_option(extra_runtime_option option)
const;
4125 inline env &set_geometry(
const geometry &size);
4130 inline bool sync_to_disk(
bool force =
true,
bool nonblock =
false);
4180 uint64_t lag,
size_t used,
4181 size_t retained)
noexcept;
4191 template <
typename VISITOR>
inline int enumerate_readers(VISITOR &visitor);
4195 inline unsigned check_readers();
4220 inline MDBX_hsr_func *get_HandleSlowReaders() const noexcept;
4232 inline
txn_managed start_write(
bool dont_wait = false);
4250 void setup(
unsigned max_maps,
unsigned max_readers = 0);
4256#ifdef MDBX_STD_FILESYSTEM_PATH
4260#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
4262 bool accede =
true);
4264 bool accede =
true);
4267 bool accede =
true);
4269 bool accede =
true);
4277 bool use_subdirectory{
false};
4283#ifdef MDBX_STD_FILESYSTEM_PATH
4286 bool accede =
true);
4288#if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
4317 MDBX_CXX20_UNLIKELY {
4318 assert(handle_ != other.handle_);
4321 inherited::operator=(std::move(other));
4346 inline
txn &operator=(
txn &&other) noexcept;
4347 inline
txn(
txn &&other) noexcept;
4348 inline ~
txn() noexcept;
4354 const
txn &b) noexcept;
4356 const
txn &b) noexcept;
4363 inline uint64_t
id() const;
4366 inline
void *get_context() const noexcept;
4369 inline
txn &set_context(
void *your_context);
4372 inline
bool is_dirty(const
void *ptr) const;
4382 inline info get_info(
bool scan_reader_lock_table =
false)
const;
4391 assert(is_readwrite());
4392 return size_t(get_info().txn_space_dirty);
4398 inline void reset_reading();
4401 inline void renew_reading();
4404 inline void park_reading(
bool autounpark =
true);
4408 inline bool unpark_reading(
bool restart_if_ousted =
true);
4417 inline size_t release_all_cursors(
bool unbind)
const;
4432 const ::std::string &name,
4437 const ::mdbx::slice &name,
4442 inline map_handle open_map_accede(
const char *name)
const;
4444 inline map_handle open_map_accede(const ::std::string &name)
const;
4446 inline map_handle open_map_accede(const ::mdbx::slice &name)
const;
4450 create_map(
const char *name,
4455 create_map(const ::std::string &name,
4460 create_map(const ::mdbx::slice &name,
4469 bool drop_map(
const char *name,
bool throw_if_absent =
false);
4473 inline bool drop_map(const ::std::string &name,
bool throw_if_absent =
false);
4477 bool drop_map(const ::mdbx::slice &name,
bool throw_if_absent =
false);
4483 bool clear_map(
const char *name,
bool throw_if_absent =
false);
4486 inline bool clear_map(const ::std::string &name,
4487 bool throw_if_absent =
false);
4490 bool clear_map(const ::mdbx::slice &name,
bool throw_if_absent =
false);
4493 inline void rename_map(
map_handle map,
const char *new_name);
4495 inline void rename_map(
map_handle map, const ::std::string &new_name);
4497 inline void rename_map(
map_handle map, const ::mdbx::slice &new_name);
4502 bool throw_if_absent =
false);
4506 bool rename_map(const ::std::string &old_name, const ::std::string &new_name,
4507 bool throw_if_absent =
false);
4511 bool rename_map(const ::mdbx::slice &old_name, const ::mdbx::slice &new_name,
4512 bool throw_if_absent =
false);
4514#if defined(DOXYGEN) || \
4515 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
4519 const ::std::string_view &name,
4536 bool drop_map(const ::std::string_view &name,
bool throw_if_absent =
false) {
4541 bool clear_map(const ::std::string_view &name,
bool throw_if_absent =
false) {
4550 const ::std::string_view &new_name,
4551 bool throw_if_absent =
false) {
4562 inline uint32_t get_tree_deepmask(
map_handle map)
const;
4572 inline canary get_canary()
const;
4576 inline uint64_t sequence(
map_handle map)
const;
4579 inline uint64_t sequence(
map_handle map, uint64_t increment);
4584 const slice &b)
const noexcept;
4588 const slice &b)
const noexcept;
4592 const pair &b)
const noexcept;
4596 const pair &b)
const noexcept;
4605 const slice &value_at_absence)
const;
4609 const slice &value_at_absence)
const;
4618 const slice &value_at_absence)
const;
4626 size_t value_length);
4628 size_t value_length);
4632 size_t value_length);
4637 size_t value_length);
4639 size_t value_length);
4642 return put(map, kv.
key, kv.
value, mode);
4645 return insert(map, kv.
key, kv.
value);
4648 return try_insert(map, kv.
key, kv.
value);
4662 const slice &new_value);
4665 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4672 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4678 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4701 bool multivalue_order_preserved =
true);
4703 bool multivalue_order_preserved =
true) {
4704 return append(map, kv.
key, kv.
value, multivalue_order_preserved);
4708 const size_t value_length,
4709 const void *values_array,
size_t values_count,
4710 put_mode mode,
bool allow_partial =
false);
4711 template <
typename VALUE>
4713 const VALUE *values_array,
size_t values_count,
4714 put_mode mode,
bool allow_partial =
false) {
4715 static_assert(::std::is_standard_layout<VALUE>::value &&
4716 !::std::is_pointer<VALUE>::value &&
4717 !::std::is_array<VALUE>::value,
4718 "Must be a standard layout type!");
4719 return put_multiple_samelength(map, key,
sizeof(VALUE), values_array,
4720 values_count, mode, allow_partial);
4722 template <
typename VALUE>
4724 const ::std::vector<VALUE> &vector,
4726 put_multiple_samelength(map, key, vector.
data(), vector.size(), mode);
4730 const pair &to)
const;
4732 const slice &to)
const;
4733 inline ptrdiff_t estimate_from_first(
map_handle map,
const slice &to)
const;
4734 inline ptrdiff_t estimate_to_last(
map_handle map,
const slice &from)
const;
4757 MDBX_CXX20_UNLIKELY {
4758 assert(handle_ != other.handle_);
4761 inherited::operator=(std::move(other));
4779 void commit_embark_read();
4818 inline ~
cursor() noexcept;
4824 const
cursor &b) noexcept;
4826 const
cursor &b) noexcept;
4828 friend inline
int compare_position_nothrow(const
cursor &left,
4830 bool ignore_nested) noexcept;
4831 friend inline
int compare_position(const
cursor &left, const
cursor &right,
4832 bool ignore_nested);
4834 bool is_before_than(const
cursor &other,
bool ignore_nested = false)
const {
4839 bool ignore_nested =
false)
const {
4852 bool ignore_nested =
false)
const {
4857 inline void *get_context() const noexcept;
4860 inline
cursor &set_context(
void *your_context);
4893 multi_exactkey_value_lesser_or_equal =
4896 multi_exactkey_value_greater_or_equal =
4903 pair_exact = pair_equal,
4918 bool throw_notfound)
4923 bool throw_notfound);
4932 slice::invalid()) {}
4945 bool throw_notfound)
const;
4951 template <
typename CALLABLE_PREDICATE>
4956 void *arg)
noexcept {
4957 auto thunk =
static_cast<wrapper *
>(context);
4958 assert(thunk->is_clean());
4959 auto &predicate = *
static_cast<CALLABLE_PREDICATE *
>(arg);
4969 return error::boolean_or_throw(
4976 template <
typename CALLABLE_PREDICATE>
4977 bool fullscan(CALLABLE_PREDICATE predicate,
bool backward =
false) {
4978 return scan(std::move(predicate), backward ? last : first,
4979 backward ? previous : next);
4982 template <
typename CALLABLE_PREDICATE>
4988 void *arg)
noexcept {
4989 auto thunk =
static_cast<wrapper *
>(context);
4990 assert(thunk->is_clean());
4991 auto &predicate = *
static_cast<CALLABLE_PREDICATE *
>(arg);
5001 return error::boolean_or_throw(
5008 template <
typename CALLABLE_PREDICATE>
5014 void *arg)
noexcept {
5015 auto thunk =
static_cast<wrapper *
>(context);
5016 assert(thunk->is_clean());
5017 auto &predicate = *
static_cast<CALLABLE_PREDICATE *
>(arg);
5027 return error::boolean_or_throw(
5035 return move_result(*
this, operation, throw_notfound);
5038 bool throw_notfound) {
5039 return move_result(*
this, operation, key, slice::invalid(), throw_notfound);
5042 const slice &value,
bool throw_notfound) {
5043 return move_result(*
this, operation, key, value, throw_notfound);
5046 bool throw_notfound) {
5047 return move(operation, &key, &value, throw_notfound);
5051 return move(first, throw_notfound);
5054 return move(previous, throw_notfound);
5057 return move(multi_prevkey_lastvalue, throw_notfound);
5060 return move(multi_currentkey_firstvalue, throw_notfound);
5063 return move(multi_currentkey_prevvalue, throw_notfound);
5069 return move(multi_currentkey_nextvalue, throw_notfound);
5072 return move(multi_currentkey_lastvalue, throw_notfound);
5075 return move(multi_nextkey_firstvalue, throw_notfound);
5078 return move(next, throw_notfound);
5081 return move(last, throw_notfound);
5085 return move(key_lesser_than, key, throw_notfound);
5088 bool throw_notfound =
true) {
5089 return move(key_lesser_or_equal, key, throw_notfound);
5092 return move(key_equal, key, throw_notfound);
5095 return move(key_exact, key, throw_notfound);
5098 bool throw_notfound =
true) {
5099 return move(key_greater_or_equal, key, throw_notfound);
5102 bool throw_notfound =
true) {
5103 return move(key_greater_than, key, throw_notfound);
5108 bool throw_notfound =
true) {
5109 return move(multi_exactkey_value_lesser_than, key, value, throw_notfound);
5113 bool throw_notfound =
true) {
5114 return move(multi_exactkey_value_lesser_or_equal, key, value,
5118 bool throw_notfound =
true) {
5119 return move(multi_exactkey_value_equal, key, value, throw_notfound);
5123 bool throw_notfound =
true) {
5124 return move(multi_exactkey_value_greater_or_equal, key, value,
5129 bool throw_notfound =
true) {
5130 return move(multi_exactkey_value_greater, key, value, throw_notfound);
5134 bool throw_notfound =
true) {
5135 return move(pair_lesser_than, key, value, throw_notfound);
5138 bool throw_notfound =
true) {
5139 return move(pair_lesser_or_equal, key, value, throw_notfound);
5142 bool throw_notfound =
true) {
5143 return move(pair_equal, key, value, throw_notfound);
5146 bool throw_notfound =
true) {
5147 return move(pair_exact, key, value, throw_notfound);
5150 bool throw_notfound =
true) {
5151 return move(pair_greater_or_equal, key, value, throw_notfound);
5154 bool throw_notfound =
true) {
5155 return move(pair_greater_than, key, value, throw_notfound);
5158 inline bool seek(
const slice &key);
5159 inline move_result find(
const slice &key,
bool throw_notfound =
true);
5160 inline move_result lower_bound(
const slice &key,
bool throw_notfound =
false);
5161 inline move_result upper_bound(
const slice &key,
bool throw_notfound =
false);
5164 inline size_t count_multivalue()
const;
5166 inline move_result find_multivalue(
const slice &key,
const slice &value,
5167 bool throw_notfound =
true);
5168 inline move_result lower_bound_multivalue(
const slice &key,
5170 bool throw_notfound =
false);
5171 inline move_result upper_bound_multivalue(
const slice &key,
5173 bool throw_notfound =
false);
5176 bool throw_notfound =
true) {
5177 return move(batch_samelength, key, throw_notfound);
5181 return move(batch_samelength, throw_notfound);
5185 return move(batch_samelength_next, throw_notfound);
5189 return move(batch_samelength_previous, throw_notfound);
5192 inline bool eof()
const;
5193 inline bool on_first()
const;
5194 inline bool on_last()
const;
5195 inline bool on_first_multival()
const;
5196 inline bool on_last_multival()
const;
5199 inline estimate_result
estimate(move_operation operation)
const;
5206 inline void renew(const ::mdbx::txn &
txn);
5213 inline void unbind();
5216 inline ::mdbx::txn
txn()
const;
5219 inline operator ::mdbx::txn()
const {
return txn(); }
5220 inline operator ::mdbx::map_handle()
const {
return map(); }
5225 inline void insert(
const slice &key,
slice value);
5227 inline slice insert_reserve(
const slice &key,
size_t value_length);
5231 inline slice upsert_reserve(
const slice &key,
size_t value_length);
5234 inline bool try_update(
const slice &key,
const slice &value);
5235 inline slice update_reserve(
const slice &key,
size_t value_length);
5239 return put(kv.
key, kv.
value, mode);
5243 return try_insert(kv.
key, kv.
value);
5249 inline bool erase(
bool whole_multivalue =
false);
5254 inline bool erase(
const slice &key,
bool whole_multivalue =
true);
5258 inline bool erase(
const slice &key,
const slice &value);
5280 MDBX_CXX20_UNLIKELY error::throw_exception(
MDBX_ENOMEM);
5289 MDBX_CXX20_UNLIKELY {
5290 assert(handle_ != other.handle_);
5293 inherited::operator=(std::move(other));
5307template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5308inline ::std::ostream &
5337 return out <<
error(errcode);
5346 return ::mdbx_version;
5349 return ::mdbx_build;
5353#if defined(__cpp_lib_is_constant_evaluated) && \
5354 __cpp_lib_is_constant_evaluated >= 201811L
5355 if (::std::is_constant_evaluated()) {
5356 for (
size_t i = 0; c_str; ++i)
5362#if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
5363 return c_str ? ::std::string_view(c_str).length() : 0;
5365 return c_str ? ::std::strlen(c_str) : 0;
5370memcpy(
void *dest,
const void *src,
size_t bytes)
noexcept {
5371#if defined(__cpp_lib_is_constant_evaluated) && \
5372 __cpp_lib_is_constant_evaluated >= 201811L
5373 if (::std::is_constant_evaluated()) {
5374 for (
size_t i = 0; i < bytes; ++i)
5375 static_cast<byte *
>(dest)[i] =
static_cast<const byte *
>(src)[i];
5379 return ::std::memcpy(dest, src, bytes);
5383 size_t bytes)
noexcept {
5384#if defined(__cpp_lib_is_constant_evaluated) && \
5385 __cpp_lib_is_constant_evaluated >= 201811L
5386 if (::std::is_constant_evaluated()) {
5387 for (
size_t i = 0; i < bytes; ++i) {
5388 const int diff = int(
static_cast<const byte *
>(a)[i]) -
5389 int(
static_cast<const byte *
>(b)[i]);
5396 return ::std::memcmp(a, b, bytes);
5407 return check_length(check_length(headroom) + check_length(payload));
5411check_length(
size_t headroom,
size_t payload,
size_t tailroom) {
5412 return check_length(check_length(headroom, payload) + check_length(tailroom));
5415inline bool exception_thunk::is_clean() const noexcept {
return !captured_; }
5417inline void exception_thunk::capture() noexcept {
5419 captured_ = ::std::current_exception();
5422inline void exception_thunk::rethrow_captured()
const {
5424 MDBX_CXX20_UNLIKELY ::std::rethrow_exception(captured_);
5430 : code_(error_code) {}
5438 return a.code_ == b.code_;
5470inline void error::throw_exception(
int error_code) {
5475inline void error::throw_on_failure()
const {
5477 MDBX_CXX20_UNLIKELY throw_exception();
5480inline void error::success_or_throw()
const {
5482 MDBX_CXX20_UNLIKELY throw_exception();
5490 else throw_exception();
5494inline void error::panic_on_failure(
const char *context_where,
5495 const char *func_who)
const noexcept {
5497 MDBX_CXX20_UNLIKELY panic(context_where, func_who);
5500inline void error::success_or_panic(
const char *context_where,
5501 const char *func_who)
const noexcept {
5503 MDBX_CXX20_UNLIKELY panic(context_where, func_who);
5506inline void error::throw_on_nullptr(
const void *ptr,
MDBX_error_t error_code) {
5511inline void error::throw_on_failure(
int error_code) {
5517 error rc(error_code);
5521inline bool error::boolean_or_throw(
int error_code) {
5522 switch (error_code) {
5528 MDBX_CXX20_UNLIKELY throw_exception(error_code);
5532inline void error::success_or_throw(
int error_code,
5538inline void error::panic_on_failure(
int error_code,
const char *context_where,
5539 const char *func_who)
noexcept {
5544inline void error::success_or_panic(
int error_code,
const char *context_where,
5545 const char *func_who)
noexcept {
5550inline bool error::boolean_or_throw(
int error_code,
5554 return boolean_or_throw(error_code);
5562 : ::
MDBX_val({
const_cast<void *
>(ptr), check_length(
bytes)}) {}
5565 :
slice(begin, static_cast<const
byte *>(end) -
5566 static_cast<const
byte *>(begin)) {}
5569 :
slice(c_str, ::
mdbx::strlen(c_str)) {}
5572 :
slice(src.iov_base, src.iov_len) {}
5575 src.iov_base =
nullptr;
5583 iov_base =
const_cast<void *
>(ptr);
5589 iov_base = src.iov_base;
5590 iov_len = src.iov_len;
5606 src.iov_base =
nullptr;
5611 return assign(begin,
static_cast<const byte *
>(
end) -
5612 static_cast<const byte *
>(begin));
5620 return assign(::std::move(src));
5628 const auto temp = *
this;
5634 return static_cast<const byte *
>(
iov_base);
5642 return static_cast<byte *
>(
iov_base);
5650 return static_cast<const char *
>(
iov_base);
5658 return static_cast<char *
>(
iov_base);
5696 return data() ==
nullptr;
5713 assert(n <= size());
5714 iov_base =
static_cast<byte *
>(iov_base) + n;
5725 assert(n <= size());
5737 return length() >= prefix.length() &&
5738 memcmp(data(), prefix.data(), prefix.length()) == 0;
5742 return length() >= suffix.length() &&
5743 memcmp(byte_ptr() + length() - suffix.length(), suffix.data(),
5744 suffix.length()) == 0;
5749 size_t h =
length() * 3977471;
5751 h = (
h ^
static_cast<const uint8_t *
>(
data())[
i]) * 1664525 + 1013904223;
5752 return h ^ 3863194411 * (
h >> 11);
5757 return byte_ptr()[n];
5768 return slice(data(), n);
5773 return slice(char_ptr() + size() - n, n);
5778 return slice(char_ptr() + from, n);
5802 const slice &b)
noexcept {
5803 const intptr_t diff = intptr_t(a.length()) - intptr_t(b.length());
5807 : memcmp(a.data(), b.data(), a.length());
5812 const size_t shortest = ::std::min(a.length(), b.length());
5815 const intptr_t diff = memcmp(a.data(), b.data(), shortest);
5819 return intptr_t(a.length()) - intptr_t(b.length());
5852template <
class ALLOCATOR>
5855 const ALLOCATOR &allocator)
const {
5859template <
class ALLOCATOR>
5865template <
class ALLOCATOR>
5871template <
class ALLOCATOR,
class CAPACITY_POLICY>
5874 const ALLOCATOR &allocator)
const {
5875 return to_hex(*
this, uppercase, wrap_width)
5879template <
class ALLOCATOR,
class CAPACITY_POLICY>
5886template <
class ALLOCATOR,
class CAPACITY_POLICY>
5893template <
class ALLOCATOR,
class CAPACITY_POLICY>
5896 return from_hex(*
this, ignore_spaces)
5900template <
class ALLOCATOR,
class CAPACITY_POLICY>
5907template <
class ALLOCATOR,
class CAPACITY_POLICY>
5932 const pair &b)
noexcept {
5945 return a.key.length() == b.key.length() &&
5946 a.value.length() == b.value.length() &&
5947 memcmp(a.key.data(), b.key.data(), a.key.length()) == 0 &&
5948 memcmp(a.value.data(), b.value.data(), a.value.length()) == 0;
5973 return a.key.length() != b.key.length() ||
5974 a.value.length() != b.value.length() ||
5975 memcmp(a.key.data(), b.key.data(), a.key.length()) != 0 ||
5976 memcmp(a.value.data(), b.value.data(), a.value.length()) != 0;
5981template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5984 :
buffer(src, !
txn.is_dirty(src.data()), allocator) {}
6009 other.handle_ =
nullptr;
6014 other.handle_ =
nullptr;
6019 handle_ =
reinterpret_cast<MDBX_env *
>(uintptr_t(0xDeadBeef));
6024 return handle_ !=
nullptr;
6032 return a.handle_ == b.handle_;
6036 return a.handle_ != b.handle_;
6040 size_lower = size_now = size_upper =
size;
6041 growth_step = shrink_threshold = 0;
6046 intptr_t upper)
noexcept {
6047 size_now = size_lower = lower;
6049 growth_step = shrink_threshold = default_value;
6071 return static_cast<size_t>(result);
6078 return static_cast<size_t>(result);
6093 return static_cast<size_t>(result);
6104 return static_cast<size_t>(result);
6123 return static_cast<size_t>(result);
6134 return static_cast<size_t>(result);
6146 return static_cast<size_t>(result);
6159 return static_cast<size_t>(result);
6171 return static_cast<size_t>(result);
6184 return static_cast<size_t>(result);
6195 return static_cast<size_t>(result);
6201 const auto flags = get_flags();
6203 operate_parameters::mode_from_flags(
flags),
6204 operate_parameters::durability_from_flags(
flags),
6205 operate_parameters::reclaiming_from_flags(
flags),
6206 operate_parameters::options_from_flags(
flags));
6210 return operate_parameters::mode_from_flags(get_flags());
6299 unsigned seconds_16dot16;
6301 return seconds_16dot16;
6305 return set_sync_period__seconds_16dot16(
unsigned(seconds * 65536));
6309 return sync_period__seconds_16dot16() / 65536.0;
6312#if __cplusplus >= 201103L
6314 return set_sync_period__seconds_16dot16(period.count());
6318 return duration(sync_period__seconds_16dot16());
6367 uint64_t txnid, uint64_t lag,
size_t used,
6368 size_t retained) noexcept
6369 : slot(slot), pid(pid), thread(thread), transaction_id(txnid),
6370 transaction_lag(lag), bytes_used(used), bytes_retained(retained) {}
6372template <
typename VISITOR>
6376 static int cb(
void *ctx,
int number,
int slot,
mdbx_pid_t pid,
6377 mdbx_tid_t thread, uint64_t txnid, uint64_t lag,
size_t used,
6378 size_t retained)
noexcept {
6379 reader_visitor_thunk *thunk =
static_cast<reader_visitor_thunk *
>(ctx);
6380 assert(thunk->is_clean());
6382 const reader_info info(slot, pid, thread, txnid, lag, used, retained);
6386 return loop_control::exit_loop;
6390 : visitor_(visitor) {}
6392 reader_visitor_thunk thunk(visitor);
6394 thunk.rethrow_captured();
6401 assert(dead_count >= 0);
6402 return static_cast<unsigned>(dead_count);
6411 return ::mdbx_env_get_hsr(handle_);
6418 assert(ptr !=
nullptr);
6426 assert(ptr !=
nullptr);
6434 assert(ptr !=
nullptr);
6442 assert(ptr !=
nullptr);
6454 other.handle_ =
nullptr;
6459 other.handle_ =
nullptr;
6464 handle_ =
reinterpret_cast<MDBX_txn *
>(uintptr_t(0xDeadBeef));
6469 return handle_ !=
nullptr;
6477 return a.handle_ == b.handle_;
6481 return a.handle_ != b.handle_;
6505inline ::mdbx::env
txn::env() const noexcept { return ::mdbx_txn_env(handle_); }
6554inline ::mdbx::map_handle
6561 assert(map.
dbi != 0);
6565inline ::mdbx::map_handle
6572 assert(map.
dbi != 0);
6576inline ::mdbx::map_handle
6581 assert(map.
dbi != 0);
6589 assert(map.
dbi != 0);
6601 assert(map.
dbi != 0);
6613 assert(map.
dbi != 0);
6633inline ::mdbx::map_handle
6639inline ::mdbx::map_handle
6706 const slice &b)
const noexcept {
6707 return ::mdbx_cmp(handle_, map.
dbi, &a, &b);
6711 const slice &b)
const noexcept {
6712 return ::mdbx_dcmp(handle_, map.
dbi, &a, &b);
6716 const pair &b)
const noexcept {
6717 return compare_keys(map, a.key, b.key);
6721 const pair &b)
const noexcept {
6722 return compare_values(map, a.value, b.value);
6739 const slice &value_at_absence)
const {
6741 const int err =
::mdbx_get(handle_, map.
dbi, &key, &result);
6746 return value_at_absence;
6753 const slice &value_at_absence)
const {
6755 const int err =
::mdbx_get_ex(handle_, map.
dbi, &key, &result, &values_count);
6760 return value_at_absence;
6767 const slice &key)
const {
6776 const slice &value_at_absence)
const {
6804 put(map, key, &value ,
6811 put(map, key, &value ,
6824 size_t value_length) {
6825 slice result(
nullptr, value_length);
6827 put(map, key, &result ,
6833 size_t value_length) {
6834 slice result(
nullptr, value_length);
6836 put(map, key, &result ,
6854 size_t value_length) {
6855 slice result(
nullptr, value_length);
6867 const slice &value) {
6868 const int err = put(map, key,
const_cast<slice *
>(&value),
6881 size_t value_length) {
6882 slice result(
nullptr, value_length);
6889 size_t value_length) {
6890 slice result(
nullptr, value_length);
6904 const int err =
::mdbx_del(handle_, map.
dbi, &key,
nullptr);
6928 const slice &new_value) {
6930 handle_, map.
dbi, &key,
const_cast<slice *
>(&new_value), &old_value,
6934template <
class ALLOCATOR,
typename CAPACITY_POLICY>
6947template <
class ALLOCATOR,
typename CAPACITY_POLICY>
6960template <
class ALLOCATOR,
typename CAPACITY_POLICY>
6974 bool multivalue_order_preserved) {
6976 handle_, map.
dbi,
const_cast<slice *
>(&key),
const_cast<slice *
>(&value),
6982 const size_t value_length,
6983 const void *values_array,
6984 size_t values_count,
put_mode mode,
6985 bool allow_partial) {
6986 MDBX_val args[2] = {{
const_cast<void *
>(values_array), value_length},
6987 {
nullptr, values_count}};
7001 return args[1].iov_len ;
7005 const pair &to)
const {
7013 const slice &to)
const {
7016 &to,
nullptr, &result));
7021 const slice &to)
const {
7024 nullptr, &to,
nullptr, &result));
7029 const slice &from)
const {
7032 nullptr,
nullptr, &result));
7057 other.handle_ =
nullptr;
7062 other.handle_ =
nullptr;
7067 handle_ =
reinterpret_cast<MDBX_cursor *
>(uintptr_t(0xDeadBeef));
7072 return handle_ !=
nullptr;
7082 const cursor &b)
noexcept {
7083 return a.handle_ == b.handle_;
7087 const cursor &b)
noexcept {
7088 return a.handle_ != b.handle_;
7092 bool ignore_nested =
false) noexcept {
7097 bool ignore_nested =
false) {
7107 bool throw_notfound)
7115 bool throw_notfound)
7117 this->
done = cursor.
move(operation, &this->key, &this->value, throw_notfound);
7121 MDBX_val *value,
bool throw_notfound)
const {
7130 if (!throw_notfound)
7142 :
pair(key, value), approximate_quantity(PTRDIFF_MIN) {
7165 bool throw_notfound) {
7170 bool throw_notfound) {
7176 bool throw_notfound) {
7182 bool throw_notfound) {
7188 bool throw_notfound) {
7223 const slice &value)
const {
7252 return ::mdbx::txn(
txn);
7292 slice result(
nullptr, value_length);
7300 size_t value_length) {
7301 slice result(
nullptr, value_length);
7321 slice result(
nullptr, value_length);
7346 slice result(
nullptr, value_length);
7353 size_t value_length) {
7354 slice result(
nullptr, value_length);
7381 bool found =
seek(key);
7382 return found ?
erase(whole_multivalue) : found;
7408template <
class ALLOCATOR,
typename CAPACITY_POLICY>
7410to_string(const ::mdbx::buffer<ALLOCATOR, CAPACITY_POLICY> &buffer) {
7422inline string to_string(const ::mdbx::env::geometry &value) {
7428inline string to_string(const ::mdbx::env::operate_parameters &value) {
7440inline string to_string(const ::mdbx::env::durability &value) {
7446inline string to_string(const ::mdbx::env::reclaiming_options &value) {
7452inline string to_string(const ::mdbx::env::operate_options &value) {
7458inline string to_string(const ::mdbx::env_managed::create_parameters &value) {
7489 return slice.hash_value();
7496#if defined(__LCC__) && __LCC__ >= 126
7497#pragma diagnostic pop
#define MDBX_CXX11_CONSTEXPR
Definition mdbx.h:454
#define MDBX_MAYBE_UNUSED
Definition mdbx.h:530
#define MDBX_CXX14_CONSTEXPR
Definition mdbx.h:476
#define MDBX_NOTHROW_PURE_FUNCTION
The 'pure nothrow' function attribute for optimization.
Definition mdbx.h:259
mode_t mdbx_mode_t
Definition mdbx.h:174
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
Definition mdbx.h:5178
#define LIBMDBX_API
Definition mdbx.h:638
#define LIBMDBX_API_TYPE
Definition mdbx.h:653
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the table. .
Definition mdbx.h:810
LIBMDBX_API int mdbx_replace_ex(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *new_data, MDBX_val *old_data, MDBX_put_flags_t flags, MDBX_preserve_func preserver, void *preserver_context)
pthread_t mdbx_tid_t
Definition mdbx.h:173
struct MDBX_env MDBX_env
Opaque structure for a database environment.
Definition mdbx.h:742
int mdbx_filehandle_t
Definition mdbx.h:171
pid_t mdbx_pid_t
Definition mdbx.h:172
@ MDBX_MAX_PAGESIZE
Definition mdbx.h:824
@ MDBX_MAXDATASIZE
Definition mdbx.h:818
@ MDBX_MAX_DBI
Definition mdbx.h:815
@ MDBX_MIN_PAGESIZE
Definition mdbx.h:821
libmdbx build information
Definition mdbx.h:680
The fours integers markers (aka "canary") associated with the environment.
Definition mdbx.h:4526
Latency of commit stages in 1/65536 of seconds units.
Definition mdbx.h:4182
Information about the environment.
Definition mdbx.h:2866
Statistics for a table in the environment.
Definition mdbx.h:2818
Information about the transaction.
Definition mdbx.h:4080
libmdbx version information
Definition mdbx.h:663
LIBMDBX_API int mdbx_cursor_del(MDBX_cursor *cursor, MDBX_put_flags_t flags)
Delete current key/data pair.
LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment)
Sequence generation for a table.
LIBMDBX_API int mdbx_get_equal_or_great(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data)
Get equal or great item from a table.
LIBMDBX_API int mdbx_cursor_scan(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context, MDBX_cursor_op start_op, MDBX_cursor_op turn_op, void *arg)
Сканирует таблицу с использованием передаваемого предиката, с уменьшением сопутствующих накладных рас...
LIBMDBX_API int mdbx_canary_put(MDBX_txn *txn, const MDBX_canary *canary)
Set integers markers (aka "canary") associated with the environment.
LIBMDBX_API int mdbx_canary_get(const MDBX_txn *txn, MDBX_canary *canary)
Returns fours integers markers (aka "canary") associated with the environment.
MDBX_put_flags_t
Data changing flags.
Definition mdbx.h:1686
int() MDBX_cmp_func(const MDBX_val *a, const MDBX_val *b) noexcept
A callback function used to compare two keys in a table.
Definition mdbx.h:4586
LIBMDBX_API int mdbx_cursor_scan_from(MDBX_cursor *cursor, MDBX_predicate_func *predicate, void *context, MDBX_cursor_op from_op, MDBX_val *from_key, MDBX_val *from_value, MDBX_cursor_op turn_op, void *arg)
LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data)
Delete items from a table.
LIBMDBX_API int mdbx_get_ex(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data, size_t *values_count)
Get items from a table and optionally number of data items for a given key.
LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *pcount)
Return count of duplicates for current key.
LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store by cursor.
LIBMDBX_API int mdbx_put(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store items into a table.
LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a table.
LIBMDBX_API int mdbx_cursor_get(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op)
Retrieve by cursor.
LIBMDBX_API int mdbx_get(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data)
Get items from a table.
@ MDBX_MULTIPLE
Definition mdbx.h:1723
@ MDBX_ALLDUPS
Definition mdbx.h:1706
@ MDBX_CURRENT
Definition mdbx.h:1701
@ MDBX_APPENDDUP
Definition mdbx.h:1719
@ MDBX_APPEND
Definition mdbx.h:1714
@ MDBX_UPSERT
Definition mdbx.h:1688
@ MDBX_RESERVE
Definition mdbx.h:1710
@ MDBX_NOOVERWRITE
Definition mdbx.h:1691
LIBMDBX_API int mdbx_cursor_on_first_dup(const MDBX_cursor *cursor)
Определяет стоит ли курсор на первом или единственном мульти-значении соответствующем ключу.
LIBMDBX_API int mdbx_cursor_renew(const MDBX_txn *txn, MDBX_cursor *cursor)
Renew a cursor handle for use within the given transaction.
LIBMDBX_API int mdbx_cursor_unbind(MDBX_cursor *cursor)
Unbind cursor from a transaction.
LIBMDBX_API MDBX_cursor * mdbx_cursor_create(void *context)
Create a cursor handle but not bind it to transaction nor DBI-handle.
LIBMDBX_API MDBX_dbi mdbx_cursor_dbi(const MDBX_cursor *cursor)
Return the cursor's table handle.
MDBX_cursor_op
Cursor operationsThis is the set of all operations for retrieving data using a cursor.
Definition mdbx.h:1763
LIBMDBX_API int mdbx_cursor_compare(const MDBX_cursor *left, const MDBX_cursor *right, bool ignore_multival)
Сравнивает позицию курсоров.
LIBMDBX_API int mdbx_cursor_on_last_dup(const MDBX_cursor *cursor)
Определяет стоит ли курсор на последнем или единственном мульти-значении соответствующем ключу.
LIBMDBX_API int mdbx_cursor_on_first(const MDBX_cursor *cursor)
Determines whether the cursor is pointed to the first key-value pair or not.
struct MDBX_cursor MDBX_cursor
Opaque structure for navigating through a table.
Definition mdbx.h:772
LIBMDBX_API int mdbx_cursor_set_userctx(MDBX_cursor *cursor, void *ctx)
Set application information associated with the cursor.
LIBMDBX_API int mdbx_cursor_open(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_cursor **cursor)
Create a cursor handle for the specified transaction and DBI handle.
LIBMDBX_API int mdbx_cursor_eof(const MDBX_cursor *cursor)
Determines whether the cursor is pointed to a key-value pair or not, i.e. was not positioned or point...
LIBMDBX_API int mdbx_cursor_bind(const MDBX_txn *txn, MDBX_cursor *cursor, MDBX_dbi dbi)
Bind cursor to specified transaction and DBI-handle.
LIBMDBX_API void * mdbx_cursor_get_userctx(const MDBX_cursor *cursor)
Get the application information associated with the MDBX_cursor.
LIBMDBX_API void mdbx_cursor_close(MDBX_cursor *cursor)
Close a cursor handle.
LIBMDBX_API MDBX_txn * mdbx_cursor_txn(const MDBX_cursor *cursor)
Return the cursor's transaction handle.
LIBMDBX_API int mdbx_txn_release_all_cursors(const MDBX_txn *txn, bool unbind)
Unbind or closes all cursors of a given transaction.
LIBMDBX_API int mdbx_cursor_on_last(const MDBX_cursor *cursor)
Determines whether the cursor is pointed to the last key-value pair or not.
LIBMDBX_API int mdbx_cursor_copy(const MDBX_cursor *src, MDBX_cursor *dest)
Copy cursor position and state.
@ MDBX_GET_CURRENT
Definition mdbx.h:1778
@ MDBX_GET_BOTH
Definition mdbx.h:1771
@ MDBX_TO_KEY_EQUAL
Definition mdbx.h:1858
@ MDBX_GET_BOTH_RANGE
Definition mdbx.h:1775
@ MDBX_SET_KEY
Definition mdbx.h:1818
@ MDBX_FIRST_DUP
Definition mdbx.h:1768
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition mdbx.h:1857
@ MDBX_GET_MULTIPLE
Definition mdbx.h:1783
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition mdbx.h:1868
@ MDBX_NEXT_NODUP
Definition mdbx.h:1803
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition mdbx.h:1865
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition mdbx.h:1866
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition mdbx.h:1871
@ MDBX_PREV_MULTIPLE
Definition mdbx.h:1825
@ MDBX_SET_RANGE
Definition mdbx.h:1821
@ MDBX_LAST_DUP
Definition mdbx.h:1789
@ MDBX_PREV
Definition mdbx.h:1806
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition mdbx.h:1873
@ MDBX_TO_PAIR_GREATER_THAN
Definition mdbx.h:1874
@ MDBX_LAST
Definition mdbx.h:1786
@ MDBX_TO_KEY_LESSER_THAN
Definition mdbx.h:1856
@ MDBX_PREV_DUP
Definition mdbx.h:1809
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition mdbx.h:1864
@ MDBX_SET
Definition mdbx.h:1815
@ MDBX_NEXT
Definition mdbx.h:1792
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition mdbx.h:1859
@ MDBX_TO_PAIR_LESSER_THAN
Definition mdbx.h:1870
@ MDBX_NEXT_MULTIPLE
Definition mdbx.h:1800
@ MDBX_PREV_NODUP
Definition mdbx.h:1812
@ MDBX_TO_PAIR_EQUAL
Definition mdbx.h:1872
@ MDBX_NEXT_DUP
Definition mdbx.h:1795
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition mdbx.h:1867
@ MDBX_TO_KEY_GREATER_THAN
Definition mdbx.h:1860
@ MDBX_FIRST
Definition mdbx.h:1765
LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name)
Переименовает таблицу по DBI-дескриптору
LIBMDBX_API int mdbx_dbi_rename2(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *name)
Переименовает таблицу по DBI-дескриптору
LIBMDBX_API int mdbx_dbi_close(MDBX_env *env, MDBX_dbi dbi)
Close a table handle. Normally unnecessary.
LIBMDBX_API int mdbx_dbi_open(MDBX_txn *txn, const char *name, MDBX_db_flags_t flags, MDBX_dbi *dbi)
Open or Create a named table in the environment.
LIBMDBX_API int mdbx_dbi_open2(MDBX_txn *txn, const MDBX_val *name, MDBX_db_flags_t flags, MDBX_dbi *dbi)
Open or Create a named table in the environment.
uint32_t MDBX_dbi
A handle for an individual table (key-value spaces) in the environment.
Definition mdbx.h:765
MDBX_db_flags_t
Table flags.
Definition mdbx.h:1636
@ MDBX_INTEGERDUP
Definition mdbx.h:1660
@ MDBX_DB_ACCEDE
Definition mdbx.h:1678
@ MDBX_DB_DEFAULTS
Definition mdbx.h:1638
@ MDBX_REVERSEKEY
Definition mdbx.h:1641
@ MDBX_DUPFIXED
Definition mdbx.h:1655
@ MDBX_INTEGERKEY
Definition mdbx.h:1651
@ MDBX_REVERSEDUP
Definition mdbx.h:1663
@ MDBX_CREATE
Definition mdbx.h:1666
@ MDBX_DUPSORT
Definition mdbx.h:1644
MDBX_log_level_t
Definition mdbx.h:885
MDBX_debug_flags_t
Runtime debug flags.
Definition mdbx.h:942
LIBMDBX_API int mdbx_env_set_hsr(MDBX_env *env, MDBX_hsr_func *hsr_callback)
Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which ...
int() MDBX_hsr_func(const MDBX_env *env, const MDBX_txn *txn, mdbx_pid_t pid, mdbx_tid_t tid, uint64_t laggard, unsigned gap, size_t space, int retry) noexcept
A Handle-Slow-Readers callback function to resolve database full/overflow issue due to a reader(s) wh...
Definition mdbx.h:6358
MDBX_error_t
Errors and return codes.
Definition mdbx.h:1882
@ MDBX_FIRST_LMDB_ERRCODE
Definition mdbx.h:1896
@ MDBX_BAD_TXN
Definition mdbx.h:1962
@ MDBX_LAST_LMDB_ERRCODE
Definition mdbx.h:1976
@ MDBX_SUCCESS
Definition mdbx.h:1884
@ MDBX_NOTFOUND
Definition mdbx.h:1899
@ MDBX_RESULT_TRUE
Definition mdbx.h:1890
@ MDBX_BUSY
Definition mdbx.h:1980
@ MDBX_EINVAL
Definition mdbx.h:2054
@ MDBX_ENOMEM
Definition mdbx.h:2056
@ MDBX_FIRST_ADDED_ERRCODE
Definition mdbx.h:1983
@ MDBX_RESULT_FALSE
Definition mdbx.h:1887
@ MDBX_LAST_ADDED_ERRCODE
Definition mdbx.h:2033
@ MDBX_KEYEXIST
Definition mdbx.h:1893
MDBX_env_flags_t
Environment flags.
Definition mdbx.h:1076
LIBMDBX_API int mdbx_estimate_distance(const MDBX_cursor *first, const MDBX_cursor *last, ptrdiff_t *distance_items)
Estimates the distance between cursors as a number of elements.
LIBMDBX_API int mdbx_estimate_move(const MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op move_op, ptrdiff_t *distance_items)
Estimates the move distance.
LIBMDBX_API int mdbx_estimate_range(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *begin_key, const MDBX_val *begin_data, const MDBX_val *end_key, const MDBX_val *end_data, ptrdiff_t *distance_items)
Estimates the size of a range as a number of elements.
LIBMDBX_API int mdbx_env_get_option(const MDBX_env *env, const MDBX_option_t option, uint64_t *pvalue)
Gets the value of extra runtime options from an environment.
int mdbx_env_set_syncperiod(MDBX_env *env, unsigned seconds_16dot16)
Sets relative period since the last unsteady commit to force flush the data buffers to disk,...
Definition mdbx.h:3118
MDBX_option_t
MDBX environment extra runtime options.
Definition mdbx.h:2158
LIBMDBX_API int mdbx_env_set_geometry(MDBX_env *env, intptr_t size_lower, intptr_t size_now, intptr_t size_upper, intptr_t growth_step, intptr_t shrink_threshold, intptr_t pagesize)
Set all size-related parameters of environment, including page size and the min/max size of the memor...
int mdbx_env_set_syncbytes(MDBX_env *env, size_t threshold)
Sets threshold to force flush the data buffers to disk, even any of MDBX_SAFE_NOSYNC flag in the envi...
Definition mdbx.h:3057
LIBMDBX_API int mdbx_env_set_option(MDBX_env *env, const MDBX_option_t option, uint64_t value)
Sets the value of a extra runtime options for an environment.
LIBMDBX_API int mdbx_env_set_userctx(MDBX_env *env, void *ctx)
Sets application information (a context pointer) associated with the environment.
LIBMDBX_API int mdbx_env_set_flags(MDBX_env *env, MDBX_env_flags_t flags, bool onoff)
Set environment flags.
@ MDBX_opt_txn_dp_initial
Controls the in-process initial allocation size for dirty pages list of a write transaction....
Definition mdbx.h:2262
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition mdbx.h:2258
@ MDBX_opt_prefault_write_enable
Controls prevention of page-faults of reclaimed and allocated pages in the MDBX_WRITEMAP mode by clea...
Definition mdbx.h:2362
@ MDBX_opt_max_db
Controls the maximum number of named tables for the environment.
Definition mdbx.h:2167
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition mdbx.h:2329
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition mdbx.h:2190
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition mdbx.h:2294
@ MDBX_opt_spill_parent4child_denominator
Controls the in-process how much of the parent transaction dirty pages will be spilled while start ea...
Definition mdbx.h:2317
@ MDBX_opt_loose_limit
Controls the in-process limit to grow a cache of dirty pages for reuse in the current transaction.
Definition mdbx.h:2230
@ MDBX_opt_rp_augment_limit
Controls the in-process limit to grow a list of reclaimed/recycled page's numbers for finding a seque...
Definition mdbx.h:2217
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition mdbx.h:2184
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition mdbx.h:2278
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h:2196
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition mdbx.h:2244
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition mdbx.h:2357
LIBMDBX_API int mdbx_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes)
Retrieve statistics for a table.
LIBMDBX_API uint64_t mdbx_txn_id(const MDBX_txn *txn)
Return the transaction's ID.
LIBMDBX_API intptr_t mdbx_limits_valsize_max(intptr_t pagesize, MDBX_db_flags_t flags)
Returns maximal data size in bytes for given page size and table flags, or -1 if pagesize is invalid.
LIBMDBX_API int mdbx_env_info_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_envinfo *info, size_t bytes)
Return information about the MDBX environment.
int mdbx_env_get_maxreaders(const MDBX_env *env, unsigned *readers)
Get the maximum number of threads/reader slots for the environment.
Definition mdbx.h:3774
int mdbx_env_get_syncperiod(const MDBX_env *env, unsigned *period_seconds_16dot16)
Get relative period since the last unsteady commit to force flush the data buffers to disk,...
Definition mdbx.h:3138
LIBMDBX_API int mdbx_env_get_maxkeysize_ex(const MDBX_env *env, MDBX_db_flags_t flags)
Returns the maximum size of keys can put.
LIBMDBX_API int mdbx_env_get_maxvalsize_ex(const MDBX_env *env, MDBX_db_flags_t flags)
Returns the maximum size of data we can put.
LIBMDBX_API int mdbx_env_stat_ex(const MDBX_env *env, const MDBX_txn *txn, MDBX_stat *stat, size_t bytes)
Return statistics about the MDBX environment.
LIBMDBX_API int mdbx_env_get_pairsize4page_max(const MDBX_env *env, MDBX_db_flags_t flags)
Returns maximal size of key-value pair to fit in a single page for specified table flags.
int mdbx_env_get_syncbytes(const MDBX_env *env, size_t *threshold)
Get threshold to force flush the data buffers to disk, even any of MDBX_SAFE_NOSYNC flag in the envir...
Definition mdbx.h:3075
LIBMDBX_API intptr_t mdbx_limits_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 with the given...
LIBMDBX_API intptr_t mdbx_limits_txnsize_max(intptr_t pagesize)
Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes for gi...
LIBMDBX_API int mdbx_dbi_dupsort_depthmask(const MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask)
Retrieve depth (bitmask) information of nested dupsort (multi-value) B+trees for given table.
LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt)
Return information about the MDBX transaction.
LIBMDBX_API int mdbx_is_dirty(const MDBX_txn *txn, const void *ptr)
Determines whether the given address is on a dirty database page of the transaction or not.
MDBX_dbi_state_t
DBI state bits returted by mdbx_dbi_flags_ex()
Definition mdbx.h:4872
LIBMDBX_API int mdbx_env_get_valsize4page_max(const MDBX_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 specified ...
LIBMDBX_API int mdbx_env_get_fd(const MDBX_env *env, mdbx_filehandle_t *fd)
Return the file descriptor for the given environment.
LIBMDBX_API void * mdbx_env_get_userctx(const MDBX_env *env)
Returns an application information (a context pointer) associated with the environment.
int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs)
Get the maximum number of named tables for the environment.
Definition mdbx.h:3819
LIBMDBX_API intptr_t mdbx_limits_keysize_max(intptr_t pagesize, MDBX_db_flags_t flags)
Returns maximal key size in bytes for given page size and table flags, or -1 if pagesize is invalid.
LIBMDBX_API int mdbx_reader_list(const MDBX_env *env, MDBX_reader_list_func *func, void *ctx)
Enumerate the entries in the reader lock table.
LIBMDBX_API intptr_t mdbx_limits_pairsize4page_max(intptr_t pagesize, MDBX_db_flags_t flags)
Returns maximal size of key-value pair to fit in a single page with the given size and table flags,...
LIBMDBX_API intptr_t mdbx_limits_dbsize_max(intptr_t pagesize)
Returns maximal database size in bytes for given page size, or -1 if pagesize is invalid.
LIBMDBX_API intptr_t mdbx_limits_dbsize_min(intptr_t pagesize)
Returns minimal database size in bytes for given page size, or -1 if pagesize is invalid.
LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags)
Get environment flags.
LIBMDBX_API int mdbx_dbi_flags_ex(const MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state)
Retrieve the DB flags and status for a table handle.
LIBMDBX_API int mdbx_txn_break(MDBX_txn *txn)
Marks transaction as broken.
LIBMDBX_API int mdbx_txn_set_userctx(MDBX_txn *txn, void *ctx)
Sets application information associated (a context pointer) with the transaction.
LIBMDBX_API int mdbx_txn_park(MDBX_txn *txn, bool autounpark)
Переводит читающую транзакцию в "припаркованное" состояние.
LIBMDBX_API int mdbx_txn_unpark(MDBX_txn *txn, bool restart_if_ousted)
Распарковывает ранее припаркованную читающую транзакцию.
MDBX_txn_flags_t
Definition mdbx.h:1537
LIBMDBX_API void * mdbx_txn_get_userctx(const MDBX_txn *txn)
Returns an application information (a context pointer) associated with the transaction.
int mdbx_txn_begin(MDBX_env *env, MDBX_txn *parent, MDBX_txn_flags_t flags, MDBX_txn **txn)
Create a transaction for use with the environment.
Definition mdbx.h:4047
struct MDBX_txn MDBX_txn
Opaque structure for a transaction handle.
Definition mdbx.h:753
LIBMDBX_API int mdbx_txn_reset(MDBX_txn *txn)
Reset a read-only transaction.
LIBMDBX_API int mdbx_txn_renew(MDBX_txn *txn)
Renew a read-only transaction.
LIBMDBX_API MDBX_txn_flags_t mdbx_txn_flags(const MDBX_txn *txn)
Return the transaction's flags.
@ MDBX_TXN_RDONLY
Definition mdbx.h:1548
@ MDBX_TXN_RDONLY_PREPARE
Definition mdbx.h:1557
@ MDBX_TXN_READWRITE
Definition mdbx.h:1542
@ MDBX_TXN_TRY
Definition mdbx.h:1563
bool rename_map(const ::mdbx::slice &old_name, const ::mdbx::slice &new_name, bool throw_if_absent=false)
Переименовывает таблицу ключ-значение.
buffer & assign(const void *begin, const void *end, bool make_reference=false)
Definition mdbx.h++:2721
buffer(size_t head_room, const struct slice &src, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2421
env_managed(const char *pathname, const operate_parameters &, bool accede=true)
constexpr bool is_reference() const noexcept
Checks whether the buffer just refers to data located outside the buffer, rather than stores it.
Definition mdbx.h++:2203
cursor_managed(void *your_context=nullptr)
Creates a new managed cursor with underlying object.
Definition mdbx.h++:5277
env & set_sync_period(const duration &period)
Sets relative period since the last unsteady commit to force flush the data buffers to disk,...
txn_managed start_nested()
Start nested write transaction.
extra_runtime_option
MDBX environment extra runtime options.
Definition mdbx.h++:4078
static buffer key_from(silo &&src) noexcept
Definition mdbx.h++:3092
env_managed & operator=(env_managed &&other) noexcept
Definition mdbx.h++:4315
constexpr byte * byte_ptr() noexcept
Returns casted to pointer to byte an address of data.
Definition mdbx.h++:2241
constexpr buffer & set_end(const void *ptr)
Sets the length by specifying the end of the data.
Definition mdbx.h++:2322
constexpr allocator_type get_allocator() const
Returns the associated allocator.
Definition mdbx.h++:2188
bool drop_map(const ::std::string_view &name, bool throw_if_absent=false)
Drop key-value map.
Definition mdbx.h++:4536
env_managed(const char *pathname, const create_parameters &, const operate_parameters &, bool accede=true)
map_handle(const map_handle &) noexcept=default
void reserve_tailroom(size_t wanna_tailroom)
Reserves space after the payload.
Definition mdbx.h++:2666
::MDBX_db_flags_t flags
Definition mdbx.h++:3532
path get_path() const
Return the path that was used for opening the environment.
static buffer hex_decode(const ::mdbx::slice &source, bool ignore_spaces=false, const allocator_type &allocator=allocator_type())
Decodes hexadecimal dump from the slice content to returned buffer.
Definition mdbx.h++:2599
int64_t as_int64_adapt() const
Definition mdbx.h++:2522
constexpr ::std::basic_string< CHAR, T, A > as_string(const A &allocator=A()) const
Definition mdbx.h++:2812
move_result to_exact_key_value_lesser_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5111
move_result previous_multiple_samelength(bool throw_notfound=false)
Definition mdbx.h++:5188
buffer encode_base64(unsigned wrap_width=0, const allocator_type &allocator=allocator_type()) const
Returns a new buffer with a Base64 dump of the slice content.
Definition mdbx.h++:2592
static buffer key_from(const double *ieee754_64bit)
Definition mdbx.h++:3104
static buffer base58(const POD &pod, unsigned wrap_width=0, const allocator_type &allocator=allocator_type())
Returns a new buffer with a Base58 dump of the given pod.
Definition mdbx.h++:2561
static bool remove(const ::std::wstring &pathname, const remove_mode mode=just_remove)
constexpr const char * end_char_ptr() const noexcept
Returns casted to const pointer to char an end of data.
Definition mdbx.h++:2260
constexpr byte & operator[](size_t n) noexcept
Accesses the specified byte of data chunk.
Definition mdbx.h++:2870
constexpr const char * char_ptr() const noexcept
Returns casted to const pointer to char an address of data.
Definition mdbx.h++:2255
buffer & assign(const char *c_str, bool make_reference=false)
Definition mdbx.h++:2735
void reserve(size_t wanna_headroom, size_t wanna_tailroom)
Reserves storage space.
Definition mdbx.h++:2648
constexpr size_t tailroom() const noexcept
Returns the number of bytes that available in currently allocated storage after the currently data en...
Definition mdbx.h++:2224
buffer & assign(const struct slice &src, bool make_reference=false)
Definition mdbx.h++:2701
void reserve_headroom(size_t wanna_headroom)
Reserves space before the payload.
Definition mdbx.h++:2663
constexpr byte * end_byte_ptr() noexcept
Returns casted to pointer to byte an end of data.
Definition mdbx.h++:2249
constexpr txn() noexcept=default
constexpr map_handle() noexcept
Definition mdbx.h++:3525
durability
Durability level.
Definition mdbx.h++:3689
@ lazy_weak_tail
Definition mdbx.h++:3692
@ robust_synchronous
Definition mdbx.h++:3690
@ half_synchronous_weak_last
Definition mdbx.h++:3691
constexpr buffer(const buffer &src, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2380
::std::allocator_traits< allocator_type > allocator_traits
Definition mdbx.h++:1682
constexpr byte operator[](size_t n) const noexcept
Accesses the specified byte of data chunk.
Definition mdbx.h++:2863
static buffer base64_decode(const ::mdbx::slice &source, bool ignore_spaces=false, const allocator_type &allocator=allocator_type())
Decodes Base64 dump from the slice content to returned buffer.
Definition mdbx.h++:2618
constexpr void * data() noexcept
Return a pointer to the beginning of the referenced data.
Definition mdbx.h++:2291
buffer & append_decoded_hex(const struct slice &data, bool ignore_spaces=false)
Definition mdbx.h++:2978
map_handle & operator=(const map_handle &) noexcept=default
duration sync_period() const
Gets relative period since the last unsteady commit that used to force flush the data buffers to disk...
buffer(const ::std::basic_string_view< CHAR, T > &view, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2366
constexpr int32_t as_int32() const
Definition mdbx.h++:2507
constexpr const void * end() const noexcept
Return a const pointer to the end of the referenced data.
Definition mdbx.h++:2286
buffer & assign_freestanding(const void *ptr, size_t bytes)
Definition mdbx.h++:2674
constexpr void swap(buffer &other) noexcept(swap_alloc::is_nothrow())
Definition mdbx.h++:2682
buffer & operator=(const buffer &src)
Definition mdbx.h++:2755
estimate_result estimate(move_operation operation, slice &key) const
uint16_t as_uint16_adapt() const
Definition mdbx.h++:2516
buffer & append_u16(uint_fast16_t u16)
Definition mdbx.h++:3003
static bool remove(const char *pathname, const remove_mode mode=just_remove)
constexpr size_t headroom() const noexcept
Returns the number of bytes that available in currently allocated storage ahead the currently beginni...
Definition mdbx.h++:2217
move_result to_pair_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5141
env & copy(const wchar_t *destination, bool compactify, bool force_dynamic_size=false)
void safe_remove_suffix(size_t n)
Drops the last "n" bytes from the data chunk.
Definition mdbx.h++:2859
void safe_remove_prefix(size_t n)
Drops the first "n" bytes from the data chunk.
Definition mdbx.h++:2855
bool is_readwrite() const
Checks whether the transaction is read-write.
Definition mdbx.h++:4378
map_handle open_map_accede(const ::std::string_view &name) const
Open existing key-value map.
move_result move(move_operation operation, const slice &key, const slice &value, bool throw_notfound)
Definition mdbx.h++:5041
constexpr const void * data() const noexcept
Return a const pointer to the beginning of the referenced data.
Definition mdbx.h++:2281
static buffer key_from(const ::std::basic_string< CHAR, T, A > &src, bool make_reference=false)
Definition mdbx.h++:3087
env_managed(const wchar_t *pathname, const operate_parameters &, bool accede=true)
move_result to_pair_lesser_than(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5133
buffer base64_decode(bool ignore_spaces=false, const allocator_type &allocator=allocator_type()) const
Decodes Base64 dump from the buffer content to new returned buffer.
Definition mdbx.h++:2642
bool clear_map(const char *name, bool throw_if_absent=false)
constexpr env() noexcept=default
buffer & add_header(const void *src, size_t bytes)
Definition mdbx.h++:2936
uint8_t as_uint8_adapt() const
Definition mdbx.h++:2517
move_result to_pair_exact(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5145
buffer encode_base58(unsigned wrap_width=0, const allocator_type &allocator=allocator_type()) const
Returns a new buffer with a Base58 dump of the slice content.
Definition mdbx.h++:2584
void rename_map(map_handle map, const ::std::string_view &new_name)
Переименовывает таблицу ключ-значение.
constexpr size_t size() const noexcept
Returns the number of bytes.
Definition mdbx.h++:2796
env & copy(filehandle fd, bool compactify, bool force_dynamic_size=false)
Copy an environment to the specified file descriptor.
typename ::std::allocator_traits< ALLOCATOR >::template rebind_alloc< uint64_t > allocator_type
Definition mdbx.h++:1678
buffer(size_t head_room, const buffer &src, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2430
buffer & assign(const ::std::basic_string< CHAR, T, A > &str, bool make_reference=false)
Definition mdbx.h++:2730
env_managed(const ::mdbx::filesystem::path &pathname, const operate_parameters &, bool accede=true)
Open existing database.
constexpr int16_t as_int16() const
Definition mdbx.h++:2508
static buffer key_from_jsonInteger(const int64_t json_integer)
Definition mdbx.h++:3124
static buffer hex(const POD &pod, bool uppercase=false, unsigned wrap_width=0, const allocator_type &allocator=allocator_type())
Returns a new buffer with a hexadecimal dump of the given pod.
Definition mdbx.h++:2552
static bool remove(const ::std::string &pathname, const remove_mode mode=just_remove)
constexpr map_handle(MDBX_dbi dbi) noexcept
Definition mdbx.h++:3526
void put(const pair &kv, put_mode mode)
Definition mdbx.h++:5238
move_result current(bool throw_notfound=true) const
Definition mdbx.h++:5065
env & copy(const char *destination, bool compactify, bool force_dynamic_size=false)
move_result to_previous_last_multi(bool throw_notfound=true)
Definition mdbx.h++:5056
static buffer key_from(const float ieee754_32bit)
Definition mdbx.h++:3132
static bool remove(const ::mdbx::filesystem::path &pathname, const remove_mode mode=just_remove)
Removes the environment's files in a proper and multiprocess-safe way.
bool drop_map(const char *name, bool throw_if_absent=false)
Drops key-value map using name.
bool is_same_or_after_than(const cursor &other, bool ignore_nested=false) const
Definition mdbx.h++:4851
size_t unbind_all_cursors() const
Unbind all cursors.
Definition mdbx.h++:4423
static buffer hex(const ::mdbx::slice &source, bool uppercase=false, unsigned wrap_width=0, const allocator_type &allocator=allocator_type())
Returns a new buffer with a hexadecimal dump of the slice content.
Definition mdbx.h++:2528
void upsert(map_handle map, const pair &kv)
Definition mdbx.h++:4650
move_result to_key_greater_or_equal(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:5097
constexpr bool empty() const noexcept
Checks whether the string is empty.
Definition mdbx.h++:2786
bool is_same_position(const cursor &other, bool ignore_nested=false) const
Definition mdbx.h++:4843
constexpr ::std::span< byte > bytes()
Definition mdbx.h++:2468
buffer(const buffer &src, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2346
bool is_after_than(const cursor &other, bool ignore_nested=false) const
Definition mdbx.h++:4847
static buffer base58_decode(const ::mdbx::slice &source, bool ignore_spaces=false, const allocator_type &allocator=allocator_type())
Decodes Base58 dump from the slice content to returned buffer.
Definition mdbx.h++:2609
buffer & operator=(const ::std::basic_string_view< CHAR, T > &view) noexcept
Definition mdbx.h++:2768
uint32_t as_uint32_adapt() const
Definition mdbx.h++:2515
buffer(size_t head_room, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2408
constexpr buffer() noexcept=default
static buffer key_from_double(const double ieee754_64bit)
Definition mdbx.h++:3096
void remove_suffix(size_t n) noexcept
Drops the last "n" bytes from the data chunk.
Definition mdbx.h++:2851
env_managed & operator=(const env_managed &)=delete
map_handle create_map(const ::std::string_view &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.
Definition mdbx.h++:4528
buffer & assign(struct slice &&src, bool make_reference=false)
Definition mdbx.h++:2709
static size_t default_pagesize() noexcept
Returns default page size for current system/platform.
Definition mdbx.h++:3794
move_result to_next_first_multi(bool throw_notfound=true)
Definition mdbx.h++:5074
buffer & assign(const void *ptr, size_t bytes, bool make_reference=false)
Definition mdbx.h++:2696
bool clear_map(const ::mdbx::slice &name, bool throw_if_absent=false)
void clear_and_reserve(size_t whole_capacity, size_t headroom=0) noexcept
Clears the contents and reserve storage.
Definition mdbx.h++:2838
static buffer base64(const POD &pod, unsigned wrap_width=0, const allocator_type &allocator=allocator_type())
Returns a new buffer with a Base64 dump of the given pod.
Definition mdbx.h++:2569
MDBX_txn * handle_
Definition mdbx.h++:4340
bool starts_with(const struct slice &prefix) const noexcept
Checks if the data starts with the given prefix.
Definition mdbx.h++:2824
constexpr size_t length() const noexcept
Returns the number of bytes.
Definition mdbx.h++:2306
static buffer key_from_u64(const uint64_t unsigned_int64)
Definition mdbx.h++:3108
move_result move(move_operation operation, const slice &key, bool throw_notfound)
Definition mdbx.h++:5037
mode
Operation mode.
Definition mdbx.h++:3681
@ write_mapped_io
Definition mdbx.h++:3684
@ readonly
Definition mdbx.h++:3682
@ write_file_io
Definition mdbx.h++:3683
move_result move(move_operation operation, bool throw_notfound)
Definition mdbx.h++:5034
constexpr byte at(size_t n) const
Accesses the specified byte of data chunk with bounds checking.
Definition mdbx.h++:2877
bool scan_from(CALLABLE_PREDICATE predicate, slice &from, move_operation start=key_greater_or_equal, move_operation turn=next)
Definition mdbx.h++:4983
operator::mdbx::txn() const
Definition mdbx.h++:5219
constexpr int8_t as_int8() const
Definition mdbx.h++:2509
buffer & append_base64(const struct slice &data, unsigned wrap_width=0)
Definition mdbx.h++:2974
MDBX_env * handle_
Definition mdbx.h++:3574
static buffer key_from(const ::std::basic_string_view< CHAR, T > &src, bool make_reference=false)
Definition mdbx.h++:3076
move_result to_exact_key_value_greater_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5121
buffer & append_byte(uint_fast8_t byte)
Definition mdbx.h++:3001
commit_latency commit_get_latency()
Commit all the operations of a transaction into the database and return latency information.
Definition mdbx.h++:4794
static buffer base58(const ::mdbx::slice &source, unsigned wrap_width=0, const allocator_type &allocator=allocator_type())
Returns a new buffer with a Base58 dump of the slice content.
Definition mdbx.h++:2537
bool is_same_or_before_than(const cursor &other, bool ignore_nested=false) const
Definition mdbx.h++:4838
bool ends_with(const struct slice &suffix) const noexcept
Checks if the data ends with the given suffix.
Definition mdbx.h++:2830
constexpr POD as_pod() const
Definition mdbx.h++:2481
static buffer key_from_float(const float ieee754_32bit)
Definition mdbx.h++:3128
buffer(const struct slice &src, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2339
constexpr ::std::span< const byte > bytes() const
Definition mdbx.h++:2465
move_result to_first(bool throw_notfound=true)
Definition mdbx.h++:5050
buffer hex_decode(bool ignore_spaces=false, const allocator_type &allocator=allocator_type()) const
Decodes hexadecimal dump from the buffer content to new returned buffer.
Definition mdbx.h++:2626
move_result to_last(bool throw_notfound=true)
Definition mdbx.h++:5080
buffer & operator=(const struct slice &src)
Definition mdbx.h++:2761
constexpr buffer(const void *ptr, size_t bytes, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2384
buffer(const ::mdbx::txn &txn, const struct slice &src, const allocator_type &allocator=allocator_type())
void close()
Explicitly closes the cursor.
constexpr buffer(const ::std::basic_string< CHAR, T, A > &str, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2390
buffer & append_base58(const struct slice &data, unsigned wrap_width=0)
Definition mdbx.h++:2970
bool is_pristine() const
Returns true for a freshly created database, but false if at least one transaction was committed.
move_result to_key_exact(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:5094
constexpr txn_managed() noexcept=default
buffer & assign(::MDBX_val &&src, bool make_reference=false)
Definition mdbx.h++:2715
constexpr bool is_freestanding() const noexcept
Checks whether data chunk stored inside the buffer, otherwise buffer just refers to data located outs...
Definition mdbx.h++:2195
static buffer key_from(const float *ieee754_32bit)
Definition mdbx.h++:3136
constexpr buffer(const ::std::basic_string_view< CHAR, T > &view, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2402
buffer & append_u48(uint_fast64_t u48)
Definition mdbx.h++:3036
move_result next_multiple_samelength(bool throw_notfound=false)
Definition mdbx.h++:5184
env_managed(const ::std::wstring &pathname, const operate_parameters &, bool accede=true)
void append(map_handle map, const pair &kv, bool multivalue_order_preserved=true)
Definition mdbx.h++:4702
cursor_managed & operator=(const cursor_managed &)=delete
CAPACITY_POLICY reservation_policy
Definition mdbx.h++:1683
remove_mode
Deletion modes for remove().
Definition mdbx.h++:3926
static buffer key_from(const int64_t signed_int64)
Definition mdbx.h++:3120
bool scan(CALLABLE_PREDICATE predicate, move_operation start=first, move_operation turn=next)
Definition mdbx.h++:4952
move_result to_current_first_multi(bool throw_notfound=true)
Definition mdbx.h++:5059
buffer & operator=(struct slice &&src)
Definition mdbx.h++:2763
buffer & add_header(const struct slice &chunk)
Definition mdbx.h++:2945
buffer & append_u32(uint_fast32_t u32)
Definition mdbx.h++:3024
buffer & append_decoded_base58(const struct slice &data, bool ignore_spaces=false)
Definition mdbx.h++:2983
bool scan_from(CALLABLE_PREDICATE predicate, pair &from, move_operation start=pair_greater_or_equal, move_operation turn=next)
Definition mdbx.h++:5009
uint128_t as_uint128_adapt() const
Definition mdbx.h++:2512
cursor_managed & operator=(cursor_managed &&other) noexcept
Definition mdbx.h++:5287
::MDBX_dbi_state_t state
Definition mdbx.h++:3533
constexpr ::std::span< const char > chars() const
Definition mdbx.h++:2469
env_managed(env_managed &&)=default
bool poll_sync_to_disk()
Performs non-blocking polling of sync-to-disk thresholds.
Definition mdbx.h++:4135
constexpr uint32_t as_uint32() const
Definition mdbx.h++:2493
cursor_managed(cursor_managed &&)=default
void commit(commit_latency &latency)
Commit all the operations of a transaction into the database and collect latency information.
Definition mdbx.h++:4789
static bool remove(const wchar_t *pathname, const remove_mode mode=just_remove)
size_t key_max(key_mode mode) const
Returns the maximal key size in bytes for specified keys mode.
Definition mdbx.h++:3890
constexpr size_t hash_value() const noexcept
Returns the hash value of the data.
Definition mdbx.h++:2805
move_result to_pair_lesser_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5137
env & copy(const ::mdbx::filesystem::path &destination, bool compactify, bool force_dynamic_size=false)
Make a copy (backup) of an existing environment to the specified path.
static buffer key_from_i32(const int32_t signed_int32)
Definition mdbx.h++:3148
move_result get_multiple_samelength(bool throw_notfound=false)
Definition mdbx.h++:5180
move_result to_key_lesser_than(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:5084
move_result to_next(bool throw_notfound=true)
Definition mdbx.h++:5077
env_managed(const ::std::string &pathname, const operate_parameters &, bool accede=true)
operator::mdbx::map_handle() const
Definition mdbx.h++:5220
size_t dbsize_max() const
Returns the maximal database size in bytes for the environment.
Definition mdbx.h++:3886
move_result get_multiple_samelength(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:5175
buffer encode_hex(bool uppercase=false, unsigned wrap_width=0, const allocator_type &allocator=allocator_type()) const
Returns a new buffer with a hexadecimal dump of the slice content.
Definition mdbx.h++:2575
static buffer wrap(const POD &pod, bool make_reference=false, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2476
static buffer key_from_u32(const uint32_t unsigned_int32)
Definition mdbx.h++:3140
void remove_prefix(size_t n) noexcept
Drops the first "n" bytes from the data chunk.
Definition mdbx.h++:2847
bool drop_map(const ::mdbx::slice &name, bool throw_if_absent=false)
Drop key-value map.
size_t close_all_cursors() const
Close all cursors.
Definition mdbx.h++:4420
static buffer key_from(const uint32_t unsigned_int32)
Definition mdbx.h++:3144
buffer & assign_reference(const void *ptr, size_t bytes)
Definition mdbx.h++:2668
move_result to_key_greater_than(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:5101
constexpr ::std::span< POD > as_span()
Definition mdbx.h++:2461
size_t get_pagesize() const
Returns pagesize of this MDBX environment.
Definition mdbx.h++:3969
void make_freestanding()
Makes buffer owning the data.
Definition mdbx.h++:2330
void put(map_handle map, const pair &kv, put_mode mode)
Definition mdbx.h++:4641
env_managed(const ::std::string &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
buffer & assign(const ::MDBX_val &src, bool make_reference=false)
Definition mdbx.h++:2705
buffer(const char *c_str, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2359
constexpr buffer(const struct slice &src, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2374
void put_multiple_samelength(map_handle map, const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)
Definition mdbx.h++:4723
env_managed(const wchar_t *pathname, const create_parameters &, const operate_parameters &, bool accede=true)
size_t transaction_size_max() const
Returns the maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
Definition mdbx.h++:3901
map_handle open_map(const ::std::string_view &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.
Definition mdbx.h++:4518
int32_t as_int32_adapt() const
Definition mdbx.h++:2523
buffer & assign(const buffer &src, bool make_reference=false)
Definition mdbx.h++:2692
size_t put_multiple_samelength(map_handle map, const slice &key, const VALUE *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
Definition mdbx.h++:4712
constexpr char * char_ptr() noexcept
Returns casted to pointer to char an address of data.
Definition mdbx.h++:2267
bool rename_map(const ::std::string &old_name, const ::std::string &new_name, bool throw_if_absent=false)
Переименовывает таблицу ключ-значение.
buffer(const void *ptr, size_t bytes, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2350
buffer & append(const struct slice &chunk)
Definition mdbx.h++:2932
bool is_empty() const
Checks whether the database is empty.
buffer & append_decoded_base64(const struct slice &data, bool ignore_spaces=false)
Definition mdbx.h++:2988
void close(bool dont_sync=false)
Explicitly closes the environment and release the memory map.
constexpr byte & at(size_t n)
Accesses the specified byte of data chunk with bounds checking.
Definition mdbx.h++:2881
move_result to_pair_greater_than(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5153
constexpr char * end_char_ptr() noexcept
Returns casted to pointer to char an end of data.
Definition mdbx.h++:2275
env & copy(const ::std::string &destination, bool compactify, bool force_dynamic_size=false)
move_operation
Definition mdbx.h++:4862
@ multi_exactkey_lowerboundvalue
Definition mdbx.h++:4877
@ seek_key
Definition mdbx.h++:4879
@ key_lowerbound
Definition mdbx.h++:4881
@ key_greater_than
Definition mdbx.h++:4888
@ multi_find_pair
Definition mdbx.h++:4876
@ key_exact
Definition mdbx.h++:4880
@ get_current
Definition mdbx.h++:4867
@ multi_exactkey_value_greater
Definition mdbx.h++:4898
virtual ~env_managed() noexcept
bool move(move_operation operation, slice &key, slice &value, bool throw_notfound)
Definition mdbx.h++:5045
static buffer key_from(const char(&text)[SIZE], bool make_reference=true)
Definition mdbx.h++:3069
void insert(const pair &kv)
Definition mdbx.h++:5241
buffer & append(const void *src, size_t bytes)
Definition mdbx.h++:2924
cursor_managed(const cursor_managed &)=delete
env_managed(const ::std::wstring &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
void upsert(const pair &kv)
Definition mdbx.h++:5245
move_result to_current_prev_multi(bool throw_notfound=true)
Definition mdbx.h++:5062
void shrink_to_fit()
Reduces memory usage by freeing unused storage space.
Definition mdbx.h++:2843
int16_t as_int16_adapt() const
Definition mdbx.h++:2524
txn_managed & operator=(const txn_managed &)=delete
static buffer key_from(const int32_t signed_int32)
Definition mdbx.h++:3152
constexpr size_t operator()(::mdbx::slice const &slice) const noexcept
Definition mdbx.h++:7488
void clear() noexcept
Clears the contents and storage.
Definition mdbx.h++:2835
static buffer base64(const ::mdbx::slice &source, unsigned wrap_width=0, const allocator_type &allocator=allocator_type())
Returns a new buffer with a Base64 dump of the slice content.
Definition mdbx.h++:2544
constexpr int64_t as_int64() const
Definition mdbx.h++:2506
bool clear_map(const ::std::string_view &name, bool throw_if_absent=false)
Definition mdbx.h++:4541
move_result to_exact_key_value_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5117
constexpr ::std::span< const POD > as_span() const
Definition mdbx.h++:2458
bool rename_map(const char *old_name, const char *new_name, bool throw_if_absent=false)
Переименовывает таблицу ключ-значение.
env_managed(const env_managed &)=delete
static buffer key_from(const double ieee754_64bit)
Definition mdbx.h++:3100
constexpr const byte * byte_ptr() const noexcept
Returns casted to const pointer to byte an address of data.
Definition mdbx.h++:2229
move_result to_current_last_multi(bool throw_notfound=true)
Definition mdbx.h++:5071
value_result try_insert(const pair &kv)
Definition mdbx.h++:5242
constexpr uint128_t as_uint128() const
Definition mdbx.h++:2486
constexpr cursor() noexcept=default
move_result to_key_lesser_or_equal(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:5087
static buffer key_from_i64(const int64_t signed_int64)
Definition mdbx.h++:3116
constexpr const byte * end_byte_ptr() const noexcept
Returns casted to const pointer to byte an end of data.
Definition mdbx.h++:2234
constexpr const struct slice & slice() const noexcept
Definition mdbx.h++:2440
move_result to_pair_greater_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5149
uint64_t as_uint64_adapt() const
Definition mdbx.h++:2514
size_t value_max(value_mode mode) const
Returns the maximal value size in bytes for specified values mode.
Definition mdbx.h++:3896
MDBX_cursor * handle_
Definition mdbx.h++:4810
buffer & append_u8(uint_fast8_t u8)
Definition mdbx.h++:2993
~cursor_managed() noexcept
Definition mdbx.h++:5299
buffer & append_u24(uint_fast32_t u24)
Definition mdbx.h++:3013
constexpr uint8_t as_uint8() const
Definition mdbx.h++:2499
buffer(buffer &&src) noexcept(move_assign_alloc::is_nothrow())
Definition mdbx.h++:2437
MDBX_dbi dbi
Definition mdbx.h++:3524
buffer(const ::std::basic_string< CHAR, T, A > &&)=delete
constexpr uint64_t as_uint64() const
Definition mdbx.h++:2490
move_result to_exact_key_value_lesser_than(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5106
static buffer key_from(const uint64_t unsigned_int64)
Definition mdbx.h++:3112
move_result to_current_next_multi(bool throw_notfound=true)
Definition mdbx.h++:5068
constexpr int128_t as_int128() const
Definition mdbx.h++:2502
buffer & append_u64(uint_fast64_t u64)
Definition mdbx.h++:3050
buffer(const ::std::basic_string< CHAR, T, A > &)=delete
buffer & append_hex(const struct slice &data, bool uppercase=false, unsigned wrap_width=0)
Definition mdbx.h++:2965
constexpr uint16_t as_uint16() const
Definition mdbx.h++:2496
size_t size_max() const
Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
Definition mdbx.h++:4386
constexpr bool is_null() const noexcept
Checks whether the data pointer of the buffer is nullptr.
Definition mdbx.h++:2791
buffer & operator=(buffer &&src) noexcept(move_assign_alloc::is_nothrow())
Definition mdbx.h++:2757
env & copy(const ::std::wstring &destination, bool compactify, bool force_dynamic_size=false)
move_result to_exact_key_value_greater_than(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:5127
txn_managed(const txn_managed &)=delete
constexpr ::std::span< char > chars()
Definition mdbx.h++:2472
static buffer clone(const buffer &src, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2687
buffer(size_t capacity, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2415
constexpr buffer(const ::std::span< POD > &span)
Definition mdbx.h++:2450
size_t value_min(value_mode mode) const noexcept
Returns the minimal value size in bytes for specified values mode.
Definition mdbx.h++:3892
constexpr void * end() noexcept
Return a pointer to the end of the referenced data.
Definition mdbx.h++:2299
value_result try_insert(map_handle map, const pair &kv)
Definition mdbx.h++:4647
buffer & append_producer(PRODUCER &producer)
Definition mdbx.h++:2950
void insert(map_handle map, const pair &kv)
Definition mdbx.h++:4644
buffer & append_producer(const PRODUCER &producer)
Definition mdbx.h++:2958
int128_t as_int128_adapt() const
Definition mdbx.h++:2520
env_managed(const ::mdbx::filesystem::path &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
Create new or open existing database.
static buffer key_from(const char *src, bool make_reference=false)
Definition mdbx.h++:3082
bool rename_map(const ::std::string_view &old_name, const ::std::string_view &new_name, bool throw_if_absent=false)
Переименовывает таблицу ключ-значение.
Definition mdbx.h++:4549
move_result to_key_equal(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:5091
move_result to_previous(bool throw_notfound=true)
Definition mdbx.h++:5053
constexpr buffer(const char *c_str, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:2395
size_t key_min(key_mode mode) const noexcept
Returns the minimal key size in bytes for specified keys mode.
Definition mdbx.h++:3888
int8_t as_int8_adapt() const
Definition mdbx.h++:2525
constexpr size_t capacity() const noexcept
Returns the number of bytes that can be held in currently allocated storage.
Definition mdbx.h++:2210
size_t size_current() const
Returns current write transaction size (i.e.summary volume of dirty pages) in bytes.
Definition mdbx.h++:4390
constexpr buffer & set_length(size_t bytes)
Set length of data.
Definition mdbx.h++:2314
buffer base58_decode(bool ignore_spaces=false, const allocator_type &allocator=allocator_type()) const
Decodes Base58 dump from the buffer content to new returned buffer.
Definition mdbx.h++:2634
constexpr env_managed() noexcept=default
bool fullscan(CALLABLE_PREDICATE predicate, bool backward=false)
Definition mdbx.h++:4977
The chunk of data stored inside the buffer or located outside it.
Definition mdbx.h++:1674
Unmanaged cursor.
Definition mdbx.h++:4808
Managed cursor.
Definition mdbx.h++:5268
Unmanaged database environment.
Definition mdbx.h++:3570
Managed database environment.
Definition mdbx.h++:4246
Unmanaged database transaction.
Definition mdbx.h++:4337
Managed database transaction.
Definition mdbx.h++:4745
static size_t key_min(MDBX_db_flags_t flags) noexcept
Returns the minimal key size in bytes for specified table flags.
Definition mdbx.h++:6081
static constexpr intptr_t compare_fast(const pair &a, const pair &b) noexcept
Three-way fast non-lexicographically length-based comparison.
Definition mdbx.h++:5931
constexpr slice & set_end(const void *ptr)
Sets the length by specifying the end of the slice data.
Definition mdbx.h++:5686
constexpr size_t size() const noexcept
Returns the number of bytes.
Definition mdbx.h++:5699
constexpr slice safe_tail(size_t n) const
Returns the last "n" bytes of the slice.
Definition mdbx.h++:5787
buffer< ALLOCATOR, CAPACITY_POLICY > encode_base58(unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a buffer with a Base58 dump of the slice content.
Definition mdbx.h++:5881
env & set_HandleSlowReaders(MDBX_hsr_func *)
Sets a Handle-Slow-Readers callback to resolve database full/overflow issue due to a reader(s) which ...
Definition mdbx.h++:6405
void * get_context() const noexcept
Returns the application context associated with the transaction.
Definition mdbx.h++:6484
static 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.
Definition mdbx.h++:6119
static constexpr intptr_t compare_fast(const slice &a, const slice &b) noexcept
Three-way fast non-lexicographically length-based comparison.
Definition mdbx.h++:5801
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.
Definition mdbx.h++:6927
value_mode
Kind of the values and sorted multi-values with corresponding comparison.
Definition mdbx.h++:3423
constexpr const void * end() const noexcept
Return a pointer to the ending of the referenced data.
Definition mdbx.h++:5669
MDBX_CXX11_CONSTEXPR_ENUM mdbx::key_mode key_mode() const noexcept
Definition mdbx.h++:5993
constexpr slice safe_head(size_t n) const
Returns the first "n" bytes of the slice.
Definition mdbx.h++:5781
void reset_reading()
Reset read-only transaction.
Definition mdbx.h++:6519
constexpr const char * char_ptr() const noexcept
Returns casted to pointer to char an address of data.
Definition mdbx.h++:5649
void success_or_panic(const char *context_where, const char *func_who) const noexcept
Definition mdbx.h++:5500
void rethrow_captured() const
Definition mdbx.h++:5422
constexpr const void * data() const noexcept
Return a pointer to the beginning of the referenced data.
Definition mdbx.h++:5665
move_result find_multivalue(const slice &key, const slice &value, bool throw_notfound=true)
Definition mdbx.h++:7174
ptrdiff_t estimate(move_operation operation, MDBX_val *key, MDBX_val *value) const
Definition mdbx.h++:7146
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.
Definition mdbx.h++:6605
static size_t dbsize_max(intptr_t pagesize)
Returns the maximal database size in bytes for specified page size.
Definition mdbx.h++:6074
::std::string::allocator_type legacy_allocator
Legacy allocator but it is recommended to use polymorphic_allocator.
Definition mdbx.h++:382
value_result try_update_reserve(map_handle map, const slice &key, size_t value_length)
Definition mdbx.h++:6888
value_result try_insert_reserve(map_handle map, const slice &key, size_t value_length)
Definition mdbx.h++:6832
void close_map(const map_handle &)
Close a key-value map (aka table) handle. Normally unnecessary.
Definition mdbx.h++:6361
env & set_sync_threshold(size_t bytes)
Sets threshold to force flush the data buffers to disk, for non-sync durability modes.
Definition mdbx.h++:6282
move_result(const cursor &cursor, bool throw_notfound)
Definition mdbx.h++:7106
constexpr bool operator!=(const error &a, const error &b) noexcept
Definition mdbx.h++:5441
constexpr bool is_null() const noexcept
Checks whether the slice data pointer is nullptr.
Definition mdbx.h++:5695
ptrdiff_t estimate_from_first(map_handle map, const slice &to) const
Definition mdbx.h++:7020
void remove_suffix(size_t n) noexcept
Drops the last "n" bytes from this slice.
Definition mdbx.h++:5724
slice & assign(const void *ptr, size_t bytes)
Definition mdbx.h++:5582
env & operator=(env &&other) noexcept
Definition mdbx.h++:6007
void unbind()
Unbind cursor from a transaction.
Definition mdbx.h++:7245
slice insert_reserve(map_handle map, const slice &key, size_t value_length)
Definition mdbx.h++:6823
string< ALLOCATOR > as_hex_string(bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a hexadecimal dump of the slice content.
Definition mdbx.h++:5854
void rename_map(map_handle map, const char *new_name)
Переименовывает таблицу ключ-значение.
Definition mdbx.h++:6625
void throw_on_failure() const
Definition mdbx.h++:5475
bool try_update(const slice &key, const slice &value)
Definition mdbx.h++:7332
void update(const slice &key, const slice &value)
Definition mdbx.h++:7327
constexpr info(map_handle::flags flags, map_handle::state state) noexcept
Definition mdbx.h++:5988
int compare_keys(map_handle map, const slice &a, const slice &b) const noexcept
Compare two keys according to a particular key-value map (aka table).
Definition mdbx.h++:6705
constexpr slice & set_length(size_t bytes)
Set slice length.
Definition mdbx.h++:5681
txn & set_context(void *your_context)
Sets the application context associated with the transaction.
Definition mdbx.h++:6488
txn_managed start_write(txn &parent)
Starts write (read-write) transaction.
Definition mdbx.h++:6438
env::durability get_durability() const
Returns current durability mode.
Definition mdbx.h++:6213
uint64_t sequence(map_handle map) const
Definition mdbx.h++:6692
void upsert(const slice &key, const slice &value)
Definition mdbx.h++:7315
bool is_clean() const noexcept
Definition mdbx.h++:5415
string< ALLOCATOR > as_base58_string(unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base58 dump of the slice content.
Definition mdbx.h++:5861
::std::pmr::string::allocator_type polymorphic_allocator
Default polymorphic allocator for modern code.
Definition mdbx.h++:388
MDBX_CXX01_CONSTEXPR_ENUM bool is_reverse(key_mode mode) noexcept
Definition mdbx.h++:3413
static bool boolean_or_throw(int error_code)
Definition mdbx.h++:5521
void swap(slice &other) noexcept
Definition mdbx.h++:5627
::mdbx_filehandle_t filehandle
Definition mdbx.h++:413
env::operate_parameters get_operation_parameters() const
Returns current operation parameters.
Definition mdbx.h++:6200
void bind(const ::mdbx::txn &txn, ::mdbx::map_handle map_handle)
Bind/renew a cursor with a new transaction and specified key-value map handle.
Definition mdbx.h++:7240
MDBX_CXX01_CONSTEXPR_ENUM bool is_msgpack(key_mode mode) noexcept
Definition mdbx.h++:3417
MDBX_env_flags_t get_flags() const
Returns environment flags.
Definition mdbx.h++:6255
static size_t dbsize_min(intptr_t pagesize)
Returns the minimal database size in bytes for specified page size.
Definition mdbx.h++:6067
constexpr slice tail(size_t n) const noexcept
Returns the last "n" bytes of the slice.
Definition mdbx.h++:5771
constexpr const version_info & get_version() noexcept
Returns libmdbx version information.
Definition mdbx.h++:5345
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
Definition mdbx.h++:6366
constexpr bool operator>(const slice &a, const slice &b) noexcept
Definition mdbx.h++:5833
void insert(const slice &key, slice value)
Definition mdbx.h++:7271
move_result lower_bound_multivalue(const slice &key, const slice &value, bool throw_notfound=false)
Definition mdbx.h++:7180
MDBX_CXX01_CONSTEXPR_ENUM bool is_usual(key_mode mode) noexcept
Definition mdbx.h++:3401
MDBX_hsr_func * get_HandleSlowReaders() const noexcept
Returns the current Handle-Slow-Readers callback used to resolve database full/overflow issue due to ...
Definition mdbx.h++:6410
constexpr slice() noexcept
Create an empty slice.
Definition mdbx.h++:5559
cursor_managed clone(void *your_context=nullptr) const
Definition mdbx.h++:7040
~cursor() noexcept
Definition mdbx.h++:7065
~txn() noexcept
Definition mdbx.h++:6462
size_t sync_threshold() const
Gets threshold used to force flush the data buffers to disk, for non-sync durability modes.
Definition mdbx.h++:6287
move_result upper_bound(const slice &key, bool throw_notfound=false)
Definition mdbx.h++:7169
constexpr void invalidate() noexcept
Depletes content of slice and make it invalid.
Definition mdbx.h++:5705
inline ::mdbx::txn txn() const
Returns the cursor's transaction.
Definition mdbx.h++:7249
value_result try_insert_reserve(const slice &key, size_t value_length)
Definition mdbx.h++:7299
static env::operate_options options_from_flags(MDBX_env_flags_t flags) noexcept
Definition mdbx.h++:6059
map_handle map() const
Definition mdbx.h++:7255
unsigned sync_period__seconds_16dot16() const
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h++:6298
MDBX_CXX11_CONSTEXPR_ENUM mdbx::value_mode value_mode() const noexcept
Definition mdbx.h++:5998
move_result find(const slice &key, bool throw_notfound=true)
Definition mdbx.h++:7160
move_result upper_bound_multivalue(const slice &key, const slice &value, bool throw_notfound=false)
Definition mdbx.h++:7186
MDBX_CXX01_CONSTEXPR_ENUM bool is_multi(value_mode mode) noexcept
Definition mdbx.h++:3496
void success_or_throw() const
Definition mdbx.h++:5480
buffer< ALLOCATOR, CAPACITY_POLICY > encode_base64(unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a buffer with a Base64 dump of the slice content.
Definition mdbx.h++:5888
void renew_reading()
Renew read-only transaction.
Definition mdbx.h++:6523
buffer< ALLOCATOR, CAPACITY_POLICY > base64_decode(bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base64 dump from the slice content to returned buffer.
Definition mdbx.h++:5909
constexpr bool ends_with(const slice &suffix) const noexcept
Checks if the data ends with the given suffix.
Definition mdbx.h++:5741
bool sync_to_disk(bool force=true, bool nonblock=false)
Flush the environment data buffers.
Definition mdbx.h++:6348
int compare_position(const cursor &left, const cursor &right, bool ignore_nested=false)
Definition mdbx.h++:7096
constexpr bool operator==(const error &a, const error &b) noexcept
Definition mdbx.h++:5437
size_t count_multivalue() const
Return count of duplicates for current key.
Definition mdbx.h++:7196
constexpr bool starts_with(const slice &prefix) const noexcept
Checks if the data starts with the given prefix.
Definition mdbx.h++:5736
static size_t pagesize_max() noexcept
Returns the maximal database page size in bytes.
Definition mdbx.h++:6065
constexpr size_t hash_value() const noexcept
Returns the hash value of referenced data.
Definition mdbx.h++:5748
bool is_dirty(const void *ptr) const
Checks whether the given data is on a dirty page.
Definition mdbx.h++:6493
slice upsert_reserve(const slice &key, size_t value_length)
Definition mdbx.h++:7320
env::mode get_mode() const
Returns current operation mode.
Definition mdbx.h++:6209
MDBX_CXX01_CONSTEXPR_ENUM bool is_samelength(key_mode mode) noexcept
Definition mdbx.h++:3409
inline ::mdbx::env env() const noexcept
Returns the transaction's environment.
Definition mdbx.h++:6505
uint32_t get_tree_deepmask(map_handle map) const
Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given table.
Definition mdbx.h++:6668
bool try_update(map_handle map, const slice &key, const slice &value)
Definition mdbx.h++:6866
void safe_remove_prefix(size_t n)
Drops the first "n" bytes from this slice.
Definition mdbx.h++:5718
comparator default_comparator(key_mode mode) noexcept
Definition mdbx.h++:3547
slice insert_reserve(const slice &key, size_t value_length)
Definition mdbx.h++:7291
static 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 size and table flags.
Definition mdbx.h++:6141
env & set_sync_period__seconds_16dot16(unsigned seconds_16dot16)
Sets relative period since the last unsteady commit to force flush the data buffers to disk,...
Definition mdbx.h++:6293
ptrdiff_t estimate(map_handle map, const pair &from, const pair &to) const
Definition mdbx.h++:7004
env::reclaiming_options get_reclaiming() const
Returns current reclaiming options.
Definition mdbx.h++:6217
void drop_map(map_handle map)
Drops key-value map using handle.
Definition mdbx.h++:6617
ptrdiff_t estimate_to_last(map_handle map, const slice &from) const
Definition mdbx.h++:7028
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 preser...
Definition mdbx.h++:6973
constexpr bool operator<(const slice &a, const slice &b) noexcept
Definition mdbx.h++:5828
env::operate_options get_options() const
Returns current operate options.
Definition mdbx.h++:6221
buffer< ALLOCATOR, CAPACITY_POLICY > extract(map_handle map, const slice &key, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
Removes and return a value of the key.
Definition mdbx.h++:6936
void park_reading(bool autounpark=true)
Park read-only transaction.
Definition mdbx.h++:6527
cursor & set_context(void *your_context)
Sets the application context associated with the cursor.
Definition mdbx.h++:7050
map_stat get_map_stat(map_handle map) const
Returns statistics for a table.
Definition mdbx.h++:6662
bool move(move_operation operation, MDBX_val *key, MDBX_val *value, bool throw_notfound) const
Definition mdbx.h++:7120
static size_t value_min(MDBX_db_flags_t flags) noexcept
Returns the minimal values size in bytes for specified table flags.
Definition mdbx.h++:6111
int compare_values(map_handle map, const slice &a, const slice &b) const noexcept
Compare two values according to a particular key-value map (aka table).
Definition mdbx.h++:6710
static env::reclaiming_options reclaiming_from_flags(MDBX_env_flags_t flags) noexcept
Definition mdbx.h++:6053
buffer< ALLOCATOR, CAPACITY_POLICY > encode_hex(bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a buffer with a hexadecimal dump of the slice content.
Definition mdbx.h++:5873
cursor & operator=(cursor &&other) noexcept
Definition mdbx.h++:7055
txn & put_canary(const canary &)
Set integers markers (aka "canary") associated with the environment.
Definition mdbx.h++:6681
slice upsert_reserve(map_handle map, const slice &key, size_t value_length)
Definition mdbx.h++:6853
buffer< ALLOCATOR, CAPACITY_POLICY > hex_decode(bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes hexadecimal dump from the slice content to returned buffer.
Definition mdbx.h++:5895
constexpr slice head(size_t n) const noexcept
Returns the first "n" bytes of the slice.
Definition mdbx.h++:5766
string to_string(const ::mdbx::slice &value)
Definition mdbx.h++:7402
env & set_sync_period__seconds_double(double seconds)
Sets relative period since the last unsteady commit to force flush the data buffers to disk,...
Definition mdbx.h++:6304
constexpr slice safe_middle(size_t from, size_t n) const
Returns the middle "n" bytes of the slice.
Definition mdbx.h++:5793
bool on_first() const
Definition mdbx.h++:7206
::std::basic_string< char, ::std::char_traits< char >, ALLOCATOR > string
Default single-byte string.
Definition mdbx.h++:411
constexpr bool empty() const noexcept
Checks whether the slice is empty.
Definition mdbx.h++:5691
bool eof() const
Definition mdbx.h++:7202
int compare_position_nothrow(const cursor &left, const cursor &right, bool ignore_nested=false) noexcept
Definition mdbx.h++:7091
MDBX_txn_flags_t flags() const
Returns transaction's flags.
Definition mdbx.h++:6507
void * get_context() const noexcept
Returns the application context associated with the environment.
Definition mdbx.h++:6273
MDBX_error_t put(const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
Definition mdbx.h++:7262
map_handle open_map_accede(const char *name) const
Open existing key-value map.
Definition mdbx.h++:6585
txn_managed prepare_read() const
Creates but not start read transaction.
Definition mdbx.h++:6422
void safe_remove_suffix(size_t n)
Drops the last "n" bytes from this slice.
Definition mdbx.h++:5729
bool seek(const slice &key)
Definition mdbx.h++:7192
env & alter_flags(MDBX_env_flags_t flags, bool on_off)
Alter environment flags.
Definition mdbx.h++:6336
env & set_context(void *your_context)
Sets the application context associated with the environment.
Definition mdbx.h++:6277
constexpr byte operator[](size_t n) const noexcept
Returns the nth byte in the referenced data.
Definition mdbx.h++:5755
static 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 fo...
Definition mdbx.h++:6191
void clear_map(map_handle map)
Clear key-value map.
Definition mdbx.h++:6621
env & set_extra_option(extra_runtime_option option, uint64_t value)
Sets the value of a extra runtime options for an environment.
Definition mdbx.h++:6322
bool is_base64(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a Base64 dump.
Definition mdbx.h++:5925
void remove_prefix(size_t n) noexcept
Drops the first "n" bytes from this slice.
Definition mdbx.h++:5712
value_result try_insert(const slice &key, slice value)
Definition mdbx.h++:7277
static void throw_on_nullptr(const void *ptr, MDBX_error_t error_code)
Definition mdbx.h++:5506
string< ALLOCATOR > as_base64_string(unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base58 dump of the slice content.
Definition mdbx.h++:5867
put_mode
Key-value pairs put mode.
Definition mdbx.h++:3555
static constexpr intptr_t compare_lexicographically(const pair &a, const pair &b) noexcept
Three-way lexicographically comparison.
Definition mdbx.h++:5938
double sync_period__seconds_double() const
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition mdbx.h++:6308
constexpr const byte * end_byte_ptr() const noexcept
Returns casted to pointer to byte an end of data.
Definition mdbx.h++:5637
static 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 ...
Definition mdbx.h++:6166
canary get_canary() const
Returns fours integers markers (aka "canary") associated with the environment.
Definition mdbx.h++:6686
txn & operator=(txn &&other) noexcept
Definition mdbx.h++:6452
bool erase(bool whole_multivalue=false)
Removes single key-value pair or all multi-values at the current cursor position.
Definition mdbx.h++:7367
buffer< ALLOCATOR, CAPACITY_POLICY > replace_reserve(map_handle map, const slice &key, slice &new_value, const typename buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type &allocator=buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type())
Definition mdbx.h++:6961
stat get_stat() const
Returns snapshot statistics about the MDBX environment.
Definition mdbx.h++:6225
uint64_t id() const
Return the transaction's ID.
Definition mdbx.h++:6513
value_result try_insert(map_handle map, const slice &key, slice value)
Definition mdbx.h++:6808
constexpr bool operator>=(const slice &a, const slice &b) noexcept
Definition mdbx.h++:5843
ptrdiff_t estimate(const cursor &from, const cursor &to)
Definition mdbx.h++:7154
static constexpr intptr_t compare_lexicographically(const slice &a, const slice &b) noexcept
Three-way lexicographically comparison.
Definition mdbx.h++:5811
slice update_reserve(map_handle map, const slice &key, size_t value_length)
Definition mdbx.h++:6880
bool is_base58(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a Base58 dump.
Definition mdbx.h++:5920
~env() noexcept
Definition mdbx.h++:6017
loop_control
Loop control constants for readers enumeration functor and other cases.
Definition mdbx.h++:3382
slice get(map_handle map, const slice &key) const
Get value by key from a key-value map (aka table).
Definition mdbx.h++:6725
constexpr void clear() noexcept
Makes the slice empty and referencing to nothing.
Definition mdbx.h++:5707
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)
Definition mdbx.h++:6981
void update(map_handle map, const slice &key, const slice &value)
Definition mdbx.h++:6861
geometry & make_dynamic(intptr_t lower=minimal_value, intptr_t upper=maximal_value) noexcept
Definition mdbx.h++:6045
constexpr byte at(size_t n) const
Returns the nth byte in the referenced data with bounds checking.
Definition mdbx.h++:5760
constexpr const byte * byte_ptr() const noexcept
Returns casted to pointer to byte an address of data.
Definition mdbx.h++:5633
key_mode
Kinds of the keys and corresponding modes of comparing it.
Definition mdbx.h++:3385
txn_managed start_read() const
Starts read (read-only) transaction.
Definition mdbx.h++:6414
bool on_last_multival() const
Definition mdbx.h++:7218
unsigned max_maps() const
Returns the maximum number of named tables for the environment.
Definition mdbx.h++:6267
void insert(map_handle map, const slice &key, slice value)
Definition mdbx.h++:6802
::std::chrono::duration< unsigned, ::std::ratio< 1, 65536 > > duration
Duration in 1/65536 units of second.
Definition mdbx.h++:459
unsigned max_readers() const
Returns the maximum number of threads/reader slots for the environment.
Definition mdbx.h++:6261
static 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.
Definition mdbx.h++:6089
int enumerate_readers(VISITOR &visitor)
Enumerate readers.
Definition mdbx.h++:6373
void * get_context() const noexcept
Returns the application context associated with the cursor.
Definition mdbx.h++:7046
static size_t max_map_handles(void)
Returns the maximum opened map handles, aka DBI-handles.
Definition mdbx.h++:6198
cursor_managed open_cursor(map_handle map) const
Opens cursor for specified key-value map handle.
Definition mdbx.h++:6541
MDBX_CXX01_CONSTEXPR_ENUM bool is_ordinal(key_mode mode) noexcept
Definition mdbx.h++:3405
bool unpark_reading(bool restart_if_ousted=true)
Resume parked read-only transaction.
Definition mdbx.h++:6531
uint64_t extra_option(extra_runtime_option option) const
Gets the value of extra runtime options from an environment.
Definition mdbx.h++:6329
constexpr const build_info & get_build() noexcept
Returns libmdbx build information.
Definition mdbx.h++:5348
char8_t byte
Definition mdbx.h++:340
bool on_first_multival() const
Definition mdbx.h++:7214
MDBX_error_t put(map_handle map, const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
Definition mdbx.h++:6792
void panic_on_failure(const char *context_where, const char *func_who) const noexcept
Definition mdbx.h++:5494
constexpr slice middle(size_t from, size_t n) const noexcept
Returns the middle "n" bytes of the slice.
Definition mdbx.h++:5776
info get_info() const
Return snapshot information about the MDBX environment.
Definition mdbx.h++:6237
void upsert(map_handle map, const slice &key, const slice &value)
Definition mdbx.h++:6848
static size_t pagesize_min() noexcept
Returns the minimal database page size in bytes.
Definition mdbx.h++:6063
constexpr bool operator<=(const slice &a, const slice &b) noexcept
Definition mdbx.h++:5838
slice update_reserve(const slice &key, size_t value_length)
Definition mdbx.h++:7345
move_result lower_bound(const slice &key, bool throw_notfound=false)
Definition mdbx.h++:7164
::MDBX_cmp_func * comparator
Definition mdbx.h++:3546
constexpr size_t length() const noexcept
Returns the number of bytes.
Definition mdbx.h++:5679
polymorphic_allocator default_allocator
Definition mdbx.h++:389
unsigned check_readers()
Checks for stale readers in the lock table and return number of cleared slots.
Definition mdbx.h++:6398
bool erase(map_handle map, const slice &key)
Removes all values for given key.
Definition mdbx.h++:6903
bool on_last() const
Definition mdbx.h++:7210
#define MDBX_STD_FILESYSTEM_PATH
Defined if mdbx::filesystem::path is available.
Definition mdbx.h++:436
buffer< ALLOCATOR, CAPACITY_POLICY > base58_decode(bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base58 dump from the slice content to returned buffer.
Definition mdbx.h++:5902
filehandle get_filehandle() const
Returns the file descriptor for the DXB file of MDBX environment.
Definition mdbx.h++:6249
env & set_geometry(const geometry &size)
Set all size-related parameters of environment.
Definition mdbx.h++:6341
map_handle::info get_handle_info(map_handle map) const
Returns information about key-value map (aka table) handle.
Definition mdbx.h++:6674
void renew(const ::mdbx::txn &txn)
Renew/bind a cursor with a new transaction and previously used key-value map handle.
Definition mdbx.h++:7236
geometry & make_fixed(intptr_t size) noexcept
Definition mdbx.h++:6039
size_t release_all_cursors(bool unbind) const
Unbind or close all cursors.
Definition mdbx.h++:6547
value_result try_update_reserve(const slice &key, size_t value_length)
Definition mdbx.h++:7352
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.
Definition mdbx.h++:6566
::mdbx::filesystem::path path
Definition mdbx.h++:440
txn_managed try_start_write()
Tries to start write (read-write) transaction without blocking.
Definition mdbx.h++:6446
bool is_hex(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a hexadecimal dump.
Definition mdbx.h++:5915
info get_info(bool scan_reader_lock_table=false) const
Returns information about the MDBX transaction.
Definition mdbx.h++:6535
pair_result get_equal_or_great(map_handle map, const slice &key) const
Get value for equal or great key from a table.
Definition mdbx.h++:6766
constexpr const char * end_char_ptr() const noexcept
Returns casted to pointer to char an end of data.
Definition mdbx.h++:5653
@ multi_reverse_samelength
@ upsert
Insert or update.
Definition mdbx.h++:3557
@ update
Update existing, don't insert new.
Definition mdbx.h++:3558
@ insert_unique
Insert only unique keys.
Definition mdbx.h++:3556
@ continue_loop
Definition mdbx.h++:3382
@ exit_loop
Definition mdbx.h++:3382
A handle for an individual table (aka key-value space, maps or sub-database) in the environment.
Definition mdbx.h++:3523
constexpr ::std::span< byte > bytes()
Definition mdbx.h++:769
static constexpr slice wrap(const char(&text)[SIZE])
Definition mdbx.h++:790
constexpr slice(const ::std::span< POD > &span)
Definition mdbx.h++:737
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned buffer.
Definition mdbx.h++:1598
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a buffer with a hexadecimal dump of a passed slice.
Definition mdbx.h++:1382
constexpr slice(const ::std::basic_string< CHAR, T, A > &str)
Create a slice that refers to the contents of "str".
Definition mdbx.h++:727
const slice source
Definition mdbx.h++:1468
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid Base58 dump, and therefore there could be dec...
slice & assign(::std::basic_string_view< CHAR, T > &&view)
Definition mdbx.h++:820
int8_t as_int8_adapt() const
constexpr uint16_t as_uint16() const
Definition mdbx.h++:1162
constexpr size_t envisage_result_length() const noexcept
Returns the buffer size in bytes needed for Base58 dump of passed slice.
Definition mdbx.h++:1440
slice & operator=(::std::basic_string_view< CHAR, T > &&view)
Definition mdbx.h++:841
constexpr uint32_t as_uint32() const
Definition mdbx.h++:1161
buffer_pair_spec(buffer_pair_spec &&pair) noexcept(buffer_type::move_assign_alloc::is_nothrow())
Definition mdbx.h++:3345
constexpr int64_t as_int64() const
Definition mdbx.h++:1170
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a buffer with a Base58 dump of a passed slice.
Definition mdbx.h++:1434
void swap(::std::basic_string_view< CHAR, T > &view) noexcept
Definition mdbx.h++:978
value_result & operator=(const value_result &) noexcept=default
bool is_printable(bool disable_utf8=false) const noexcept
Checks whether the content of the slice is printable.
int128_t as_int128_adapt() const
char * write_bytes(char *dest, size_t dest_size) const
Fills the destination with data decoded from Base64 dump from a passed slice.
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned string.
Definition mdbx.h++:1589
constexpr int16_t as_int16() const
Definition mdbx.h++:1172
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned string.
Definition mdbx.h++:1638
slice value
Definition mdbx.h++:3218
::std::ostream & output(::std::ostream &out) const
Output Base64 dump of passed slice to the std::ostream.
constexpr bool is_reference() const noexcept
Checks whether one of the buffers just refers to data located outside the buffer, rather than stores ...
Definition mdbx.h++:3358
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition mdbx.h++:1404
buffer_pair_spec(const slice &key, const slice &value, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3320
slice value
Definition mdbx.h++:3234
::std::pair< buffer_type, buffer_type > stl_pair
Definition mdbx.h++:3296
::std::ostream & output(::std::ostream &out) const
Output hexadecimal dump of passed slice to the std::ostream.
pair_result(const pair_result &) noexcept=default
const slice source
Definition mdbx.h++:1578
const slice source
Definition mdbx.h++:1363
constexpr size_t envisage_result_length() const noexcept
Returns the number of bytes needed for conversion hexadecimal dump from a passed slice to decoded dat...
Definition mdbx.h++:1557
buffer_pair_spec(const txn &txn, const pair &pair, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3338
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned buffer.
Definition mdbx.h++:1551
slice & assign(const ::std::basic_string< CHAR, T, ALLOCATOR > &str)
Definition mdbx.h++:809
constexpr bool is_freestanding() const noexcept
Checks whether data chunk stored inside the buffers both, otherwise at least one of buffers just refe...
Definition mdbx.h++:3352
constexpr POD as_pod() const
Definition mdbx.h++:1142
char * write_bytes(char *dest, size_t dest_size) const
Fills the destination with data decoded from Base58 dump from a passed slice.
constexpr pair_result() noexcept
Definition mdbx.h++:3277
pair & operator=(const pair &) noexcept=default
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition mdbx.h++:1665
constexpr uint128_t as_uint128() const
Definition mdbx.h++:1156
uint16_t as_uint16_adapt() const
constexpr to_hex(const slice &source, bool uppercase=false, unsigned wrap_width=0) noexcept
Definition mdbx.h++:1366
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a buffer with a Base64 dump of a passed slice.
Definition mdbx.h++:1488
buffer_pair_spec(const slice &key, const slice &value, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3323
slice & operator=(const ::std::basic_string_view< CHAR, T > &view)
Definition mdbx.h++:836
std::pair< slice, slice > stl_pair
Definition mdbx.h++:3233
value_result(const value_result &) noexcept=default
constexpr slice(const slice &) noexcept=default
constexpr ::std::span< POD > as_span()
Definition mdbx.h++:756
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a hexadecimal dump of a passed slice.
Definition mdbx.h++:1374
constexpr from_base58(const slice &source, bool ignore_spaces=false) noexcept
Definition mdbx.h++:1580
buffer_pair_spec(const stl_pair &pair, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3316
buffer_type key
Definition mdbx.h++:3297
constexpr int8_t as_int8() const
Definition mdbx.h++:1173
constexpr ::std::span< char > chars()
Definition mdbx.h++:773
constexpr slice(size_t invalid_length) noexcept
Definition mdbx.h++:1192
constexpr size_t envisage_result_length() const noexcept
Returns the buffer size in bytes needed for Base64 dump of passed slice.
Definition mdbx.h++:1494
static constexpr size_t round(const size_t value)
Definition mdbx.h++:1329
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition mdbx.h++:1458
constexpr size_t envisage_result_length() const noexcept
Returns the number of bytes needed for conversion Base64 dump from a passed slice to decoded data.
Definition mdbx.h++:1654
value_result(const slice &value, bool done) noexcept
Definition mdbx.h++:3220
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition mdbx.h++:1616
const slice source
Definition mdbx.h++:1414
constexpr pair(const stl_pair &couple) noexcept
Definition mdbx.h++:3237
constexpr ::std::span< const char > chars() const
Definition mdbx.h++:770
constexpr from_base64(const slice &source, bool ignore_spaces=false) noexcept
Definition mdbx.h++:1629
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid data and could be encoded or unexpectedly not...
Definition mdbx.h++:1408
uint8_t as_uint8_adapt() const
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned string.
Definition mdbx.h++:1543
constexpr ::std::span< const POD > as_span() const
Definition mdbx.h++:745
constexpr size_t envisage_result_length() const noexcept
Returns the number of bytes needed for conversion Base58 dump from a passed slice to decoded data.
Definition mdbx.h++:1605
buffer_pair_spec(const txn &txn, const slice &key, const slice &value, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3335
slice & assign(const ::std::basic_string_view< CHAR, T > &view)
Definition mdbx.h++:816
constexpr ::std::basic_string_view< CHAR, T > string_view() const noexcept
Return a string_view that references the same data as this slice.
Definition mdbx.h++:848
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition mdbx.h++:1568
int32_t as_int32_adapt() const
@ max_length
Definition mdbx.h++:703
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base64 dump of a passed slice.
Definition mdbx.h++:1479
constexpr pair_result(const slice &key, const slice &value, bool done) noexcept
Definition mdbx.h++:3279
constexpr from_hex(const slice &source, bool ignore_spaces=false) noexcept
Definition mdbx.h++:1535
buffer_pair_spec(const buffer_type &key, const buffer_type &value, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3304
char * write_bytes(char *dest, size_t dest_size) const
Fills the buffer by hexadecimal dump of a passed slice.
static constexpr pair invalid() noexcept
Definition mdbx.h++:3248
bool done
Definition mdbx.h++:3276
::std::ostream & output(::std::ostream &out) const
Output Base58 dump of passed slice to the std::ostream.
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid data and could be encoded or unexpectedly not...
Definition mdbx.h++:1462
buffer_pair_spec(const pair &pair, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3331
constexpr ::std::span< const byte > bytes() const
Definition mdbx.h++:766
static constexpr slice wrap(const POD &pod)
Definition mdbx.h++:795
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned buffer.
Definition mdbx.h++:1647
void make_freestanding()
Makes buffers owning the data.
Definition mdbx.h++:3364
constexpr to_base64(const slice &source, unsigned wrap_width=0) noexcept
Definition mdbx.h++:1471
pair(const pair &) noexcept=default
static constexpr slice invalid() noexcept
Build an invalid slice which non-zero length and refers to null address.
Definition mdbx.h++:1138
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid Base64 dump, and therefore there could be dec...
slice & operator=(const slice &) noexcept=default
uint128_t as_uint128_adapt() const
constexpr int128_t as_int128() const
Definition mdbx.h++:1166
slice key
Definition mdbx.h++:3234
constexpr pair(const slice &key, const slice &value) noexcept
Definition mdbx.h++:3235
const slice source
Definition mdbx.h++:1627
pair_result & operator=(const pair_result &) noexcept=default
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base58 dump of a passed slice.
Definition mdbx.h++:1425
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition mdbx.h++:1512
typename buffer_type::allocator_traits allocator_traits
Definition mdbx.h++:3294
char * write_bytes(char *dest, size_t dest_size) const
Fills the destination with data decoded from hexadecimal dump from a passed slice.
static constexpr size_t advise(const size_t current, const size_t wanna)
Definition mdbx.h++:1340
constexpr int32_t as_int32() const
Definition mdbx.h++:1171
int64_t as_int64_adapt() const
buffer_pair_spec(const stl_pair &pair, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3313
constexpr ::std::basic_string< CHAR, T, ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Definition mdbx.h++:864
constexpr uint8_t as_uint8() const
Definition mdbx.h++:1163
CAPACITY_POLICY reservation_policy
Definition mdbx.h++:3295
constexpr operator::std::basic_string() const
Definition mdbx.h++:872
constexpr uint64_t as_uint64() const
Definition mdbx.h++:1160
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid hexadecimal dump, and therefore there could b...
uint32_t as_uint32_adapt() const
buffer_pair_spec(const pair &pair, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3328
char * write_bytes(char *dest, size_t dest_size) const
Fills the buffer by Base64 dump of passed slice.
buffer_pair_spec(buffer_type &&key, buffer_type &&value) noexcept(buffer_type::move_assign_alloc::is_nothrow())
Definition mdbx.h++:3342
constexpr slice(const ::std::basic_string_view< CHAR, T > &sv)
Create a slice that refers to the same contents as "string_view".
Definition mdbx.h++:780
int16_t as_int16_adapt() const
typename buffer_type::allocator_type allocator_type
Definition mdbx.h++:3293
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid data and could be encoded or unexpectedly not...
Definition mdbx.h++:1516
uint64_t as_uint64_adapt() const
constexpr buffer_pair_spec() noexcept=default
constexpr to_base58(const slice &source, unsigned wrap_width=0) noexcept
Definition mdbx.h++:1417
buffer_pair_spec(const buffer_type &key, const buffer_type &value, bool make_reference, const allocator_type &allocator=allocator_type())
Definition mdbx.h++:3307
slice(::std::basic_string_view< CHAR, T > &&sv)
Definition mdbx.h++:784
constexpr size_t envisage_result_length() const noexcept
Returns the buffer size in bytes needed for hexadecimal dump of a passed slice.
Definition mdbx.h++:1388
bool done
Definition mdbx.h++:3219
char * write_bytes(char *dest, size_t dest_size) const
Fills the buffer by Base58 dump of passed slice.
const slice source
Definition mdbx.h++:1533
buffer< ALLOCATOR, CAPACITY_POLICY > make_buffer(PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
Definition mdbx.h++:3160
inline ::std::ostream & operator<<(::std::ostream &out, const to_hex &wrapper)
Definition mdbx.h++:1519
string< ALLOCATOR > make_string(PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
Definition mdbx.h++:3188
ImmutableByteProducer C++20 concept.
MutableByteProducer C++20 concept.
Base58 decoder which satisfy SliceTranscoder concept.
Definition mdbx.h++:1577
Base64 decoder which satisfy SliceTranscoder concept.
Definition mdbx.h++:1626
Hexadecimal decoder which satisfy SliceTranscoder concept.
Definition mdbx.h++:1532
Combines pair of slices for key and value to represent result of certain operations.
Definition mdbx.h++:3232
Combines pair of slices for key and value with boolean flag to represent result of certain operations...
Definition mdbx.h++:3275
References a data located outside the slice.
Definition mdbx.h++:698
Base58 encoder which satisfy SliceTranscoder concept.
Definition mdbx.h++:1413
Base64 encoder which satisfy SliceTranscoder concept.
Definition mdbx.h++:1467
Hexadecimal encoder which satisfy SliceTranscoder concept.
Definition mdbx.h++:1362
Combines data slice with boolean flag to represent result of certain operations.
Definition mdbx.h++:3217
fatal(exception &&src) noexcept
Definition mdbx.h++:569
fatal(const ::mdbx::error &) noexcept
exception(const exception &)=default
void throw_exception() const
fatal(const exception &src) noexcept
Definition mdbx.h++:568
exception(exception &&)=default
error(const error &)=default
virtual ~fatal() noexcept
fatal & operator=(fatal &&)=default
fatal(const fatal &src) noexcept
Definition mdbx.h++:570
exception & operator=(exception &&)=default
error & operator=(error &&)=default
fatal(fatal &&src) noexcept
Definition mdbx.h++:571
fatal & operator=(const fatal &)=default
exception_thunk() noexcept=default
exception & operator=(const exception &)=default
exception(const ::mdbx::error &) noexcept
error & operator=(const error &)=default
virtual ~exception() noexcept
Implements error information and throwing corresponding exceptions.
Definition mdbx.h++:484
Base class for all libmdbx's exceptions that are corresponds to libmdbx errors.
Definition mdbx.h++:547
Transfers C++ exceptions thru C callbacks.
Definition mdbx.h++:469
Fatal exception that lead termination anyway in dangerous unrecoverable cases.
Definition mdbx.h++:563
LIBMDBX_API void throw_allocators_mismatch()
#define MDBX_DECLARE_EXCEPTION(NAME)
Definition mdbx.h++:577
LIBMDBX_API void throw_incomparable_cursors()
LIBMDBX_API void throw_out_range()
LIBMDBX_API void throw_bad_value_size()
LIBMDBX_API void throw_max_length_exceeded()
LIBMDBX_API void throw_too_small_target_buffer()
uint64_t mdbx_key_from_int64(const int64_t i64)
Definition mdbx.h:4804
LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit)
LIBMDBX_API uint64_t mdbx_key_from_double(const double ieee754_64bit)
LIBMDBX_API uint32_t mdbx_key_from_float(const float ieee754_32bit)
LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit)
uint32_t mdbx_key_from_int32(const int32_t i32)
Definition mdbx.h:4808
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)
#define MDBX_CXX20_CONSTEXPR
Definition mdbx.h++:182
#define MDBX_CXX17_FALLTHROUGH
Definition mdbx.h++:251
#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE)
Definition mdbx.h++:293
#define MDBX_LIKELY(cond)
Definition mdbx.h++:221
#define MDBX_CXX11_CONSTEXPR_ENUM
Definition mdbx.h++:194
#define MDBX_UNLIKELY(cond)
Definition mdbx.h++:231
#define MDBX_CXX17_CONSTEXPR
Definition mdbx.h++:168
#define MDBX_CONSTEXPR_ASSERT(expr)
Definition mdbx.h++:213
#define MDBX_IF_CONSTEXPR
Definition mdbx.h++:240
#define MDBX_CXX01_CONSTEXPR_ENUM
Definition mdbx.h++:193
#define MDBX_CXX20_LIKELY
Definition mdbx.h++:258
The libmdbx C API header file.
constexpr bool allocator_is_always_equal() noexcept
Definition mdbx.h++:1200
The libmdbx C++ API namespace.
Definition mdbx.h++:327
constexpr allocated(allocator_pointer ptr, size_t bytes) noexcept
Definition mdbx.h++:1745
constexpr allocated(const allocated &) noexcept=default
constexpr allocated(allocated &&) noexcept=default
allocator_pointer ptr_
Definition mdbx.h++:1743
size_t capacity_bytes_
Definition mdbx.h++:1744
estimate_result(const cursor &cursor, move_operation operation)
Definition mdbx.h++:4930
estimate_result & operator=(const estimate_result &) noexcept=default
ptrdiff_t approximate_quantity
Definition mdbx.h++:4929
estimate_result(const estimate_result &) noexcept=default
estimate_result(const cursor &cursor, move_operation operation, const slice &key)
Definition mdbx.h++:4933
move_result & operator=(const move_result &) noexcept=default
move_result(const move_result &) noexcept=default
move_result(cursor &cursor, move_operation operation, const slice &key, bool throw_notfound)
Definition mdbx.h++:4917
move_result(cursor &cursor, move_operation operation, bool throw_notfound)
Definition mdbx.h++:4914
Tagged type for output to std::ostream.
Definition mdbx.h++:3623
intptr_t bytes
Definition mdbx.h++:3624
constexpr size(intptr_t bytes) noexcept
Definition mdbx.h++:3625
Database geometry for size management.
Definition mdbx.h++:3599
constexpr geometry(intptr_t size_lower, intptr_t size_now=default_value, intptr_t size_upper=maximal_value, intptr_t growth_step=default_value, intptr_t shrink_threshold=default_value, intptr_t pagesize=default_value) noexcept
Definition mdbx.h++:3669
constexpr geometry(const geometry &) noexcept=default
intptr_t size_upper
The upper bound of database size in bytes.
Definition mdbx.h++:3647
intptr_t pagesize
The database page size for new database creation or default_value otherwise.
Definition mdbx.h++:3661
constexpr geometry() noexcept
Definition mdbx.h++:3666
intptr_t growth_step
The growth step in bytes, must be greater than zero to allow the database to grow.
Definition mdbx.h++:3651
intptr_t size_now
The size in bytes to setup the database size for now.
Definition mdbx.h++:3635
intptr_t shrink_threshold
The shrink threshold in bytes, must be greater than zero to allow the database to shrink.
Definition mdbx.h++:3655
intptr_t size_lower
The lower bound of database size in bytes.
Definition mdbx.h++:3630
Operate options.
Definition mdbx.h++:3711
constexpr operate_options() noexcept
Definition mdbx.h++:3725
constexpr operate_options & operator=(const operate_options &) noexcept=default
constexpr operate_options(const operate_options &) noexcept=default
operate_options(MDBX_env_flags_t) noexcept
Operate parameters.
Definition mdbx.h++:3734
env::operate_options options
Definition mdbx.h++:3744
constexpr operate_parameters(const unsigned max_maps, const unsigned max_readers=0, const env::mode mode=env::mode::write_mapped_io, env::durability durability=env::durability::robust_synchronous, const env::reclaiming_options &reclaiming=env::reclaiming_options(), const env::operate_options &options=env::operate_options()) noexcept
Definition mdbx.h++:3748
static env::mode mode_from_flags(MDBX_env_flags_t) noexcept
constexpr operate_parameters & operator=(const operate_parameters &) noexcept=default
constexpr operate_parameters(const operate_parameters &) noexcept=default
env::reclaiming_options reclaiming
Definition mdbx.h++:3743
static env::durability durability_from_flags(MDBX_env_flags_t) noexcept
constexpr operate_parameters() noexcept
Definition mdbx.h++:3746
MDBX_env_flags_t make_flags(bool accede=true, bool use_subdirectory=false) const
Reader information.
Definition mdbx.h++:4158
mdbx_tid_t thread
The reader thread ID.
Definition mdbx.h++:4161
uint64_t transaction_lag
Definition mdbx.h++:4164
size_t bytes_used
Definition mdbx.h++:4168
uint64_t transaction_id
Definition mdbx.h++:4162
int slot
The reader lock table slot number.
Definition mdbx.h++:4159
mdbx_pid_t pid
The reader process ID.
Definition mdbx.h++:4160
size_t bytes_retained
Definition mdbx.h++:4171
Garbage reclaiming options.
Definition mdbx.h++:3697
constexpr reclaiming_options(const reclaiming_options &) noexcept=default
reclaiming_options(MDBX_env_flags_t) noexcept
constexpr reclaiming_options & operator=(const reclaiming_options &) noexcept=default
constexpr reclaiming_options() noexcept
Definition mdbx.h++:3702
Additional parameters for creating a new database.
Definition mdbx.h++:4274
constexpr create_parameters() noexcept=default
env::geometry geometry
Definition mdbx.h++:4275
map_handle::state state
Definition mdbx.h++:3536
info(const info &) noexcept=default
map_handle::flags flags
Definition mdbx.h++:3535
info & operator=(const info &) noexcept=default
constexpr bool is_inplace() const noexcept
Definition mdbx.h++:1780
static constexpr size_t advise_capacity(const size_t current, const size_t wanna)
Definition mdbx.h++:1878
constexpr bin & operator=(const bin &ditto) noexcept
Definition mdbx.h++:1853
constexpr bin(size_t capacity_bytes=0) noexcept
Definition mdbx.h++:1825
constexpr byte inplace_lastbyte() const noexcept
Definition mdbx.h++:1773
constexpr bool is_allocated() const noexcept
Definition mdbx.h++:1790
constexpr bin(bin &&ditto) noexcept
Definition mdbx.h++:1840
constexpr byte & inplace_lastbyte() noexcept
Definition mdbx.h++:1776
constexpr bin(allocator_pointer ptr, size_t capacity_bytes) noexcept
Definition mdbx.h++:1830
constexpr size_t capacity() const noexcept
Definition mdbx.h++:1898
constexpr ~bin()
Definition mdbx.h++:1835
constexpr const byte * address() const noexcept
Definition mdbx.h++:1889
constexpr byte * make_allocated(allocator_pointer ptr, size_t capacity_bytes) noexcept
Definition mdbx.h++:1810
constexpr byte * address() noexcept
Definition mdbx.h++:1894
constexpr bin & operator=(bin &&ditto) noexcept
Definition mdbx.h++:1871
constexpr byte * make_inplace() noexcept
Definition mdbx.h++:1793