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"
36 #elif _MSC_VER >= 1910
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>)
69 #include <type_traits>
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
78 #include <string_view>
81 #if defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L
83 #elif defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L && \
84 __has_include(<experimental/filesystem>)
85 #include <experimental/filesystem>
88 #if defined(__cpp_lib_span) && __cpp_lib_span >= 202002L
92 #if __cplusplus >= 201103L
99 #if (defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L) || \
100 (defined(__cpp_lib_endian) && __cpp_lib_endian >= 201907L) || \
101 (defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L) || \
102 (defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L)
104 #elif !(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
105 defined(__ORDER_BIG_ENDIAN__))
106 #if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
107 #define __ORDER_LITTLE_ENDIAN__ __LITTLE_ENDIAN
108 #define __ORDER_BIG_ENDIAN__ __BIG_ENDIAN
109 #define __BYTE_ORDER__ __BYTE_ORDER
110 #elif defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
111 #define __ORDER_LITTLE_ENDIAN__ _LITTLE_ENDIAN
112 #define __ORDER_BIG_ENDIAN__ _BIG_ENDIAN
113 #define __BYTE_ORDER__ _BYTE_ORDER
115 #define __ORDER_LITTLE_ENDIAN__ 1234
116 #define __ORDER_BIG_ENDIAN__ 4321
117 #if defined(__LITTLE_ENDIAN__) || \
118 (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) || \
119 defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
120 defined(__MIPSEL__) || defined(_MIPSEL) || defined(__MIPSEL) || \
121 defined(_M_ARM) || defined(_M_ARM64) || defined(__e2k__) || \
122 defined(__elbrus_4c__) || defined(__elbrus_8c__) || defined(__bfin__) || \
123 defined(__BFIN__) || defined(__ia64__) || defined(_IA64) || \
124 defined(__IA64__) || defined(__ia64) || defined(_M_IA64) || \
125 defined(__itanium__) || defined(__ia32__) || defined(__CYGWIN__) || \
126 defined(_WIN64) || defined(_WIN32) || defined(__TOS_WIN__) || \
128 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
129 #elif defined(__BIG_ENDIAN__) || \
130 (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)) || \
131 defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
132 defined(__MIPSEB__) || defined(_MIPSEB) || defined(__MIPSEB) || \
133 defined(__m68k__) || defined(M68000) || defined(__hppa__) || \
134 defined(__hppa) || defined(__HPPA__) || defined(__sparc__) || \
135 defined(__sparc) || defined(__370__) || defined(__THW_370__) || \
136 defined(__s390__) || defined(__s390x__) || defined(__SYSC_ZARCH__)
137 #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
145 #define MDBX_CXX17_CONSTEXPR constexpr
146 #elif defined(__cpp_constexpr) && __cpp_constexpr >= 201603L && \
147 ((defined(_MSC_VER) && _MSC_VER >= 1915) || \
148 (defined(__clang__) && __clang_major__ > 5) || \
149 (defined(__GNUC__) && __GNUC__ > 7) || \
150 (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
151 #define MDBX_CXX17_CONSTEXPR constexpr
153 #define MDBX_CXX17_CONSTEXPR inline
159 #define MDBX_CXX20_CONSTEXPR constexpr
160 #elif defined(__cpp_lib_is_constant_evaluated) && \
161 __cpp_lib_is_constant_evaluated >= 201811L && \
162 defined(__cpp_lib_constexpr_string) && \
163 __cpp_lib_constexpr_string >= 201907L
164 #define MDBX_CXX20_CONSTEXPR constexpr
166 #define MDBX_CXX20_CONSTEXPR inline
169 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
170 #define MDBX_CXX01_CONSTEXPR_ENUM MDBX_CXX01_CONSTEXPR
171 #define MDBX_CXX11_CONSTEXPR_ENUM MDBX_CXX11_CONSTEXPR
172 #define MDBX_CXX14_CONSTEXPR_ENUM MDBX_CXX14_CONSTEXPR
173 #define MDBX_CXX17_CONSTEXPR_ENUM MDBX_CXX17_CONSTEXPR
174 #define MDBX_CXX20_CONSTEXPR_ENUM MDBX_CXX20_CONSTEXPR
176 #define MDBX_CXX01_CONSTEXPR_ENUM inline
177 #define MDBX_CXX11_CONSTEXPR_ENUM inline
178 #define MDBX_CXX14_CONSTEXPR_ENUM inline
179 #define MDBX_CXX17_CONSTEXPR_ENUM inline
180 #define MDBX_CXX20_CONSTEXPR_ENUM inline
185 #if defined(CONSTEXPR_ASSERT)
186 #define MDBX_CONSTEXPR_ASSERT(expr) CONSTEXPR_ASSERT(expr)
188 #define MDBX_CONSTEXPR_ASSERT(expr) void(0)
190 #define MDBX_CONSTEXPR_ASSERT(expr) \
191 ((expr) ? void(0) : [] { assert(!#expr); }())
195 #if defined(DOXYGEN) || \
196 (defined(__GNUC__) || __has_builtin(__builtin_expect)) && \
197 !defined(__COVERITY__)
198 #define MDBX_LIKELY(cond) __builtin_expect(!!(cond), 1)
200 #define MDBX_LIKELY(x) (x)
204 #ifndef MDBX_UNLIKELY
205 #if defined(DOXYGEN) || \
206 (defined(__GNUC__) || __has_builtin(__builtin_expect)) && \
207 !defined(__COVERITY__)
208 #define MDBX_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
210 #define MDBX_UNLIKELY(x) (x)
217 #define MDBX_IF_CONSTEXPR constexpr
218 #elif defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606L
219 #define MDBX_IF_CONSTEXPR constexpr
221 #define MDBX_IF_CONSTEXPR
224 #if defined(DOXYGEN) || \
225 (__has_cpp_attribute(fallthrough) && \
226 (!defined(__clang__) || __clang__ > 4)) || \
227 __cplusplus >= 201703L
228 #define MDBX_CXX17_FALLTHROUGH [[fallthrough]]
230 #define MDBX_CXX17_FALLTHROUGH
233 #if defined(DOXYGEN) || (__has_cpp_attribute(likely) >= 201803L && \
234 (!defined(__GNUC__) || __GNUC__ > 9))
235 #define MDBX_CXX20_LIKELY [[likely]]
237 #define MDBX_CXX20_LIKELY
240 #ifndef MDBX_CXX20_UNLIKELY
241 #if defined(DOXYGEN) || (__has_cpp_attribute(unlikely) >= 201803L && \
242 (!defined(__GNUC__) || __GNUC__ > 9))
243 #define MDBX_CXX20_UNLIKELY [[unlikely]]
245 #define MDBX_CXX20_UNLIKELY
249 #ifndef MDBX_HAVE_CXX20_CONCEPTS
250 #if defined(__cpp_lib_concepts) && __cpp_lib_concepts >= 202002L
252 #define MDBX_HAVE_CXX20_CONCEPTS 1
253 #elif defined(DOXYGEN)
254 #define MDBX_HAVE_CXX20_CONCEPTS 1
256 #define MDBX_HAVE_CXX20_CONCEPTS 0
260 #ifndef MDBX_CXX20_CONCEPT
261 #if MDBX_HAVE_CXX20_CONCEPTS || defined(DOXYGEN)
262 #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) CONCEPT NAME
264 #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) typename NAME
268 #ifndef MDBX_ASSERT_CXX20_CONCEPT_SATISFIED
269 #if MDBX_HAVE_CXX20_CONCEPTS || defined(DOXYGEN)
270 #define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE) \
271 static_assert(CONCEPT<TYPE>)
273 #define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, NAME) \
274 static_assert(true, MDBX_STRINGIFY(CONCEPT) "<" MDBX_STRINGIFY(TYPE) ">")
279 #pragma warning(push, 4)
280 #pragma warning(disable : 4127)
281 #pragma warning(disable : 4251)
283 #pragma warning(disable : 4275)
288 #pragma warning(disable : 4702)
291 #if defined(__LCC__) && __LCC__ >= 126
292 #pragma diagnostic push
294 #pragma diag_suppress 3058
296 #pragma diag_suppress 3060
311 #if defined(DOXYGEN) || (defined(__cpp_char8_t) && __cpp_char8_t >= 201811)
317 using byte = char8_t;
321 using byte =
unsigned char;
324 #if defined(__cpp_lib_endian) && __cpp_lib_endian >= 201907L
325 using endian = ::std::endian;
326 #elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
327 defined(__ORDER_BIG_ENDIAN__)
329 little = __ORDER_LITTLE_ENDIAN__,
330 big = __ORDER_BIG_ENDIAN__,
331 native = __BYTE_ORDER__
335 "Please use a C++ compiler provides byte order information or C++20 support"
352 size_t bytes) noexcept;
355 size_t bytes) noexcept;
361 #if defined(DOXYGEN) || \
362 (defined(__cpp_lib_memory_resource) && \
363 __cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI)
387 template <
class ALLOCATOR = default_allocator>
388 using string = ::std::basic_string<char, ::std::char_traits<char>, ALLOCATOR>;
391 #if defined(DOXYGEN) || \
392 (defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \
393 defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L && \
394 (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || \
395 __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) && \
396 (!defined(__IPHONE_OS_VERSION_MIN_REQUIRED) || \
397 __IPHONE_OS_VERSION_MIN_REQUIRED >= 130100))
398 namespace filesystem = ::std::filesystem;
405 #define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path
406 #elif defined(__cpp_lib_experimental_filesystem) && \
407 __cpp_lib_experimental_filesystem >= 201406L
408 namespace filesystem = ::std::experimental::filesystem;
409 #define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path
412 #ifdef MDBX_STD_FILESYSTEM_PATH
414 #elif defined(_WIN32) || defined(_WIN64)
415 using path = ::std::wstring;
420 #if defined(__SIZEOF_INT128__) || \
421 (defined(_INTEGRAL_MAX_BITS) && _INTEGRAL_MAX_BITS >= 128)
422 #ifndef MDBX_U128_TYPE
423 #define MDBX_U128_TYPE __uint128_t
425 #ifndef MDBX_I128_TYPE
426 #define MDBX_I128_TYPE __int128_t
430 #if __cplusplus >= 201103L || defined(DOXYGEN)
432 using duration = ::std::chrono::duration<unsigned, ::std::ratio<1, 65536>>;
443 ::std::exception_ptr captured_;
451 inline
bool is_clean() const noexcept;
452 inline
void capture() noexcept;
453 inline
void rethrow_captured() const;
469 const error &b) noexcept;
471 const error &b) noexcept;
482 const
char *what() const noexcept;
485 ::std::
string message() const;
490 [[noreturn]]
void panic(const
char *context_where_when,
491 const
char *func_who_what) const noexcept;
492 [[noreturn]]
void throw_exception() const;
493 [[noreturn]] static inline
void throw_exception(
int error_code);
494 inline
void throw_on_failure() const;
495 inline
void success_or_throw() const;
497 inline
void panic_on_failure(const
char *context_where,
498 const
char *func_who) const noexcept;
499 inline
void success_or_panic(const
char *context_where,
500 const
char *func_who) const noexcept;
501 static inline
void throw_on_nullptr(const
void *ptr,
MDBX_error_t error_code);
502 static inline
void success_or_throw(
MDBX_error_t error_code);
503 static
void success_or_throw(
int error_code) {
504 success_or_throw(
static_cast<MDBX_error_t>(error_code));
506 static inline void throw_on_failure(
int error_code);
507 static inline bool boolean_or_throw(
int error_code);
508 static inline void success_or_throw(
int error_code,
const exception_thunk &);
509 static inline bool boolean_or_throw(
int error_code,
const exception_thunk &);
510 static inline void panic_on_failure(
int error_code,
const char *context_where,
511 const char *func_who) noexcept;
512 static inline void success_or_panic(
int error_code,
const char *context_where,
513 const char *func_who) noexcept;
521 using base = ::std::runtime_error;
540 fatal(const ::mdbx::error &) noexcept;
550 #define MDBX_DECLARE_EXCEPTION(NAME) \
551 struct LIBMDBX_API_TYPE NAME : public exception { \
552 NAME(const ::mdbx::error &); \
553 virtual ~NAME() noexcept; \
585 #undef MDBX_DECLARE_EXCEPTION
606 #if MDBX_HAVE_CXX20_CONCEPTS || defined(DOXYGEN)
611 template <
typename T>
613 { a.is_empty() } -> std::same_as<bool>;
614 { a.envisage_result_length() } -> std::same_as<size_t>;
615 { a.write_bytes(&array[0],
size_t(42)) } -> std::same_as<char *>;
621 template <
typename T>
623 { a.is_empty() } -> std::same_as<bool>;
624 { a.envisage_result_length() } -> std::same_as<size_t>;
625 { a.write_bytes(&array[0],
size_t(42)) } -> std::same_as<char *>;
631 template <
typename T>
635 { a.is_erroneous() } -> std::same_as<bool>;
641 typename CAPACITY_POLICY = default_capacity_policy,
643 inline buffer<ALLOCATOR, CAPACITY_POLICY>
644 make_buffer(PRODUCER &producer,
const ALLOCATOR &allocator = ALLOCATOR());
647 typename CAPACITY_POLICY = default_capacity_policy,
649 inline buffer<ALLOCATOR, CAPACITY_POLICY>
650 make_buffer(
const PRODUCER &producer,
const ALLOCATOR &allocator = ALLOCATOR());
654 inline string<ALLOCATOR>
make_string(PRODUCER &producer,
655 const ALLOCATOR &allocator = ALLOCATOR());
659 inline string<ALLOCATOR>
make_string(
const PRODUCER &producer,
660 const ALLOCATOR &allocator = ALLOCATOR());
687 template <
size_t SIZE>
696 template <
class CHAR,
class T,
class A>
698 slice(const ::std::basic_string<CHAR, T, A> &str)
699 :
slice(str.data(), str.length() * sizeof(CHAR)) {}
706 #if defined(DOXYGEN) || (defined(__cpp_lib_span) && __cpp_lib_span >= 202002L)
707 template <
typename POD>
709 :
slice(span.begin(), span.end()) {
710 static_assert(::std::is_standard_layout<POD>::value &&
711 !::std::is_pointer<POD>::value,
712 "Must be a standard layout type!");
715 template <
typename POD>
716 MDBX_CXX14_CONSTEXPR ::std::span<const POD>
as_span()
const {
717 static_assert(::std::is_standard_layout<POD>::value &&
718 !::std::is_pointer<POD>::value,
719 "Must be a standard layout type!");
722 return ::std::span<const POD>(
static_cast<const POD *
>(data()),
723 size() /
sizeof(POD));
727 template <
typename POD> MDBX_CXX14_CONSTEXPR ::std::span<POD>
as_span() {
728 static_assert(::std::is_standard_layout<POD>::value &&
729 !::std::is_pointer<POD>::value,
730 "Must be a standard layout type!");
733 return ::std::span<POD>(
static_cast<POD *
>(data()), size() /
sizeof(POD));
737 MDBX_CXX14_CONSTEXPR ::std::span<const byte>
bytes()
const {
738 return as_span<const byte>();
740 MDBX_CXX14_CONSTEXPR ::std::span<byte>
bytes() {
return as_span<byte>(); }
741 MDBX_CXX14_CONSTEXPR ::std::span<const char>
chars()
const {
742 return as_span<const char>();
744 MDBX_CXX14_CONSTEXPR ::std::span<char>
chars() {
return as_span<char>(); }
747 #if defined(DOXYGEN) || \
748 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
750 template <
class CHAR,
class T>
752 :
slice(sv.data(), sv.data() + sv.length()) {}
754 template <
class CHAR,
class T>
760 template <
size_t SIZE>
765 template <
typename POD>
767 static_assert(::std::is_standard_layout<POD>::value &&
768 !::std::is_pointer<POD>::value,
769 "Must be a standard layout type!");
770 return slice(&pod,
sizeof(pod));
773 inline slice &assign(
const void *ptr,
size_t bytes);
774 inline slice &assign(
const slice &src) noexcept;
778 inline slice &assign(
const void *begin,
const void *end);
779 template <
class CHAR,
class T,
class ALLOCATOR>
780 slice &
assign(const ::std::basic_string<CHAR, T, ALLOCATOR> &str) {
781 return assign(str.data(), str.length() *
sizeof(CHAR));
783 inline slice &assign(
const char *c_str);
784 #if defined(DOXYGEN) || \
785 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
786 template <
class CHAR,
class T>
788 return assign(view.begin(), view.end());
790 template <
class CHAR,
class T>
799 inline slice &operator=(
slice &&src) noexcept;
802 operator const MDBX_val *()
const noexcept {
return this; }
804 #if defined(DOXYGEN) || \
805 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
806 template <
class CHAR,
class T>
811 template <
class CHAR,
class T>
817 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>>
818 MDBX_CXX11_CONSTEXPR ::std::basic_string_view<CHAR, T>
819 string_view() const noexcept {
820 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
821 return ::std::basic_string_view<CHAR, T>(char_ptr(), length());
825 template <
class CHAR,
class T>
827 operator ::std::basic_string_view<CHAR, T>() const noexcept {
828 return this->string_view<CHAR, T>();
832 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>,
833 class ALLOCATOR = default_allocator>
834 MDBX_CXX20_CONSTEXPR ::std::basic_string<CHAR, T, ALLOCATOR>
835 as_string(
const ALLOCATOR &allocator = ALLOCATOR())
const {
836 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
837 return ::std::basic_string<CHAR, T, ALLOCATOR>(char_ptr(), length(),
841 template <
class CHAR,
class T,
class ALLOCATOR>
843 operator ::std::basic_string<CHAR, T, ALLOCATOR>()
const {
844 return as_string<CHAR, T, ALLOCATOR>();
848 template <
class ALLOCATOR = default_allocator>
849 inline string<ALLOCATOR>
850 as_hex_string(
bool uppercase =
false,
unsigned wrap_width = 0,
851 const ALLOCATOR &allocator = ALLOCATOR())
const;
855 template <
class ALLOCATOR = default_allocator>
856 inline string<ALLOCATOR>
857 as_base58_string(
unsigned wrap_width = 0,
858 const ALLOCATOR &allocator = ALLOCATOR())
const;
862 template <
class ALLOCATOR = default_allocator>
863 inline string<ALLOCATOR>
864 as_base64_string(
unsigned wrap_width = 0,
865 const ALLOCATOR &allocator = ALLOCATOR())
const;
869 class CAPACITY_POLICY = default_capacity_policy>
870 inline buffer<ALLOCATOR, CAPACITY_POLICY>
871 encode_hex(
bool uppercase =
false,
unsigned wrap_width = 0,
872 const ALLOCATOR &allocator = ALLOCATOR())
const;
877 class CAPACITY_POLICY = default_capacity_policy>
878 inline buffer<ALLOCATOR, CAPACITY_POLICY>
879 encode_base58(
unsigned wrap_width = 0,
880 const ALLOCATOR &allocator = ALLOCATOR())
const;
885 class CAPACITY_POLICY = default_capacity_policy>
886 inline buffer<ALLOCATOR, CAPACITY_POLICY>
887 encode_base64(
unsigned wrap_width = 0,
888 const ALLOCATOR &allocator = ALLOCATOR())
const;
892 class CAPACITY_POLICY = default_capacity_policy>
893 inline buffer<ALLOCATOR, CAPACITY_POLICY>
894 hex_decode(
bool ignore_spaces =
false,
895 const ALLOCATOR &allocator = ALLOCATOR())
const;
900 class CAPACITY_POLICY = default_capacity_policy>
901 inline buffer<ALLOCATOR, CAPACITY_POLICY>
902 base58_decode(
bool ignore_spaces =
false,
903 const ALLOCATOR &allocator = ALLOCATOR())
const;
908 class CAPACITY_POLICY = default_capacity_policy>
909 inline buffer<ALLOCATOR, CAPACITY_POLICY>
910 base64_decode(
bool ignore_spaces =
false,
911 const ALLOCATOR &allocator = ALLOCATOR())
const;
926 is_hex(
bool ignore_spaces = false) const noexcept;
934 is_base58(
bool ignore_spaces = false) const noexcept;
942 is_base64(
bool ignore_spaces = false) const noexcept;
944 inline
void swap(
slice &other) noexcept;
946 #if defined(DOXYGEN) || \
947 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
948 template <
class CHAR,
class T>
949 void swap(::std::basic_string_view<CHAR, T> &view) noexcept {
950 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
951 const auto temp = ::std::basic_string_view<CHAR, T>(*
this);
1010 inline
void remove_prefix(
size_t n) noexcept;
1014 inline
void remove_suffix(
size_t n) noexcept;
1018 inline
void safe_remove_prefix(
size_t n);
1022 inline
void safe_remove_suffix(
size_t n);
1026 starts_with(const
slice &prefix) const noexcept;
1030 ends_with(const
slice &suffix) const noexcept;
1069 hash_value() const noexcept;
1080 compare_fast(const
slice &a, const
slice &b) noexcept;
1088 compare_lexicographically(const
slice &a, const
slice &b) noexcept;
1090 const
slice &b) noexcept;
1092 const
slice &b) noexcept;
1094 const
slice &b) noexcept;
1096 const
slice &b) noexcept;
1098 const
slice &b) noexcept;
1100 const
slice &b) noexcept;
1104 return !(iov_base ==
nullptr && iov_len != 0);
1110 return slice(
size_t(-1));
1114 static_assert(::std::is_standard_layout<POD>::value &&
1115 !::std::is_pointer<POD>::value,
1116 "Must be a standard layout type!");
1120 memcpy(&r, data(),
sizeof(r));
1126 #ifdef MDBX_U128_TYPE
1128 return as_pod<MDBX_U128_TYPE>();
1136 #ifdef MDBX_I128_TYPE
1138 return as_pod<MDBX_I128_TYPE>();
1146 #ifdef MDBX_U128_TYPE
1154 #ifdef MDBX_I128_TYPE
1169 namespace allocation_aware_details {
1172 #if defined(__cpp_lib_allocator_traits_is_always_equal) && \
1173 __cpp_lib_allocator_traits_is_always_equal >= 201411L
1174 return ::std::allocator_traits<A>::is_always_equal::value;
1176 return ::std::is_empty<A>::value;
1180 template <
typename T,
typename A =
typename T::allocator_type,
1181 bool PoCMA = ::std::allocator_traits<
1182 A>::propagate_on_container_move_assignment::value>
1186 static constexpr
bool is_nothrow() noexcept {
1187 return allocator_is_always_equal<A>();
1190 return allocator_is_always_equal<A>() ||
1191 target->get_allocator() == source.get_allocator();
1194 assert(target->get_allocator() != source.get_allocator());
1200 template <
typename T,
typename A>
struct move_assign_alloc<T, A, true> {
1201 static constexpr
bool is_nothrow() noexcept {
1202 return allocator_is_always_equal<A>() ||
1203 ::std::is_nothrow_move_assignable<A>::value;
1205 static constexpr
bool is_moveable(T *, T &) noexcept {
return true; }
1207 assert(target->get_allocator() != source.get_allocator());
1208 target->get_allocator() = ::std::move(source.get_allocator());
1212 template <
typename T,
typename A =
typename T::allocator_type,
1213 bool PoCCA = ::std::allocator_traits<
1214 A>::propagate_on_container_copy_assignment::value>
1218 static constexpr
bool is_nothrow() noexcept {
return false; }
1220 const T &source) noexcept {
1221 assert(target->get_allocator() != source.get_allocator());
1227 template <
typename T,
typename A>
struct copy_assign_alloc<T, A, true> {
1228 static constexpr
bool is_nothrow() noexcept {
1229 return allocator_is_always_equal<A>() ||
1230 ::std::is_nothrow_copy_assignable<A>::value;
1233 propagate(T *target,
const T &source) noexcept(is_nothrow()) {
1235 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1236 MDBX_CXX20_UNLIKELY target->get_allocator() =
1237 ::std::allocator_traits<A>::select_on_container_copy_construction(
1238 source.get_allocator());
1247 template <
typename T,
typename A =
typename T::allocator_type,
1249 ::std::allocator_traits<A>::propagate_on_container_swap::value>
1252 template <
typename T,
typename A>
struct swap_alloc<T, A, false> {
1253 static constexpr
bool is_nothrow() noexcept {
1254 return allocator_is_always_equal<A>();
1257 T &source) noexcept(is_nothrow()) {
1259 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1269 template <
typename T,
typename A>
struct swap_alloc<T, A, true> {
1270 static constexpr
bool is_nothrow() noexcept {
1271 return allocator_is_always_equal<A>() ||
1272 #if defined(__cpp_lib_is_swappable) && __cpp_lib_is_swappable >= 201603L
1273 ::std::is_nothrow_swappable<A>() ||
1275 (::std::is_nothrow_move_constructible<A>::value &&
1276 ::std::is_nothrow_move_assignable<A>::value);
1279 T &source) noexcept(is_nothrow()) {
1281 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1282 MDBX_CXX20_UNLIKELY ::std::swap(*target, source);
1295 extra_inplace_storage = 0,
1296 pettiness_threshold = 64,
1301 static_assert((pettiness_threshold & (pettiness_threshold - 1)) == 0,
1302 "pettiness_threshold must be a power of 2");
1303 static_assert(pettiness_threshold % 2 == 0,
1304 "pettiness_threshold must be even");
1305 static_assert(pettiness_threshold >=
sizeof(uint64_t),
1306 "pettiness_threshold must be > 7");
1307 constexpr
const auto pettiness_mask = ~size_t(pettiness_threshold - 1);
1308 return (value + pettiness_threshold - 1) & pettiness_mask;
1312 const size_t wanna) {
1313 static_assert(max_reserve % pettiness_threshold == 0,
1314 "max_reserve must be a multiple of pettiness_threshold");
1315 static_assert(max_reserve / 3 > pettiness_threshold,
1316 "max_reserve must be > pettiness_threshold * 3");
1317 if (wanna > current)
1319 return round(wanna + ::std::min(
size_t(max_reserve), current));
1321 if (current - wanna >
1324 ::std::min(wanna + pettiness_threshold,
size_t(max_reserve)))
1325 return round(wanna);
1335 const bool uppercase =
false;
1336 const unsigned wrap_width = 0;
1338 unsigned wrap_width = 0) noexcept
1339 : source(source), uppercase(uppercase), wrap_width(wrap_width) {
1344 template <
class ALLOCATOR = default_allocator>
1346 return make_string<ALLOCATOR>(*
this, allocator);
1354 return make_buffer<ALLOCATOR>(*
this, allocator);
1360 const size_t bytes = source.
length() << 1;
1361 return wrap_width ? bytes + bytes / wrap_width : bytes;
1371 ::std::ostream &
output(::std::ostream &out)
const;
1386 const unsigned wrap_width = 0;
1389 : source(source), wrap_width(wrap_width) {
1395 template <
class ALLOCATOR = default_allocator>
1397 return make_string<ALLOCATOR>(*
this, allocator);
1406 return make_buffer<ALLOCATOR>(*
this, allocator);
1412 const size_t bytes = (source.
length() * 11 + 7) / 8;
1413 return wrap_width ? bytes + bytes / wrap_width : bytes;
1425 ::std::ostream &
output(::std::ostream &out)
const;
1440 const unsigned wrap_width = 0;
1443 : source(source), wrap_width(wrap_width) {
1449 template <
class ALLOCATOR = default_allocator>
1451 return make_string<ALLOCATOR>(*
this, allocator);
1460 return make_buffer<ALLOCATOR>(*
this, allocator);
1466 const size_t bytes = (source.
length() + 2) / 3 * 4;
1467 return wrap_width ? bytes + bytes / wrap_width : bytes;
1479 ::std::ostream &
output(::std::ostream &out)
const;
1491 return wrapper.
output(out);
1495 return wrapper.
output(out);
1499 return wrapper.
output(out);
1505 const bool ignore_spaces =
false;
1507 bool ignore_spaces =
false) noexcept
1508 : source(source), ignore_spaces(ignore_spaces) {
1513 template <
class ALLOCATOR = default_allocator>
1515 return make_string<ALLOCATOR>(*
this, allocator);
1523 return make_buffer<ALLOCATOR>(*
this, allocator);
1529 return source.
length() >> 1;
1550 const bool ignore_spaces =
false;
1552 bool ignore_spaces =
false) noexcept
1553 : source(source), ignore_spaces(ignore_spaces) {
1559 template <
class ALLOCATOR = default_allocator>
1561 return make_string<ALLOCATOR>(*
this, allocator);
1570 return make_buffer<ALLOCATOR>(*
this, allocator);
1599 const bool ignore_spaces =
false;
1601 bool ignore_spaces =
false) noexcept
1602 : source(source), ignore_spaces(ignore_spaces) {
1608 template <
class ALLOCATOR = default_allocator>
1610 return make_string<ALLOCATOR>(*
this, allocator);
1619 return make_buffer<ALLOCATOR>(*
this, allocator);
1626 return (source.
length() + 3) / 4 * 3;
1645 template <class ALLOCATOR, typename CAPACITY_POLICY> class
buffer {
1647 #if !defined(_MSC_VER) || _MSC_VER > 1900
1649 ALLOCATOR>::template rebind_alloc<uint64_t>;
1651 using allocator_type =
typename ALLOCATOR::template rebind<uint64_t>::other;
1657 max_capacity = (max_length / 3u * 4u + 1023u) & ~
size_t(1023),
1658 extra_inplace_storage = reservation_policy::extra_inplace_storage,
1659 pettiness_threshold = reservation_policy::pettiness_threshold
1674 using allocator_pointer =
typename allocator_traits::pointer;
1675 using allocator_const_pointer =
typename allocator_traits::const_pointer;
1677 MDBX_CXX20_CONSTEXPR ::std::pair<allocator_pointer, size_t>
1678 allocate_storage(
size_t bytes) {
1679 assert(bytes >=
sizeof(bin));
1680 constexpr
size_t unit =
sizeof(
typename allocator_type::value_type);
1681 static_assert((unit & (unit - 1)) == 0,
1682 "size of ALLOCATOR::value_type should be a power of 2");
1683 static_assert(unit > 0,
"size of ALLOCATOR::value_type must be > 0");
1684 const size_t n = (bytes + unit - 1) / unit;
1685 return ::std::make_pair(allocator_traits::allocate(get_allocator(), n),
1690 constexpr
size_t unit =
sizeof(
typename allocator_type::value_type);
1691 assert(ptr && bytes >=
sizeof(bin) && bytes >= unit && bytes % unit == 0);
1692 allocator_traits::deallocate(get_allocator(), ptr, bytes / unit);
1696 to_address(allocator_pointer ptr) noexcept {
1697 #if defined(__cpp_lib_to_address) && __cpp_lib_to_address >= 201711L
1698 return static_cast<void *
>(::std::to_address(ptr));
1700 return static_cast<void *
>(::std::addressof(*ptr));
1704 to_address(allocator_const_pointer ptr) noexcept {
1705 #if defined(__cpp_lib_to_address) && __cpp_lib_to_address >= 201711L
1706 return static_cast<const void *
>(::std::to_address(ptr));
1708 return static_cast<const void *
>(::std::addressof(*ptr));
1716 constexpr
allocated(allocator_pointer ptr,
size_t bytes) noexcept
1717 : ptr_(ptr), capacity_bytes_(bytes) {}
1727 uint64_t align_hint_;
1728 byte inplace_[(sizeof(
allocated) + extra_inplace_storage + 7u) &
1731 static constexpr
bool
1732 is_suitable_for_inplace(
size_t capacity_bytes) noexcept {
1733 static_assert(
sizeof(
bin) ==
sizeof(inplace_),
"WTF?");
1734 return capacity_bytes <
sizeof(
bin);
1741 le_lastbyte_mask = 0x80,
1745 be_lastbyte_mask = 0x01
1750 endian::native == endian::little || endian::native == endian::big,
1751 "Only the little-endian or big-endian bytes order are supported");
1752 return (endian::native == endian::little) ? le_lastbyte_mask
1756 return inplace_[
sizeof(
bin) - 1];
1759 return inplace_[
sizeof(
bin) - 1];
1763 return (lastbyte() & inplace_lastbyte_mask()) != 0;
1767 template <
bool destroy_ptr>
1772 allocated_.~allocated();
1774 if (::std::is_trivial<allocator_pointer>::value)
1776 ::std::memset(&allocated_.ptr_, 0,
sizeof(allocated_.ptr_));
1777 lastbyte() = inplace_lastbyte_mask();
1779 is_suitable_for_inplace(capacity()));
1783 template <
bool construct_ptr>
1787 (capacity_bytes & be_lastbyte_mask) == 0 &&
1789 (
sizeof(allocated_.capacity_bytes_) - 1) * CHAR_BIT) &
1790 le_lastbyte_mask) == 0);
1793 new (&allocated_)
allocated(ptr, capacity_bytes);
1796 allocated_.ptr_ = ptr;
1797 allocated_.capacity_bytes_ = capacity_bytes;
1800 capacity() == capacity_bytes);
1806 make_inplace<false>();
1807 (void)capacity_bytes;
1810 size_t capacity_bytes) noexcept {
1812 make_allocated<true>(ptr, capacity_bytes);
1817 allocated_.~allocated();
1820 if (ditto.is_inplace()) {
1823 memcpy(inplace_, ditto.inplace_,
sizeof(inplace_));
1826 new (&allocated_)
allocated(::std::move(ditto.allocated_));
1827 ditto.make_inplace<
true>();
1833 if (ditto.is_inplace()) {
1838 allocated_.~allocated();
1839 memcpy(inplace_, ditto.inplace_,
sizeof(inplace_));
1841 }
else if (is_inplace())
1842 make_allocated<true>(ditto.allocated_.ptr_,
1843 ditto.allocated_.capacity_bytes_);
1845 make_allocated<false>(ditto.allocated_.ptr_,
1846 ditto.allocated_.capacity_bytes_);
1851 operator=(
const_cast<const bin &
>(ditto));
1852 if (ditto.is_allocated())
1853 ditto.make_inplace<
true>();
1858 const size_t wanna) {
1862 const size_t advised = reservation_policy::advise(current, wanna);
1863 assert(advised >= wanna);
1864 return ::std::min(
size_t(max_capacity),
1865 ::std::max(
sizeof(
bin) - 1, advised));
1871 :
static_cast<const byte *
>(to_address(allocated_.ptr_));
1874 return is_inplace() ? inplace_
1875 :
static_cast<byte *
>(to_address(allocated_.ptr_));
1878 return is_inplace() ?
sizeof(
bin) - 1 : allocated_.capacity_bytes_;
1883 capacity = bin::advise_capacity(0, capacity);
1884 if (bin_.is_suitable_for_inplace(capacity))
1887 const auto pair = allocate_storage(capacity);
1888 assert(
pair.second >= capacity);
1889 new (&bin_) bin(
pair.first,
pair.second);
1891 return bin_.address();
1895 if (bin_.is_allocated()) {
1896 deallocate_storage(bin_.allocated_.ptr_,
1897 bin_.allocated_.capacity_bytes_);
1898 bin_.template make_inplace<true>();
1902 template <
bool external_content>
1904 reshape(
const size_t wanna_capacity,
const size_t wanna_headroom,
1905 const void *
const content,
const size_t length) {
1906 assert(wanna_capacity >= wanna_headroom + length);
1907 const size_t old_capacity = bin_.capacity();
1908 const size_t new_capacity =
1909 bin::advise_capacity(old_capacity, wanna_capacity);
1912 assert(bin_.is_inplace() ==
1913 bin::is_suitable_for_inplace(new_capacity));
1914 byte *
const new_place = bin_.address() + wanna_headroom;
1917 if (external_content)
1918 memcpy(new_place, content, length);
1920 const size_t old_headroom =
1921 bin_.address() -
static_cast<const byte *
>(content);
1922 assert(old_capacity >= old_headroom + length);
1924 MDBX_CXX20_UNLIKELY ::std::memmove(new_place, content,
1931 if (bin::is_suitable_for_inplace(new_capacity)) {
1932 assert(bin_.is_allocated());
1933 const auto old_allocated = ::std::move(bin_.allocated_.ptr_);
1934 byte *
const new_place =
1935 bin_.template make_inplace<true>() + wanna_headroom;
1938 deallocate_storage(old_allocated, old_capacity);
1942 if (!bin_.is_allocated()) {
1943 const auto pair = allocate_storage(new_capacity);
1944 assert(pair.second >= new_capacity);
1945 byte *
const new_place =
1946 static_cast<byte *
>(to_address(pair.first)) + wanna_headroom;
1949 bin_.template make_allocated<true>(pair.first, pair.second);
1953 const auto old_allocated = ::std::move(bin_.allocated_.ptr_);
1954 if (external_content)
1955 deallocate_storage(old_allocated, old_capacity);
1956 const auto pair = allocate_storage(new_capacity);
1957 assert(pair.second >= new_capacity);
1958 byte *
const new_place =
1959 bin_.template make_allocated<false>(pair.first, pair.second) +
1963 if (!external_content)
1964 deallocate_storage(old_allocated, old_capacity);
1969 assert(capacity() >= offset);
1970 return bin_.address() + offset;
1973 assert(capacity() >= offset);
1974 return bin_.address() + offset;
1978 assert(capacity() >= offset + length);
1979 return static_cast<byte *
>(memcpy(get(offset), ptr, length));
1985 silo() noexcept : allocator_type() { init(0); }
1987 silo(
const allocator_type &alloc) noexcept : allocator_type(alloc) {
1997 ::std::is_nothrow_move_constructible<allocator_type>::value)
1998 : allocator_type(::std::move(ditto.get_allocator())),
1999 bin_(::std::move(ditto.bin_)) {}
2004 assert(capacity >= headroom + length);
2006 put(headroom, ptr, length);
2011 size_t length,
const allocator_type &alloc)
2012 : silo(capacity, alloc) {
2013 assert(capacity >= headroom + length);
2015 put(headroom, ptr, length);
2019 : silo(length, 0, ptr, length) {}
2021 const allocator_type &alloc)
2022 : silo(length, 0, ptr, length, alloc) {}
2024 ~silo() { release(); }
2029 size_t length,
size_t tailroom) {
2030 return reshape<true>(headroom + length + tailroom, headroom, ptr, length);
2033 return assign(0, ptr, length, 0);
2038 assert(ditto.get() + headroom == content.byte_ptr());
2040 allocator_is_always_equal<allocator_type>()) {
2041 if (
MDBX_UNLIKELY(get_allocator() != ditto.get_allocator()))
2042 MDBX_CXX20_UNLIKELY {
2044 allocation_aware_details::copy_assign_alloc<
2045 silo, allocator_type>::propagate(
this, ditto);
2048 content.iov_base = reshape<true>(ditto.capacity(), headroom,
2049 content.data(), content.length());
2054 assign(silo &&ditto,
size_t headroom, slice &content) noexcept(
2055 allocation_aware_details::move_assign_alloc<
2056 silo, allocator_type>::is_nothrow()) {
2057 assert(ditto.get() + headroom == content.byte_ptr());
2058 if (allocation_aware_details::move_assign_alloc<
2059 silo, allocator_type>::is_moveable(
this, ditto)) {
2061 allocation_aware_details::move_assign_alloc<
2062 silo, allocator_type>::propagate(
this, ditto);
2064 bin_ = ::std::move(ditto.bin_);
2065 assert(get() + headroom == content.byte_ptr());
2068 content.iov_base = reshape<true>(ditto.capacity(), headroom,
2069 content.data(), content.length());
2076 return reshape<true>(0, 0,
nullptr, 0);
2080 return reshape<false>(whole_capacity, headroom,
nullptr, 0);
2085 reshape<false>(capacity, headroom, content.iov_base, content.iov_len);
2088 allocation_aware_details::swap_alloc<silo,
2089 allocator_type>::is_nothrow()) {
2090 allocation_aware_details::swap_alloc<silo, allocator_type>::propagate(
2092 ::std::swap(bin_, ditto.bin_);
2098 capacity() const noexcept {
2099 return bin_.capacity();
2102 data(
size_t offset = 0) const noexcept {
2106 data(
size_t offset = 0) noexcept {
2115 assert(is_reference());
2117 slice_.iov_base = silo_.
data();
2121 silo_begin() const noexcept {
2122 return static_cast<const byte *
>(silo_.data());
2126 silo_end() const noexcept {
2127 return silo_begin() + silo_.capacity();
2130 struct data_preserver :
public exception_thunk {
2132 data_preserver(allocator_type &allocator) : data(allocator) {}
2133 static int callback(
void *context,
MDBX_val *target,
const void *src,
2134 size_t bytes) noexcept {
2135 auto self =
static_cast<data_preserver *
>(context);
2136 assert(self->is_clean());
2137 assert(&self->data.slice_ == target);
2140 self->data.assign(src, bytes,
false);
2168 return silo_.get_allocator();
2175 static_assert(
size_t(-
long(max_length)) > max_length,
"WTF?");
2176 return size_t(byte_ptr() - silo_begin()) < silo_.capacity();
2183 return !is_freestanding();
2190 return is_freestanding() ? silo_.capacity() : 0;
2197 return is_freestanding() ? slice_.
byte_ptr() - silo_begin() : 0;
2204 return is_freestanding() ? capacity() - headroom() - slice_.
length() : 0;
2222 return const_cast<byte *
>(slice_.
byte_ptr());
2248 return const_cast<char *
>(slice_.
char_ptr());
2261 return slice_.
data();
2272 return const_cast<void *
>(slice_.
data());
2280 return const_cast<void *
>(slice_.
end());
2287 slice_.
length() + headroom() <=
2295 bytes + headroom() <= silo_.capacity());
2303 return set_length(
static_cast<const char *
>(ptr) - char_ptr());
2316 : silo_(allocator) {}
2320 : silo_(allocator), slice_(src) {
2321 if (!make_reference)
2327 :
buffer(src.slice_, make_reference, allocator) {}
2329 buffer(
const void *ptr,
size_t bytes,
bool make_reference,
2333 template <
class CHAR,
class T,
class A>
2334 buffer(const ::std::basic_string<CHAR, T, A> &) =
delete;
2335 template <
class CHAR,
class T,
class A>
2336 buffer(const ::std::basic_string<CHAR, T, A> &&) =
delete;
2338 buffer(
const char *c_str,
bool make_reference,
2342 #if defined(DOXYGEN) || \
2343 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2344 template <
class CHAR,
class T>
2345 buffer(const ::std::basic_string_view<CHAR, T> &view,
bool make_reference,
2353 : silo_(src.data(), src.length(), allocator),
2354 slice_(silo_.data(), src.length()) {}
2358 :
buffer(src.slice_, allocator) {}
2365 template <
class CHAR,
class T,
class A>
2367 buffer(const ::std::basic_string<CHAR, T, A> &str,
2375 #if defined(DOXYGEN) || \
2376 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2377 template <
class CHAR,
class T>
2379 buffer(const ::std::basic_string_view<CHAR, T> &view,
2386 : silo_(allocator) {
2387 slice_.iov_base = silo_.init(check_length(head_room, tail_room));
2388 assert(slice_.iov_len == 0);
2392 : silo_(allocator) {
2393 slice_.iov_base = silo_.init(check_length(capacity));
2394 assert(slice_.iov_len == 0);
2399 : silo_(allocator) {
2401 silo_.init(check_length(head_room, src.
length(), tail_room));
2402 slice_.iov_len = src.
length();
2403 memcpy(slice_.iov_base, src.
data(), src.
length());
2408 :
buffer(head_room, src.slice_, tail_room, allocator) {}
2414 : silo_(::std::move(src.silo_)), slice_(::std::move(src.slice_)) {}
2424 #if defined(DOXYGEN) || (defined(__cpp_lib_span) && __cpp_lib_span >= 202002L)
2425 template <
typename POD>
2427 :
buffer(span.begin(), span.end()) {
2428 static_assert(::std::is_standard_layout<POD>::value &&
2429 !::std::is_pointer<POD>::value,
2430 "Must be a standard layout type!");
2433 template <
typename POD>
2434 MDBX_CXX14_CONSTEXPR ::std::span<const POD>
as_span()
const {
2435 return slice_.template as_span<const POD>();
2437 template <
typename POD> MDBX_CXX14_CONSTEXPR ::std::span<POD>
as_span() {
2438 return slice_.template as_span<POD>();
2441 MDBX_CXX14_CONSTEXPR ::std::span<const byte>
bytes()
const {
2442 return as_span<const byte>();
2444 MDBX_CXX14_CONSTEXPR ::std::span<byte>
bytes() {
return as_span<byte>(); }
2445 MDBX_CXX14_CONSTEXPR ::std::span<const char>
chars()
const {
2446 return as_span<const char>();
2448 MDBX_CXX14_CONSTEXPR ::std::span<char>
chars() {
return as_span<char>(); }
2451 template <
typename POD>
2458 return slice_.
as_pod<POD>();
2461 #ifdef MDBX_U128_TYPE
2477 #ifdef MDBX_I128_TYPE
2487 #ifdef MDBX_U128_TYPE
2495 #ifdef MDBX_I128_TYPE
2504 static buffer hex(const ::mdbx::slice &source,
bool uppercase =
false,
2505 unsigned wrap_width = 0,
2507 return source.template encode_hex<ALLOCATOR, CAPACITY_POLICY>(
2508 uppercase, wrap_width, allocator);
2515 return source.template encode_base58<ALLOCATOR, CAPACITY_POLICY>(wrap_width,
2522 return source.template encode_base64<ALLOCATOR, CAPACITY_POLICY>(wrap_width,
2527 template <
typename POD>
2529 unsigned wrap_width = 0,
2536 template <
typename POD>
2544 template <
typename POD>
2553 return slice().template encode_hex<ALLOCATOR, CAPACITY_POLICY>(
2554 uppercase, wrap_width, allocator);
2562 return slice().template encode_base58<ALLOCATOR, CAPACITY_POLICY>(
2563 wrap_width, allocator);
2570 return slice().template encode_base64<ALLOCATOR, CAPACITY_POLICY>(
2571 wrap_width, allocator);
2576 bool ignore_spaces =
false,
2578 return source.template hex_decode<ALLOCATOR, CAPACITY_POLICY>(ignore_spaces,
2587 return source.template base58_decode<ALLOCATOR, CAPACITY_POLICY>(
2588 ignore_spaces, allocator);
2596 return source.template base64_decode<ALLOCATOR, CAPACITY_POLICY>(
2597 ignore_spaces, allocator);
2604 return hex_decode(
slice(), ignore_spaces, allocator);
2612 return base58_decode(
slice(), ignore_spaces, allocator);
2620 return base64_decode(
slice(), ignore_spaces, allocator);
2624 void reserve(
size_t wanna_headroom,
size_t wanna_tailroom) {
2625 wanna_headroom = ::std::min(::std::max(headroom(), wanna_headroom),
2626 wanna_headroom + pettiness_threshold);
2627 wanna_tailroom = ::std::min(::std::max(tailroom(), wanna_tailroom),
2628 wanna_tailroom + pettiness_threshold);
2629 const size_t wanna_capacity =
2630 check_length(wanna_headroom, slice_.
length(), wanna_tailroom);
2631 silo_.resize(wanna_capacity, wanna_headroom, slice_);
2632 assert(headroom() >= wanna_headroom &&
2633 headroom() <= wanna_headroom + pettiness_threshold);
2634 assert(tailroom() >= wanna_tailroom &&
2635 tailroom() <= wanna_tailroom + pettiness_threshold);
2646 slice_.
assign(ptr, bytes);
2651 silo_.
assign(
static_cast<const typename silo::value_type *
>(ptr),
2652 check_length(bytes));
2653 slice_.
assign(silo_.data(), bytes);
2659 silo_.swap(other.silo_);
2660 slice_.
swap(other.slice_);
2669 return assign(src.slice_, make_reference);
2672 buffer &
assign(
const void *ptr,
size_t bytes,
bool make_reference =
false) {
2673 return make_reference ? assign_reference(ptr, bytes)
2674 : assign_freestanding(ptr, bytes);
2678 return assign(src.
data(), src.
length(), make_reference);
2682 return assign(src.iov_base, src.iov_len, make_reference);
2686 assign(src.
data(), src.
length(), make_reference);
2692 assign(src.iov_base, src.iov_len, make_reference);
2693 src.iov_base =
nullptr;
2698 bool make_reference =
false) {
2699 return assign(begin,
2700 static_cast<const byte *
>(end) -
2701 static_cast<const byte *
>(begin),
2705 template <
class CHAR,
class T,
class A>
2707 bool make_reference =
false) {
2708 return assign(str.data(), str.length(), make_reference);
2712 return assign(c_str, ::mdbx::strlen(c_str), make_reference);
2715 #if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
2716 template <
class CHAR,
class T>
2717 buffer &assign(const ::std::basic_string_view<CHAR, T> &view,
2718 bool make_reference =
false) {
2719 return assign(view.data(), view.length(), make_reference);
2722 template <
class CHAR,
class T>
2723 buffer &assign(::std::basic_string_view<CHAR, T> &&view,
2724 bool make_reference =
false) {
2725 assign(view.data(), view.length(), make_reference);
2734 return assign(::std::move(src));
2741 #if defined(DOXYGEN) || \
2742 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2743 template <
class CHAR,
class T>
2745 return assign(view);
2749 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>>
2750 ::std::basic_string_view<CHAR, T> string_view() const noexcept {
2755 template <
class CHAR,
class T>
2756 operator ::std::basic_string_view<CHAR, T>() const noexcept {
2757 return string_view<CHAR, T>();
2763 return length() == 0;
2768 return data() ==
nullptr;
2785 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>,
2786 class A = legacy_allocator>
2787 MDBX_CXX20_CONSTEXPR ::std::basic_string<CHAR, T, A>
2789 return slice_.
as_string<CHAR, T, A>(allocator);
2792 template <
class CHAR,
class T,
class A>
2794 operator ::std::basic_string<CHAR, T, A>()
const {
2795 return as_string<CHAR, T, A>();
2815 slice_.
assign(silo_.clear_and_reserve(whole_capacity, headroom),
size_t(0));
2848 return byte_ptr()[n];
2860 return byte_ptr()[n];
2866 return slice_.
head(n);
2872 return slice_.
tail(n);
2878 size_t n) const noexcept {
2879 return slice_.
middle(from, n);
2902 MDBX_CXX20_UNLIKELY reserve_tailroom(bytes);
2903 memcpy(slice_.
byte_ptr() + size(), src, bytes);
2904 slice_.iov_len += bytes;
2909 return append(chunk.data(), chunk.size());
2914 MDBX_CXX20_UNLIKELY reserve_headroom(bytes);
2916 memcpy(
static_cast<char *
>(slice_.iov_base) - bytes, src, bytes);
2917 slice_.iov_len += bytes;
2922 return add_header(chunk.data(), chunk.size());
2925 template <MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER)>
2927 const size_t wanna_bytes = producer.envisage_result_length();
2929 MDBX_CXX20_UNLIKELY reserve_tailroom(wanna_bytes);
2930 return set_end(producer.write_bytes(end_char_ptr(), tailroom()));
2933 template <MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER)>
2935 const size_t wanna_bytes = producer.envisage_result_length();
2937 MDBX_CXX20_UNLIKELY reserve_tailroom(wanna_bytes);
2938 return set_end(producer.write_bytes(end_char_ptr(), tailroom()));
2942 unsigned wrap_width = 0) {
2943 return append_producer(
to_hex(data, uppercase, wrap_width));
2947 return append_producer(
to_base58(data, wrap_width));
2951 return append_producer(
to_base64(data, wrap_width));
2955 bool ignore_spaces =
false) {
2956 return append_producer(
from_hex(data, ignore_spaces));
2960 bool ignore_spaces =
false) {
2961 return append_producer(
from_base58(data, ignore_spaces));
2965 bool ignore_spaces =
false) {
2966 return append_producer(
from_base64(data, ignore_spaces));
2971 MDBX_CXX20_UNLIKELY reserve_tailroom(1);
2973 slice_.iov_len += 1;
2981 MDBX_CXX20_UNLIKELY reserve_tailroom(2);
2982 const auto ptr = slice_.
byte_ptr();
2983 ptr[0] = uint8_t(u16);
2984 ptr[1] = uint8_t(u16 >> 8);
2985 slice_.iov_len += 2;
2991 MDBX_CXX20_UNLIKELY reserve_tailroom(3);
2992 const auto ptr = slice_.
byte_ptr();
2993 ptr[0] = uint8_t(u24);
2994 ptr[1] = uint8_t(u24 >> 8);
2995 ptr[2] = uint8_t(u24 >> 16);
2996 slice_.iov_len += 3;
3002 MDBX_CXX20_UNLIKELY reserve_tailroom(4);
3003 const auto ptr = slice_.
byte_ptr();
3004 ptr[0] = uint8_t(u32);
3005 ptr[1] = uint8_t(u32 >> 8);
3006 ptr[2] = uint8_t(u32 >> 16);
3007 ptr[3] = uint8_t(u32 >> 24);
3008 slice_.iov_len += 4;
3014 MDBX_CXX20_UNLIKELY reserve_tailroom(6);
3015 const auto ptr = slice_.
byte_ptr();
3016 ptr[0] = uint8_t(u48);
3017 ptr[1] = uint8_t(u48 >> 8);
3018 ptr[2] = uint8_t(u48 >> 16);
3019 ptr[3] = uint8_t(u48 >> 24);
3020 ptr[4] = uint8_t(u48 >> 32);
3021 ptr[5] = uint8_t(u48 >> 40);
3022 slice_.iov_len += 6;
3028 MDBX_CXX20_UNLIKELY reserve_tailroom(8);
3029 const auto ptr = slice_.
byte_ptr();
3030 ptr[0] = uint8_t(u64);
3031 ptr[1] = uint8_t(u64 >> 8);
3032 ptr[2] = uint8_t(u64 >> 16);
3033 ptr[3] = uint8_t(u64 >> 24);
3034 ptr[4] = uint8_t(u64 >> 32);
3035 ptr[5] = uint8_t(u64 >> 40);
3036 ptr[6] = uint8_t(u64 >> 48);
3037 ptr[7] = uint8_t(u64 >> 56);
3038 slice_.iov_len += 8;
3044 template <
size_t SIZE>
3049 #if defined(DOXYGEN) || \
3050 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
3051 template <
class CHAR,
class T>
3053 bool make_reference =
false) {
3054 return buffer(src, make_reference);
3059 return buffer(src, make_reference);
3062 template <
class CHAR,
class T,
class A>
3064 bool make_reference =
false) {
3065 return buffer(src, make_reference);
3069 return buffer(::std::move(src));
3077 return key_from_double(ieee754_64bit);
3085 return wrap(unsigned_int64);
3089 return key_from_u64(unsigned_int64);
3097 return key_from_i64(signed_int64);
3109 return key_from_float(ieee754_32bit);
3117 return wrap(unsigned_int32);
3121 return key_from_u32(unsigned_int32);
3129 return key_from_i32(signed_int32);
3133 template <
class ALLOCATOR,
class CAPACITY_POLICY,
3135 inline buffer<ALLOCATOR, CAPACITY_POLICY>
3140 producer.envisage_result_length(), allocator);
3148 template <
class ALLOCATOR,
class CAPACITY_POLICY,
3150 inline buffer<ALLOCATOR, CAPACITY_POLICY>
3155 producer.envisage_result_length(), allocator);
3163 template <
class ALLOCATOR, MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER)>
3165 const ALLOCATOR &allocator) {
3169 result.resize(producer.envisage_result_length());
3170 result.resize(producer.write_bytes(
const_cast<char *
>(result.data()),
3171 result.capacity()) -
3177 template <
class ALLOCATOR, MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER)>
3179 const ALLOCATOR &allocator) {
3183 result.resize(producer.envisage_result_length());
3184 result.resize(producer.write_bytes(
const_cast<char *
>(result.data()),
3185 result.capacity()) -
3197 : value(value), done(done) {}
3201 assert(!done ||
bool(value));
3212 : key(key), value(value) {}
3214 : key(couple.first), value(couple.second) {}
3221 assert(
bool(key) ==
bool(value));
3230 compare_fast(
const pair &a,
const pair &b) noexcept;
3234 compare_lexicographically(
const pair &a,
const pair &b) noexcept;
3236 const pair &b) noexcept;
3238 const pair &b) noexcept;
3240 const pair &b) noexcept;
3242 const pair &b) noexcept;
3244 const pair &b) noexcept;
3246 const pair &b) noexcept;
3254 :
pair(
pair::invalid()), done(false) {}
3257 :
pair(key, value), done(done) {}
3261 assert(!done || (
bool(key) &&
bool(value)));
3266 template <
typename ALLOCATOR,
typename CAPACITY_POLICY>
3272 using stl_pair = ::std::pair<buffer_type, buffer_type>;
3278 : key(allocator), value(allocator) {}
3282 : key(key, allocator), value(value, allocator) {}
3284 bool make_reference,
3286 : key(key, make_reference, allocator),
3287 value(value, make_reference, allocator) {}
3298 : key(key, allocator), value(value, allocator) {}
3301 : key(key, make_reference, allocator),
3302 value(value, make_reference, allocator) {}
3313 : key(
txn, key, allocator), value(
txn, value, allocator) {}
3319 buffer_type::move_assign_alloc::is_nothrow())
3320 : key(::std::move(key)), value(::std::move(value)) {}
3322 buffer_type::move_assign_alloc::is_nothrow())
3329 return key.is_freestanding() && value.is_freestanding();
3335 return key.is_reference() || value.is_reference();
3341 key.make_freestanding();
3342 value.make_freestanding();
3345 operator pair() const noexcept {
return pair(key, value); }
3348 template <
typename BUFFER>
3350 typename BUFFER::reservation_policy>;
3409 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
3505 operator bool() const noexcept {
return dbi != 0; }
3555 inline
env &operator=(
env &&other) noexcept;
3556 inline
env(
env &&other) noexcept;
3557 inline ~
env() noexcept;
3563 const
env &b) noexcept;
3565 const
env &b) noexcept;
3578 maximal_value = INTPTR_MAX,
3601 intptr_t size_lower{minimal_value};
3606 intptr_t size_now{default_value};
3618 intptr_t size_upper{maximal_value};
3622 intptr_t growth_step{default_value};
3626 intptr_t shrink_threshold{default_value};
3632 intptr_t pagesize{default_value};
3634 inline geometry &make_fixed(intptr_t size) noexcept;
3635 inline geometry &make_dynamic(intptr_t lower = minimal_value,
3636 intptr_t upper = maximal_value) noexcept;
3641 intptr_t size_now = default_value,
3642 intptr_t size_upper = maximal_value,
3643 intptr_t growth_step = default_value,
3644 intptr_t shrink_threshold = default_value,
3645 intptr_t pagesize = default_value) noexcept
3646 : size_lower(size_lower), size_now(size_now), size_upper(size_upper),
3647 growth_step(growth_step), shrink_threshold(shrink_threshold),
3648 pagesize(pagesize) {}
3671 bool coalesce{
false};
3683 bool no_sticky_threads{
false};
3686 bool nested_write_transactions{
false};
3688 bool exclusive{
false};
3690 bool disable_readahead{
false};
3692 bool disable_clear_memory{
false};
3705 unsigned max_maps{0};
3708 unsigned max_readers{0};
3717 const unsigned max_maps,
const unsigned max_readers = 0,
3722 : max_maps(max_maps), max_readers(max_readers),
mode(
mode),
3732 bool use_subdirectory =
3769 static inline size_t pagesize_min() noexcept;
3771 static inline
size_t pagesize_max() noexcept;
3774 static inline
size_t dbsize_min(intptr_t pagesize);
3777 static inline
size_t dbsize_max(intptr_t pagesize);
3785 static inline
size_t key_max(intptr_t pagesize,
MDBX_db_flags_t flags);
3788 static inline
size_t key_max(intptr_t pagesize,
key_mode mode);
3800 static inline
size_t value_min(
value_mode) noexcept;
3804 static inline
size_t value_max(intptr_t pagesize,
MDBX_db_flags_t flags);
3807 static inline
size_t value_max(intptr_t pagesize,
value_mode);
3817 static inline
size_t pairsize4page_max(intptr_t pagesize,
3821 static inline
size_t pairsize4page_max(intptr_t pagesize,
value_mode);
3827 static inline
size_t pairsize4page_max(const
env &,
value_mode);
3831 static inline
size_t valsize4page_max(intptr_t pagesize,
3835 static inline
size_t valsize4page_max(intptr_t pagesize,
value_mode);
3841 static inline
size_t valsize4page_max(const
env &,
value_mode);
3845 static inline
size_t transaction_size_max(intptr_t pagesize);
3849 size_t dbsize_min()
const {
return limits::dbsize_min(this->get_pagesize()); }
3851 size_t dbsize_max()
const {
return limits::dbsize_max(this->get_pagesize()); }
3858 return limits::value_min(
mode);
3862 return limits::value_max(*
this,
mode);
3867 return limits::transaction_size_max(this->get_pagesize());
3872 #ifdef MDBX_STD_FILESYSTEM_PATH
3874 bool force_dynamic_size =
false);
3876 #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3877 env &
copy(const ::std::wstring &destination,
bool compactify,
3878 bool force_dynamic_size =
false);
3879 env &
copy(
const wchar_t *destination,
bool compactify,
3880 bool force_dynamic_size =
false);
3883 bool force_dynamic_size =
false);
3884 env &
copy(
const char *destination,
bool compactify,
3885 bool force_dynamic_size =
false);
3909 #ifdef MDBX_STD_FILESYSTEM_PATH
3913 #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
3914 static bool remove(const ::std::wstring &pathname,
3931 inline stat get_stat()
const;
3937 inline info get_info()
const;
3941 inline stat get_stat(
const txn &)
const;
3945 inline info get_info(
const txn &)
const;
3959 inline unsigned max_readers()
const;
3963 inline unsigned max_maps()
const;
3966 inline void *get_context() const noexcept;
3969 inline
env &set_context(
void *your_context);
3985 inline
env &set_sync_threshold(
size_t bytes);
3992 inline
size_t sync_threshold() const;
3994 #if __cplusplus >= 201103L || defined(DOXYGEN)
4027 inline env &set_sync_period__seconds_16dot16(
unsigned seconds_16dot16);
4031 inline unsigned sync_period__seconds_16dot16()
const;
4036 inline env &set_sync_period__seconds_double(
double seconds);
4040 inline double sync_period__seconds_double()
const;
4081 inline env &set_extra_option(extra_runtime_option option, uint64_t value);
4084 inline uint64_t extra_option(extra_runtime_option option)
const;
4090 inline env &set_geometry(
const geometry &size);
4095 inline bool sync_to_disk(
bool force =
true,
bool nonblock =
false);
4145 uint64_t lag,
size_t used,
4146 size_t retained) noexcept;
4156 template <
typename VISITOR>
inline int enumerate_readers(VISITOR &visitor);
4160 inline unsigned check_readers();
4185 inline MDBX_hsr_func *get_HandleSlowReaders() const noexcept;
4194 inline
txn_managed start_write(
bool dont_wait = false);
4212 void setup(
unsigned max_maps,
unsigned max_readers = 0);
4218 #ifdef MDBX_STD_FILESYSTEM_PATH
4222 #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
4224 bool accede =
true);
4226 bool accede =
true);
4229 bool accede =
true);
4231 bool accede =
true);
4239 bool use_subdirectory{
false};
4245 #ifdef MDBX_STD_FILESYSTEM_PATH
4248 bool accede =
true);
4250 #if defined(_WIN32) || defined(_WIN64) || defined(DOXYGEN)
4279 MDBX_CXX20_UNLIKELY {
4280 assert(handle_ != other.handle_);
4283 inherited::operator=(std::move(other));
4308 inline
txn &operator=(
txn &&other) noexcept;
4309 inline
txn(
txn &&other) noexcept;
4310 inline ~
txn() noexcept;
4316 const
txn &b) noexcept;
4318 const
txn &b) noexcept;
4325 inline uint64_t
id() const;
4328 inline
void *get_context() const noexcept;
4331 inline
txn &set_context(
void *your_context);
4334 inline
bool is_dirty(const
void *ptr) const;
4344 inline info get_info(
bool scan_reader_lock_table =
false)
const;
4353 assert(is_readwrite());
4354 return size_t(get_info().txn_space_dirty);
4360 inline void reset_reading();
4363 inline void renew_reading();
4372 inline size_t release_all_cursors(
bool unbind)
const;
4392 inline map_handle open_map_accede(
const char *name)
const;
4398 create_map(
const char *name,
4412 bool drop_map(
const char *name,
bool throw_if_absent =
false);
4422 bool clear_map(
const char *name,
bool throw_if_absent =
false);
4426 bool throw_if_absent =
false);
4429 inline void rename_map(
map_handle map,
const char *new_name);
4436 bool throw_if_absent =
false);
4441 bool throw_if_absent =
false);
4443 #if defined(DOXYGEN) || \
4444 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
4448 const ::std::string_view &name,
4452 inline map_handle open_map_accede(const ::std::string_view &name)
const;
4455 create_map(const ::std::string_view &name,
4461 bool drop_map(const ::std::string_view &name,
bool throw_if_absent =
false);
4464 bool clear_map(const ::std::string_view &name,
bool throw_if_absent =
false);
4466 inline void rename_map(
map_handle map, const ::std::string_view &new_name);
4471 const ::std::string_view &new_name,
4472 bool throw_if_absent =
false);
4481 inline uint32_t get_tree_deepmask(
map_handle map)
const;
4491 inline canary get_canary()
const;
4495 inline uint64_t sequence(
map_handle map)
const;
4498 inline uint64_t sequence(
map_handle map, uint64_t increment);
4503 const slice &b)
const noexcept;
4507 const slice &b)
const noexcept;
4511 const pair &b)
const noexcept;
4515 const pair &b)
const noexcept;
4524 const slice &value_at_absence)
const;
4528 const slice &value_at_absence)
const;
4537 const slice &value_at_absence)
const;
4545 size_t value_length);
4547 size_t value_length);
4551 size_t value_length);
4556 size_t value_length);
4558 size_t value_length);
4568 const slice &new_value);
4571 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4578 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4584 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4607 bool multivalue_order_preserved =
true);
4610 const size_t value_length,
const void *values_array,
4611 size_t values_count,
put_mode mode,
4612 bool allow_partial =
false);
4613 template <
typename VALUE>
4615 const VALUE *values_array,
size_t values_count,
4616 put_mode mode,
bool allow_partial =
false) {
4617 static_assert(::std::is_standard_layout<VALUE>::value &&
4618 !::std::is_pointer<VALUE>::value &&
4619 !::std::is_array<VALUE>::value,
4620 "Must be a standard layout type!");
4621 return put_multiple(map, key,
sizeof(VALUE), values_array, values_count,
4622 mode, allow_partial);
4624 template <
typename VALUE>
4626 const ::std::vector<VALUE> &vector,
put_mode mode) {
4627 put_multiple(map, key, vector.data(), vector.size(), mode);
4631 const pair &to)
const;
4633 const slice &to)
const;
4634 inline ptrdiff_t estimate_from_first(
map_handle map,
const slice &to)
const;
4635 inline ptrdiff_t estimate_to_last(
map_handle map,
const slice &from)
const;
4658 MDBX_CXX20_UNLIKELY {
4659 assert(handle_ != other.handle_);
4662 inherited::operator=(std::move(other));
4680 void commit_embark_read();
4719 inline ~
cursor() noexcept;
4725 const
cursor &b) noexcept;
4727 const
cursor &b) noexcept;
4731 bool ignore_nested) noexcept;
4733 bool ignore_nested);
4735 bool is_before_than(const
cursor &other,
bool ignore_nested = false)
const {
4740 bool ignore_nested =
false)
const {
4753 bool ignore_nested =
false)
const {
4758 inline void *get_context() const noexcept;
4761 inline
cursor &set_context(
void *your_context);
4794 multi_exactkey_value_lesser_or_equal =
4797 multi_exactkey_value_greater_or_equal =
4804 pair_exact = pair_equal,
4815 bool throw_notfound)
4820 bool throw_notfound);
4829 slice::invalid()) {}
4842 bool throw_notfound)
const;
4848 template <
typename CALLABLE_PREDICATE>
4853 void *arg) noexcept {
4854 auto thunk =
static_cast<wrapper *
>(context);
4855 assert(thunk->is_clean());
4856 auto &predicate = *
static_cast<CALLABLE_PREDICATE *
>(arg);
4873 template <
typename CALLABLE_PREDICATE>
4874 bool fullscan(CALLABLE_PREDICATE predicate,
bool backward =
false) {
4875 return scan(std::move(predicate), backward ? last : first,
4876 backward ? previous : next);
4879 template <
typename CALLABLE_PREDICATE>
4885 void *arg) noexcept {
4886 auto thunk =
static_cast<wrapper *
>(context);
4887 assert(thunk->is_clean());
4888 auto &predicate = *
static_cast<CALLABLE_PREDICATE *
>(arg);
4905 template <
typename CALLABLE_PREDICATE>
4911 void *arg) noexcept {
4912 auto thunk =
static_cast<wrapper *
>(context);
4913 assert(thunk->is_clean());
4914 auto &predicate = *
static_cast<CALLABLE_PREDICATE *
>(arg);
4932 return move_result(*
this, operation, throw_notfound);
4935 bool throw_notfound) {
4939 const slice &value,
bool throw_notfound) {
4940 return move_result(*
this, operation, key, value, throw_notfound);
4943 bool throw_notfound) {
4944 return move(operation, &key, &value, throw_notfound);
4948 return move(first, throw_notfound);
4951 return move(previous, throw_notfound);
4954 return move(multi_prevkey_lastvalue, throw_notfound);
4957 return move(multi_currentkey_firstvalue, throw_notfound);
4960 return move(multi_currentkey_prevvalue, throw_notfound);
4966 return move(multi_currentkey_nextvalue, throw_notfound);
4969 return move(multi_currentkey_lastvalue, throw_notfound);
4972 return move(multi_nextkey_firstvalue, throw_notfound);
4975 return move(next, throw_notfound);
4978 return move(last, throw_notfound);
4982 return move(key_lesser_than, key, throw_notfound);
4985 bool throw_notfound =
true) {
4986 return move(key_lesser_or_equal, key, throw_notfound);
4989 return move(key_equal, key, throw_notfound);
4992 return move(key_exact, key, throw_notfound);
4995 bool throw_notfound =
true) {
4996 return move(key_greater_or_equal, key, throw_notfound);
4999 bool throw_notfound =
true) {
5000 return move(key_greater_than, key, throw_notfound);
5005 bool throw_notfound =
true) {
5006 return move(multi_exactkey_value_lesser_than, key, value, throw_notfound);
5010 bool throw_notfound =
true) {
5011 return move(multi_exactkey_value_lesser_or_equal, key, value,
5015 bool throw_notfound =
true) {
5016 return move(multi_exactkey_value_equal, key, value, throw_notfound);
5020 bool throw_notfound =
true) {
5021 return move(multi_exactkey_value_greater_or_equal, key, value,
5026 bool throw_notfound =
true) {
5027 return move(multi_exactkey_value_greater, key, value, throw_notfound);
5031 bool throw_notfound =
true) {
5032 return move(pair_lesser_than, key, value, throw_notfound);
5035 bool throw_notfound =
true) {
5036 return move(pair_lesser_or_equal, key, value, throw_notfound);
5039 bool throw_notfound =
true) {
5040 return move(pair_equal, key, value, throw_notfound);
5043 bool throw_notfound =
true) {
5044 return move(pair_exact, key, value, throw_notfound);
5047 bool throw_notfound =
true) {
5048 return move(pair_greater_or_equal, key, value, throw_notfound);
5051 bool throw_notfound =
true) {
5052 return move(pair_greater_than, key, value, throw_notfound);
5055 inline bool seek(
const slice &key);
5056 inline move_result find(
const slice &key,
bool throw_notfound =
true);
5057 inline move_result lower_bound(
const slice &key,
bool throw_notfound =
false);
5061 inline size_t count_multivalue()
const;
5064 bool throw_notfound =
true);
5067 bool throw_notfound =
false);
5070 bool throw_notfound =
false);
5072 inline bool eof()
const;
5073 inline bool on_first()
const;
5074 inline bool on_last()
const;
5075 inline bool on_first_multival()
const;
5076 inline bool on_last_multival()
const;
5086 inline void renew(const ::mdbx::txn &
txn);
5093 inline void unbind();
5096 inline ::mdbx::txn
txn()
const;
5099 inline operator ::mdbx::txn()
const {
return txn(); }
5100 inline operator ::mdbx::map_handle()
const {
return map(); }
5104 inline void insert(
const slice &key,
slice value);
5106 inline slice insert_reserve(
const slice &key,
size_t value_length);
5110 inline slice upsert_reserve(
const slice &key,
size_t value_length);
5113 inline bool try_update(
const slice &key,
const slice &value);
5114 inline slice update_reserve(
const slice &key,
size_t value_length);
5119 inline bool erase(
bool whole_multivalue =
false);
5124 inline bool erase(
const slice &key,
bool whole_multivalue =
true);
5128 inline bool erase(
const slice &key,
const slice &value);
5159 MDBX_CXX20_UNLIKELY {
5160 assert(handle_ != other.handle_);
5163 inherited::operator=(std::move(other));
5177 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5178 inline ::std::ostream &
5207 return out <<
error(errcode);
5223 #if defined(__cpp_lib_is_constant_evaluated) && \
5224 __cpp_lib_is_constant_evaluated >= 201811L
5225 if (::std::is_constant_evaluated()) {
5226 for (
size_t i = 0; c_str; ++i)
5232 #if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
5233 return c_str ? ::std::string_view(c_str).length() : 0;
5235 return c_str ? ::std::strlen(c_str) : 0;
5240 memcpy(
void *dest,
const void *src,
size_t bytes) noexcept {
5241 #if defined(__cpp_lib_is_constant_evaluated) && \
5242 __cpp_lib_is_constant_evaluated >= 201811L
5243 if (::std::is_constant_evaluated()) {
5244 for (
size_t i = 0; i < bytes; ++i)
5245 static_cast<byte *
>(dest)[i] =
static_cast<const byte *
>(src)[i];
5249 return ::std::memcpy(dest, src, bytes);
5253 size_t bytes) noexcept {
5254 #if defined(__cpp_lib_is_constant_evaluated) && \
5255 __cpp_lib_is_constant_evaluated >= 201811L
5256 if (::std::is_constant_evaluated()) {
5257 for (
size_t i = 0; i < bytes; ++i) {
5258 const int diff = int(
static_cast<const byte *
>(a)[i]) -
5259 int(
static_cast<const byte *
>(b)[i]);
5266 return ::std::memcmp(a, b, bytes);
5277 return check_length(check_length(headroom) + check_length(payload));
5281 check_length(
size_t headroom,
size_t payload,
size_t tailroom) {
5282 return check_length(check_length(headroom, payload) + check_length(tailroom));
5289 captured_ = ::std::current_exception();
5294 MDBX_CXX20_UNLIKELY ::std::rethrow_exception(captured_);
5300 : code_(error_code) {}
5308 return a.code_ == b.code_;
5347 MDBX_CXX20_UNLIKELY throw_exception();
5352 MDBX_CXX20_UNLIKELY throw_exception();
5360 else throw_exception();
5365 const char *func_who)
const noexcept {
5367 MDBX_CXX20_UNLIKELY panic(context_where, func_who);
5371 const char *func_who)
const noexcept {
5373 MDBX_CXX20_UNLIKELY panic(context_where, func_who);
5387 error rc(error_code);
5392 switch (error_code) {
5398 MDBX_CXX20_UNLIKELY throw_exception(error_code);
5409 const char *func_who) noexcept {
5415 const char *func_who) noexcept {
5424 return boolean_or_throw(error_code);
5432 : ::
MDBX_val({
const_cast<void *
>(ptr), check_length(
bytes)}) {}
5435 :
slice(begin, static_cast<const
byte *>(end) -
5436 static_cast<const
byte *>(begin)) {}
5439 :
slice(c_str, ::
mdbx::strlen(c_str)) {}
5442 :
slice(src.iov_base, src.iov_len) {}
5445 src.iov_base =
nullptr;
5453 iov_base =
const_cast<void *
>(ptr);
5454 iov_len = check_length(
bytes);
5459 iov_base = src.iov_base;
5460 iov_len = src.iov_len;
5465 return assign(src.iov_base, src.iov_len);
5475 assign(src.iov_base, src.iov_len);
5476 src.iov_base =
nullptr;
5481 return assign(begin,
static_cast<const byte *
>(
end) -
5482 static_cast<const byte *
>(begin));
5486 return assign(c_str, ::mdbx::strlen(c_str));
5490 return assign(::std::move(src));
5494 return assign(::std::move(src));
5498 const auto temp = *
this;
5504 return static_cast<const byte *
>(iov_base);
5512 return static_cast<byte *
>(iov_base);
5520 return static_cast<const char *
>(iov_base);
5528 return static_cast<char *
>(iov_base);
5552 iov_len = check_length(
bytes);
5566 return data() ==
nullptr;
5583 assert(n <= size());
5584 iov_base =
static_cast<byte *
>(iov_base) + n;
5595 assert(n <= size());
5607 return length() >= prefix.length() &&
5608 memcmp(data(), prefix.data(), prefix.length()) == 0;
5612 return length() >= suffix.length() &&
5613 memcmp(byte_ptr() + length() - suffix.length(), suffix.data(),
5614 suffix.length()) == 0;
5619 size_t h =
length() * 3977471;
5620 for (
size_t i = 0; i <
length(); ++i)
5621 h = (h ^
static_cast<const uint8_t *
>(
data())[i]) * 1664525 + 1013904223;
5622 return h ^ 3863194411 * (h >> 11);
5627 return byte_ptr()[n];
5638 return slice(data(), n);
5643 return slice(char_ptr() + size() - n, n);
5648 return slice(char_ptr() + from, n);
5672 const slice &b) noexcept {
5673 const intptr_t diff = intptr_t(a.length()) - intptr_t(b.length());
5677 : memcmp(a.data(), b.data(), a.length());
5682 const size_t shortest = ::std::min(a.length(), b.length());
5685 const intptr_t diff = memcmp(a.data(), b.data(), shortest);
5689 return intptr_t(a.length()) - intptr_t(b.length());
5722 template <
class ALLOCATOR>
5725 const ALLOCATOR &allocator)
const {
5726 return to_hex(*
this, uppercase, wrap_width).
as_string<ALLOCATOR>(allocator);
5729 template <
class ALLOCATOR>
5735 template <
class ALLOCATOR>
5741 template <
class ALLOCATOR,
class CAPACITY_POLICY>
5744 const ALLOCATOR &allocator)
const {
5745 return to_hex(*
this, uppercase, wrap_width)
5746 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
5749 template <
class ALLOCATOR,
class CAPACITY_POLICY>
5753 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
5756 template <
class ALLOCATOR,
class CAPACITY_POLICY>
5760 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
5763 template <
class ALLOCATOR,
class CAPACITY_POLICY>
5766 return from_hex(*
this, ignore_spaces)
5767 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
5770 template <
class ALLOCATOR,
class CAPACITY_POLICY>
5774 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
5777 template <
class ALLOCATOR,
class CAPACITY_POLICY>
5781 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
5802 const pair &b) noexcept {
5815 return a.key.length() == b.key.length() &&
5816 a.value.length() == b.value.length() &&
5817 memcmp(a.key.data(), b.key.data(), a.key.length()) == 0 &&
5818 memcmp(a.value.data(), b.value.data(), a.value.length()) == 0;
5843 return a.key.length() != b.key.length() ||
5844 a.value.length() != b.value.length() ||
5845 memcmp(a.key.data(), b.key.data(), a.key.length()) != 0 ||
5846 memcmp(a.value.data(), b.value.data(), a.value.length()) != 0;
5851 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5854 :
buffer(src, !
txn.is_dirty(src.data()), allocator) {}
5879 other.handle_ =
nullptr;
5884 other.handle_ =
nullptr;
5889 handle_ =
reinterpret_cast<MDBX_env *
>(uintptr_t(0xDeadBeef));
5894 return handle_ !=
nullptr;
5902 return a.handle_ == b.handle_;
5906 return a.handle_ != b.handle_;
5910 size_lower = size_now = size_upper =
size;
5911 growth_step = shrink_threshold = 0;
5916 intptr_t upper) noexcept {
5917 size_now = size_lower = lower;
5919 growth_step = shrink_threshold = default_value;
5941 return static_cast<size_t>(result);
5948 return static_cast<size_t>(result);
5963 return static_cast<size_t>(result);
5974 return static_cast<size_t>(result);
5993 return static_cast<size_t>(result);
6004 return static_cast<size_t>(result);
6016 return static_cast<size_t>(result);
6029 return static_cast<size_t>(result);
6041 return static_cast<size_t>(result);
6054 return static_cast<size_t>(result);
6065 return static_cast<size_t>(result);
6069 const auto flags = get_flags();
6071 operate_parameters::mode_from_flags(
flags),
6072 operate_parameters::durability_from_flags(
flags),
6073 operate_parameters::reclaiming_from_flags(
flags),
6074 operate_parameters::options_from_flags(
flags));
6078 return operate_parameters::mode_from_flags(get_flags());
6167 unsigned seconds_16dot16;
6169 return seconds_16dot16;
6173 return set_sync_period__seconds_16dot16(
unsigned(seconds * 65536));
6177 return sync_period__seconds_16dot16() / 65536.0;
6180 #if __cplusplus >= 201103L
6182 return set_sync_period__seconds_16dot16(period.count());
6186 return duration(sync_period__seconds_16dot16());
6235 uint64_t txnid, uint64_t lag,
size_t used,
6236 size_t retained) noexcept
6237 : slot(slot), pid(pid), thread(thread), transaction_id(txnid),
6238 transaction_lag(lag), bytes_used(used), bytes_retained(retained) {}
6240 template <
typename VISITOR>
6244 static int cb(
void *ctx,
int number,
int slot,
mdbx_pid_t pid,
6245 mdbx_tid_t thread, uint64_t txnid, uint64_t lag,
size_t used,
6246 size_t retained) noexcept {
6247 reader_visitor_thunk *thunk =
static_cast<reader_visitor_thunk *
>(ctx);
6248 assert(thunk->is_clean());
6250 const reader_info info(slot, pid, thread, txnid, lag, used, retained);
6258 : visitor_(visitor) {}
6260 reader_visitor_thunk thunk(visitor);
6262 thunk.rethrow_captured();
6269 assert(dead_count >= 0);
6270 return static_cast<unsigned>(dead_count);
6286 assert(ptr !=
nullptr);
6294 assert(ptr !=
nullptr);
6302 assert(ptr !=
nullptr);
6314 other.handle_ =
nullptr;
6319 other.handle_ =
nullptr;
6324 handle_ =
reinterpret_cast<MDBX_txn *
>(uintptr_t(0xDeadBeef));
6329 return handle_ !=
nullptr;
6337 return a.handle_ == b.handle_;
6341 return a.handle_ != b.handle_;
6406 inline ::mdbx::map_handle
6413 assert(map.
dbi != 0);
6421 assert(map.
dbi != 0);
6433 assert(map.
dbi != 0);
6449 #if defined(DOXYGEN) || \
6450 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
6452 inline ::mdbx::map_handle
6459 assert(map.
dbi != 0);
6463 inline ::mdbx::map_handle
6468 assert(map.
dbi != 0);
6480 assert(map.
dbi != 0);
6485 const ::std::string_view &new_name) {
6490 inline ::mdbx::map_handle
6496 inline ::mdbx::map_handle
6498 return open_map_accede(::std::string_view(name));
6508 return drop_map(::std::string_view(name), throw_if_absent);
6512 return clear_map(::std::string_view(name), throw_if_absent);
6516 return rename_map(map, ::std::string_view(new_name));
6521 inline ::mdbx::map_handle
6527 inline ::mdbx::map_handle
6529 return open_map_accede(name.c_str());
6539 return drop_map(name.c_str(), throw_if_absent);
6543 return clear_map(name.c_str(), throw_if_absent);
6547 return rename_map(map, new_name.c_str());
6596 const slice &b)
const noexcept {
6601 const slice &b)
const noexcept {
6606 const pair &b)
const noexcept {
6607 return compare_keys(map, a.key, b.key);
6611 const pair &b)
const noexcept {
6612 return compare_values(map, a.value, b.value);
6629 const slice &value_at_absence)
const {
6631 const int err =
::mdbx_get(handle_, map.
dbi, &key, &result);
6636 return value_at_absence;
6643 const slice &value_at_absence)
const {
6645 const int err =
::mdbx_get_ex(handle_, map.
dbi, &key, &result, &values_count);
6650 return value_at_absence;
6657 const slice &key)
const {
6666 const slice &value_at_absence)
const {
6694 put(map, key, &value ,
6701 put(map, key, &value ,
6714 size_t value_length) {
6715 slice result(
nullptr, value_length);
6717 put(map, key, &result ,
6723 size_t value_length) {
6724 slice result(
nullptr, value_length);
6726 put(map, key, &result ,
6744 size_t value_length) {
6745 slice result(
nullptr, value_length);
6757 const slice &value) {
6758 const int err = put(map, key,
const_cast<slice *
>(&value),
6771 size_t value_length) {
6772 slice result(
nullptr, value_length);
6779 size_t value_length) {
6780 slice result(
nullptr, value_length);
6794 const int err =
::mdbx_del(handle_, map.
dbi, &key,
nullptr);
6818 const slice &new_value) {
6820 handle_, map.
dbi, &key,
const_cast<slice *
>(&new_value), &old_value,
6824 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
6837 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
6850 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
6864 bool multivalue_order_preserved) {
6866 handle_, map.
dbi,
const_cast<slice *
>(&key),
const_cast<slice *
>(&value),
6872 const size_t value_length,
6873 const void *values_array,
size_t values_count,
6874 put_mode mode,
bool allow_partial) {
6875 MDBX_val args[2] = {{
const_cast<void *
>(values_array), value_length},
6876 {
nullptr, values_count}};
6890 return args[1].iov_len ;
6894 const pair &to)
const {
6902 const slice &to)
const {
6905 &to,
nullptr, &result));
6910 const slice &to)
const {
6913 nullptr, &to,
nullptr, &result));
6918 const slice &from)
const {
6921 nullptr,
nullptr, &result));
6946 other.handle_ =
nullptr;
6951 other.handle_ =
nullptr;
6956 handle_ =
reinterpret_cast<MDBX_cursor *
>(uintptr_t(0xDeadBeef));
6961 return handle_ !=
nullptr;
6971 const cursor &b) noexcept {
6972 return a.handle_ == b.handle_;
6976 const cursor &b) noexcept {
6977 return a.handle_ != b.handle_;
6981 bool ignore_nested =
false) noexcept {
6986 bool ignore_nested =
false) {
6996 bool throw_notfound)
7004 bool throw_notfound)
7006 this->
done = cursor.
move(operation, &this->key, &this->value, throw_notfound);
7010 MDBX_val *value,
bool throw_notfound)
const {
7019 if (!throw_notfound)
7031 :
pair(key, value), approximate_quantity(PTRDIFF_MIN) {
7054 bool throw_notfound) {
7060 bool throw_notfound) {
7066 bool throw_notfound) {
7101 const slice &value)
const {
7130 return ::mdbx::txn(
txn);
7166 slice result(
nullptr, value_length);
7174 size_t value_length) {
7175 slice result(
nullptr, value_length);
7195 slice result(
nullptr, value_length);
7220 slice result(
nullptr, value_length);
7227 size_t value_length) {
7228 slice result(
nullptr, value_length);
7255 bool found =
seek(key);
7256 return found ?
erase(whole_multivalue) : found;
7282 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
7284 to_string(const ::mdbx::buffer<ALLOCATOR, CAPACITY_POLICY> &buffer) {
7296 inline string to_string(const ::mdbx::env::geometry &value) {
7302 inline string to_string(const ::mdbx::env::operate_parameters &value) {
7314 inline string to_string(const ::mdbx::env::durability &value) {
7320 inline string to_string(const ::mdbx::env::reclaiming_options &value) {
7326 inline string to_string(const ::mdbx::env::operate_options &value) {
7332 inline string to_string(const ::mdbx::env_managed::create_parameters &value) {
7363 return slice.hash_value();
7370 #if defined(__LCC__) && __LCC__ >= 126
7371 #pragma diagnostic pop
7375 #pragma warning(pop)
#define MDBX_CXX11_CONSTEXPR
Definition: mdbx.h:460
#define MDBX_MAYBE_UNUSED
Definition: mdbx.h:536
#define MDBX_CXX14_CONSTEXPR
Definition: mdbx.h:482
#define MDBX_NOTHROW_PURE_FUNCTION
The 'pure nothrow' function attribute for optimization.
Definition: mdbx.h:270
mode_t mdbx_mode_t
Definition: mdbx.h:211
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
Definition: mdbx.h:4846
#define LIBMDBX_API
Definition: mdbx.h:648
#define LIBMDBX_API_TYPE
Definition: mdbx.h:659
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the database. .
Definition: mdbx.h:816
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)
LIBMDBX_API int mdbx_dbi_rename2(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *name)
Переименовает таблицу по DBI-хендлу.
LIBMDBX_VERINFO_API const struct MDBX_version_info mdbx_version
libmdbx version information
pthread_t mdbx_tid_t
Definition: mdbx.h:210
LIBMDBX_VERINFO_API const struct MDBX_build_info mdbx_build
libmdbx build information
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 database in the environment.
LIBMDBX_API MDBX_hsr_func * mdbx_env_get_hsr(const MDBX_env *env)
Gets current Handle-Slow-Readers callback used to resolve database full/overflow issue due to a reade...
struct MDBX_env MDBX_env
Opaque structure for a database environment.
Definition: mdbx.h:748
int mdbx_filehandle_t
Definition: mdbx.h:208
pid_t mdbx_pid_t
Definition: mdbx.h:209
@ MDBX_MAX_PAGESIZE
Definition: mdbx.h:830
@ MDBX_MAXDATASIZE
Definition: mdbx.h:824
@ MDBX_MAX_DBI
Definition: mdbx.h:821
@ MDBX_MIN_PAGESIZE
Definition: mdbx.h:827
libmdbx build information
Definition: mdbx.h:686
The fours integers markers (aka "canary") associated with the environment.
Definition: mdbx.h:4247
Latency of commit stages in 1/65536 of seconds units.
Definition: mdbx.h:3991
Information about the environment.
Definition: mdbx.h:2682
Statistics for a database in the environment.
Definition: mdbx.h:2634
Information about the transaction.
Definition: mdbx.h:3890
libmdbx version information
Definition: mdbx.h:669
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 database.
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 database.
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:1696
int() MDBX_cmp_func(const MDBX_val *a, const MDBX_val *b) noexcept
A callback function used to compare two keys in a database.
Definition: mdbx.h:4307
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_cmp(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b)
Compare two keys according to a particular database.
LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data)
Delete items from a database.
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 database 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 database.
LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a database.
LIBMDBX_API int mdbx_dcmp(const MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *a, const MDBX_val *b)
Compare two data items according to a particular database.
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 database.
@ MDBX_MULTIPLE
Definition: mdbx.h:1733
@ MDBX_ALLDUPS
Definition: mdbx.h:1716
@ MDBX_CURRENT
Definition: mdbx.h:1711
@ MDBX_APPENDDUP
Definition: mdbx.h:1729
@ MDBX_APPEND
Definition: mdbx.h:1724
@ MDBX_UPSERT
Definition: mdbx.h:1698
@ MDBX_RESERVE
Definition: mdbx.h:1720
@ MDBX_NOOVERWRITE
Definition: mdbx.h:1701
LIBMDBX_API int mdbx_cursor_on_first_dup(const MDBX_cursor *cursor)
Определяет стоит ли курсор на первом или единственном мульти-значении соответствующем ключу.
LIBMDBX_API MDBX_txn * mdbx_cursor_txn(const MDBX_cursor *cursor)
Return the cursor's transaction handle.
LIBMDBX_API MDBX_cursor * mdbx_cursor_create(void *context)
Create a cursor handle but not bind it to transaction nor DBI-handle.
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 void * mdbx_cursor_get_userctx(const MDBX_cursor *cursor)
Get the application information associated with the MDBX_cursor.
LIBMDBX_API MDBX_dbi mdbx_cursor_dbi(const MDBX_cursor *cursor)
Return the cursor's database handle.
MDBX_cursor_op
Cursor operationsThis is the set of all operations for retrieving data using a cursor.
Definition: mdbx.h:1766
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 database.
Definition: mdbx.h:778
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_close(MDBX_cursor *cursor)
Close a cursor 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:1781
@ MDBX_GET_BOTH
Definition: mdbx.h:1774
@ MDBX_TO_KEY_EQUAL
Definition: mdbx.h:1861
@ MDBX_GET_BOTH_RANGE
Definition: mdbx.h:1778
@ MDBX_SET_KEY
Definition: mdbx.h:1821
@ MDBX_FIRST_DUP
Definition: mdbx.h:1771
@ MDBX_TO_KEY_LESSER_OR_EQUAL
Definition: mdbx.h:1860
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_THAN
Definition: mdbx.h:1871
@ MDBX_NEXT_NODUP
Definition: mdbx.h:1806
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_OR_EQUAL
Definition: mdbx.h:1868
@ MDBX_TO_EXACT_KEY_VALUE_EQUAL
Definition: mdbx.h:1869
@ MDBX_TO_PAIR_LESSER_OR_EQUAL
Definition: mdbx.h:1874
@ MDBX_SET_RANGE
Definition: mdbx.h:1824
@ MDBX_LAST_DUP
Definition: mdbx.h:1792
@ MDBX_PREV
Definition: mdbx.h:1809
@ MDBX_TO_PAIR_GREATER_OR_EQUAL
Definition: mdbx.h:1876
@ MDBX_TO_PAIR_GREATER_THAN
Definition: mdbx.h:1877
@ MDBX_LAST
Definition: mdbx.h:1789
@ MDBX_TO_KEY_LESSER_THAN
Definition: mdbx.h:1859
@ MDBX_PREV_DUP
Definition: mdbx.h:1812
@ MDBX_TO_EXACT_KEY_VALUE_LESSER_THAN
Definition: mdbx.h:1867
@ MDBX_SET
Definition: mdbx.h:1818
@ MDBX_NEXT
Definition: mdbx.h:1795
@ MDBX_TO_KEY_GREATER_OR_EQUAL
Definition: mdbx.h:1862
@ MDBX_TO_PAIR_LESSER_THAN
Definition: mdbx.h:1873
@ MDBX_PREV_NODUP
Definition: mdbx.h:1815
@ MDBX_TO_PAIR_EQUAL
Definition: mdbx.h:1875
@ MDBX_NEXT_DUP
Definition: mdbx.h:1798
@ MDBX_TO_EXACT_KEY_VALUE_GREATER_OR_EQUAL
Definition: mdbx.h:1870
@ MDBX_TO_KEY_GREATER_THAN
Definition: mdbx.h:1863
@ MDBX_FIRST
Definition: mdbx.h:1768
LIBMDBX_API int mdbx_dbi_rename(MDBX_txn *txn, MDBX_dbi dbi, const char *name)
Переименовает таблицу по DBI-хендлу.
LIBMDBX_API int mdbx_dbi_close(MDBX_env *env, MDBX_dbi dbi)
Close a database 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 database in the environment.
uint32_t MDBX_dbi
A handle for an individual database (key-value spaces) in the environment.
Definition: mdbx.h:771
MDBX_db_flags_t
Database flags.
Definition: mdbx.h:1641
@ MDBX_INTEGERDUP
Definition: mdbx.h:1665
@ MDBX_DB_ACCEDE
Definition: mdbx.h:1683
@ MDBX_DB_DEFAULTS
Definition: mdbx.h:1643
@ MDBX_REVERSEKEY
Definition: mdbx.h:1646
@ MDBX_DUPFIXED
Definition: mdbx.h:1660
@ MDBX_INTEGERKEY
Definition: mdbx.h:1656
@ MDBX_REVERSEDUP
Definition: mdbx.h:1668
@ MDBX_CREATE
Definition: mdbx.h:1671
@ MDBX_DUPSORT
Definition: mdbx.h:1649
MDBX_log_level_t
Definition: mdbx.h:891
MDBX_debug_flags_t
Runtime debug flags.
Definition: mdbx.h:951
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:5999
MDBX_error_t
Errors and return codes.
Definition: mdbx.h:1889
@ MDBX_FIRST_LMDB_ERRCODE
Definition: mdbx.h:1903
@ MDBX_BAD_TXN
Definition: mdbx.h:1969
@ MDBX_LAST_LMDB_ERRCODE
Definition: mdbx.h:1983
@ MDBX_SUCCESS
Definition: mdbx.h:1891
@ MDBX_NOTFOUND
Definition: mdbx.h:1906
@ MDBX_RESULT_TRUE
Definition: mdbx.h:1897
@ MDBX_BUSY
Definition: mdbx.h:1987
@ MDBX_EINVAL
Definition: mdbx.h:2053
@ MDBX_ENOMEM
Definition: mdbx.h:2055
@ MDBX_FIRST_ADDED_ERRCODE
Definition: mdbx.h:1990
@ MDBX_RESULT_FALSE
Definition: mdbx.h:1894
@ MDBX_LAST_ADDED_ERRCODE
Definition: mdbx.h:2032
@ MDBX_KEYEXIST
Definition: mdbx.h:1900
MDBX_env_flags_t
Environment flags.
Definition: mdbx.h:1089
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:2929
MDBX_option_t
MDBX environment extra runtime options.
Definition: mdbx.h:2161
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:2868
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:2265
@ MDBX_opt_txn_dp_limit
Controls the in-process limit of dirty pages for a write transaction.
Definition: mdbx.h:2261
@ 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:2364
@ MDBX_opt_max_db
Controls the maximum number of named databases for the environment.
Definition: mdbx.h:2170
@ MDBX_opt_merge_threshold_16dot16_percent
Controls the in-process threshold of semi-empty pages merge.
Definition: mdbx.h:2331
@ MDBX_opt_sync_bytes
Controls interprocess/shared threshold to force flush the data buffers to disk, if MDBX_SAFE_NOSYNC i...
Definition: mdbx.h:2193
@ MDBX_opt_spill_min_denominator
Controls the in-process how minimal part of the dirty pages should be spilled when necessary.
Definition: mdbx.h:2297
@ 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:2320
@ 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:2233
@ 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:2220
@ MDBX_opt_max_readers
Defines the maximum number of threads/reader slots for all processes interacting with the database.
Definition: mdbx.h:2187
@ MDBX_opt_spill_max_denominator
Controls the in-process how maximal part of the dirty pages may be spilled when necessary.
Definition: mdbx.h:2281
@ MDBX_opt_sync_period
Controls interprocess/shared relative period since the last unsteady commit to force flush the data b...
Definition: mdbx.h:2199
@ MDBX_opt_dp_reserve_limit
Controls the in-process limit of a pre-allocated memory items for dirty pages.
Definition: mdbx.h:2247
@ MDBX_opt_writethrough_threshold
Controls the choosing between use write-through disk writes and usual ones with followed flush by the...
Definition: mdbx.h:2359
LIBMDBX_API int mdbx_dbi_stat(const MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes)
Retrieve statistics for a database.
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 database flags, or -1 if pagesize is inval...
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:3584
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:2949
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 database flags.
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_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:2886
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 overflow/large-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 database.
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:4541
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 overflow/large-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.
int mdbx_env_get_maxdbs(const MDBX_env *env, MDBX_dbi *dbs)
Get the maximum number of named databases for the environment.
Definition: mdbx.h:3629
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 database flags, or -1 if pagesize is invali...
LIBMDBX_API size_t mdbx_default_pagesize(void)
Returns the default size of database page for the current system.
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 database 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 database handle.
LIBMDBX_API int mdbx_txn_break(MDBX_txn *txn)
Marks transaction as broken.
LIBMDBX_API void * mdbx_txn_get_userctx(const MDBX_txn *txn)
Returns an application information (a context pointer) associated with the transaction.
LIBMDBX_API int mdbx_txn_set_userctx(MDBX_txn *txn, void *ctx)
Sets application information associated (a context pointer) with the transaction.
LIBMDBX_API MDBX_env * mdbx_txn_env(const MDBX_txn *txn)
Returns the transaction's MDBX_env.
LIBMDBX_API int mdbx_txn_flags(const MDBX_txn *txn)
Return the transaction's flags.
MDBX_txn_flags_t
Definition: mdbx.h:1558
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:3857
struct MDBX_txn MDBX_txn
Opaque structure for a transaction handle.
Definition: mdbx.h:759
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.
@ MDBX_TXN_RDONLY
Definition: mdbx.h:1569
@ MDBX_TXN_RDONLY_PREPARE
Definition: mdbx.h:1578
@ MDBX_TXN_READWRITE
Definition: mdbx.h:1563
@ MDBX_TXN_TRY
Definition: mdbx.h:1584
buffer(size_t head_room, const struct slice &src, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2397
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++:2182
cursor_managed(void *your_context=nullptr)
Creates a new managed cursor with underlying object.
Definition: mdbx.h++:5147
txn_managed start_nested()
Start nested write transaction.
extra_runtime_option
Definition: mdbx.h++:4043
static buffer key_from(silo &&src) noexcept
Definition: mdbx.h++:3068
buffer & append_u64(uint_fast64_t u64)
Definition: mdbx.h++:3026
constexpr allocator_type get_allocator() const
Returns the associated allocator.
Definition: mdbx.h++:2167
bool drop_map(const ::std::string_view &name, bool throw_if_absent=false)
Drop key-value map.
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++:2642
::MDBX_db_flags_t flags
Definition: mdbx.h++:3508
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++:2575
int64_t as_int64_adapt() const
Definition: mdbx.h++:2498
move_result to_exact_key_value_lesser_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5008
constexpr const byte * end_byte_ptr() const noexcept
Returns casted to const pointer to byte an end of data.
Definition: mdbx.h++:2213
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++:2568
static buffer key_from(const double *ieee754_64bit)
Definition: mdbx.h++:3080
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++:2537
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++:2239
constexpr char * end_char_ptr() noexcept
Returns casted to pointer to char an end of data.
Definition: mdbx.h++:2254
buffer & assign(const buffer &src, bool make_reference=false)
Definition: mdbx.h++:2668
void reserve(size_t wanna_headroom, size_t wanna_tailroom)
Reserves storage space.
Definition: mdbx.h++:2624
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++:2203
cursor_managed & operator=(const cursor_managed &)=delete
void reserve_headroom(size_t wanna_headroom)
Reserves space before the payload.
Definition: mdbx.h++:2639
constexpr txn() noexcept=default
constexpr map_handle() noexcept
Definition: mdbx.h++:3501
env & copy(const char *destination, bool compactify, bool force_dynamic_size=false)
durability
Durability level.
Definition: mdbx.h++:3659
@ lazy_weak_tail
Definition: mdbx.h++:3662
@ robust_synchronous
Definition: mdbx.h++:3660
@ half_synchronous_weak_last
Definition: mdbx.h++:3661
constexpr buffer(const buffer &src, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2357
::std::allocator_traits< allocator_type > allocator_traits
Definition: mdbx.h++:1653
constexpr byte operator[](size_t n) const noexcept
Accesses the specified byte of data chunk.
Definition: mdbx.h++:2839
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++:2594
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++:2345
constexpr int32_t as_int32() const
Definition: mdbx.h++:2483
constexpr void swap(buffer &other) noexcept(swap_alloc::is_nothrow())
Definition: mdbx.h++:2658
estimate_result estimate(move_operation operation, slice &key) const
uint16_t as_uint16_adapt() const
Definition: mdbx.h++:2492
constexpr char * char_ptr() noexcept
Returns casted to pointer to char an address of data.
Definition: mdbx.h++:2246
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++:2196
move_result to_pair_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5038
constexpr buffer & set_length(size_t bytes)
Set length of data.
Definition: mdbx.h++:2293
void safe_remove_suffix(size_t n)
Drops the last "n" bytes from the data chunk.
Definition: mdbx.h++:2835
void safe_remove_prefix(size_t n)
Drops the first "n" bytes from the data chunk.
Definition: mdbx.h++:2831
bool is_readwrite() const
Checks whether the transaction is read-write.
Definition: mdbx.h++:4340
move_result move(move_operation operation, const slice &key, const slice &value, bool throw_notfound)
Definition: mdbx.h++:4938
buffer & assign(const void *begin, const void *end, bool make_reference=false)
Definition: mdbx.h++:2697
static buffer key_from(const ::std::basic_string< CHAR, T, A > &src, bool make_reference=false)
Definition: mdbx.h++:3063
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.
buffer & assign_reference(const void *ptr, size_t bytes)
Definition: mdbx.h++:2644
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++:5030
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++:2618
bool clear_map(const char *name, bool throw_if_absent=false)
constexpr env() noexcept=default
buffer & assign_freestanding(const void *ptr, size_t bytes)
Definition: mdbx.h++:2650
uint8_t as_uint8_adapt() const
Definition: mdbx.h++:2493
move_result to_pair_exact(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5042
buffer & operator=(const ::std::basic_string_view< CHAR, T > &view) noexcept
Definition: mdbx.h++:2744
buffer & operator=(struct slice &&src)
Definition: mdbx.h++:2739
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++:2560
constexpr size_t size() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:2772
size_t put_multiple(map_handle map, const slice &key, const VALUE *values_array, size_t values_count, put_mode mode, bool allow_partial=false)
Definition: mdbx.h++:4614
typename ::std::allocator_traits< ALLOCATOR >::template rebind_alloc< uint64_t > allocator_type
Definition: mdbx.h++:1649
constexpr const byte * byte_ptr() const noexcept
Returns casted to const pointer to byte an address of data.
Definition: mdbx.h++:2208
buffer(size_t head_room, const buffer &src, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2406
constexpr ::std::span< const POD > as_span() const
Definition: mdbx.h++:2434
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++:2484
static buffer key_from_jsonInteger(const int64_t json_integer)
Definition: mdbx.h++:3100
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++:2528
constexpr ::std::span< const byte > bytes() const
Definition: mdbx.h++:2441
buffer & assign(const struct slice &src, bool make_reference=false)
Definition: mdbx.h++:2677
env & copy(const ::std::string &destination, bool compactify, bool force_dynamic_size=false)
static bool remove(const ::std::string &pathname, const remove_mode mode=just_remove)
constexpr map_handle(MDBX_dbi dbi) noexcept
Definition: mdbx.h++:3502
move_result current(bool throw_notfound=true) const
Definition: mdbx.h++:4962
constexpr void * data() noexcept
Return a pointer to the beginning of the referenced data.
Definition: mdbx.h++:2270
move_result to_previous_last_multi(bool throw_notfound=true)
Definition: mdbx.h++:4953
static buffer key_from(const float ieee754_32bit)
Definition: mdbx.h++:3108
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.
buffer & assign(::MDBX_val &&src, bool make_reference=false)
Definition: mdbx.h++:2691
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++:4752
size_t unbind_all_cursors() const
Unbind all cursors.
Definition: mdbx.h++:4378
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++:2504
move_result to_key_greater_or_equal(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:4994
constexpr bool empty() const noexcept
Checks whether the string is empty.
Definition: mdbx.h++:2762
bool is_same_position(const cursor &other, bool ignore_nested=false) const
Definition: mdbx.h++:4744
buffer(const buffer &src, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2325
bool is_after_than(const cursor &other, bool ignore_nested=false) const
Definition: mdbx.h++:4748
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++:2585
uint32_t as_uint32_adapt() const
Definition: mdbx.h++:2491
buffer(size_t head_room, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2384
constexpr buffer() noexcept=default
static buffer key_from_double(const double ieee754_64bit)
Definition: mdbx.h++:3072
void remove_suffix(size_t n) noexcept
Drops the last "n" bytes from the data chunk.
Definition: mdbx.h++:2827
constexpr void * end() noexcept
Return a pointer to the end of the referenced data.
Definition: mdbx.h++:2278
static size_t default_pagesize() noexcept
Returns default page size for current system/platform.
Definition: mdbx.h++:3762
buffer & assign(const ::MDBX_val &src, bool make_reference=false)
Definition: mdbx.h++:2681
move_result to_next_first_multi(bool throw_notfound=true)
Definition: mdbx.h++:4971
void clear_and_reserve(size_t whole_capacity, size_t headroom=0) noexcept
Clears the contents and reserve storage.
Definition: mdbx.h++:2814
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++:2545
MDBX_txn * handle_
Definition: mdbx.h++:4302
bool starts_with(const struct slice &prefix) const noexcept
Checks if the data starts with the given prefix.
Definition: mdbx.h++:2800
constexpr size_t length() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:2285
static buffer key_from_u64(const uint64_t unsigned_int64)
Definition: mdbx.h++:3084
move_result move(move_operation operation, const slice &key, bool throw_notfound)
Definition: mdbx.h++:4934
mode
Operation mode.
Definition: mdbx.h++:3652
@ readonly
Definition: mdbx.h++:3653
@ write_file_io
Definition: mdbx.h++:3654
move_result move(move_operation operation, bool throw_notfound)
Definition: mdbx.h++:4931
constexpr byte at(size_t n) const
Accesses the specified byte of data chunk with bounds checking.
Definition: mdbx.h++:2853
bool scan_from(CALLABLE_PREDICATE predicate, slice &from, move_operation start=key_greater_or_equal, move_operation turn=next)
Definition: mdbx.h++:4880
operator::mdbx::txn() const
Definition: mdbx.h++:5099
constexpr int8_t as_int8() const
Definition: mdbx.h++:2485
MDBX_env * handle_
Definition: mdbx.h++:3549
static buffer key_from(const ::std::basic_string_view< CHAR, T > &src, bool make_reference=false)
Definition: mdbx.h++:3052
move_result to_exact_key_value_greater_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5018
commit_latency commit_get_latency()
Commit all the operations of a transaction into the database and return latency information.
Definition: mdbx.h++:4695
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++:2513
bool is_same_or_before_than(const cursor &other, bool ignore_nested=false) const
Definition: mdbx.h++:4739
bool ends_with(const struct slice &suffix) const noexcept
Checks if the data ends with the given suffix.
Definition: mdbx.h++:2806
constexpr POD as_pod() const
Definition: mdbx.h++:2457
buffer & assign(const ::std::basic_string< CHAR, T, A > &str, bool make_reference=false)
Definition: mdbx.h++:2706
env_managed & operator=(const env_managed &)=delete
constexpr ::std::span< POD > as_span()
Definition: mdbx.h++:2437
static buffer key_from_float(const float ieee754_32bit)
Definition: mdbx.h++:3104
buffer(const struct slice &src, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2318
move_result to_first(bool throw_notfound=true)
Definition: mdbx.h++:4947
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++:2602
buffer & append_decoded_hex(const struct slice &data, bool ignore_spaces=false)
Definition: mdbx.h++:2954
move_result to_last(bool throw_notfound=true)
Definition: mdbx.h++:4977
buffer & append_byte(uint_fast8_t byte)
Definition: mdbx.h++:2977
constexpr buffer(const void *ptr, size_t bytes, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2361
buffer(const ::mdbx::txn &txn, const struct slice &src, const allocator_type &allocator=allocator_type())
constexpr const void * end() const noexcept
Return a const pointer to the end of the referenced data.
Definition: mdbx.h++:2265
void close()
Explicitly closes the cursor.
env & set_sync_period(const duration &period)
Sets relative period since the last unsteady commit to force flush the data buffers to disk,...
map_handle & operator=(const map_handle &) noexcept=default
constexpr buffer(const ::std::basic_string< CHAR, T, A > &str, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2367
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++:4991
constexpr byte * byte_ptr() noexcept
Returns casted to pointer to byte an address of data.
Definition: mdbx.h++:2220
constexpr const char * char_ptr() const noexcept
Returns casted to const pointer to char an address of data.
Definition: mdbx.h++:2234
constexpr ::std::span< char > chars()
Definition: mdbx.h++:2448
constexpr txn_managed() noexcept=default
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++:2174
static buffer key_from(const float *ieee754_32bit)
Definition: mdbx.h++:3112
buffer & append_u24(uint_fast32_t u24)
Definition: mdbx.h++:2989
constexpr buffer(const ::std::basic_string_view< CHAR, T > &view, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2379
env_managed & operator=(env_managed &&other) noexcept
Definition: mdbx.h++:4277
env_managed(const ::std::wstring &pathname, const operate_parameters &, bool accede=true)
buffer & append_decoded_base64(const struct slice &data, bool ignore_spaces=false)
Definition: mdbx.h++:2964
constexpr ::std::span< const char > chars() const
Definition: mdbx.h++:2445
buffer & append_base58(const struct slice &data, unsigned wrap_width=0)
Definition: mdbx.h++:2946
CAPACITY_POLICY reservation_policy
Definition: mdbx.h++:1654
buffer & append_u48(uint_fast64_t u48)
Definition: mdbx.h++:3012
remove_mode
Deletion modes for remove().
Definition: mdbx.h++:3891
buffer & assign(const void *ptr, size_t bytes, bool make_reference=false)
Definition: mdbx.h++:2672
static buffer key_from(const int64_t signed_int64)
Definition: mdbx.h++:3096
bool scan(CALLABLE_PREDICATE predicate, move_operation start=first, move_operation turn=next)
Definition: mdbx.h++:4849
move_result to_current_first_multi(bool throw_notfound=true)
Definition: mdbx.h++:4956
buffer & add_header(const void *src, size_t bytes)
Definition: mdbx.h++:2912
env & copy(const wchar_t *destination, bool compactify, bool force_dynamic_size=false)
bool scan_from(CALLABLE_PREDICATE predicate, pair &from, move_operation start=pair_greater_or_equal, move_operation turn=next)
Definition: mdbx.h++:4906
buffer & operator=(buffer &&src) noexcept(move_assign_alloc::is_nothrow())
Definition: mdbx.h++:2733
uint128_t as_uint128_adapt() const
Definition: mdbx.h++:2488
env & copy(filehandle fd, bool compactify, bool force_dynamic_size=false)
Copy an environment to the specified file descriptor.
::MDBX_dbi_state_t state
Definition: mdbx.h++:3509
env_managed(env_managed &&)=default
bool poll_sync_to_disk()
Performs non-blocking polling of sync-to-disk thresholds.
Definition: mdbx.h++:4100
constexpr uint32_t as_uint32() const
Definition: mdbx.h++:2469
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++:4690
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++:3855
constexpr size_t hash_value() const noexcept
Returns the hash value of the data.
Definition: mdbx.h++:2781
move_result to_pair_lesser_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5034
constexpr ::std::basic_string< CHAR, T, A > as_string(const A &allocator=A()) const
Definition: mdbx.h++:2788
static buffer key_from_i32(const int32_t signed_int32)
Definition: mdbx.h++:3124
move_result to_key_lesser_than(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:4981
move_result to_next(bool throw_notfound=true)
Definition: mdbx.h++:4974
env_managed(const ::std::string &pathname, const operate_parameters &, bool accede=true)
size_t dbsize_max() const
Returns the maximal database size in bytes for the environment.
Definition: mdbx.h++:3851
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++:2551
static buffer wrap(const POD &pod, bool make_reference=false, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2452
buffer & append(const void *src, size_t bytes)
Definition: mdbx.h++:2900
static buffer key_from_u32(const uint32_t unsigned_int32)
Definition: mdbx.h++:3116
void remove_prefix(size_t n) noexcept
Drops the first "n" bytes from the data chunk.
Definition: mdbx.h++:2823
size_t close_all_cursors() const
Close all cursors.
Definition: mdbx.h++:4375
static buffer key_from(const uint32_t unsigned_int32)
Definition: mdbx.h++:3120
constexpr byte & operator[](size_t n) noexcept
Accesses the specified byte of data chunk.
Definition: mdbx.h++:2846
move_result to_key_greater_than(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:4998
buffer & append_decoded_base58(const struct slice &data, bool ignore_spaces=false)
Definition: mdbx.h++:2959
size_t get_pagesize() const
Returns pagesize of this MDBX environment.
Definition: mdbx.h++:3934
void make_freestanding()
Makes buffer owning the data.
Definition: mdbx.h++:2309
buffer & append_hex(const struct slice &data, bool uppercase=false, unsigned wrap_width=0)
Definition: mdbx.h++:2941
env_managed(const ::std::string &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
buffer(const char *c_str, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2338
buffer & append_producer(PRODUCER &producer)
Definition: mdbx.h++:2926
constexpr buffer(const struct slice &src, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2351
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++:3866
buffer & append(const struct slice &chunk)
Definition: mdbx.h++:2908
int32_t as_int32_adapt() const
Definition: mdbx.h++:2499
constexpr const struct slice & slice() const noexcept
Definition: mdbx.h++:2416
constexpr ::std::span< byte > bytes()
Definition: mdbx.h++:2444
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++:2329
bool is_empty() const
Checks whether the database is empty.
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++:2857
move_result to_pair_greater_than(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5050
move_result upper_bound(const slice &key, bool throw_notfound=false)
move_operation
Definition: mdbx.h++:4763
@ multi_exactkey_lowerboundvalue
Definition: mdbx.h++:4778
@ seek_key
Definition: mdbx.h++:4780
@ key_lowerbound
Definition: mdbx.h++:4782
@ multi_find_pair
Definition: mdbx.h++:4777
@ key_exact
Definition: mdbx.h++:4781
@ get_current
Definition: mdbx.h++:4768
virtual ~env_managed() noexcept
bool move(move_operation operation, slice &key, slice &value, bool throw_notfound)
Definition: mdbx.h++:4942
static buffer key_from(const char(&text)[SIZE], bool make_reference=true)
Definition: mdbx.h++:3045
cursor_managed(const cursor_managed &)=delete
constexpr const void * data() const noexcept
Return a const pointer to the beginning of the referenced data.
Definition: mdbx.h++:2260
env_managed(const ::std::wstring &pathname, const create_parameters &, const operate_parameters &, bool accede=true)
buffer & assign(struct slice &&src, bool make_reference=false)
Definition: mdbx.h++:2685
move_result to_current_prev_multi(bool throw_notfound=true)
Definition: mdbx.h++:4959
void shrink_to_fit()
Reduces memory usage by freeing unused storage space.
Definition: mdbx.h++:2819
int16_t as_int16_adapt() const
Definition: mdbx.h++:2500
static buffer key_from(const int32_t signed_int32)
Definition: mdbx.h++:3128
constexpr size_t operator()(::mdbx::slice const &slice) const noexcept
Definition: mdbx.h++:7362
void clear() noexcept
Clears the contents and storage.
Definition: mdbx.h++:2811
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++:2520
constexpr int64_t as_int64() const
Definition: mdbx.h++:2482
bool clear_map(const ::std::string_view &name, bool throw_if_absent=false)
move_result to_exact_key_value_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5014
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++:3076
move_result to_current_last_multi(bool throw_notfound=true)
Definition: mdbx.h++:4968
constexpr uint128_t as_uint128() const
Definition: mdbx.h++:2462
constexpr cursor() noexcept=default
move_result to_key_lesser_or_equal(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:4984
static buffer key_from_i64(const int64_t signed_int64)
Definition: mdbx.h++:3092
buffer & append_u16(uint_fast16_t u16)
Definition: mdbx.h++:2979
move_result to_pair_greater_or_equal(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5046
uint64_t as_uint64_adapt() const
Definition: mdbx.h++:2490
size_t value_max(value_mode mode) const
Returns the maximal value size in bytes for specified values mode.
Definition: mdbx.h++:3861
MDBX_cursor * handle_
Definition: mdbx.h++:4711
buffer & operator=(const struct slice &src)
Definition: mdbx.h++:2737
constexpr byte * end_byte_ptr() noexcept
Returns casted to pointer to byte an end of data.
Definition: mdbx.h++:2228
~cursor_managed() noexcept
Definition: mdbx.h++:5169
constexpr uint8_t as_uint8() const
Definition: mdbx.h++:2475
buffer(buffer &&src) noexcept(move_assign_alloc::is_nothrow())
Definition: mdbx.h++:2413
MDBX_dbi dbi
Definition: mdbx.h++:3500
buffer(const ::std::basic_string< CHAR, T, A > &&)=delete
constexpr uint64_t as_uint64() const
Definition: mdbx.h++:2466
move_result to_exact_key_value_lesser_than(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5003
env & copy(const ::std::wstring &destination, bool compactify, bool force_dynamic_size=false)
static buffer key_from(const uint64_t unsigned_int64)
Definition: mdbx.h++:3088
move_result to_current_next_multi(bool throw_notfound=true)
Definition: mdbx.h++:4965
constexpr int128_t as_int128() const
Definition: mdbx.h++:2478
move_result upper_bound_multivalue(const slice &key, const slice &value, bool throw_notfound=false)
buffer(const ::std::basic_string< CHAR, T, A > &)=delete
buffer & append_u8(uint_fast8_t u8)
Definition: mdbx.h++:2969
constexpr uint16_t as_uint16() const
Definition: mdbx.h++:2472
size_t size_max() const
Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
Definition: mdbx.h++:4348
buffer & assign(const char *c_str, bool make_reference=false)
Definition: mdbx.h++:2711
buffer & append_base64(const struct slice &data, unsigned wrap_width=0)
Definition: mdbx.h++:2950
cursor_managed & operator=(cursor_managed &&other) noexcept
Definition: mdbx.h++:5157
constexpr bool is_null() const noexcept
Checks whether the data pointer of the buffer is nullptr.
Definition: mdbx.h++:2767
move_result to_exact_key_value_greater_than(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5024
txn_managed(const txn_managed &)=delete
buffer & add_header(const struct slice &chunk)
Definition: mdbx.h++:2921
static buffer clone(const buffer &src, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2663
buffer(size_t capacity, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2391
txn_managed & operator=(const txn_managed &)=delete
constexpr buffer(const ::std::span< POD > &span)
Definition: mdbx.h++:2426
buffer & append_u32(uint_fast32_t u32)
Definition: mdbx.h++:3000
size_t value_min(value_mode mode) const noexcept
Returns the minimal value size in bytes for specified values mode.
Definition: mdbx.h++:3857
int128_t as_int128_adapt() const
Definition: mdbx.h++:2496
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++:3058
bool rename_map(const ::std::string_view &old_name, const ::std::string_view &new_name, bool throw_if_absent=false)
Переименовывает таблицу ключ-значение.
move_result to_key_equal(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:4988
constexpr buffer & set_end(const void *ptr)
Sets the length by specifying the end of the data.
Definition: mdbx.h++:2301
move_result to_previous(bool throw_notfound=true)
Definition: mdbx.h++:4950
buffer & append_producer(const PRODUCER &producer)
Definition: mdbx.h++:2934
constexpr buffer(const char *c_str, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2372
void put_multiple(map_handle map, const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)
Definition: mdbx.h++:4625
size_t key_min(key_mode mode) const noexcept
Returns the minimal key size in bytes for specified keys mode.
Definition: mdbx.h++:3853
int8_t as_int8_adapt() const
Definition: mdbx.h++:2501
buffer & operator=(const buffer &src)
Definition: mdbx.h++:2731
constexpr size_t capacity() const noexcept
Returns the number of bytes that can be held in currently allocated storage.
Definition: mdbx.h++:2189
size_t size_current() const
Returns current write transaction size (i.e.summary volume of dirty pages) in bytes.
Definition: mdbx.h++:4352
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++:2610
constexpr env_managed() noexcept=default
bool fullscan(CALLABLE_PREDICATE predicate, bool backward=false)
Definition: mdbx.h++:4874
The chunk of data stored inside the buffer or located outside it.
Definition: mdbx.h++:1645
Unmanaged cursor.
Definition: mdbx.h++:4709
Managed cursor.
Definition: mdbx.h++:5138
Unmanaged database environment.
Definition: mdbx.h++:3545
Managed database environment.
Definition: mdbx.h++:4208
Unmanaged database transaction.
Definition: mdbx.h++:4299
Managed database transaction.
Definition: mdbx.h++:4646
static size_t key_min(MDBX_db_flags_t flags) noexcept
Returns the minimal key size in bytes for specified database flags.
Definition: mdbx.h++:5951
static constexpr intptr_t compare_fast(const pair &a, const pair &b) noexcept
Three-way fast non-lexicographically length-based comparison.
Definition: mdbx.h++:5801
constexpr slice & set_end(const void *ptr)
Sets the length by specifying the end of the slice data.
Definition: mdbx.h++:5556
constexpr size_t size() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:5569
constexpr slice safe_tail(size_t n) const
Returns the last "n" bytes of the slice.
Definition: mdbx.h++:5657
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++:5751
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++:6273
void * get_context() const noexcept
Returns the application context associated with the transaction.
Definition: mdbx.h++:6344
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 database flags.
Definition: mdbx.h++:5989
static constexpr intptr_t compare_fast(const slice &a, const slice &b) noexcept
Three-way fast non-lexicographically length-based comparison.
Definition: mdbx.h++:5671
constexpr MDBX_error_t code() const noexcept
Returns error code.
Definition: mdbx.h++:5331
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++:6817
value_mode
Kind of the values and sorted multi-values with corresponding comparison.
Definition: mdbx.h++:3399
constexpr const void * end() const noexcept
Return a pointer to the ending of the referenced data.
Definition: mdbx.h++:5539
MDBX_CXX11_CONSTEXPR_ENUM mdbx::key_mode key_mode() const noexcept
Definition: mdbx.h++:5863
constexpr slice safe_head(size_t n) const
Returns the first "n" bytes of the slice.
Definition: mdbx.h++:5651
void reset_reading()
Reset a read-only transaction.
Definition: mdbx.h++:6379
constexpr const char * char_ptr() const noexcept
Returns casted to pointer to char an address of data.
Definition: mdbx.h++:5519
void success_or_panic(const char *context_where, const char *func_who) const noexcept
Definition: mdbx.h++:5370
void rethrow_captured() const
Definition: mdbx.h++:5292
constexpr const void * data() const noexcept
Return a pointer to the beginning of the referenced data.
Definition: mdbx.h++:5535
move_result find_multivalue(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:7058
ptrdiff_t estimate(move_operation operation, MDBX_val *key, MDBX_val *value) const
Definition: mdbx.h++:7035
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++:6425
static size_t dbsize_max(intptr_t pagesize)
Returns the maximal database size in bytes for specified page size.
Definition: mdbx.h++:5944
::std::string::allocator_type legacy_allocator
Legacy allocator but it is recommended to use polymorphic_allocator.
Definition: mdbx.h++:359
value_result try_update_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:6778
value_result try_insert_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:6722
void close_map(const map_handle &)
Close a key-value map (aka sub-database) handle. Normally unnecessary.
Definition: mdbx.h++:6229
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++:6150
move_result(const cursor &cursor, bool throw_notfound)
Definition: mdbx.h++:6995
constexpr bool operator!=(const error &a, const error &b) noexcept
Definition: mdbx.h++:5311
constexpr bool is_null() const noexcept
Checks whether the slice data pointer is nullptr.
Definition: mdbx.h++:5565
ptrdiff_t estimate_from_first(map_handle map, const slice &to) const
Definition: mdbx.h++:6909
void remove_suffix(size_t n) noexcept
Drops the last "n" bytes from this slice.
Definition: mdbx.h++:5594
slice & assign(const void *ptr, size_t bytes)
Definition: mdbx.h++:5452
env & operator=(env &&other) noexcept
Definition: mdbx.h++:5877
void unbind()
Unbind cursor from a transaction.
Definition: mdbx.h++:7123
constexpr const byte * end_byte_ptr() const noexcept
Returns casted to pointer to byte an end of data.
Definition: mdbx.h++:5507
slice insert_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:6713
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++:5724
void rename_map(map_handle map, const char *new_name)
Переименовывает таблицу ключ-значение.
Definition: mdbx.h++:6445
void throw_on_failure() const
Definition: mdbx.h++:5345
bool try_update(const slice &key, const slice &value)
Definition: mdbx.h++:7206
void update(const slice &key, const slice &value)
Definition: mdbx.h++:7201
constexpr info(map_handle::flags flags, map_handle::state state) noexcept
Definition: mdbx.h++:5858
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 sub-database).
Definition: mdbx.h++:6595
constexpr slice & set_length(size_t bytes)
Set slice length.
Definition: mdbx.h++:5551
txn & set_context(void *your_context)
Sets the application context associated with the transaction.
Definition: mdbx.h++:6348
env::durability get_durability() const
Returns current durability mode.
Definition: mdbx.h++:6081
uint64_t sequence(map_handle map) const
Definition: mdbx.h++:6582
void upsert(const slice &key, const slice &value)
Definition: mdbx.h++:7189
bool is_clean() const noexcept
Definition: mdbx.h++:5285
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++:5731
::std::pmr::string::allocator_type polymorphic_allocator
Default polymorphic allocator for modern code.
Definition: mdbx.h++:365
MDBX_CXX01_CONSTEXPR_ENUM bool is_reverse(key_mode mode) noexcept
Definition: mdbx.h++:3389
static bool boolean_or_throw(int error_code)
Definition: mdbx.h++:5391
void swap(slice &other) noexcept
Definition: mdbx.h++:5497
::mdbx_filehandle_t filehandle
Definition: mdbx.h++:390
env::operate_parameters get_operation_parameters() const
Returns current operation parameters.
Definition: mdbx.h++:6068
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++:7118
MDBX_CXX01_CONSTEXPR_ENUM bool is_msgpack(key_mode mode) noexcept
Definition: mdbx.h++:3393
MDBX_env_flags_t get_flags() const
Returns environment flags.
Definition: mdbx.h++:6123
static size_t dbsize_min(intptr_t pagesize)
Returns the minimal database size in bytes for specified page size.
Definition: mdbx.h++:5937
constexpr slice tail(size_t n) const noexcept
Returns the last "n" bytes of the slice.
Definition: mdbx.h++:5641
constexpr error(MDBX_error_t error_code) noexcept
Definition: mdbx.h++:5299
constexpr const version_info & get_version() noexcept
Returns libmdbx version information.
Definition: mdbx.h++:5215
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++:6234
constexpr bool operator>(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:5703
void insert(const slice &key, slice value)
Definition: mdbx.h++:7145
move_result lower_bound_multivalue(const slice &key, const slice &value, bool throw_notfound=false)
Definition: mdbx.h++:7064
MDBX_CXX01_CONSTEXPR_ENUM bool is_usual(key_mode mode) noexcept
Definition: mdbx.h++:3377
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++:6278
constexpr slice() noexcept
Create an empty slice.
Definition: mdbx.h++:5429
cursor_managed clone(void *your_context=nullptr) const
Definition: mdbx.h++:6929
~cursor() noexcept
Definition: mdbx.h++:6954
~txn() noexcept
Definition: mdbx.h++:6322
size_t sync_threshold() const
Gets threshold used to force flush the data buffers to disk, for non-sync durability modes.
Definition: mdbx.h++:6155
txn_managed start_write(bool dont_wait=false)
Starts write (read-write) transaction.
Definition: mdbx.h++:6298
constexpr void invalidate() noexcept
Depletes content of slice and make it invalid.
Definition: mdbx.h++:5575
inline ::mdbx::txn txn() const
Returns the cursor's transaction.
Definition: mdbx.h++:7127
value_result try_insert_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:7173
static env::operate_options options_from_flags(MDBX_env_flags_t flags) noexcept
Definition: mdbx.h++:5929
map_handle map() const
Definition: mdbx.h++:7133
unsigned sync_period__seconds_16dot16() const
Gets relative period since the last unsteady commit that used to force flush the data buffers to disk...
Definition: mdbx.h++:6166
MDBX_CXX11_CONSTEXPR_ENUM mdbx::value_mode value_mode() const noexcept
Definition: mdbx.h++:5868
move_result find(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:7049
MDBX_CXX01_CONSTEXPR_ENUM bool is_multi(value_mode mode) noexcept
Definition: mdbx.h++:3472
void success_or_throw() const
Definition: mdbx.h++:5350
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++:5758
void renew_reading()
Renew a read-only transaction.
Definition: mdbx.h++:6383
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++:5779
constexpr bool ends_with(const slice &suffix) const noexcept
Checks if the data ends with the given suffix.
Definition: mdbx.h++:5611
bool sync_to_disk(bool force=true, bool nonblock=false)
Flush the environment data buffers.
Definition: mdbx.h++:6216
int compare_position(const cursor &left, const cursor &right, bool ignore_nested=false)
Definition: mdbx.h++:6985
constexpr bool operator==(const error &a, const error &b) noexcept
Definition: mdbx.h++:5307
size_t count_multivalue() const
Return count of duplicates for current key.
Definition: mdbx.h++:7074
constexpr bool starts_with(const slice &prefix) const noexcept
Checks if the data starts with the given prefix.
Definition: mdbx.h++:5606
static size_t pagesize_max() noexcept
Returns the maximal database page size in bytes.
Definition: mdbx.h++:5935
constexpr size_t hash_value() const noexcept
Returns the hash value of referenced data.
Definition: mdbx.h++:5618
bool is_dirty(const void *ptr) const
Checks whether the given data is on a dirty page.
Definition: mdbx.h++:6353
slice upsert_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:7194
env::mode get_mode() const
Returns current operation mode.
Definition: mdbx.h++:6077
MDBX_CXX01_CONSTEXPR_ENUM bool is_samelength(key_mode mode) noexcept
Definition: mdbx.h++:3385
void capture() noexcept
Definition: mdbx.h++:5287
inline ::mdbx::env env() const noexcept
Returns the transaction's environment.
Definition: mdbx.h++:6365
uint32_t get_tree_deepmask(map_handle map) const
Returns depth (bitmask) information of nested dupsort (multi-value) B+trees for given database.
Definition: mdbx.h++:6558
bool try_update(map_handle map, const slice &key, const slice &value)
Definition: mdbx.h++:6756
void safe_remove_prefix(size_t n)
Drops the first "n" bytes from this slice.
Definition: mdbx.h++:5588
comparator default_comparator(key_mode mode) noexcept
Definition: mdbx.h++:3523
slice insert_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:7165
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 database flags.
Definition: mdbx.h++:6011
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++:6161
ptrdiff_t estimate(map_handle map, const pair &from, const pair &to) const
Definition: mdbx.h++:6893
env::reclaiming_options get_reclaiming() const
Returns current reclaiming options.
Definition: mdbx.h++:6085
void drop_map(map_handle map)
Drops key-value map using handle.
Definition: mdbx.h++:6437
ptrdiff_t estimate_to_last(map_handle map, const slice &from) const
Definition: mdbx.h++:6917
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++:6863
constexpr bool operator<(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:5698
env::operate_options get_options() const
Returns current operate options.
Definition: mdbx.h++:6089
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++:6826
cursor & set_context(void *your_context)
Sets the application context associated with the cursor.
Definition: mdbx.h++:6939
map_stat get_map_stat(map_handle map) const
Returns statistics for a sub-database.
Definition: mdbx.h++:6552
bool move(move_operation operation, MDBX_val *key, MDBX_val *value, bool throw_notfound) const
Definition: mdbx.h++:7009
static size_t value_min(MDBX_db_flags_t flags) noexcept
Returns the minimal values size in bytes for specified database flags.
Definition: mdbx.h++:5981
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 sub-database).
Definition: mdbx.h++:6600
static env::reclaiming_options reclaiming_from_flags(MDBX_env_flags_t flags) noexcept
Definition: mdbx.h++:5923
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++:5743
cursor & operator=(cursor &&other) noexcept
Definition: mdbx.h++:6944
txn & put_canary(const canary &)
Set integers markers (aka "canary") associated with the environment.
Definition: mdbx.h++:6571
slice upsert_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:6743
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++:5765
constexpr slice head(size_t n) const noexcept
Returns the first "n" bytes of the slice.
Definition: mdbx.h++:5636
constexpr bool is_result_false() const noexcept
Definition: mdbx.h++:5323
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++:6172
constexpr slice safe_middle(size_t from, size_t n) const
Returns the middle "n" bytes of the slice.
Definition: mdbx.h++:5663
bool on_first() const
Definition: mdbx.h++:7084
string to_string(const ::MDBX_error_t &errcode)
Definition: mdbx.h++:7356
::std::basic_string< char, ::std::char_traits< char >, ALLOCATOR > string
Default single-byte string.
Definition: mdbx.h++:388
constexpr bool empty() const noexcept
Checks whether the slice is empty.
Definition: mdbx.h++:5561
bool eof() const
Definition: mdbx.h++:7080
int compare_position_nothrow(const cursor &left, const cursor &right, bool ignore_nested=false) noexcept
Definition: mdbx.h++:6980
MDBX_txn_flags_t flags() const
Returns transaction's flags.
Definition: mdbx.h++:6367
void * get_context() const noexcept
Returns the application context associated with the environment.
Definition: mdbx.h++:6141
MDBX_error_t put(const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
Definition: mdbx.h++:7140
map_handle open_map_accede(const char *name) const
Open existing key-value map.
Definition: mdbx.h++:6417
txn_managed prepare_read() const
Creates but not start read transaction.
Definition: mdbx.h++:6290
void safe_remove_suffix(size_t n)
Drops the last "n" bytes from this slice.
Definition: mdbx.h++:5599
bool seek(const slice &key)
Definition: mdbx.h++:7070
env & alter_flags(MDBX_env_flags_t flags, bool on_off)
Alter environment flags.
Definition: mdbx.h++:6204
env & set_context(void *your_context)
Sets the application context associated with the environment.
Definition: mdbx.h++:6145
constexpr byte operator[](size_t n) const noexcept
Returns the nth byte in the referenced data.
Definition: mdbx.h++:5625
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++:6061
void clear_map(map_handle map)
Clear key-value map.
Definition: mdbx.h++:6441
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++:6190
bool is_base64(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a Base64 dump.
Definition: mdbx.h++:5795
void remove_prefix(size_t n) noexcept
Drops the first "n" bytes from this slice.
Definition: mdbx.h++:5582
value_result try_insert(const slice &key, slice value)
Definition: mdbx.h++:7151
static void throw_on_nullptr(const void *ptr, MDBX_error_t error_code)
Definition: mdbx.h++:5376
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++:5737
put_mode
Key-value pairs put mode.
Definition: mdbx.h++:3531
static constexpr intptr_t compare_lexicographically(const pair &a, const pair &b) noexcept
Three-way lexicographically comparison.
Definition: mdbx.h++:5808
double sync_period__seconds_double() const
Gets relative period since the last unsteady commit that used to force flush the data buffers to disk...
Definition: mdbx.h++:6176
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 overflow/large-page for specified ...
Definition: mdbx.h++:6036
canary get_canary() const
Returns fours integers markers (aka "canary") associated with the environment.
Definition: mdbx.h++:6576
txn & operator=(txn &&other) noexcept
Definition: mdbx.h++:6312
bool erase(bool whole_multivalue=false)
Removes single key-value pair or all multi-values at the current cursor position.
Definition: mdbx.h++:7241
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++:6851
stat get_stat() const
Returns snapshot statistics about the MDBX environment.
Definition: mdbx.h++:6093
uint64_t id() const
Return the transaction's ID.
Definition: mdbx.h++:6373
value_result try_insert(map_handle map, const slice &key, slice value)
Definition: mdbx.h++:6698
constexpr bool is_mdbx_error() const noexcept
Returns true for MDBX's errors.
Definition: mdbx.h++:5333
constexpr bool operator>=(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:5713
ptrdiff_t estimate(const cursor &from, const cursor &to)
Definition: mdbx.h++:7043
static constexpr intptr_t compare_lexicographically(const slice &a, const slice &b) noexcept
Three-way lexicographically comparison.
Definition: mdbx.h++:5681
slice update_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:6770
bool is_base58(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a Base58 dump.
Definition: mdbx.h++:5790
~env() noexcept
Definition: mdbx.h++:5887
loop_control
Loop control constants for readers enumeration functor and other cases.
Definition: mdbx.h++:3358
slice get(map_handle map, const slice &key) const
Get value by key from a key-value map (aka sub-database).
Definition: mdbx.h++:6615
constexpr bool is_failure() const noexcept
Definition: mdbx.h++:5327
constexpr void clear() noexcept
Makes the slice empty and referencing to nothing.
Definition: mdbx.h++:5577
void update(map_handle map, const slice &key, const slice &value)
Definition: mdbx.h++:6751
geometry & make_dynamic(intptr_t lower=minimal_value, intptr_t upper=maximal_value) noexcept
Definition: mdbx.h++:5915
constexpr byte at(size_t n) const
Returns the nth byte in the referenced data with bounds checking.
Definition: mdbx.h++:5630
key_mode
Kinds of the keys and corresponding modes of comparing it.
Definition: mdbx.h++:3361
txn_managed start_read() const
Starts read (read-only) transaction.
Definition: mdbx.h++:6282
bool on_last_multival() const
Definition: mdbx.h++:7096
unsigned max_maps() const
Returns the maximum number of named databases for the environment.
Definition: mdbx.h++:6135
void insert(map_handle map, const slice &key, slice value)
Definition: mdbx.h++:6692
::std::chrono::duration< unsigned, ::std::ratio< 1, 65536 > > duration
Duration in 1/65536 units of second.
Definition: mdbx.h++:432
unsigned max_readers() const
Returns the maximum number of threads/reader slots for the environment.
Definition: mdbx.h++:6129
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 database flags.
Definition: mdbx.h++:5959
int enumerate_readers(VISITOR &visitor)
Enumerate readers.
Definition: mdbx.h++:6241
void * get_context() const noexcept
Returns the application context associated with the cursor.
Definition: mdbx.h++:6935
cursor_managed open_cursor(map_handle map) const
Opens cursor for specified key-value map handle.
Definition: mdbx.h++:6393
MDBX_CXX01_CONSTEXPR_ENUM bool is_ordinal(key_mode mode) noexcept
Definition: mdbx.h++:3381
uint64_t extra_option(extra_runtime_option option) const
Gets the value of extra runtime options from an environment.
Definition: mdbx.h++:6197
constexpr const build_info & get_build() noexcept
Returns libmdbx build information.
Definition: mdbx.h++:5218
char8_t byte
Definition: mdbx.h++:317
bool on_first_multival() const
Definition: mdbx.h++:7092
MDBX_error_t put(map_handle map, const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
Definition: mdbx.h++:6682
void panic_on_failure(const char *context_where, const char *func_who) const noexcept
Definition: mdbx.h++:5364
constexpr slice middle(size_t from, size_t n) const noexcept
Returns the middle "n" bytes of the slice.
Definition: mdbx.h++:5646
info get_info() const
Return snapshot information about the MDBX environment.
Definition: mdbx.h++:6105
void upsert(map_handle map, const slice &key, const slice &value)
Definition: mdbx.h++:6738
static size_t pagesize_min() noexcept
Returns the minimal database page size in bytes.
Definition: mdbx.h++:5933
constexpr bool operator<=(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:5708
slice update_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:7219
move_result lower_bound(const slice &key, bool throw_notfound=false)
Definition: mdbx.h++:7053
::MDBX_cmp_func * comparator
Definition: mdbx.h++:3522
constexpr size_t length() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:5549
polymorphic_allocator default_allocator
Definition: mdbx.h++:366
unsigned check_readers()
Checks for stale readers in the lock table and return number of cleared slots.
Definition: mdbx.h++:6266
bool erase(map_handle map, const slice &key)
Removes all values for given key.
Definition: mdbx.h++:6793
constexpr bool is_result_true() const noexcept
Definition: mdbx.h++:5319
bool on_last() const
Definition: mdbx.h++:7088
size_t put_multiple(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++:6871
#define MDBX_STD_FILESYSTEM_PATH
Defined if mdbx::filesystem::path is available.
Definition: mdbx.h++:405
constexpr const byte * byte_ptr() const noexcept
Returns casted to pointer to byte an address of data.
Definition: mdbx.h++:5503
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++:5772
filehandle get_filehandle() const
Returns the file descriptor for the DXB file of MDBX environment.
Definition: mdbx.h++:6117
env & set_geometry(const geometry &size)
Set all size-related parameters of environment.
Definition: mdbx.h++:6209
map_handle::info get_handle_info(map_handle map) const
Returns information about key-value map (aka sub-database) handle.
Definition: mdbx.h++:6564
void renew(const ::mdbx::txn &txn)
Renew/bind a cursor with a new transaction and previously used key-value map handle.
Definition: mdbx.h++:7114
geometry & make_fixed(intptr_t size) noexcept
Definition: mdbx.h++:5909
size_t release_all_cursors(bool unbind) const
Unbind or close all cursors.
Definition: mdbx.h++:6399
constexpr bool is_success() const noexcept
Definition: mdbx.h++:5315
value_result try_update_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:7226
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++:6407
::mdbx::filesystem::path path
Definition: mdbx.h++:413
txn_managed try_start_write()
Tries to start write (read-write) transaction without blocking.
Definition: mdbx.h++:6306
bool is_hex(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a hexadecimal dump.
Definition: mdbx.h++:5785
info get_info(bool scan_reader_lock_table=false) const
Returns information about the MDBX transaction.
Definition: mdbx.h++:6387
pair_result get_equal_or_great(map_handle map, const slice &key) const
Get value for equal or great key from a database.
Definition: mdbx.h++:6656
constexpr const char * end_char_ptr() const noexcept
Returns casted to pointer to char an end of data.
Definition: mdbx.h++:5523
@ multi_reverse_samelength
@ upsert
Insert or update.
Definition: mdbx.h++:3533
@ update
Update existing, don't insert new.
Definition: mdbx.h++:3534
@ insert_unique
Insert only unique keys.
Definition: mdbx.h++:3532
@ continue_loop
Definition: mdbx.h++:3358
@ exit_loop
Definition: mdbx.h++:3358
A handle for an individual database (key-value spaces) in the environment.
Definition: mdbx.h++:3499
::std::ostream & output(::std::ostream &out) const
Output Base58 dump of passed slice to the std::ostream.
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++:1405
constexpr static slice wrap(const POD &pod)
Definition: mdbx.h++:766
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++:819
char * write_bytes(char *dest, size_t dest_size) const
Fills the destination with data decoded from Base64 dump from a passed slice.
static constexpr slice wrap(const char(&text)[SIZE])
Definition: mdbx.h++:761
constexpr slice(const ::std::span< POD > &span)
Definition: mdbx.h++:708
constexpr slice(const ::std::basic_string< CHAR, T, A > &str)
Create a slice that refers to the contents of "str".
Definition: mdbx.h++:698
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a hexadecimal dump of a passed slice.
Definition: mdbx.h++:1345
const slice source
Definition: mdbx.h++:1439
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid Base58 dump, and therefore there could be dec...
constexpr ::std::span< const char > chars() const
Definition: mdbx.h++:741
int8_t as_int8_adapt() const
constexpr uint16_t as_uint16() const
Definition: mdbx.h++:1133
constexpr size_t envisage_result_length() const noexcept
Returns the buffer size in bytes needed for Base58 dump of passed slice.
Definition: mdbx.h++:1411
char * write_bytes(char *dest, size_t dest_size) const
Fills the destination with data decoded from Base58 dump from a passed slice.
constexpr static slice invalid() noexcept
Build an invalid slice which non-zero length and refers to null address.
Definition: mdbx.h++:1109
constexpr uint32_t as_uint32() const
Definition: mdbx.h++:1132
buffer_pair_spec(buffer_pair_spec &&pair) noexcept(buffer_type::move_assign_alloc::is_nothrow())
Definition: mdbx.h++:3321
char * write_bytes(char *dest, size_t dest_size) const
Fills the buffer by Base64 dump of passed slice.
char * write_bytes(char *dest, size_t dest_size) const
Fills the buffer by hexadecimal dump of a passed slice.
constexpr int64_t as_int64() const
Definition: mdbx.h++:1141
@ max_length
Definition: mdbx.h++:674
void swap(::std::basic_string_view< CHAR, T > &view) noexcept
Definition: mdbx.h++:949
pair_result & operator=(const pair_result &) noexcept=default
slice & operator=(const ::std::basic_string_view< CHAR, T > &view)
Definition: mdbx.h++:807
bool is_printable(bool disable_utf8=false) const noexcept
Checks whether the content of the slice is printable.
int128_t as_int128_adapt() const
constexpr int16_t as_int16() const
Definition: mdbx.h++:1143
slice value
Definition: mdbx.h++:3194
slice & assign(const ::std::basic_string< CHAR, T, ALLOCATOR > &str)
Definition: mdbx.h++:780
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++:3334
char * write_bytes(char *dest, size_t dest_size) const
Fills the buffer by Base58 dump of passed slice.
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1375
buffer_pair_spec(const slice &key, const slice &value, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3296
slice value
Definition: mdbx.h++:3210
::std::pair< buffer_type, buffer_type > stl_pair
Definition: mdbx.h++:3272
pair_result(const pair_result &) noexcept=default
const slice source
Definition: mdbx.h++:1549
const slice source
Definition: mdbx.h++:1334
constexpr static pair invalid() noexcept
Definition: mdbx.h++:3224
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++:1528
buffer_pair_spec(const txn &txn, const pair &pair, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3314
slice & assign(::std::basic_string_view< CHAR, T > &&view)
Definition: mdbx.h++:791
slice & assign(const ::std::basic_string_view< CHAR, T > &view)
Definition: mdbx.h++:787
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++:3328
constexpr POD as_pod() const
Definition: mdbx.h++:1113
constexpr pair_result() noexcept
Definition: mdbx.h++:3253
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1636
constexpr uint128_t as_uint128() const
Definition: mdbx.h++:1127
uint16_t as_uint16_adapt() const
constexpr to_hex(const slice &source, bool uppercase=false, unsigned wrap_width=0) noexcept
Definition: mdbx.h++:1337
buffer_pair_spec(const slice &key, const slice &value, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3299
std::pair< slice, slice > stl_pair
Definition: mdbx.h++:3209
value_result & operator=(const value_result &) noexcept=default
value_result(const value_result &) noexcept=default
constexpr slice(const slice &) noexcept=default
pair & operator=(const pair &) noexcept=default
slice & operator=(const slice &) noexcept=default
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned string.
Definition: mdbx.h++:1609
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base64 dump of a passed slice.
Definition: mdbx.h++:1450
constexpr from_base58(const slice &source, bool ignore_spaces=false) noexcept
Definition: mdbx.h++:1551
buffer_pair_spec(const stl_pair &pair, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3292
buffer_type key
Definition: mdbx.h++:3273
constexpr int8_t as_int8() const
Definition: mdbx.h++:1144
constexpr slice(size_t invalid_length) noexcept
Definition: mdbx.h++:1163
constexpr size_t envisage_result_length() const noexcept
Returns the buffer size in bytes needed for Base64 dump of passed slice.
Definition: mdbx.h++:1465
static constexpr size_t round(const size_t value)
Definition: mdbx.h++:1300
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1429
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++:1625
value_result(const slice &value, bool done) noexcept
Definition: mdbx.h++:3196
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1587
const slice source
Definition: mdbx.h++:1385
constexpr pair(const stl_pair &couple) noexcept
Definition: mdbx.h++:3213
constexpr from_base64(const slice &source, bool ignore_spaces=false) noexcept
Definition: mdbx.h++:1600
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned string.
Definition: mdbx.h++:1514
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++:1379
uint8_t as_uint8_adapt() const
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++:1576
buffer_pair_spec(const txn &txn, const slice &key, const slice &value, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3311
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1539
int32_t as_int32_adapt() const
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned buffer.
Definition: mdbx.h++:1522
constexpr pair_result(const slice &key, const slice &value, bool done) noexcept
Definition: mdbx.h++:3255
constexpr ::std::span< byte > bytes()
Definition: mdbx.h++:740
constexpr from_hex(const slice &source, bool ignore_spaces=false) noexcept
Definition: mdbx.h++:1506
buffer_pair_spec(const buffer_type &key, const buffer_type &value, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3280
constexpr ::std::span< POD > as_span()
Definition: mdbx.h++:727
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base58 dump of a passed slice.
Definition: mdbx.h++:1396
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++:1459
bool done
Definition: mdbx.h++:3252
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++:1433
buffer_pair_spec(const pair &pair, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3307
constexpr ::std::basic_string< CHAR, T, ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Definition: mdbx.h++:835
void make_freestanding()
Makes buffers owning the data.
Definition: mdbx.h++:3340
constexpr to_base64(const slice &source, unsigned wrap_width=0) noexcept
Definition: mdbx.h++:1442
pair(const pair &) noexcept=default
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid Base64 dump, and therefore there could be dec...
uint128_t as_uint128_adapt() const
constexpr int128_t as_int128() const
Definition: mdbx.h++:1137
slice key
Definition: mdbx.h++:3210
constexpr pair(const slice &key, const slice &value) noexcept
Definition: mdbx.h++:3211
const slice source
Definition: mdbx.h++:1598
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1483
typename buffer_type::allocator_traits allocator_traits
Definition: mdbx.h++:3270
::std::ostream & output(::std::ostream &out) const
Output hexadecimal dump of passed slice to the std::ostream.
static constexpr size_t advise(const size_t current, const size_t wanna)
Definition: mdbx.h++:1311
constexpr int32_t as_int32() const
Definition: mdbx.h++:1142
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned string.
Definition: mdbx.h++:1560
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++:1353
constexpr ::std::span< const POD > as_span() const
Definition: mdbx.h++:716
int64_t as_int64_adapt() const
buffer_pair_spec(const stl_pair &pair, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3289
constexpr uint8_t as_uint8() const
Definition: mdbx.h++:1134
CAPACITY_POLICY reservation_policy
Definition: mdbx.h++:3271
constexpr ::std::span< char > chars()
Definition: mdbx.h++:744
constexpr uint64_t as_uint64() const
Definition: mdbx.h++:1131
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned buffer.
Definition: mdbx.h++:1618
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid hexadecimal dump, and therefore there could b...
char * write_bytes(char *dest, size_t dest_size) const
Fills the destination with data decoded from hexadecimal dump from a passed slice.
::std::ostream & output(::std::ostream &out) const
Output Base64 dump of passed slice to the std::ostream.
constexpr ::std::span< const byte > bytes() const
Definition: mdbx.h++:737
uint32_t as_uint32_adapt() const
buffer_pair_spec(const pair &pair, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3304
slice & operator=(::std::basic_string_view< CHAR, T > &&view)
Definition: mdbx.h++:812
buffer_pair_spec(buffer_type &&key, buffer_type &&value) noexcept(buffer_type::move_assign_alloc::is_nothrow())
Definition: mdbx.h++:3318
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++:751
int16_t as_int16_adapt() const
typename buffer_type::allocator_type allocator_type
Definition: mdbx.h++:3269
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++:1487
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++:1388
buffer_pair_spec(const buffer_type &key, const buffer_type &value, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:3283
slice(::std::basic_string_view< CHAR, T > &&sv)
Definition: mdbx.h++:755
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++:1359
bool done
Definition: mdbx.h++:3195
const slice source
Definition: mdbx.h++:1504
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned buffer.
Definition: mdbx.h++:1569
buffer< ALLOCATOR, CAPACITY_POLICY > make_buffer(PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
Definition: mdbx.h++:3136
string< ALLOCATOR > make_string(PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
Definition: mdbx.h++:3164
inline ::std::ostream & operator<<(::std::ostream &out, const to_hex &wrapper)
Definition: mdbx.h++:1490
ImmutableByteProducer C++20 concept.
MutableByteProducer C++20 concept.
SliceTranscoder C++20 concept.
Definition: mdbx.h++:3267
Definition: mdbx.h++:1293
Base58 decoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1548
Base64 decoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1597
Hexadecimal decoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1503
Combines pair of slices for key and value to represent result of certain operations.
Definition: mdbx.h++:3208
Combines pair of slices for key and value with boolean flag to represent result of certain operations...
Definition: mdbx.h++:3251
References a data located outside the slice.
Definition: mdbx.h++:669
Base58 encoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1384
Base64 encoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1438
Hexadecimal encoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1333
Combines data slice with boolean flag to represent result of certain operations.
Definition: mdbx.h++:3193
error & operator=(const error &)=default
fatal(exception &&src) noexcept
Definition: mdbx.h++:542
fatal(const ::mdbx::error &) noexcept
exception(const exception &)=default
void throw_exception() const
error & operator=(error &&)=default
fatal(const exception &src) noexcept
Definition: mdbx.h++:541
exception(exception &&)=default
error(const error &)=default
virtual ~fatal() noexcept
fatal(const fatal &src) noexcept
Definition: mdbx.h++:543
fatal & operator=(const fatal &)=default
fatal(fatal &&src) noexcept
Definition: mdbx.h++:544
exception_thunk() noexcept=default
exception(const ::mdbx::error &) noexcept
virtual ~exception() noexcept
fatal & operator=(fatal &&)=default
Implements error information and throwing corresponding exceptions.
Definition: mdbx.h++:457
Base class for all libmdbx's exceptions that are corresponds to libmdbx errors.
Definition: mdbx.h++:520
Transfers C++ exceptions thru C callbacks.
Definition: mdbx.h++:442
Fatal exception that lead termination anyway in dangerous unrecoverable cases.
Definition: mdbx.h++:536
LIBMDBX_API void throw_allocators_mismatch()
#define MDBX_DECLARE_EXCEPTION(NAME)
Definition: mdbx.h++:550
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:4473
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:4477
LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)
#define MDBX_CXX20_CONSTEXPR
Definition: mdbx.h++:159
#define MDBX_CXX17_FALLTHROUGH
Definition: mdbx.h++:228
#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE)
Definition: mdbx.h++:270
#define MDBX_LIKELY(cond)
Definition: mdbx.h++:198
#define MDBX_CXX11_CONSTEXPR_ENUM
Definition: mdbx.h++:171
#define MDBX_UNLIKELY(cond)
Definition: mdbx.h++:208
#define MDBX_CXX17_CONSTEXPR
Definition: mdbx.h++:145
#define MDBX_CONSTEXPR_ASSERT(expr)
Definition: mdbx.h++:190
#define MDBX_IF_CONSTEXPR
Definition: mdbx.h++:217
#define MDBX_CXX01_CONSTEXPR_ENUM
Definition: mdbx.h++:170
#define MDBX_CXX20_LIKELY
Definition: mdbx.h++:235
The libmdbx C API header file.
constexpr bool allocator_is_always_equal() noexcept
Definition: mdbx.h++:1171
Definition: mdbx.h++:1215
Definition: mdbx.h++:1183
Definition: mdbx.h++:1250
The libmdbx C++ API namespace.
Definition: mdbx.h++:304
Definition: mdbx.h++:1713
constexpr allocated(allocator_pointer ptr, size_t bytes) noexcept
Definition: mdbx.h++:1716
constexpr allocated(const allocated &) noexcept=default
constexpr allocated(allocated &&) noexcept=default
allocator_pointer ptr_
Definition: mdbx.h++:1714
size_t capacity_bytes_
Definition: mdbx.h++:1715
Definition: mdbx.h++:4825
estimate_result(const cursor &cursor, move_operation operation)
Definition: mdbx.h++:4827
ptrdiff_t approximate_quantity
Definition: mdbx.h++:4826
estimate_result(const estimate_result &) noexcept=default
estimate_result(const cursor &cursor, move_operation operation, const slice &key)
Definition: mdbx.h++:4830
estimate_result & operator=(const estimate_result &) noexcept=default
Definition: mdbx.h++:4809
move_result(const move_result &) noexcept=default
move_result(cursor &cursor, move_operation operation, const slice &key, bool throw_notfound)
Definition: mdbx.h++:4814
move_result & operator=(const move_result &) noexcept=default
move_result(cursor &cursor, move_operation operation, bool throw_notfound)
Definition: mdbx.h++:4811
Tagged type for output to std::ostream.
Definition: mdbx.h++:3594
intptr_t bytes
Definition: mdbx.h++:3595
constexpr size(intptr_t bytes) noexcept
Definition: mdbx.h++:3596
Database geometry for size management.
Definition: mdbx.h++:3574
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++:3640
constexpr geometry(const geometry &) noexcept=default
intptr_t size_upper
The upper bound of database size in bytes.
Definition: mdbx.h++:3618
intptr_t pagesize
The database page size for new database creation or default_value otherwise.
Definition: mdbx.h++:3632
constexpr geometry() noexcept
Definition: mdbx.h++:3637
intptr_t growth_step
The growth step in bytes, must be greater than zero to allow the database to grow.
Definition: mdbx.h++:3622
intptr_t size_now
The size in bytes to setup the database size for now.
Definition: mdbx.h++:3606
intptr_t shrink_threshold
The shrink threshold in bytes, must be greater than zero to allow the database to shrink.
Definition: mdbx.h++:3626
intptr_t size_lower
The lower bound of database size in bytes.
Definition: mdbx.h++:3601
Definition: mdbx.h++:3766
Operate options.
Definition: mdbx.h++:3681
constexpr operate_options() noexcept
Definition: mdbx.h++:3693
constexpr operate_options(const operate_options &) noexcept=default
operate_options(MDBX_env_flags_t) noexcept
constexpr operate_options & operator=(const operate_options &) noexcept=default
Operate parameters.
Definition: mdbx.h++:3702
constexpr operate_parameters & operator=(const operate_parameters &) noexcept=default
env::operate_options options
Definition: mdbx.h++:3712
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++:3716
static env::mode mode_from_flags(MDBX_env_flags_t) noexcept
constexpr operate_parameters(const operate_parameters &) noexcept=default
env::reclaiming_options reclaiming
Definition: mdbx.h++:3711
static env::durability durability_from_flags(MDBX_env_flags_t) noexcept
constexpr operate_parameters() noexcept
Definition: mdbx.h++:3714
MDBX_env_flags_t make_flags(bool accede=true, bool use_subdirectory=false) const
Reader information.
Definition: mdbx.h++:4123
mdbx_tid_t thread
The reader thread ID.
Definition: mdbx.h++:4126
uint64_t transaction_lag
Definition: mdbx.h++:4129
size_t bytes_used
Definition: mdbx.h++:4133
uint64_t transaction_id
Definition: mdbx.h++:4127
int slot
The reader lock table slot number.
Definition: mdbx.h++:4124
mdbx_pid_t pid
The reader process ID.
Definition: mdbx.h++:4125
size_t bytes_retained
Definition: mdbx.h++:4136
Garbage reclaiming options.
Definition: mdbx.h++:3667
constexpr reclaiming_options(const reclaiming_options &) noexcept=default
constexpr reclaiming_options & operator=(const reclaiming_options &) noexcept=default
reclaiming_options(MDBX_env_flags_t) noexcept
constexpr reclaiming_options() noexcept
Definition: mdbx.h++:3672
Additional parameters for creating a new database.
Definition: mdbx.h++:4236
constexpr create_parameters() noexcept=default
env::geometry geometry
Definition: mdbx.h++:4237
Definition: mdbx.h++:3510
map_handle::state state
Definition: mdbx.h++:3512
info(const info &) noexcept=default
map_handle::flags flags
Definition: mdbx.h++:3511
info & operator=(const info &) noexcept=default
Definition: mdbx.h++:1712
constexpr bin & operator=(bin &&ditto) noexcept
Definition: mdbx.h++:1850
constexpr byte * address() noexcept
Definition: mdbx.h++:1873
constexpr bool is_inplace() const noexcept
Definition: mdbx.h++:1762
constexpr byte * make_allocated(allocator_pointer ptr, size_t capacity_bytes) noexcept
Definition: mdbx.h++:1785
static constexpr size_t advise_capacity(const size_t current, const size_t wanna)
Definition: mdbx.h++:1857
constexpr bin(size_t capacity_bytes=0) noexcept
Definition: mdbx.h++:1804
constexpr bool is_allocated() const noexcept
Definition: mdbx.h++:1765
constexpr byte & lastbyte() noexcept
Definition: mdbx.h++:1758
constexpr bin(bin &&ditto) noexcept
Definition: mdbx.h++:1819
constexpr bin(allocator_pointer ptr, size_t capacity_bytes) noexcept
Definition: mdbx.h++:1809
constexpr size_t capacity() const noexcept
Definition: mdbx.h++:1877
constexpr ~bin()
Definition: mdbx.h++:1814
constexpr byte * make_inplace() noexcept
Definition: mdbx.h++:1768
constexpr byte lastbyte() const noexcept
Definition: mdbx.h++:1755
static constexpr byte inplace_lastbyte_mask() noexcept
Definition: mdbx.h++:1748
constexpr bin & operator=(const bin &ditto) noexcept
Definition: mdbx.h++:1832
constexpr const byte * address() const noexcept
Definition: mdbx.h++:1868