libmdbx
0.11.6.39 (2022-04-13T11:05:50+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
|
|
Go to the documentation of this file.
19 #if defined(__SIZEOF_INT128__) && !defined(__GLIBCXX_TYPE_INT_N_0) && \
20 defined(__clang__) && __clang_major__ < 4
21 #define __GLIBCXX_BITSIZE_INT_N_0 128
22 #define __GLIBCXX_TYPE_INT_N_0 __int128
25 #if !defined(__cplusplus) || __cplusplus < 201103L
26 #if !defined(_MSC_VER) || _MSC_VER < 1900
27 #error "C++11 compiler or better is required"
28 #elif _MSC_VER >= 1910
30 "Please add `/Zc:__cplusplus` to MSVC compiler options to enforce it conform ISO C++"
34 #if (defined(_WIN32) || defined(_WIN64)) && MDBX_WITHOUT_MSVC_CRT
36 "CRT is required for C++ API, the MDBX_WITHOUT_MSVC_CRT option must be disabled"
40 #define __has_include(header) (0)
43 #if __has_include(<version>)
61 #include <type_traits>
65 #if defined(__cpp_lib_memory_resource) && __cpp_lib_memory_resource >= 201603L
66 #include <memory_resource>
69 #if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
70 #include <string_view>
73 #if defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L
75 #elif __has_include(<experimental/filesystem>)
76 #include <experimental/filesystem>
81 #if (defined(__cpp_lib_bit_cast) && __cpp_lib_bit_cast >= 201806L) || \
82 (defined(__cpp_lib_endian) && __cpp_lib_endian >= 201907L) || \
83 (defined(__cpp_lib_bitops) && __cpp_lib_bitops >= 201907L) || \
84 (defined(__cpp_lib_int_pow2) && __cpp_lib_int_pow2 >= 202002L)
86 #elif !(defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
87 defined(__ORDER_BIG_ENDIAN__))
88 #if defined(__BYTE_ORDER) && defined(__LITTLE_ENDIAN) && defined(__BIG_ENDIAN)
89 #define __ORDER_LITTLE_ENDIAN__ __LITTLE_ENDIAN
90 #define __ORDER_BIG_ENDIAN__ __BIG_ENDIAN
91 #define __BYTE_ORDER__ __BYTE_ORDER
92 #elif defined(_BYTE_ORDER) && defined(_LITTLE_ENDIAN) && defined(_BIG_ENDIAN)
93 #define __ORDER_LITTLE_ENDIAN__ _LITTLE_ENDIAN
94 #define __ORDER_BIG_ENDIAN__ _BIG_ENDIAN
95 #define __BYTE_ORDER__ _BYTE_ORDER
97 #define __ORDER_LITTLE_ENDIAN__ 1234
98 #define __ORDER_BIG_ENDIAN__ 4321
99 #if defined(__LITTLE_ENDIAN__) || \
100 (defined(_LITTLE_ENDIAN) && !defined(_BIG_ENDIAN)) || \
101 defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
102 defined(__MIPSEL__) || defined(_MIPSEL) || defined(__MIPSEL) || \
103 defined(_M_ARM) || defined(_M_ARM64) || defined(__e2k__) || \
104 defined(__elbrus_4c__) || defined(__elbrus_8c__) || defined(__bfin__) || \
105 defined(__BFIN__) || defined(__ia64__) || defined(_IA64) || \
106 defined(__IA64__) || defined(__ia64) || defined(_M_IA64) || \
107 defined(__itanium__) || defined(__ia32__) || defined(__CYGWIN__) || \
108 defined(_WIN64) || defined(_WIN32) || defined(__TOS_WIN__) || \
110 #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__
111 #elif defined(__BIG_ENDIAN__) || \
112 (defined(_BIG_ENDIAN) && !defined(_LITTLE_ENDIAN)) || \
113 defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
114 defined(__MIPSEB__) || defined(_MIPSEB) || defined(__MIPSEB) || \
115 defined(__m68k__) || defined(M68000) || defined(__hppa__) || \
116 defined(__hppa) || defined(__HPPA__) || defined(__sparc__) || \
117 defined(__sparc) || defined(__370__) || defined(__THW_370__) || \
118 defined(__s390__) || defined(__s390x__) || defined(__SYSC_ZARCH__)
119 #define __BYTE_ORDER__ __ORDER_BIG_ENDIAN__
124 #if defined(DOXYGEN) || \
125 defined(__cpp_constexpr) && __cpp_constexpr >= 201603L && \
126 ((defined(_MSC_VER) && _MSC_VER >= 1915) || \
127 (defined(__clang__) && __clang_major__ > 5) || \
128 (defined(__GNUC__) && __GNUC__ > 7) || \
129 (!defined(__GNUC__) && !defined(__clang__) && !defined(_MSC_VER)))
130 #define MDBX_CXX17_CONSTEXPR constexpr
132 #define MDBX_CXX17_CONSTEXPR inline
135 #if defined(DOXYGEN) || defined(__cpp_lib_is_constant_evaluated) && \
136 __cpp_lib_is_constant_evaluated >= 201811L && \
137 defined(__cpp_lib_constexpr_string) && \
138 __cpp_lib_constexpr_string >= 201907L
139 #define MDBX_CXX20_CONSTEXPR constexpr
141 #define MDBX_CXX20_CONSTEXPR inline
144 #if defined(CONSTEXPR_ASSERT)
145 #define MDBX_CONSTEXPR_ASSERT(expr) CONSTEXPR_ASSERT(expr)
147 #define MDBX_CONSTEXPR_ASSERT(expr) void(0)
149 #define MDBX_CONSTEXPR_ASSERT(expr) \
150 ((expr) ? void(0) : [] { assert(!#expr); }())
154 #if defined(DOXYGEN) || \
155 (defined(__GNUC__) || __has_builtin(__builtin_expect)) && \
156 !defined(__COVERITY__)
157 #define MDBX_LIKELY(cond) __builtin_expect(!!(cond), 1)
159 #define MDBX_LIKELY(x) (x)
163 #ifndef MDBX_UNLIKELY
164 #if defined(DOXYGEN) || \
165 (defined(__GNUC__) || __has_builtin(__builtin_expect)) && \
166 !defined(__COVERITY__)
167 #define MDBX_UNLIKELY(cond) __builtin_expect(!!(cond), 0)
169 #define MDBX_UNLIKELY(x) (x)
173 #if defined(__cpp_if_constexpr) && __cpp_if_constexpr >= 201606L
174 #define MDBX_IF_CONSTEXPR constexpr
176 #define MDBX_IF_CONSTEXPR
179 #if defined(DOXYGEN) || \
180 (__has_cpp_attribute(fallthrough) && \
181 (!defined(__clang__) || __clang__ > 4)) || \
182 __cplusplus >= 201703L
183 #define MDBX_CXX17_FALLTHROUGH [[fallthrough]]
185 #define MDBX_CXX17_FALLTHROUGH
188 #if defined(DOXYGEN) || (__has_cpp_attribute(likely) >= 201803L && \
189 (!defined(__GNUC__) || __GNUC__ > 9))
190 #define MDBX_CXX20_LIKELY [[likely]]
192 #define MDBX_CXX20_LIKELY
195 #ifndef MDBX_CXX20_UNLIKELY
196 #if defined(DOXYGEN) || (__has_cpp_attribute(unlikely) >= 201803L && \
197 (!defined(__GNUC__) || __GNUC__ > 9))
198 #define MDBX_CXX20_UNLIKELY [[unlikely]]
200 #define MDBX_CXX20_UNLIKELY
204 #ifndef MDBX_CXX20_CONCEPT
205 #if defined(DOXYGEN) || \
206 (defined(__cpp_concepts) && __cpp_concepts >= 201907L && \
207 (!defined(__clang__) || \
208 (__clang_major__ >= 12 && !defined(__APPLE__) && \
209 !defined(__ANDROID_API__)) || \
212 #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) CONCEPT NAME
214 #define MDBX_CXX20_CONCEPT(CONCEPT, NAME) typename NAME
218 #ifndef MDBX_ASSERT_CXX20_CONCEPT_SATISFIED
219 #if defined(DOXYGEN) || \
220 (defined(__cpp_concepts) && __cpp_concepts >= 201907L && \
221 (!defined(__clang__) || \
222 (__clang_major__ >= 12 && !defined(__APPLE__) && \
223 !defined(__ANDROID_API__)) || \
226 #define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE) \
227 static_assert(CONCEPT<TYPE>)
229 #define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, NAME) \
230 static_assert(true, MDBX_STRINGIFY(CONCEPT) "<" MDBX_STRINGIFY(TYPE) ">")
235 #pragma warning(push, 4)
236 #pragma warning(disable : 4127)
237 #pragma warning(disable : 4251)
239 #pragma warning(disable : 4275)
244 #pragma warning(disable : 4702)
255 #if defined(DOXYGEN) || (defined(__cpp_char8_t) && __cpp_char8_t >= 201811)
261 using byte = char8_t;
265 using byte =
unsigned char;
268 #if defined(__cpp_lib_endian) && __cpp_lib_endian >= 201907L
269 using endian = ::std::endian;
270 #elif defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && \
271 defined(__ORDER_BIG_ENDIAN__)
275 native = __BYTE_ORDER__
279 "Please use a C++ compiler provides byte order information or C++20 support"
310 #if defined(DOXYGEN) || \
311 (defined(__cpp_lib_memory_resource) && \
312 __cpp_lib_memory_resource >= 201603L && _GLIBCXX_USE_CXX11_ABI)
318 template <
class ALLOCATOR = legacy_allocator>
319 using string = ::std::basic_string<char, ::std::char_traits<char>, ALLOCATOR>;
322 #if defined(DOXYGEN) || \
323 (defined(__cpp_lib_filesystem) && __cpp_lib_filesystem >= 201703L && \
324 (!defined(__MAC_OS_X_VERSION_MIN_REQUIRED) || \
325 __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) && \
326 (!defined(__IPHONE_OS_VERSION_MIN_REQUIRED) || \
327 __IPHONE_OS_VERSION_MIN_REQUIRED >= 130100))
328 namespace filesystem = ::std::filesystem;
329 #define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path
330 #elif defined(__cpp_lib_experimental_filesystem) && \
331 __cpp_lib_experimental_filesystem >= 201406L
332 namespace filesystem = ::std::experimental::filesystem;
333 #define MDBX_STD_FILESYSTEM_PATH ::mdbx::filesystem::path
336 #ifdef MDBX_STD_FILESYSTEM_PATH
338 #elif defined(_WIN32) || defined(_WIN64)
339 using path = ::std::wstring;
349 ::std::exception_ptr captured_;
357 inline bool is_clean()
const noexcept;
358 inline void capture() noexcept;
359 inline void rethrow_captured()
const;
375 const error &b) noexcept;
377 const error &b) noexcept;
388 const char *what()
const noexcept;
396 [[noreturn]]
void panic(
const char *context_where_when,
397 const char *func_who_what)
const noexcept;
398 [[noreturn]]
void throw_exception()
const;
399 [[noreturn]]
static inline void throw_exception(
int error_code);
400 inline void throw_on_failure()
const;
401 inline void success_or_throw()
const;
403 inline void panic_on_failure(
const char *context_where,
404 const char *func_who)
const noexcept;
405 inline void success_or_panic(
const char *context_where,
406 const char *func_who)
const noexcept;
407 static inline void throw_on_nullptr(
const void *ptr,
MDBX_error_t error_code);
408 static inline void success_or_throw(
MDBX_error_t error_code);
410 success_or_throw(
static_cast<MDBX_error_t>(error_code));
412 static inline void throw_on_failure(
int error_code);
413 static inline bool boolean_or_throw(
int error_code);
414 static inline void success_or_throw(
int error_code,
const exception_thunk &);
415 static inline void panic_on_failure(
int error_code,
const char *context_where,
416 const char *func_who) noexcept;
417 static inline void success_or_panic(
int error_code,
const char *context_where,
418 const char *func_who) noexcept;
426 using base = ::std::runtime_error;
430 exception(const ::mdbx::error &) noexcept;
436 const ::mdbx::error
error() const noexcept {
return error_; }
445 fatal(const ::mdbx::error &) noexcept;
452 virtual ~
fatal() noexcept;
455 #define MDBX_DECLARE_EXCEPTION(NAME) \
456 struct LIBMDBX_API_TYPE NAME : public exception { \
457 NAME(const ::mdbx::error &); \
458 virtual ~NAME() noexcept; \
488 #undef MDBX_DECLARE_EXCEPTION
501 size_t bytes) noexcept;
504 #if defined(DOXYGEN) || \
505 (defined(__cpp_concepts) && __cpp_concepts >= 201907L && \
506 (!defined(__clang__) || \
507 (__clang_major__ >= 12 && !defined(__APPLE__) && \
508 !defined(__ANDROID_API__)) || \
512 template <
typename T>
514 { a.is_empty() } -> std::same_as<bool>;
515 { a.envisage_result_length() } -> std::same_as<size_t>;
516 { a.write_bytes(&array[0],
size_t(42)) } -> std::same_as<char *>;
519 template <
typename T>
521 { a.is_empty() } -> std::same_as<bool>;
522 { a.envisage_result_length() } -> std::same_as<size_t>;
523 { a.write_bytes(&array[0],
size_t(42)) } -> std::same_as<char *>;
526 template <
typename T>
528 requires(
const slice &source,
const T &a) {
530 { a.is_erroneous() } -> std::same_as<bool>;
536 typename CAPACITY_POLICY = default_capacity_policy,
538 inline buffer<ALLOCATOR, CAPACITY_POLICY>
539 make_buffer(PRODUCER &producer,
const ALLOCATOR &allocator = ALLOCATOR());
542 typename CAPACITY_POLICY = default_capacity_policy,
544 inline buffer<ALLOCATOR, CAPACITY_POLICY>
545 make_buffer(
const PRODUCER &producer,
const ALLOCATOR &allocator = ALLOCATOR());
549 inline string<ALLOCATOR>
make_string(PRODUCER &producer,
550 const ALLOCATOR &allocator = ALLOCATOR());
554 inline string<ALLOCATOR>
make_string(
const PRODUCER &producer,
555 const ALLOCATOR &allocator = ALLOCATOR());
582 template <
size_t SIZE>
591 template <
class CHAR,
class T,
class A>
593 slice(const ::std::basic_string<CHAR, T, A> &str)
594 :
slice(str.data(), str.length() * sizeof(CHAR)) {}
601 #if defined(DOXYGEN) || \
602 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
603 template <
class CHAR,
class T>
606 :
slice(sv.data(), sv.data() + sv.length()) {}
608 template <
class CHAR,
class T>
614 template <
size_t SIZE>
619 template <
typename POD>
621 static_assert(::std::is_standard_layout<POD>::value &&
622 !::std::is_pointer<POD>::value,
623 "Must be a standard layout type!");
624 return slice(&pod,
sizeof(pod));
627 inline slice &assign(
const void *ptr,
size_t bytes);
628 inline slice &assign(
const slice &src) noexcept;
632 inline slice &assign(
const void *begin,
const void *end);
633 template <
class CHAR,
class T,
class ALLOCATOR>
634 slice &
assign(const ::std::basic_string<CHAR, T, ALLOCATOR> &str) {
635 return assign(str.data(), str.length() *
sizeof(CHAR));
637 inline slice &assign(
const char *c_str);
638 #if defined(DOXYGEN) || \
639 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
640 template <
class CHAR,
class T>
642 return assign(view.begin(), view.end());
644 template <
class CHAR,
class T>
652 slice &operator=(
const slice &) noexcept =
default;
653 inline slice &operator=(
slice &&src) noexcept;
656 #if defined(DOXYGEN) || \
657 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
658 template <
class CHAR,
class T>
663 template <
class CHAR,
class T>
669 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>>
670 MDBX_CXX11_CONSTEXPR ::std::basic_string_view<CHAR, T>
672 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
673 return ::std::basic_string_view<CHAR, T>(char_ptr(), length());
677 template <
class CHAR,
class T>
679 operator ::std::basic_string_view<CHAR, T>() const noexcept {
680 return this->string_view<CHAR, T>();
684 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>,
685 class ALLOCATOR = legacy_allocator>
686 MDBX_CXX20_CONSTEXPR ::std::basic_string<CHAR, T, ALLOCATOR>
687 as_string(
const ALLOCATOR &allocator = ALLOCATOR())
const {
688 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
689 return ::std::basic_string<CHAR, T, ALLOCATOR>(char_ptr(), length(),
693 template <
class CHAR,
class T,
class ALLOCATOR>
695 operator ::std::basic_string<CHAR, T, ALLOCATOR>()
const {
696 return as_string<CHAR, T, ALLOCATOR>();
700 template <
class ALLOCATOR = legacy_allocator>
702 as_hex_string(
bool uppercase =
false,
unsigned wrap_width = 0,
703 const ALLOCATOR &allocator = ALLOCATOR())
const;
707 template <
class ALLOCATOR = legacy_allocator>
709 as_base58_string(
unsigned wrap_width = 0,
710 const ALLOCATOR &allocator = ALLOCATOR())
const;
714 template <
class ALLOCATOR = legacy_allocator>
716 as_base64_string(
unsigned wrap_width = 0,
717 const ALLOCATOR &allocator = ALLOCATOR())
const;
723 encode_hex(
bool uppercase =
false,
unsigned wrap_width = 0,
724 const ALLOCATOR &allocator = ALLOCATOR())
const;
731 encode_base58(
unsigned wrap_width = 0,
732 const ALLOCATOR &allocator = ALLOCATOR())
const;
739 encode_base64(
unsigned wrap_width = 0,
740 const ALLOCATOR &allocator = ALLOCATOR())
const;
746 hex_decode(
bool ignore_spaces =
false,
747 const ALLOCATOR &allocator = ALLOCATOR())
const;
754 base58_decode(
bool ignore_spaces =
false,
755 const ALLOCATOR &allocator = ALLOCATOR())
const;
762 base64_decode(
bool ignore_spaces =
false,
763 const ALLOCATOR &allocator = ALLOCATOR())
const;
771 is_printable(
bool disable_utf8 =
false) const noexcept;
778 is_hex(
bool ignore_spaces =
false) const noexcept;
786 is_base58(
bool ignore_spaces =
false) const noexcept;
794 is_base64(
bool ignore_spaces =
false) const noexcept;
796 inline
void swap(
slice &other) noexcept;
798 #if defined(DOXYGEN) || \
799 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
800 template <
class CHAR,
class T>
801 void swap(::std::basic_string_view<CHAR, T> &view) noexcept {
802 static_assert(
sizeof(CHAR) == 1,
"Must be single byte characters");
803 const auto temp = ::std::basic_string_view<CHAR, T>(*
this);
862 inline
void remove_prefix(
size_t n) noexcept;
866 inline
void remove_suffix(
size_t n) noexcept;
870 inline
void safe_remove_prefix(
size_t n);
874 inline
void safe_remove_suffix(
size_t n);
878 starts_with(const
slice &prefix) const noexcept;
882 ends_with(const
slice &suffix) const noexcept;
921 hash_value() const noexcept;
931 compare_fast(const
slice &a, const
slice &b) noexcept;
939 compare_lexicographically(const
slice &a, const
slice &b) noexcept;
941 const
slice &b) noexcept;
943 const
slice &b) noexcept;
945 const
slice &b) noexcept;
947 const
slice &b) noexcept;
949 const
slice &b) noexcept;
951 const
slice &b) noexcept;
955 return !(iov_base ==
nullptr && iov_len != 0);
961 return slice(
size_t(-1));
971 namespace allocation_aware_details {
974 #if defined(__cpp_lib_allocator_traits_is_always_equal) && \
975 __cpp_lib_allocator_traits_is_always_equal >= 201411L
976 return ::std::allocator_traits<A>::is_always_equal::value;
978 return ::std::is_empty<A>::value;
982 template <
typename T,
typename A =
typename T::allocator_type,
983 bool PoCMA = ::std::allocator_traits<
984 A>::propagate_on_container_move_assignment::value>
989 return allocator_is_always_equal<A>();
992 return allocator_is_always_equal<A>() ||
993 target->get_allocator() == source.get_allocator();
996 assert(target->get_allocator() != source.get_allocator());
1004 return allocator_is_always_equal<A>() ||
1005 ::std::is_nothrow_move_assignable<A>::value;
1009 assert(target->get_allocator() != source.get_allocator());
1010 target->get_allocator() = ::std::move(source.get_allocator());
1014 template <
typename T,
typename A =
typename T::allocator_type,
1015 bool PoCCA = ::std::allocator_traits<
1016 A>::propagate_on_container_copy_assignment::value>
1022 const T &source) noexcept {
1023 assert(target->get_allocator() != source.get_allocator());
1031 return allocator_is_always_equal<A>() ||
1032 ::std::is_nothrow_copy_assignable<A>::value;
1035 propagate(T *target,
const T &source) noexcept(is_nothrow()) {
1037 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1039 ::std::allocator_traits<A>::select_on_container_copy_construction(
1040 source.get_allocator());
1049 template <
typename T,
typename A =
typename T::allocator_type,
1051 ::std::allocator_traits<A>::propagate_on_container_swap::value>
1056 return allocator_is_always_equal<A>();
1059 T &source) noexcept(is_nothrow()) {
1061 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1073 return allocator_is_always_equal<A>() ||
1074 #if defined(__cpp_lib_is_swappable) && __cpp_lib_is_swappable >= 201603L
1075 ::std::is_nothrow_swappable<A>() ||
1077 (::std::is_nothrow_move_constructible<A>::value &&
1078 ::std::is_nothrow_move_assignable<A>::value);
1081 T &source) noexcept(is_nothrow()) {
1083 if (
MDBX_UNLIKELY(target->get_allocator() != source.get_allocator()))
1084 MDBX_CXX20_UNLIKELY ::std::swap(*target, source);
1097 extra_inplace_storage = 0,
1098 pettiness_threshold = 64,
1103 static_assert((pettiness_threshold & (pettiness_threshold - 1)) == 0,
1104 "pettiness_threshold must be a power of 2");
1105 static_assert(pettiness_threshold % 2 == 0,
1106 "pettiness_threshold must be even");
1107 static_assert(pettiness_threshold >=
sizeof(uint64_t),
1108 "pettiness_threshold must be > 7");
1109 constexpr
const auto pettiness_mask = ~size_t(pettiness_threshold - 1);
1110 return (value + pettiness_threshold - 1) & pettiness_mask;
1114 const size_t wanna) {
1115 static_assert(max_reserve % pettiness_threshold == 0,
1116 "max_reserve must be a multiple of pettiness_threshold");
1117 static_assert(max_reserve / 3 > pettiness_threshold,
1118 "max_reserve must be > pettiness_threshold * 3");
1119 if (wanna > current)
1121 return round(wanna + ::std::min(
size_t(max_reserve), current));
1123 if (current - wanna >
1126 ::std::min(wanna + pettiness_threshold,
size_t(max_reserve)))
1127 return round(wanna);
1137 const bool uppercase =
false;
1138 const unsigned wrap_width = 0;
1140 unsigned wrap_width = 0) noexcept
1141 : source(source), uppercase(uppercase), wrap_width(wrap_width) {
1146 template <
class ALLOCATOR = legacy_allocator>
1148 return make_string<ALLOCATOR>(*
this, allocator);
1156 return make_buffer<ALLOCATOR>(*
this, allocator);
1162 const size_t bytes = source.
length() << 1;
1163 return wrap_width ? bytes + bytes / wrap_width : bytes;
1168 char *write_bytes(
char *dest,
size_t dest_size)
const;
1173 ::std::ostream &output(::std::ostream &out)
const;
1188 const unsigned wrap_width = 0;
1191 : source(source), wrap_width(wrap_width) {
1197 template <
class ALLOCATOR = legacy_allocator>
1199 return make_string<ALLOCATOR>(*
this, allocator);
1208 return make_buffer<ALLOCATOR>(*
this, allocator);
1214 const size_t bytes =
1215 source.
length() / 8 * 11 + (source.
length() % 8 * 43 + 31) / 32;
1216 return wrap_width ? bytes + bytes / wrap_width : bytes;
1222 char *write_bytes(
char *dest,
size_t dest_size)
const;
1228 ::std::ostream &output(::std::ostream &out)
const;
1243 const unsigned wrap_width = 0;
1246 : source(source), wrap_width(wrap_width) {
1252 template <
class ALLOCATOR = legacy_allocator>
1254 return make_string<ALLOCATOR>(*
this, allocator);
1263 return make_buffer<ALLOCATOR>(*
this, allocator);
1269 const size_t bytes = (source.
length() + 2) / 3 * 4;
1270 return wrap_width ? bytes + bytes / wrap_width : bytes;
1276 char *write_bytes(
char *dest,
size_t dest_size)
const;
1282 ::std::ostream &output(::std::ostream &out)
const;
1294 return wrapper.
output(out);
1298 return wrapper.
output(out);
1302 return wrapper.
output(out);
1308 const bool ignore_spaces =
false;
1310 bool ignore_spaces =
false) noexcept
1311 : source(source), ignore_spaces(ignore_spaces) {
1316 template <
class ALLOCATOR = legacy_allocator>
1318 return make_string<ALLOCATOR>(*
this, allocator);
1326 return make_buffer<ALLOCATOR>(*
this, allocator);
1332 return source.
length() >> 1;
1338 char *write_bytes(
char *dest,
size_t dest_size)
const;
1346 bool is_erroneous() const noexcept;
1353 const bool ignore_spaces =
false;
1355 bool ignore_spaces =
false) noexcept
1356 : source(source), ignore_spaces(ignore_spaces) {
1362 template <
class ALLOCATOR = legacy_allocator>
1364 return make_string<ALLOCATOR>(*
this, allocator);
1373 return make_buffer<ALLOCATOR>(*
this, allocator);
1380 return source.
length() / 11 * 8 + source.
length() % 11 * 32 / 43;
1386 char *write_bytes(
char *dest,
size_t dest_size)
const;
1395 bool is_erroneous() const noexcept;
1402 const bool ignore_spaces =
false;
1404 bool ignore_spaces =
false) noexcept
1405 : source(source), ignore_spaces(ignore_spaces) {
1411 template <
class ALLOCATOR = legacy_allocator>
1413 return make_string<ALLOCATOR>(*
this, allocator);
1422 return make_buffer<ALLOCATOR>(*
this, allocator);
1429 return (source.
length() + 3) / 4 * 3;
1435 char *write_bytes(
char *dest,
size_t dest_size)
const;
1444 bool is_erroneous() const noexcept;
1448 template <class ALLOCATOR, typename CAPACITY_POLICY> class
buffer {
1450 #if !defined(_MSC_VER) || _MSC_VER > 1900
1451 using allocator_type = typename ::std::allocator_traits<
1452 ALLOCATOR>::template rebind_alloc<uint64_t>;
1454 using allocator_type =
typename ALLOCATOR::template rebind<uint64_t>::other;
1460 max_capacity = (max_length / 3u * 4u + 1023u) & ~
size_t(1023),
1461 extra_inplace_storage = reservation_policy::extra_inplace_storage,
1462 pettiness_threshold = reservation_policy::pettiness_threshold
1481 using allocator_pointer =
typename allocator_traits::pointer;
1482 using allocator_const_pointer =
typename allocator_traits::const_pointer;
1484 MDBX_CXX20_CONSTEXPR ::std::pair<allocator_pointer, size_t>
1485 allocate_storage(
size_t bytes) {
1486 assert(bytes >=
sizeof(bin));
1487 constexpr
size_t unit =
sizeof(
typename allocator_type::value_type);
1488 static_assert((unit & (unit - 1)) == 0,
1489 "size of ALLOCATOR::value_type should be a power of 2");
1490 static_assert(unit > 0,
"size of ALLOCATOR::value_type must be > 0");
1491 const size_t n = (bytes + unit - 1) / unit;
1492 return ::std::make_pair(allocator_traits::allocate(get_allocator(), n),
1497 constexpr
size_t unit =
sizeof(
typename allocator_type::value_type);
1498 assert(ptr && bytes >=
sizeof(bin) && bytes >= unit && bytes % unit == 0);
1499 allocator_traits::deallocate(get_allocator(), ptr, bytes / unit);
1503 to_address(allocator_pointer ptr) noexcept {
1504 #if defined(__cpp_lib_to_address) && __cpp_lib_to_address >= 201711L
1505 return static_cast<void *
>(::std::to_address(ptr));
1507 return static_cast<void *
>(::std::addressof(*ptr));
1511 to_address(allocator_const_pointer ptr) noexcept {
1512 #if defined(__cpp_lib_to_address) && __cpp_lib_to_address >= 201711L
1513 return static_cast<const void *
>(::std::to_address(ptr));
1515 return static_cast<const void *
>(::std::addressof(*ptr));
1523 constexpr
allocated(allocator_pointer ptr,
size_t bytes) noexcept
1524 : ptr_(ptr), capacity_bytes_(bytes) {}
1528 operator=(const
allocated &) noexcept = default;
1530 operator=(
allocated &&) noexcept = default;
1534 uint64_t align_hint_;
1535 byte inplace_[(sizeof(
allocated) + extra_inplace_storage + 7u) &
1538 static constexpr
bool
1539 is_suitable_for_inplace(
size_t capacity_bytes) noexcept {
1540 static_assert(
sizeof(
bin) ==
sizeof(inplace_),
"WTF?");
1541 return capacity_bytes <
sizeof(
bin);
1548 le_lastbyte_mask = 0x80,
1552 be_lastbyte_mask = 0x01
1557 endian::native == endian::little || endian::native == endian::big,
1558 "Only the little-endian or big-endian bytes order are supported");
1559 return (endian::native == endian::little) ? le_lastbyte_mask
1563 return inplace_[
sizeof(
bin) - 1];
1566 return inplace_[
sizeof(
bin) - 1];
1570 return (lastbyte() & inplace_lastbyte_mask()) != 0;
1574 template <
bool destroy_ptr>
1579 allocated_.~allocated();
1581 if (::std::is_trivial<allocator_pointer>::value)
1583 ::std::memset(&allocated_.ptr_, 0,
sizeof(allocated_.ptr_));
1584 lastbyte() = inplace_lastbyte_mask();
1586 is_suitable_for_inplace(capacity()));
1590 template <
bool construct_ptr>
1594 (capacity_bytes & be_lastbyte_mask) == 0 &&
1596 (
sizeof(allocated_.capacity_bytes_) - 1) * CHAR_BIT) &
1597 le_lastbyte_mask) == 0);
1600 new (&allocated_)
allocated(ptr, capacity_bytes);
1603 allocated_.ptr_ = ptr;
1604 allocated_.capacity_bytes_ = capacity_bytes;
1607 capacity() == capacity_bytes);
1613 make_inplace<false>();
1614 (void)capacity_bytes;
1617 size_t capacity_bytes) noexcept {
1619 make_allocated<true>(ptr, capacity_bytes);
1624 allocated_.~allocated();
1627 if (ditto.is_inplace()) {
1630 memcpy(inplace_, ditto.inplace_,
sizeof(inplace_));
1633 new (&allocated_)
allocated(::std::move(ditto.allocated_));
1634 ditto.make_inplace<
true>();
1640 if (ditto.is_inplace()) {
1645 allocated_.~allocated();
1646 memcpy(inplace_, ditto.inplace_,
sizeof(inplace_));
1648 }
else if (is_inplace())
1649 make_allocated<true>(ditto.allocated_.ptr_,
1650 ditto.allocated_.capacity_bytes_);
1652 make_allocated<false>(ditto.allocated_.ptr_,
1653 ditto.allocated_.capacity_bytes_);
1658 operator=(
const_cast<const bin &
>(ditto));
1659 if (ditto.is_allocated())
1660 ditto.make_inplace<
true>();
1665 const size_t wanna) {
1669 const size_t advised = reservation_policy::advise(current, wanna);
1670 assert(advised >= wanna);
1671 return ::std::min(
size_t(max_capacity),
1672 ::std::max(
sizeof(
bin) - 1, advised));
1678 :
static_cast<const byte *
>(to_address(allocated_.ptr_));
1681 return is_inplace() ? inplace_
1682 :
static_cast<byte *
>(to_address(allocated_.ptr_));
1685 return is_inplace() ?
sizeof(
bin) - 1 : allocated_.capacity_bytes_;
1690 capacity = bin::advise_capacity(0, capacity);
1691 if (bin_.is_suitable_for_inplace(capacity))
1694 const auto pair = allocate_storage(capacity);
1695 assert(
pair.second >= capacity);
1696 new (&bin_) bin(
pair.first,
pair.second);
1698 return bin_.address();
1702 if (bin_.is_allocated()) {
1703 deallocate_storage(bin_.allocated_.ptr_,
1704 bin_.allocated_.capacity_bytes_);
1705 bin_.template make_inplace<true>();
1709 template <
bool external_content>
1711 reshape(
const size_t wanna_capacity,
const size_t wanna_headroom,
1712 const void *
const content,
const size_t length) {
1713 assert(wanna_capacity >= wanna_headroom + length);
1714 const size_t old_capacity = bin_.capacity();
1715 const size_t new_capacity =
1716 bin::advise_capacity(old_capacity, wanna_capacity);
1717 assert(new_capacity >= wanna_capacity);
1720 assert(bin_.is_inplace() ==
1721 bin::is_suitable_for_inplace(new_capacity));
1722 byte *
const new_place = bin_.address() + wanna_headroom;
1725 if (external_content)
1726 memcpy(new_place, content, length);
1728 const size_t old_headroom =
1729 bin_.address() -
static_cast<const byte *
>(content);
1730 assert(old_capacity >= old_headroom + length);
1732 MDBX_CXX20_UNLIKELY ::std::memmove(new_place, content,
1739 if (bin::is_suitable_for_inplace(new_capacity)) {
1740 assert(bin_.is_allocated());
1741 const auto old_allocated = ::std::move(bin_.allocated_.ptr_);
1742 byte *
const new_place =
1743 bin_.template make_inplace<true>() + wanna_headroom;
1746 deallocate_storage(old_allocated, old_capacity);
1750 if (!bin_.is_allocated()) {
1751 const auto pair = allocate_storage(new_capacity);
1752 assert(pair.second >= new_capacity);
1753 byte *
const new_place =
1754 static_cast<byte *
>(to_address(pair.first)) + wanna_headroom;
1757 bin_.template make_allocated<true>(pair.first, pair.second);
1761 const auto old_allocated = ::std::move(bin_.allocated_.ptr_);
1762 if (external_content)
1763 deallocate_storage(old_allocated, old_capacity);
1764 const auto pair = allocate_storage(new_capacity);
1765 assert(pair.second >= new_capacity);
1766 byte *
const new_place =
1767 bin_.template make_allocated<false>(pair.first, pair.second) +
1771 if (!external_content)
1772 deallocate_storage(old_allocated, old_capacity);
1777 assert(capacity() >= offset);
1778 return bin_.address() + offset;
1781 assert(capacity() >= offset);
1782 return bin_.address() + offset;
1786 assert(capacity() >= offset + length);
1787 return static_cast<byte *
>(memcpy(get(offset), ptr, length));
1793 silo() noexcept : allocator_type() { init(0); }
1795 silo(
const allocator_type &alloc) noexcept : allocator_type(alloc) {
1805 ::std::is_nothrow_move_constructible<allocator_type>::value)
1806 : allocator_type(::std::move(ditto.get_allocator())),
1807 bin_(::std::move(ditto.bin_)) {}
1812 assert(capacity >= headroom + length);
1814 put(headroom, ptr, length);
1819 size_t length,
const allocator_type &alloc)
1820 : silo(capacity, alloc) {
1821 assert(capacity >= headroom + length);
1823 put(headroom, ptr, length);
1827 : silo(length, 0, ptr, length) {}
1829 const allocator_type &alloc)
1830 : silo(length, 0, ptr, length, alloc) {}
1832 ~silo() { release(); }
1837 size_t length,
size_t tailroom) {
1838 return reshape<true>(headroom + length + tailroom, headroom, ptr, length);
1841 return assign(0, ptr, length, 0);
1846 assert(ditto.get() + headroom == content.byte_ptr());
1848 allocator_is_always_equal<allocator_type>()) {
1849 if (
MDBX_UNLIKELY(get_allocator() != ditto.get_allocator()))
1852 allocation_aware_details::copy_assign_alloc<
1853 silo, allocator_type>::propagate(
this, ditto);
1856 content.iov_base = reshape<true>(ditto.capacity(), headroom,
1857 content.data(), content.length());
1862 assign(silo &&ditto,
size_t headroom, slice &content) noexcept(
1863 allocation_aware_details::move_assign_alloc<
1864 silo, allocator_type>::is_nothrow()) {
1865 assert(ditto.get() + headroom == content.byte_ptr());
1866 if (allocation_aware_details::move_assign_alloc<
1867 silo, allocator_type>::is_moveable(
this, ditto)) {
1869 allocation_aware_details::move_assign_alloc<
1870 silo, allocator_type>::propagate(
this, ditto);
1872 bin_ = ::std::move(ditto.bin_);
1873 assert(get() + headroom == content.byte_ptr());
1876 content.iov_base = reshape<true>(ditto.capacity(), headroom,
1877 content.data(), content.length());
1887 reshape<false>(capacity, headroom, content.iov_base, content.iov_len);
1890 allocation_aware_details::swap_alloc<silo,
1891 allocator_type>::is_nothrow()) {
1892 allocation_aware_details::swap_alloc<silo, allocator_type>::propagate(
1894 ::std::swap(bin_, ditto.bin_);
1900 capacity() const noexcept {
1901 return bin_.capacity();
1904 data(
size_t offset = 0) const noexcept {
1908 data(
size_t offset = 0) noexcept {
1917 assert(is_reference());
1919 slice_.iov_base = silo_.data();
1923 silo_begin() const noexcept {
1924 return static_cast<const byte *
>(silo_.data());
1928 silo_end() const noexcept {
1929 return silo_begin() + silo_.capacity();
1932 struct data_preserver :
public exception_thunk {
1934 data_preserver(allocator_type &allocator) : data(allocator) {}
1935 static int callback(
void *context,
MDBX_val *target,
const void *src,
1936 size_t bytes) noexcept {
1937 auto self =
static_cast<data_preserver *
>(context);
1938 assert(self->is_clean());
1939 assert(&self->data.slice_ == target);
1942 self->data.assign(src, bytes,
false);
1965 return silo_.get_allocator();
1972 static_assert(
size_t(-
long(max_length)) > max_length,
"WTF?");
1973 return size_t(byte_ptr() - silo_begin()) < silo_.capacity();
1980 return !is_freestanding();
1987 return is_freestanding() ? silo_.capacity() : 0;
1994 return is_freestanding() ? slice_.
byte_ptr() - silo_begin() : 0;
2001 return is_freestanding() ? capacity() - headroom() - slice_.
length() : 0;
2019 return const_cast<byte *
>(slice_.
byte_ptr());
2045 return const_cast<char *
>(slice_.
char_ptr());
2058 return slice_.
data();
2069 return const_cast<void *
>(slice_.
data());
2077 return const_cast<void *
>(slice_.
end());
2084 slice_.
length() + headroom() <=
2092 bytes + headroom() <= silo_.capacity());
2100 return set_length(
static_cast<const char *
>(ptr) - char_ptr());
2113 : silo_(allocator) {}
2117 : silo_(allocator), slice_(src) {
2118 if (!make_reference)
2124 :
buffer(src.slice_, make_reference, allocator) {}
2126 buffer(
const void *ptr,
size_t bytes,
bool make_reference,
2130 template <
class CHAR,
class T,
class A>
2131 buffer(const ::std::basic_string<CHAR, T, A> &) =
delete;
2132 template <
class CHAR,
class T,
class A>
2133 buffer(const ::std::basic_string<CHAR, T, A> &&) =
delete;
2135 buffer(
const char *c_str,
bool make_reference,
2139 #if defined(DOXYGEN) || \
2140 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2141 template <
class CHAR,
class T>
2142 buffer(const ::std::basic_string_view<CHAR, T> &view,
bool make_reference,
2150 : silo_(src.data(), src.length(), allocator),
2151 slice_(silo_.data(), src.length()) {}
2155 :
buffer(src.slice_, allocator) {}
2162 template <
class CHAR,
class T,
class A>
2164 buffer(const ::std::basic_string<CHAR, T, A> &str,
2172 #if defined(DOXYGEN) || \
2173 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2174 template <
class CHAR,
class T>
2176 buffer(const ::std::basic_string_view<CHAR, T> &view,
2183 : silo_(allocator) {
2184 slice_.iov_base = silo_.init(check_length(head_room, tail_room));
2185 assert(slice_.iov_len == 0);
2189 : silo_(allocator) {
2190 slice_.iov_base = silo_.init(check_length(capacity));
2191 assert(slice_.iov_len == 0);
2196 : silo_(allocator) {
2198 silo_.init(check_length(head_room, src.
length(), tail_room));
2199 slice_.iov_len = src.
length();
2200 memcpy(slice_.iov_base, src.
data(), src.
length());
2205 :
buffer(head_room, src.slice_, tail_room, allocator) {}
2208 const allocator_type &allocator = allocator_type());
2211 : silo_(::std::move(src.silo_)), slice_(::std::move(src.slice_)) {}
2221 template <
typename POD>
2228 void reserve(
size_t wanna_headroom,
size_t wanna_tailroom) {
2229 wanna_headroom = ::std::min(::std::max(headroom(), wanna_headroom),
2230 wanna_headroom + pettiness_threshold);
2231 wanna_tailroom = ::std::min(::std::max(tailroom(), wanna_tailroom),
2232 wanna_tailroom + pettiness_threshold);
2233 const size_t wanna_capacity =
2234 check_length(wanna_headroom, slice_.
length(), wanna_tailroom);
2235 silo_.resize(wanna_capacity, wanna_headroom, slice_);
2236 assert(headroom() >= wanna_headroom &&
2237 headroom() <= wanna_headroom + pettiness_threshold);
2238 assert(tailroom() >= wanna_tailroom &&
2239 tailroom() <= wanna_tailroom + pettiness_threshold);
2250 slice_.
assign(ptr, bytes);
2255 silo_.assign(
static_cast<const typename silo::value_type *
>(ptr),
2256 check_length(bytes));
2257 slice_.
assign(silo_.data(), bytes);
2263 silo_.swap(other.silo_);
2264 slice_.
swap(other.slice_);
2273 return assign(src.slice_, make_reference);
2276 buffer &
assign(
const void *ptr,
size_t bytes,
bool make_reference =
false) {
2277 return make_reference ? assign_reference(ptr, bytes)
2278 : assign_freestanding(ptr, bytes);
2282 return assign(src.
data(), src.
length(), make_reference);
2286 return assign(src.iov_base, src.iov_len, make_reference);
2290 assign(src.
data(), src.
length(), make_reference);
2296 assign(src.iov_base, src.iov_len, make_reference);
2297 src.iov_base =
nullptr;
2302 bool make_reference =
false) {
2303 return assign(begin,
2304 static_cast<const byte *
>(end) -
2305 static_cast<const byte *
>(begin),
2309 template <
class CHAR,
class T,
class A>
2311 bool make_reference =
false) {
2312 return assign(str.data(), str.length(), make_reference);
2316 return assign(c_str, ::mdbx::strlen(c_str), make_reference);
2319 #if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
2320 template <
class CHAR,
class T>
2321 buffer &assign(const ::std::basic_string_view<CHAR, T> &view,
2322 bool make_reference =
false) {
2323 return assign(view.data(), view.length(), make_reference);
2326 template <
class CHAR,
class T>
2327 buffer &assign(::std::basic_string_view<CHAR, T> &&view,
2328 bool make_reference =
false) {
2329 assign(view.data(), view.length(), make_reference);
2338 return assign(::std::move(src));
2345 #if defined(DOXYGEN) || \
2346 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2347 template <
class CHAR,
class T>
2349 return assign(view);
2353 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>>
2359 template <
class CHAR,
class T>
2360 operator ::std::basic_string_view<CHAR, T>() const noexcept {
2361 return string_view<CHAR, T>();
2367 return length() == 0;
2372 return data() ==
nullptr;
2389 template <
class CHAR =
char,
class T = ::std::
char_traits<CHAR>,
2390 class A = legacy_allocator>
2391 MDBX_CXX20_CONSTEXPR ::std::basic_string<CHAR, T, A>
2393 return slice_.
as_string<CHAR, T, A>(allocator);
2396 template <
class CHAR,
class T,
class A>
2398 operator ::std::basic_string<CHAR, T, A>()
const {
2399 return as_string<CHAR, T, A>();
2450 return byte_ptr()[n];
2462 return byte_ptr()[n];
2468 return slice_.
head(n);
2474 return slice_.
tail(n);
2480 size_t n) const noexcept {
2481 return slice_.
middle(from, n);
2505 memcpy(slice_.
byte_ptr() + size(), src, bytes);
2506 slice_.iov_len += bytes;
2511 return append(chunk.
data(), chunk.
size());
2518 memcpy(
static_cast<char *
>(slice_.iov_base) - bytes, src, bytes);
2519 slice_.iov_len += bytes;
2524 return add_header(chunk.
data(), chunk.
size());
2527 template <MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER)>
2529 const size_t wanna_bytes = producer.envisage_result_length();
2532 return set_end(producer.write_bytes(end_char_ptr(), tailroom()));
2535 template <MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER)>
2537 const size_t wanna_bytes = producer.envisage_result_length();
2540 return set_end(producer.write_bytes(end_char_ptr(), tailroom()));
2544 unsigned wrap_width = 0) {
2545 return append_producer(
to_hex(data, uppercase, wrap_width));
2549 return append_producer(
to_base58(data, wrap_width));
2553 return append_producer(
to_base64(data, wrap_width));
2557 bool ignore_spaces =
false) {
2558 return append_producer(
from_hex(data, ignore_spaces));
2562 bool ignore_spaces =
false) {
2563 return append_producer(
from_base58(data, ignore_spaces));
2567 bool ignore_spaces =
false) {
2568 return append_producer(
from_base64(data, ignore_spaces));
2573 template <
size_t SIZE>
2578 #if defined(DOXYGEN) || \
2579 (defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L)
2580 template <
class CHAR,
class T>
2582 bool make_reference =
false) {
2583 return buffer(src, make_reference);
2588 return buffer(src, make_reference);
2591 template <
class CHAR,
class T,
class A>
2593 bool make_reference =
false) {
2594 return buffer(src, make_reference);
2598 return buffer(::std::move(src));
2610 return wrap(unsigned_int64);
2630 return wrap(unsigned_int32);
2638 template <
class ALLOCATOR,
class CAPACITY_POLICY,
2640 inline buffer<ALLOCATOR, CAPACITY_POLICY>
2645 producer.envisage_result_length(), allocator);
2653 template <
class ALLOCATOR,
class CAPACITY_POLICY,
2655 inline buffer<ALLOCATOR, CAPACITY_POLICY>
2660 producer.envisage_result_length(), allocator);
2668 template <
class ALLOCATOR, MDBX_CXX20_CONCEPT(MutableByteProducer, PRODUCER)>
2670 const ALLOCATOR &allocator) {
2674 result.resize(producer.envisage_result_length());
2675 result.resize(producer.write_bytes(
const_cast<char *
>(result.data()),
2676 result.capacity()) -
2682 template <
class ALLOCATOR, MDBX_CXX20_CONCEPT(ImmutableByteProducer, PRODUCER)>
2684 const ALLOCATOR &allocator) {
2688 result.resize(producer.envisage_result_length());
2689 result.resize(producer.write_bytes(
const_cast<char *
>(result.data()),
2690 result.capacity()) -
2702 : value(value), done(done) {}
2706 assert(!done ||
bool(value));
2716 : key(key), value(value) {}
2717 pair(
const pair &) noexcept =
default;
2718 pair &operator=(
const pair &) noexcept =
default;
2720 assert(
bool(key) ==
bool(value));
2730 :
pair(key, value), done(done) {}
2734 assert(!done || (
bool(key) &&
bool(value)));
2769 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS || defined(DOXYGEN)
2844 operator bool() const noexcept {
return dbi != 0; }
2853 info(
const info &) noexcept =
default;
2854 info &operator=(
const info &) noexcept =
default;
2855 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS
2861 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS
2894 env(const
env &) noexcept = default;
2895 inline
env &operator=(
env &&other) noexcept;
2896 inline
env(
env &&other) noexcept;
2897 inline ~
env() noexcept;
2903 const
env &b) noexcept;
2905 const
env &b) noexcept;
2914 maximal_value = INTPTR_MAX,
2937 intptr_t size_lower{minimal_value};
2942 intptr_t size_now{default_value};
2954 intptr_t size_upper{maximal_value};
2958 intptr_t growth_step{default_value};
2962 intptr_t shrink_threshold{default_value};
2968 intptr_t pagesize{default_value};
2970 inline geometry &make_fixed(intptr_t size) noexcept;
2971 inline geometry &make_dynamic(intptr_t lower = minimal_value,
2972 intptr_t upper = maximal_value) noexcept;
2977 intptr_t size_now = default_value,
2978 intptr_t size_upper = maximal_value,
2979 intptr_t growth_step = default_value,
2980 intptr_t shrink_threshold = default_value,
2981 intptr_t pagesize = default_value) noexcept
2982 : size_lower(size_lower), size_now(size_now), size_upper(size_upper),
2983 growth_step(growth_step), shrink_threshold(shrink_threshold),
2984 pagesize(pagesize) {}
3007 bool coalesce{
false};
3019 bool orphan_read_transactions{
false};
3020 bool nested_write_transactions{
false};
3022 bool exclusive{
false};
3024 bool disable_readahead{
false};
3026 bool disable_clear_memory{
false};
3039 unsigned max_maps{0};
3042 unsigned max_readers{0};
3051 const unsigned max_maps,
const unsigned max_readers = 0,
3056 : max_maps(max_maps), max_readers(max_readers),
mode(
mode),
3063 make_flags(
bool accede =
true,
3064 bool use_subdirectory =
3088 bool is_pristine()
const;
3091 bool is_empty()
const;
3101 static inline size_t pagesize_min() noexcept;
3103 static inline size_t pagesize_max() noexcept;
3106 static inline size_t dbsize_min(intptr_t pagesize);
3109 static inline size_t dbsize_max(intptr_t pagesize);
3117 static inline size_t key_max(intptr_t pagesize,
MDBX_db_flags_t flags);
3120 static inline size_t key_max(intptr_t pagesize,
key_mode mode);
3132 static inline size_t value_min(
value_mode) noexcept;
3135 static inline size_t value_max(intptr_t pagesize,
MDBX_db_flags_t flags);
3138 static inline size_t value_max(intptr_t pagesize,
value_mode);
3147 static inline size_t transaction_size_max(intptr_t pagesize);
3151 size_t dbsize_min()
const {
return limits::dbsize_min(this->get_pagesize()); }
3153 size_t dbsize_max()
const {
return limits::dbsize_max(this->get_pagesize()); }
3160 return limits::value_min(
mode);
3164 return limits::value_max(*
this,
mode);
3169 return limits::transaction_size_max(this->get_pagesize());
3174 #ifdef MDBX_STD_FILESYSTEM_PATH
3176 bool force_dynamic_size =
false);
3178 #if defined(_WIN32) || defined(_WIN64)
3179 env ©(const ::std::wstring &destination,
bool compactify,
3180 bool force_dynamic_size =
false);
3183 bool force_dynamic_size =
false);
3186 env ©(
filehandle fd,
bool compactify,
bool force_dynamic_size =
false);
3207 #ifdef MDBX_STD_FILESYSTEM_PATH
3209 const remove_mode mode = just_remove);
3211 #if defined(_WIN32) || defined(_WIN64)
3212 static bool remove(const ::std::wstring &,
3213 const remove_mode mode = just_remove);
3216 const remove_mode mode = just_remove);
3225 inline stat get_stat()
const;
3231 inline info get_info()
const;
3235 inline stat get_stat(
const txn &)
const;
3239 inline info get_info(
const txn &)
const;
3245 path get_path()
const;
3252 inline unsigned max_readers()
const;
3255 inline unsigned max_maps()
const;
3258 inline void *get_context() const noexcept;
3261 inline
env &set_context(
void *);
3276 inline
env &set_sync_threshold(
size_t bytes);
3297 inline
env &set_sync_period(
unsigned seconds_16dot16);
3318 inline
env &set_sync_period(
double seconds);
3324 inline
env &set_geometry(const geometry &size);
3329 inline
bool sync_to_disk(
bool force =
true,
bool nonblock =
false);
3334 bool poll_sync_to_disk() {
return sync_to_disk(
false,
true); }
3362 uint64_t transaction_lag;
3368 size_t bytes_retained;
3379 uint64_t lag,
size_t used,
3380 size_t retained) noexcept;
3390 template <
typename VISITOR>
inline int enumerate_readers(VISITOR &visitor);
3394 inline unsigned check_readers();
3419 inline MDBX_hsr_func *get_HandleSlowReaders() const noexcept;
3446 void setup(
unsigned max_maps,
unsigned max_readers = 0);
3452 #ifdef MDBX_STD_FILESYSTEM_PATH
3454 bool accede =
true);
3456 #if defined(_WIN32) || defined(_WIN64)
3458 bool accede =
true);
3461 bool accede =
true);
3467 bool use_subdirectory{
false};
3473 #ifdef MDBX_STD_FILESYSTEM_PATH
3477 #if defined(_WIN32) || defined(_WIN64)
3497 void close(
bool dont_sync =
false);
3503 assert(handle_ != other.handle_);
3506 inherited::operator=(std::move(other));
3530 txn(const
txn &) noexcept = default;
3531 inline
txn &operator=(
txn &&other) noexcept;
3532 inline
txn(
txn &&other) noexcept;
3533 inline ~
txn() noexcept;
3539 const
txn &b) noexcept;
3541 const
txn &b) noexcept;
3548 inline uint64_t
id() const;
3551 inline
bool is_dirty(const
void *ptr) const;
3561 inline info get_info(
bool scan_reader_lock_table =
false)
const;
3570 assert(is_readwrite());
3571 return size_t(get_info().txn_space_dirty);
3577 inline void reset_reading();
3580 inline void renew_reading();
3601 create_map(
const char *name,
3615 bool drop_map(
const char *name,
bool throw_if_absent =
false);
3625 bool clear_map(
const char *name,
bool throw_if_absent =
false);
3629 bool throw_if_absent =
false);
3636 inline uint32_t get_tree_deepmask(
map_handle map)
const;
3646 inline canary get_canary()
const;
3650 inline uint64_t sequence(
map_handle map)
const;
3653 inline uint64_t sequence(
map_handle map, uint64_t increment);
3658 const slice &b)
const noexcept;
3662 const slice &b)
const noexcept;
3666 const pair &b)
const noexcept;
3670 const pair &b)
const noexcept;
3679 const slice &value_at_absence)
const;
3683 const slice &value_at_absence)
const;
3692 const slice &value_at_absence)
const;
3700 size_t value_length);
3702 size_t value_length);
3706 size_t value_length);
3711 size_t value_length);
3713 size_t value_length);
3723 const slice &new_value);
3726 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
3733 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
3739 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
3762 bool multivalue_order_preserved =
true);
3765 const size_t value_length,
const void *values_array,
3766 size_t values_count,
put_mode mode,
3767 bool allow_partial =
false);
3768 template <
typename VALUE>
3770 const ::std::vector<VALUE> &vector,
put_mode mode) {
3771 put_multiple(map, key,
sizeof(VALUE), vector.
data(), vector.size(), mode,
3802 assert(handle_ != other.handle_);
3805 inherited::operator=(std::move(other));
3839 inline ~
cursor() noexcept;
3844 const
cursor &b) noexcept;
3846 const
cursor &b) noexcept;
3873 bool throw_notfound);
3875 const slice &key,
bool throw_notfound);
3878 bool throw_notfound);
3885 bool throw_notfound)
const
3892 inline move_result to_first(
bool throw_notfound =
true);
3893 inline move_result to_previous(
bool throw_notfound =
true);
3894 inline move_result to_previous_last_multi(
bool throw_notfound =
true);
3895 inline move_result to_current_first_multi(
bool throw_notfound =
true);
3896 inline move_result to_current_prev_multi(
bool throw_notfound =
true);
3897 inline move_result current(
bool throw_notfound =
true)
const;
3898 inline move_result to_current_next_multi(
bool throw_notfound =
true);
3899 inline move_result to_current_last_multi(
bool throw_notfound =
true);
3900 inline move_result to_next_first_multi(
bool throw_notfound =
true);
3901 inline move_result to_next(
bool throw_notfound =
true);
3902 inline move_result to_last(
bool throw_notfound =
true);
3905 bool throw_notfound);
3907 inline move_result lower_bound(
const slice &key,
bool throw_notfound =
true);
3910 const slice &value,
bool throw_notfound);
3912 bool throw_notfound =
true);
3915 bool throw_notfound =
false);
3917 inline bool seek(
const slice &key);
3919 bool throw_notfound);
3922 inline size_t count_multivalue()
const;
3924 inline bool eof()
const;
3925 inline bool on_first()
const;
3926 inline bool on_last()
const;
3942 inline ::mdbx::txn
txn()
const;
3945 inline operator ::mdbx::txn()
const {
return txn(); }
3946 inline operator ::mdbx::map_handle()
const {
return map(); }
3950 inline void insert(
const slice &key,
slice value);
3952 inline slice insert_reserve(
const slice &key,
size_t value_length);
3956 inline slice upsert_reserve(
const slice &key,
size_t value_length);
3959 inline bool try_update(
const slice &key,
const slice &value);
3960 inline slice update_reserve(
const slice &key,
size_t value_length);
3965 inline bool erase(
bool whole_multivalue =
false);
3970 inline bool erase(
const slice &key,
bool whole_multivalue =
true);
3974 inline bool erase(
const slice &key,
const slice &value);
4005 assert(handle_ != other.handle_);
4008 inherited::operator=(std::move(other));
4019 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
const slice &);
4020 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
const pair &);
4021 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
const pair_result &);
4022 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4023 inline ::std::ostream &
4030 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4031 const env::geometry::size &);
4032 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
const env::geometry &);
4033 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4034 const env::operate_parameters &);
4036 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4038 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4039 const env::reclaiming_options &);
4040 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4041 const env::operate_options &);
4042 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4043 const env_managed::create_parameters &);
4045 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4047 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
4049 LIBMDBX_API ::std::ostream &
operator<<(::std::ostream &,
const error &);
4052 return out <<
error(errcode);
4068 #if defined(__cpp_lib_is_constant_evaluated) && \
4069 __cpp_lib_is_constant_evaluated >= 201811L
4070 if (::std::is_constant_evaluated()) {
4071 for (
size_t i = 0; c_str; ++i)
4077 #if defined(__cpp_lib_string_view) && __cpp_lib_string_view >= 201606L
4078 return c_str ? ::std::string_view(c_str).length() : 0;
4080 return c_str ? ::std::strlen(c_str) : 0;
4085 size_t bytes) noexcept {
4086 #if defined(__cpp_lib_is_constant_evaluated) && \
4087 __cpp_lib_is_constant_evaluated >= 201811L
4088 if (::std::is_constant_evaluated()) {
4089 for (
size_t i = 0; i < bytes; ++i)
4090 static_cast<byte *
>(dest)[i] =
static_cast<const byte *
>(src)[i];
4094 return ::std::memcpy(dest, src, bytes);
4098 size_t bytes) noexcept {
4099 #if defined(__cpp_lib_is_constant_evaluated) && \
4100 __cpp_lib_is_constant_evaluated >= 201811L
4101 if (::std::is_constant_evaluated()) {
4102 for (
size_t i = 0; i < bytes; ++i) {
4104 static_cast<const byte *
>(a)[i] -
static_cast<const byte *
>(b)[i];
4111 return ::std::memcmp(a, b, bytes);
4122 return check_length(check_length(headroom) + check_length(payload));
4127 return check_length(check_length(headroom, payload) + check_length(tailroom));
4134 captured_ = ::std::current_exception();
4139 MDBX_CXX20_UNLIKELY ::std::rethrow_exception(captured_);
4145 : code_(error_code) {}
4153 return a.code_ == b.code_;
4204 else throw_exception();
4209 const char *func_who)
const noexcept {
4215 const char *func_who)
const noexcept {
4231 error rc(error_code);
4236 switch (error_code) {
4253 const char *func_who) noexcept {
4259 const char *func_who) noexcept {
4269 : ::
MDBX_val({
const_cast<void *
>(ptr), check_length(bytes)}) {}
4272 :
slice(begin, static_cast<const
byte *>(end) -
4273 static_cast<const
byte *>(begin)) {}
4276 :
slice(c_str, ::
mdbx::strlen(c_str)) {}
4279 :
slice(src.iov_base, src.iov_len) {}
4282 src.iov_base =
nullptr;
4290 iov_base =
const_cast<void *
>(ptr);
4291 iov_len = check_length(bytes);
4296 iov_base = src.iov_base;
4297 iov_len = src.iov_len;
4302 return assign(src.iov_base, src.iov_len);
4312 assign(src.iov_base, src.iov_len);
4313 src.iov_base =
nullptr;
4318 return assign(begin,
static_cast<const byte *
>(
end) -
4319 static_cast<const byte *
>(begin));
4323 return assign(c_str, ::mdbx::strlen(c_str));
4327 return assign(::std::move(src));
4331 return assign(::std::move(src));
4335 const auto temp = *
this;
4341 return static_cast<const byte *
>(iov_base);
4349 return static_cast<byte *
>(iov_base);
4357 return static_cast<const char *
>(iov_base);
4365 return static_cast<char *
>(iov_base);
4389 iov_len = check_length(bytes);
4403 return data() ==
nullptr;
4420 assert(n <= size());
4421 iov_base =
static_cast<byte *
>(iov_base) + n;
4432 assert(n <= size());
4444 return length() >= prefix.length() &&
4445 memcmp(data(), prefix.data(), prefix.length()) == 0;
4449 return length() >= suffix.length() &&
4450 memcmp(byte_ptr() + length() - suffix.length(), suffix.data(),
4451 suffix.length()) == 0;
4456 size_t h =
length() * 3977471;
4457 for (
size_t i = 0; i <
length(); ++i)
4458 h = (h ^
static_cast<const uint8_t *
>(
data())[i]) * 1664525 + 1013904223;
4459 return h ^ 3863194411 * (h >> 11);
4464 return byte_ptr()[n];
4475 return slice(data(), n);
4480 return slice(char_ptr() + size() - n, n);
4485 return slice(char_ptr() + from, n);
4509 const slice &b) noexcept {
4510 const intptr_t diff = intptr_t(a.length()) - intptr_t(b.length());
4514 : memcmp(a.data(), b.data(), a.length());
4519 const size_t shortest = ::std::min(a.length(), b.length());
4522 const intptr_t diff = memcmp(a.data(), b.data(), shortest);
4526 return intptr_t(a.length()) - intptr_t(b.length());
4559 template <
class ALLOCATOR>
4560 inline string<ALLOCATOR>
4562 const ALLOCATOR &allocator)
const {
4563 return to_hex(*
this, uppercase, wrap_width).
as_string<ALLOCATOR>(allocator);
4566 template <
class ALLOCATOR>
4572 template <
class ALLOCATOR>
4578 template <
class ALLOCATOR,
class CAPACITY_POLICY>
4581 const ALLOCATOR &allocator)
const {
4582 return to_hex(*
this, uppercase, wrap_width)
4583 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
4586 template <
class ALLOCATOR,
class CAPACITY_POLICY>
4590 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
4593 template <
class ALLOCATOR,
class CAPACITY_POLICY>
4597 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
4600 template <
class ALLOCATOR,
class CAPACITY_POLICY>
4603 return from_hex(*
this, ignore_spaces)
4604 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
4607 template <
class ALLOCATOR,
class CAPACITY_POLICY>
4611 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
4614 template <
class ALLOCATOR,
class CAPACITY_POLICY>
4618 .
as_buffer<ALLOCATOR, CAPACITY_POLICY>(allocator);
4638 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
4641 :
buffer(src, !
txn.is_dirty(src.data()), allocator) {}
4649 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS
4656 #if CONSTEXPR_ENUM_FLAGS_OPERATIONS
4670 other.handle_ =
nullptr;
4675 other.handle_ =
nullptr;
4680 handle_ =
reinterpret_cast<MDBX_env *
>(uintptr_t(0xDeadBeef));
4685 return handle_ !=
nullptr;
4693 return a.handle_ == b.handle_;
4697 return a.handle_ != b.handle_;
4701 size_lower = size_now = size_upper =
size;
4702 growth_step = shrink_threshold = 0;
4707 intptr_t upper) noexcept {
4708 size_now = size_lower = lower;
4710 growth_step = shrink_threshold = default_value;
4732 return static_cast<size_t>(result);
4739 return static_cast<size_t>(result);
4754 return static_cast<size_t>(result);
4765 return static_cast<size_t>(result);
4784 return static_cast<size_t>(result);
4795 return static_cast<size_t>(result);
4806 return static_cast<size_t>(result);
4810 const auto flags = get_flags();
4812 operate_parameters::mode_from_flags(
flags),
4813 operate_parameters::durability_from_flags(
flags),
4814 operate_parameters::reclaiming_from_flags(
flags),
4815 operate_parameters::options_from_flags(
flags));
4819 return operate_parameters::mode_from_flags(get_flags());
4902 return set_sync_period(
unsigned(seconds * 65536));
4936 uint64_t txnid, uint64_t lag,
size_t used,
4937 size_t retained) noexcept
4938 : slot(slot), pid(pid), thread(thread), transaction_id(txnid),
4939 transaction_lag(lag), bytes_used(used), bytes_retained(retained) {}
4941 template <
typename VISITOR>
4945 static int cb(
void *ctx,
int number,
int slot,
mdbx_pid_t pid,
4946 mdbx_tid_t thread, uint64_t txnid, uint64_t lag,
size_t used,
4947 size_t retained) noexcept {
4948 reader_visitor_thunk *thunk =
static_cast<reader_visitor_thunk *
>(ctx);
4949 assert(thunk->is_clean());
4951 const reader_info info(slot, pid, thread, txnid, lag, used, retained);
4959 : visitor_(visitor) {}
4961 reader_visitor_thunk thunk(visitor);
4963 thunk.rethrow_captured();
4970 assert(dead_count >= 0);
4971 return static_cast<unsigned>(dead_count);
4987 assert(ptr !=
nullptr);
4995 assert(ptr !=
nullptr);
5003 assert(ptr !=
nullptr);
5015 other.handle_ =
nullptr;
5020 other.handle_ =
nullptr;
5025 handle_ =
reinterpret_cast<MDBX_txn *
>(uintptr_t(0xDeadBeef));
5030 return handle_ !=
nullptr;
5038 return a.handle_ == b.handle_;
5042 return a.handle_ != b.handle_;
5091 inline ::mdbx::map_handle
5098 assert(map.
dbi != 0);
5102 inline ::mdbx::map_handle
5116 assert(map.
dbi != 0);
5131 return drop_map(name.c_str(), throw_if_absent);
5139 return clear_map(name.c_str(), throw_if_absent);
5186 const slice &b)
const noexcept {
5191 const slice &b)
const noexcept {
5196 const pair &b)
const noexcept {
5197 return compare_keys(map, a.key, b.key);
5201 const pair &b)
const noexcept {
5202 return compare_values(map, a.value, b.value);
5219 const slice &value_at_absence)
const {
5221 const int err =
::mdbx_get(handle_, map.
dbi, &key, &result);
5226 return value_at_absence;
5233 const slice &value_at_absence)
const {
5235 const int err =
::mdbx_get_ex(handle_, map.
dbi, &key, &result, &values_count);
5240 return value_at_absence;
5247 const slice &key)
const {
5256 const slice &value_at_absence)
const {
5284 put(map, key, &value ,
5291 put(map, key, &value ,
5304 size_t value_length) {
5305 slice result(
nullptr, value_length);
5307 put(map, key, &result ,
5313 size_t value_length) {
5314 slice result(
nullptr, value_length);
5316 put(map, key, &result ,
5334 size_t value_length) {
5335 slice result(
nullptr, value_length);
5347 const slice &value) {
5348 const int err = put(map, key,
const_cast<slice *
>(&value),
5361 size_t value_length) {
5362 slice result(
nullptr, value_length);
5369 size_t value_length) {
5370 slice result(
nullptr, value_length);
5384 const int err =
::mdbx_del(handle_, map.
dbi, &key,
nullptr);
5408 const slice &new_value) {
5410 handle_, map.
dbi, &key,
const_cast<slice *
>(&new_value), &old_value,
5414 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5427 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5440 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5454 bool multivalue_order_preserved) {
5456 handle_, map.
dbi,
const_cast<slice *
>(&key),
const_cast<slice *
>(&value),
5462 const size_t value_length,
5463 const void *values_array,
size_t values_count,
5464 put_mode mode,
bool allow_partial) {
5465 MDBX_val args[2] = {{
const_cast<void *
>(values_array), value_length},
5466 {
nullptr, values_count}};
5480 return args[1].iov_len ;
5493 &to,
nullptr, &result));
5500 nullptr, &to,
nullptr, &result));
5507 nullptr,
nullptr, &result));
5517 other.handle_ =
nullptr;
5522 other.handle_ =
nullptr;
5527 handle_ =
reinterpret_cast<MDBX_cursor *
>(uintptr_t(0xDeadBeef));
5532 return handle_ !=
nullptr;
5542 const cursor &b) noexcept {
5543 return a.handle_ == b.handle_;
5547 const cursor &b) noexcept {
5548 return a.handle_ != b.handle_;
5552 bool throw_notfound)
5559 bool throw_notfound)
5566 const slice &key,
bool throw_notfound)
5568 this->
done = cursor.
move(operation, &this->key, &this->
value, throw_notfound);
5574 bool throw_notfound)
5576 this->
done = cursor.
move(operation, &this->key, &this->value, throw_notfound);
5580 MDBX_val *value,
bool throw_notfound)
const {
5587 if (!throw_notfound)
5610 bool throw_notfound) {
5611 return move_result(*
this, operation, throw_notfound);
5659 const slice &key,
bool throw_notfound) {
5660 return move_result(*
this, operation, key, throw_notfound);
5668 bool throw_notfound) {
5674 bool throw_notfound) {
5675 return move_result(*
this, operation, key, value, throw_notfound);
5680 bool throw_notfound) {
5686 bool throw_notfound) {
5695 bool throw_notfound) {
5696 return move(operation, &key, &value, throw_notfound);
5727 return estimate(operation, &unused_key,
nullptr);
5741 return ::mdbx::txn(
txn);
5777 slice result(
nullptr, value_length);
5785 size_t value_length) {
5786 slice result(
nullptr, value_length);
5806 slice result(
nullptr, value_length);
5831 slice result(
nullptr, value_length);
5838 size_t value_length) {
5839 slice result(
nullptr, value_length);
5866 bool found =
seek(key);
5867 return found ?
erase(whole_multivalue) : found;
5887 template <
class ALLOCATOR,
typename CAPACITY_POLICY>
5889 to_string(const ::mdbx::buffer<ALLOCATOR, CAPACITY_POLICY> &buffer) {
5901 inline string to_string(const ::mdbx::env::geometry &value) {
5907 inline string to_string(const ::mdbx::env::operate_parameters &value) {
5919 inline string to_string(const ::mdbx::env::durability &value) {
5925 inline string to_string(const ::mdbx::env::reclaiming_options &value) {
5931 inline string to_string(const ::mdbx::env::operate_options &value) {
5937 inline string to_string(const ::mdbx::env_managed::create_parameters &value) {
5968 return slice.hash_value();
5975 #pragma warning(pop)
pair(const slice &key, const slice &value) noexcept
Definition: mdbx.h++:2715
bool on_first() const
Definition: mdbx.h++:5709
Base64 encoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1241
const slice source
Definition: mdbx.h++:1352
@ multi_exactkey_lowerboundvalue
Definition: mdbx.h++:3863
void panic_on_failure(const char *context_where, const char *func_who) const noexcept
Definition: mdbx.h++:4208
MDBX_CXX20_CONSTEXPR slice(const ::std::basic_string< CHAR, T, A > &str)
Create a slice that refers to the contents of "str".
Definition: mdbx.h++:593
@ MDBX_RESERVE
Definition: mdbx.h:1497
info get_info() const
Return snapshot information about the MDBX environment.
Definition: mdbx.h++:4846
slice(::std::basic_string_view< CHAR, T > &&sv)
Definition: mdbx.h++:609
static size_t dbsize_min(intptr_t pagesize)
Returns the minimal database size in bytes for specified page size.
Definition: mdbx.h++:4728
MDBX_CXX20_CONSTEXPR ::std::basic_string< CHAR, T, ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Definition: mdbx.h++:687
constexpr allocated(allocator_pointer ptr, size_t bytes) noexcept
Definition: mdbx.h++:1523
MDBX_CXX11_CONSTEXPR bool is_null() const noexcept
Checks whether the slice data pointer is nullptr.
Definition: mdbx.h++:4402
#define MDBX_ASSERT_CXX20_CONCEPT_SATISFIED(CONCEPT, TYPE)
Definition: mdbx.h++:226
@ multi_currentkey_lastvalue
Definition: mdbx.h++:3859
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1390
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_ptrdouble(const double *const ieee754_64bit)
move_result to_next(bool throw_notfound=true)
Definition: mdbx.h++:5650
MDBX_CXX11_CONSTEXPR bool is_success() const noexcept
Definition: mdbx.h++:4160
@ multi_find_pair
Definition: mdbx.h++:3862
MDBX_dbi_state_t
DBI state bits returted by mdbx_dbi_flags_ex()
Definition: mdbx.h:3849
env & set_sync_period(unsigned seconds_16dot16)
Sets relative period since the last unsteady commit to force flush the data buffers to disk,...
Definition: mdbx.h++:4896
MDBX_CXX20_CONSTEXPR buffer(const char *c_str, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2169
buffer(size_t capacity, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2188
void throw_on_failure() const
Definition: mdbx.h++:4190
uint64_t id() const
Return the transaction's ID.
Definition: mdbx.h++:5065
durability
Durability level.
Definition: mdbx.h++:2995
@ MDBX_MAX_DBI
Definition: mdbx.h:765
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++:5416
Definition: mdbx.h++:3098
LIBMDBX_API int mdbx_cursor_bind(MDBX_txn *txn, MDBX_cursor *cursor, MDBX_dbi dbi)
Bind cursor to specified transaction and DBI handle.
buffer & assign(const ::std::basic_string< CHAR, T, A > &str, bool make_reference=false)
Definition: mdbx.h++:2310
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1439
stat get_stat() const
Returns snapshot statistics about the MDBX environment.
Definition: mdbx.h++:4834
LIBMDBX_API int mdbx_cursor_get(MDBX_cursor *cursor, MDBX_val *key, MDBX_val *data, MDBX_cursor_op op)
Retrieve by cursor.
MDBX_CXX17_CONSTEXPR bin & operator=(bin &&ditto) noexcept
Definition: mdbx.h++:1657
const MDBX_CXX11_CONSTEXPR build_info & get_build() noexcept
Returns libmdbx build information.
Definition: mdbx.h++:4063
MDBX_CXX11_CONSTEXPR size_t envisage_result_length() const noexcept
Returns the buffer size in bytes needed for Base58 dump of passed slice.
Definition: mdbx.h++:1213
move_result find_multivalue(const slice &key, const slice &value, bool throw_notfound=true)
Definition: mdbx.h++:5678
@ MDBX_SET_KEY
Definition: mdbx.h:1598
void clear() noexcept
Clears the contents and storage.
Definition: mdbx.h++:2415
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++:4750
libmdbx version information
Definition: mdbx.h:613
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1286
void safe_remove_suffix(size_t n)
Drops the last "n" bytes from the data chunk.
Definition: mdbx.h++:2437
MDBX_CXX20_CONSTEXPR ~bin()
Definition: mdbx.h++:1621
static constexpr bool is_nothrow() noexcept
Definition: mdbx.h++:1030
Definition: mdbx.h++:2848
@ insert_unique
Insert only unique keys.
Definition: mdbx.h++:2872
env::reclaiming_options get_reclaiming() const
Returns current reclaiming options.
Definition: mdbx.h++:4826
slice update_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:5830
static MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR intptr_t compare_fast(const slice &a, const slice &b) noexcept
Three-way fast non-lexicographically length-based comparison.
Definition: mdbx.h++:4508
buffer & assign(const ::MDBX_val &src, bool make_reference=false)
Definition: mdbx.h++:2285
MDBX_NOTHROW_PURE_FUNCTION bool starts_with(const struct slice &prefix) const noexcept
Checks if the data starts with the given prefix.
Definition: mdbx.h++:2404
MDBX_CXX20_CONSTEXPR buffer(const struct slice &src, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2148
MDBX_CXX11_CONSTEXPR byte * byte_ptr() noexcept
Returns casted to pointer to byte an address of data.
Definition: mdbx.h++:2017
void put_multiple(map_handle map, const slice &key, const ::std::vector< VALUE > &vector, put_mode mode)
Definition: mdbx.h++:3769
env_managed & operator=(env_managed &&other)
Definition: mdbx.h++:3500
map_handle::flags flags
Definition: mdbx.h++:2849
concept SliceTranscoder
Definition: mdbx.h++:527
@ multi_nextkey_firstvalue
Definition: mdbx.h++:3860
@ multi_currentkey_firstvalue
Definition: mdbx.h++:3856
int mdbx_filehandle_t
Definition: mdbx.h:196
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.
MDBX_dbi dbi
Definition: mdbx.h++:2839
bool sync_to_disk(bool force=true, bool nonblock=false)
Flush the environment data buffers.
Definition: mdbx.h++:4917
void insert(map_handle map, const slice &key, slice value)
Definition: mdbx.h++:5282
const MDBX_CXX11_CONSTEXPR char * char_ptr() const noexcept
Returns casted to const pointer to char an address of data.
Definition: mdbx.h++:2031
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_float(const float ieee754_32bit)
MDBX_CXX11_CONSTEXPR char * char_ptr() noexcept
Returns casted to pointer to char an address of data.
Definition: mdbx.h++:2043
LIBMDBX_VERINFO_API const struct MDBX_build_info mdbx_build
libmdbx build information
info get_info(bool scan_reader_lock_table=false) const
Returns information about the MDBX transaction.
Definition: mdbx.h++:5079
buffer & assign(const struct slice &src, bool make_reference=false)
Definition: mdbx.h++:2281
static MDBX_CXX11_CONSTEXPR size_t round(const size_t value)
Definition: mdbx.h++:1102
fatal(const fatal &src) noexcept
Definition: mdbx.h++:448
#define MDBX_CXX20_LIKELY
Definition: mdbx.h++:190
void swap(::std::basic_string_view< CHAR, T > &view) noexcept
Definition: mdbx.h++:801
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:3262
MDBX_NOTHROW_CONST_FUNCTION 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...
Reader information.
Definition: mdbx.h++:3357
MDBX_CXX11_CONSTEXPR bool is_mdbx_error() const noexcept
Returns true for MDBX's errors.
Definition: mdbx.h++:4178
Base58 decoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1351
Managed cursor.
Definition: mdbx.h++:3984
fatal(exception &&src) noexcept
Definition: mdbx.h++:447
MDBX_CXX11_CONSTEXPR byte operator[](size_t n) const noexcept
Returns the nth byte in the referenced data.
Definition: mdbx.h++:4462
ptrdiff_t estimate(map_handle map, pair from, pair to) const
Definition: mdbx.h++:5483
static MDBX_CXX20_CONSTEXPR void propagate(T *target, T &source)
Definition: mdbx.h++:1008
MDBX_CXX11_CONSTEXPR size_t envisage_result_length() const noexcept
Returns the buffer size in bytes needed for Base64 dump of passed slice.
Definition: mdbx.h++:1268
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1177
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned buffer.
Definition: mdbx.h++:1421
MDBX_CXX11_CONSTEXPR geometry() noexcept
Definition: mdbx.h++:2973
void renew(::mdbx::txn &txn)
Renew/bind a cursor with a new transaction and previously used key-value map handle.
Definition: mdbx.h++:5730
MDBX_CXX11_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++:2976
LIBMDBX_API int mdbx_env_set_userctx(MDBX_env *env, void *ctx)
Sets application information (a context pointer) associated with the environment.
buffer(const ::std::basic_string_view< CHAR, T > &view, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2142
static env::reclaiming_options reclaiming_from_flags(MDBX_env_flags_t flags) noexcept
Definition: mdbx.h++:4714
loop_control
Loop control constants for readers enumeration functor and other cases.
Definition: mdbx.h++:2743
MDBX_CXX17_CONSTEXPR byte * make_allocated(allocator_pointer ptr, size_t capacity_bytes) noexcept
Definition: mdbx.h++:1592
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++:4979
MDBX_CXX11_CONSTEXPR const struct slice & slice() const noexcept
Definition: mdbx.h++:2213
LIBMDBX_API int mdbx_env_get_flags(const MDBX_env *env, unsigned *flags)
Get environment flags.
@ key_exact
Definition: mdbx.h++:3866
env & operator=(env &&other) noexcept
Definition: mdbx.h++:4668
LIBMDBX_API int mdbx_cursor_open(MDBX_txn *txn, MDBX_dbi dbi, MDBX_cursor **cursor)
Create a cursor handle for the specified transaction and DBI handle.
@ MDBX_DUPFIXED
Definition: mdbx.h:1436
MDBX_CXX11_CONSTEXPR bool empty() const noexcept
Checks whether the slice is empty.
Definition: mdbx.h++:4398
::MDBX_dbi_state_t state
Definition: mdbx.h++:2847
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++:5185
intptr_t growth_step
The growth step in bytes, must be greater than zero to allow the database to grow.
Definition: mdbx.h++:2958
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++:4891
@ max_length
Definition: mdbx.h++:569
MDBX_NOTHROW_CONST_FUNCTION 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.
intptr_t shrink_threshold
The shrink threshold in bytes, must be greater than zero to allow the database to shrink.
Definition: mdbx.h++:2962
slice get(map_handle map, const slice &key) const
Get value by key from a key-value map (aka sub-database).
Definition: mdbx.h++:5205
static size_t dbsize_max(intptr_t pagesize)
Returns the maximal database size in bytes for specified page size.
Definition: mdbx.h++:4735
Unmanaged database environment.
Definition: mdbx.h++:2885
MDBX_txn * handle_
Definition: mdbx.h++:3525
MDBX_CXX11_CONSTEXPR to_hex(const slice &source, bool uppercase=false, unsigned wrap_width=0) noexcept
Definition: mdbx.h++:1139
const slice source
Definition: mdbx.h++:1401
MDBX_CXX11_CONSTEXPR void * data() noexcept
Return a pointer to the beginning of the referenced data.
Definition: mdbx.h++:2067
static constexpr bool is_nothrow() noexcept
Definition: mdbx.h++:1020
MDBX_env_flags_t
Environment flags.
Definition: mdbx.h:964
int enumerate_readers(VISITOR &visitor)
Enumerate readers.
Definition: mdbx.h++:4942
buffer & assign(struct slice &&src, bool make_reference=false)
Definition: mdbx.h++:2289
MDBX_CXX20_CONSTEXPR void swap(buffer &other) noexcept(swap_alloc::is_nothrow())
Definition: mdbx.h++:2262
MDBX_CXX17_CONSTEXPR byte * address() noexcept
Definition: mdbx.h++:1680
::mdbx_filehandle_t filehandle
Definition: mdbx.h++:321
#define MDBX_NOTHROW_PURE_FUNCTION
Definition: mdbx.h:270
typename ::std::allocator_traits< ALLOCATOR >::template rebind_alloc< uint64_t > allocator_type
Definition: mdbx.h++:1452
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++:1290
LIBMDBX_API int mdbx_canary_put(MDBX_txn *txn, const MDBX_canary *canary)
Set integers markers (aka "canary") associated with the environment.
slice value
Definition: mdbx.h++:2699
void clear_map(map_handle map)
Clear key-value map.
Definition: mdbx.h++:5134
LIBMDBX_API int mdbx_txn_renew(MDBX_txn *txn)
Renew a read-only transaction.
static MDBX_CXX20_CONSTEXPR void propagate(T *target, T &source) noexcept
Definition: mdbx.h++:995
const ::mdbx::error error() const noexcept
Definition: mdbx.h++:436
bool seek(const slice &key)
Definition: mdbx.h++:5690
void update(const slice &key, const slice &value)
Definition: mdbx.h++:5812
MDBX_NOTHROW_PURE_FUNCTION 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.
@ MDBX_BAD_TXN
Definition: mdbx.h:1724
void renew_reading()
Renew a read-only transaction.
Definition: mdbx.h++:5075
@ MDBX_NOTFOUND
Definition: mdbx.h:1662
MDBX_CXX11_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++:4935
@ MDBX_TXN_TRY
Definition: mdbx.h:1397
LIBMDBX_API int mdbx_get_equal_or_great(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *key, MDBX_val *data)
Get equal or great item from a database.
libmdbx build information
Definition: mdbx.h:630
MDBX_CXX11_CONSTEXPR to_base58(const slice &source, unsigned wrap_width=0) noexcept
Definition: mdbx.h++:1190
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++:4780
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.
int slot
The reader lock table slot number.
Definition: mdbx.h++:3358
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid Base58 dump, and therefore there could be dec...
txn_managed start_write(bool dont_wait=false)
Starts write (read-write) transaction.
Definition: mdbx.h++:4999
MDBX_CXX11_CONSTEXPR info(map_handle::flags flags, map_handle::state state) noexcept
Definition: mdbx.h++:4645
Definition: mdbx.h++:1519
LIBMDBX_API void throw_too_small_target_buffer()
@ MDBX_UPSERT
Definition: mdbx.h:1474
Hexadecimal decoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1306
@ key_lowerbound
Definition: mdbx.h++:3867
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++:4609
Information about the environment.
Definition: mdbx.h:2328
MDBX_debug_flags_t
Runtime debug flags.
Definition: mdbx.h:857
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint64_t mdbx_txn_id(const MDBX_txn *txn)
Return the transaction's ID.
intptr_t size_upper
The upper bound of database size in bytes.
Definition: mdbx.h++:2954
@ MDBX_MULTIPLE
Definition: mdbx.h:1510
Statistics for a database in the environment.
Definition: mdbx.h:2280
MDBX_DECLARE_EXCEPTION(bad_map_id)
#define __ORDER_LITTLE_ENDIAN__
Definition: mdbx.h++:97
MDBX_CXX14_CONSTEXPR byte & at(size_t n)
Accesses the specified byte of data chunk with bounds checking.
Definition: mdbx.h++:2459
mdbx_tid_t thread
The reader thread ID.
Definition: mdbx.h++:3360
A handle for an individual database (key-value spaces) in the environment.
Definition: mdbx.h++:2838
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:2506
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++:4580
bool is_readwrite() const
Checks whether the transaction is read-write.
Definition: mdbx.h++:3557
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool operator>=(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:4550
const slice source
Definition: mdbx.h++:1307
MDBX_CXX11_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++:1428
MDBX_CXX14_CONSTEXPR slice & set_end(const void *ptr)
Sets the length by specifying the end of the slice data.
Definition: mdbx.h++:4393
slice key
Definition: mdbx.h++:2714
void remove_suffix(size_t n) noexcept
Drops the last "n" bytes from this slice.
Definition: mdbx.h++:4431
MDBX_CXX11_CONSTEXPR void * end() noexcept
Return a pointer to the end of the referenced data.
Definition: mdbx.h++:2075
filehandle get_filehandle() const
Returns the file descriptor for the DXB file of MDBX environment.
Definition: mdbx.h++:4858
@ update
Update existing, don't insert new.
Definition: mdbx.h++:2874
@ multi_currentkey_prevvalue
Definition: mdbx.h++:3857
static buffer key_from(const char(&text)[SIZE], bool make_reference=true)
Definition: mdbx.h++:2574
#define LIBMDBX_API
Definition: mdbx.h:592
@ MDBX_NEXT
Definition: mdbx.h:1572
buffer & add_header(const void *src, size_t bytes)
Definition: mdbx.h++:2514
unsigned check_readers()
Checks for stale readers in the lock table and return number of cleared slots.
Definition: mdbx.h++:4967
static buffer key_from(const char *src, bool make_reference=false)
Definition: mdbx.h++:2587
MDBX_CXX11_CONSTEXPR byte & operator[](size_t n) noexcept
Accesses the specified byte of data chunk.
Definition: mdbx.h++:2448
void insert(const slice &key, slice value)
Definition: mdbx.h++:5756
static MDBX_CXX11_CONSTEXPR size_t advise(const size_t current, const size_t wanna)
Definition: mdbx.h++:1113
env & set_geometry(const geometry &size)
Set all size-related parameters of environment.
Definition: mdbx.h++:4910
MDBX_NOTHROW_PURE_FUNCTION bool ends_with(const struct slice &suffix) const noexcept
Checks if the data ends with the given suffix.
Definition: mdbx.h++:2410
static constexpr bool is_nothrow() noexcept
Definition: mdbx.h++:1072
MDBX_CXX14_CONSTEXPR void clear() noexcept
Makes the slice empty and referencing to nothing.
Definition: mdbx.h++:4414
buffer(size_t head_room, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2181
@ MDBX_SUCCESS
Definition: mdbx.h:1647
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) MDBX_CXX17_NOEXCEPT
A Handle-Slow-Readers callback function to resolve database full/overflow issue due to a reader(s) wh...
Definition: mdbx.h:4985
static env::durability durability_from_flags(MDBX_env_flags_t) noexcept
const MDBX_CXX11_CONSTEXPR byte * byte_ptr() const noexcept
Returns casted to pointer to byte an address of data.
Definition: mdbx.h++:4340
MDBX_NOTHROW_PURE_FUNCTION 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.
MDBX_CXX17_CONSTEXPR byte * make_inplace() noexcept
Definition: mdbx.h++:1575
LIBMDBX_API int mdbx_dbi_flags_ex(MDBX_txn *txn, MDBX_dbi dbi, unsigned *flags, unsigned *state)
Retrieve the DB flags and status for a database handle.
move_result to_previous(bool throw_notfound=true)
Definition: mdbx.h++:5618
MDBX_CXX11_CONSTEXPR map_handle() noexcept
Definition: mdbx.h++:2840
char8_t byte
Definition: mdbx.h++:261
#define MDBX_LIKELY(cond)
Definition: mdbx.h++:157
LIBMDBX_API int mdbx_dbi_stat(MDBX_txn *txn, MDBX_dbi dbi, MDBX_stat *stat, size_t bytes)
Retrieve statistics for a database.
buffer & assign(const char *c_str, bool make_reference=false)
Definition: mdbx.h++:2315
static size_t pagesize_max() noexcept
Returns the maximal database page size in bytes.
Definition: mdbx.h++:4726
static constexpr bool is_nothrow() noexcept
Definition: mdbx.h++:988
MDBX_CXX11_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++:1379
buffer & operator=(const ::std::basic_string_view< CHAR, T > &view) noexcept
Definition: mdbx.h++:2348
MDBX_cursor * handle_
Definition: mdbx.h++:3831
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.
::std::ostream & output(::std::ostream &out) const
Output Base58 dump of passed slice to the std::ostream.
MDBX_CXX11_CONSTEXPR reclaiming_options() noexcept
Definition: mdbx.h++:3008
static buffer key_from(const float *ieee754_32bit)
Definition: mdbx.h++:2625
MDBX_NOTHROW_CONST_FUNCTION uint32_t mdbx_key_from_int32(const int32_t i32)
Definition: mdbx.h:3785
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid hexadecimal dump, and therefore there could b...
constexpr byte lastbyte() const noexcept
Definition: mdbx.h++:1562
bool is_clean() const noexcept
Definition: mdbx.h++:4130
size_t size_current() const
Returns current write transaction size (i.e.summary volume of dirty pages) in bytes.
Definition: mdbx.h++:3569
unsigned max_readers() const
Returns the maximum number of threads/reader slots for the environment.
Definition: mdbx.h++:4870
LIBMDBX_API MDBX_dbi mdbx_cursor_dbi(const MDBX_cursor *cursor)
Return the cursor's database handle.
#define bool
Definition: mdbx.h:379
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API uint32_t mdbx_key_from_ptrfloat(const float *const ieee754_32bit)
@ multi_reverse_samelength
MDBX_CXX20_CONSTEXPR bin(allocator_pointer ptr, size_t capacity_bytes) noexcept
Definition: mdbx.h++:1616
LIBMDBX_API int mdbx_get_ex(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.
#define MDBX_CXX14_CONSTEXPR
Definition: mdbx.h:433
@ get_current
Definition: mdbx.h++:3853
@ multi_currentkey_nextvalue
Definition: mdbx.h++:3858
buffer & operator=(buffer &&src) noexcept(move_assign_alloc::is_nothrow())
Definition: mdbx.h++:2337
MDBX_cursor_op
Cursor operations.
Definition: mdbx.h:1543
concept MutableByteProducer
Definition: mdbx.h++:513
MDBX_NOTHROW_PURE_FUNCTION 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...
move_result(const cursor &cursor, bool throw_notfound)
Definition: mdbx.h++:5551
void update(map_handle map, const slice &key, const slice &value)
Definition: mdbx.h++:5341
txn_managed prepare_read() const
Creates but not start read transaction.
Definition: mdbx.h++:4991
static env::operate_options options_from_flags(MDBX_env_flags_t flags) noexcept
Definition: mdbx.h++:4720
concept ImmutableByteProducer
Definition: mdbx.h++:520
Operate options.
Definition: mdbx.h++:3017
@ MDBX_LAST
Definition: mdbx.h:1566
buffer & operator=(const buffer &src)
Definition: mdbx.h++:2335
static void throw_on_nullptr(const void *ptr, MDBX_error_t error_code)
Definition: mdbx.h++:4220
slice upsert_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:5805
static buffer key_from(const ::std::basic_string_view< CHAR, T > &src, bool make_reference=false)
Definition: mdbx.h++:2581
move_result to_current_last_multi(bool throw_notfound=true)
Definition: mdbx.h++:5642
MDBX_error_t put(map_handle map, const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
Definition: mdbx.h++:5272
constexpr const byte * address() const noexcept
Definition: mdbx.h++:1675
value_result try_insert(const slice &key, slice value)
Definition: mdbx.h++:5762
#define MDBX_CXX20_CONCEPT(CONCEPT, NAME)
Definition: mdbx.h++:212
buffer & append_producer(PRODUCER &producer)
Definition: mdbx.h++:2528
Fatal exception that lead termination anyway in dangerous unrecoverable cases.
Definition: mdbx.h++:441
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_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++:1979
Unmanaged cursor.
Definition: mdbx.h++:3829
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++:5441
CAPACITY_POLICY reservation_policy
Definition: mdbx.h++:1457
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++:5461
buffer & append_base58(const struct slice &data, unsigned wrap_width=0)
Definition: mdbx.h++:2548
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API MDBX_env * mdbx_txn_env(const MDBX_txn *txn)
Returns the transaction's MDBX_env.
bool erase(map_handle map, const slice &key)
Removes all values for given key.
Definition: mdbx.h++:5383
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned string.
Definition: mdbx.h++:1363
MDBX_CXX11_CONSTEXPR env() noexcept=default
static buffer key_from(const int32_t signed_int32)
Definition: mdbx.h++:2633
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API void * mdbx_env_get_userctx(const MDBX_env *env)
Returns an application information (a context pointer) associated with the environment.
buffer & append_base64(const struct slice &data, unsigned wrap_width=0)
Definition: mdbx.h++:2552
MDBX_CXX14_CONSTEXPR slice safe_tail(size_t n) const
Returns the last "n" bytes of the slice.
Definition: mdbx.h++:4494
struct MDBX_env MDBX_env
Opaque structure for a database environment.
Definition: mdbx.h:692
The chunk of data stored inside the buffer or located outside it.
Definition: mdbx.h++:302
bool move(move_operation operation, MDBX_val *key, MDBX_val *value, bool throw_notfound) const
Definition: mdbx.h++:5579
size_t key_max(key_mode mode) const
Returns the maximal key size in bytes for specified keys mode.
Definition: mdbx.h++:3157
MDBX_CXX11_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++:3050
Garbage reclaiming options.
Definition: mdbx.h++:3003
value_result try_update_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:5837
void remove_prefix(size_t n) noexcept
Drops the first "n" bytes from this slice.
Definition: mdbx.h++:4419
@ MDBX_MAXDATASIZE
Definition: mdbx.h:768
pthread_t mdbx_tid_t
Definition: mdbx.h:198
buffer(buffer &&src) noexcept(move_assign_alloc::is_nothrow())
Definition: mdbx.h++:2210
MDBX_NOTHROW_PURE_FUNCTION 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.
map_handle::info get_handle_info(map_handle map) const
Returns information about key-value map (aka sub-database) handle.
Definition: mdbx.h++:5154
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base58 dump of a passed slice.
Definition: mdbx.h++:1198
string< ALLOCATOR > make_string(PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
Definition: mdbx.h++:2669
static bool boolean_or_throw(int error_code)
Definition: mdbx.h++:4235
env & set_context(void *)
Sets the application context associated with the environment.
Definition: mdbx.h++:4886
MDBX_CXX11_CONSTEXPR map_handle(MDBX_dbi dbi) noexcept
Definition: mdbx.h++:2841
static buffer key_from(const silo &&src) noexcept
Definition: mdbx.h++:2597
::std::basic_string< char, ::std::char_traits< char >, ALLOCATOR > string
Default singe-byte string.
Definition: mdbx.h++:319
geometry & make_fixed(intptr_t size) noexcept
Definition: mdbx.h++:4700
value_result try_update_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:5368
LIBMDBX_API void throw_allocators_mismatch()
put_mode
Key-value pairs put mode.
Definition: mdbx.h++:2871
@ MDBX_ENOMEM
Definition: mdbx.h:1796
::std::ostream & output(::std::ostream &out) const
Output hexadecimal dump of passed slice to the std::ostream.
map_stat get_map_stat(map_handle map) const
Returns statistics for a sub-database.
Definition: mdbx.h++:5142
const slice source
Definition: mdbx.h++:1187
~cursor_managed() noexcept
Definition: mdbx.h++:4014
inline ::mdbx::env env() const noexcept
Returns the transaction's environment.
Definition: mdbx.h++:5057
int(* MDBX_preserve_func)(void *context, MDBX_val *target, const void *src, size_t bytes)
Definition: mdbx.h:4149
buffer(const char *c_str, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2135
@ MDBX_DB_DEFAULTS
Definition: mdbx.h:1419
LIBMDBX_API void mdbx_cursor_close(MDBX_cursor *cursor)
Close a cursor handle.
MDBX_NOTHROW_PURE_FUNCTION 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.
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool starts_with(const slice &prefix) const noexcept
Checks if the data starts with the given prefix.
Definition: mdbx.h++:4443
Combines pair of slices for key and value with boolean flag to represent result of certain operations...
Definition: mdbx.h++:2727
buffer(const buffer &src, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2122
MDBX_NOTHROW_CONST_FUNCTION uint64_t mdbx_key_from_int64(const int64_t i64)
Definition: mdbx.h:3781
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++:4568
::std::pmr::string::allocator_type polymorphic_allocator
Default polymorphic allocator for modern code.
Definition: mdbx.h++:314
static buffer key_from(const int64_t signed_int64)
Definition: mdbx.h++:2613
buffer & append(const void *src, size_t bytes)
Definition: mdbx.h++:2502
@ MDBX_PREV_NODUP
Definition: mdbx.h:1592
env::operate_options options
Definition: mdbx.h++:3046
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++:5190
::MDBX_db_flags_t flags
Definition: mdbx.h++:2846
slice value
Definition: mdbx.h++:2714
#define MDBX_CXX17_FALLTHROUGH
Definition: mdbx.h++:183
MDBX_CXX11_CONSTEXPR ::mdbx::key_mode key_mode() const noexcept
Definition: mdbx.h++:4652
const MDBX_CXX11_CONSTEXPR char * end_char_ptr() const noexcept
Returns casted to const pointer to char an end of data.
Definition: mdbx.h++:2036
pair_result(const slice &key, const slice &value, bool done) noexcept
Definition: mdbx.h++:2729
static MDBX_CXX14_CONSTEXPR slice invalid() noexcept
Build an invalid slice which non-zero length and refers to null address.
Definition: mdbx.h++:960
MDBX_CXX20_CONSTEXPR buffer(const buffer &src, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2154
LIBMDBX_API int mdbx_drop(MDBX_txn *txn, MDBX_dbi dbi, bool del)
Empty or delete and close a database.
@ MDBX_MAX_PAGESIZE
Definition: mdbx.h:774
LIBMDBX_API int mdbx_del(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, const MDBX_val *data)
Delete items from a database.
bool done
Definition: mdbx.h++:2700
Operate parameters.
Definition: mdbx.h++:3036
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a Base64 dump of a passed slice.
Definition: mdbx.h++:1253
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base58 dump from a passed slice to returned buffer.
Definition: mdbx.h++:1372
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++:5246
Unmanaged database transaction.
Definition: mdbx.h++:3522
ptrdiff_t estimate(move_operation operation, MDBX_val *key, MDBX_val *value) const
Definition: mdbx.h++:5595
@ readonly
Definition: mdbx.h++:2989
slice insert_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:5776
txn & put_canary(const canary &)
Set integers markers (aka "canary") associated with the environment.
Definition: mdbx.h++:5161
buffer & assign(const void *begin, const void *end, bool make_reference=false)
Definition: mdbx.h++:2301
buffer & append_decoded_base64(const struct slice &data, bool ignore_spaces=false)
Definition: mdbx.h++:2566
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++:1262
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR size_t hash_value() const noexcept
Returns the hash value of the data.
Definition: mdbx.h++:2385
buffer(const struct slice &src, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2115
value_mode
Kind of the values and sorted multi-values with corresponding comparison.
Definition: mdbx.h++:2764
Definition: mdbx.h++:1520
void safe_remove_prefix(size_t n)
Drops the first "n" bytes from the data chunk.
Definition: mdbx.h++:2433
size_t value_max(value_mode mode) const
Returns the maximal value size in bytes for specified values mode.
Definition: mdbx.h++:3163
void shrink_to_fit()
Reduces memory usage by freeing unused storage space.
Definition: mdbx.h++:2421
txn & operator=(txn &&other) noexcept
Definition: mdbx.h++:5013
MDBX_CXX11_CONSTEXPR cursor() noexcept=default
MDBX_CXX11_CONSTEXPR bool is_result_true() const noexcept
Definition: mdbx.h++:4164
LIBMDBX_API int mdbx_txn_break(MDBX_txn *txn)
Marks transaction as broken.
Base class for all libmdbx's exceptions that are corresponds to libmdbx errors.
Definition: mdbx.h++:425
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool operator>(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:4540
static MDBX_CXX14_CONSTEXPR slice wrap(const char(&text)[SIZE])
Definition: mdbx.h++:615
@ MDBX_LAST_ADDED_ERRCODE
Definition: mdbx.h:1774
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1232
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_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++:1971
#define false
Definition: mdbx.h:385
::std::basic_string_view< CHAR, T > string_view() const noexcept
Return a string_view that references the data of this buffer.
Definition: mdbx.h++:2354
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_jsonInteger(const int64_t json_integer)
constexpr size_t capacity() const noexcept
Definition: mdbx.h++:1684
ptrdiff_t estimate_to_last(map_handle map, slice from) const
Definition: mdbx.h++:5504
Tagged type for output to std::ostream.
Definition: mdbx.h++:2930
buffer & assign(const void *ptr, size_t bytes, bool make_reference=false)
Definition: mdbx.h++:2276
MDBX_CXX11_CONSTEXPR MDBX_error_t code() const noexcept
Returns error code.
Definition: mdbx.h++:4176
remove_mode
Deletion modes for remove().
Definition: mdbx.h++:3189
~txn() noexcept
Definition: mdbx.h++:5023
@ MDBX_SET_RANGE
Definition: mdbx.h:1601
move_result to_current_first_multi(bool throw_notfound=true)
Definition: mdbx.h++:5626
ptrdiff_t estimate(const cursor &from, const cursor &to)
Definition: mdbx.h++:5603
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++:5407
@ MDBX_REVERSEKEY
Definition: mdbx.h:1422
@ lazy_weak_tail
Definition: mdbx.h++:2998
slice & assign(const ::std::basic_string< CHAR, T, ALLOCATOR > &str)
Definition: mdbx.h++:634
value_result try_insert_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:5312
@ MDBX_GET_CURRENT
Definition: mdbx.h:1558
move_result to_current_prev_multi(bool throw_notfound=true)
Definition: mdbx.h++:5630
MDBX_CXX11_CONSTEXPR txn() noexcept=default
void safe_remove_suffix(size_t n)
Drops the last "n" bytes from this slice.
Definition: mdbx.h++:4436
fatal(fatal &&src) noexcept
Definition: mdbx.h++:449
@ previous
Definition: mdbx.h++:3852
uint32_t MDBX_dbi
A handle for an individual database (key-value spaces) in the environment.
Definition: mdbx.h:715
MDBX_CXX14_CONSTEXPR size_t operator()(::mdbx::slice const &slice) const noexcept
Definition: mdbx.h++:5967
Base64 decoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1400
MDBX_CXX11_CONSTEXPR bool is_result_false() const noexcept
Definition: mdbx.h++:4168
slice & operator=(const ::std::basic_string_view< CHAR, T > &view)
Definition: mdbx.h++:659
@ continue_loop
Definition: mdbx.h++:2743
buffer & assign(const buffer &src, bool make_reference=false)
Definition: mdbx.h++:2272
MDBX_env * handle_
Definition: mdbx.h++:2889
#define MDBX_CXX17_CONSTEXPR
Definition: mdbx.h++:130
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR size_t length() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:2082
MDBX_CXX11_CONSTEXPR operate_options() noexcept
Definition: mdbx.h++:3027
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++:4742
void remove_suffix(size_t n) noexcept
Drops the last "n" bytes from the data chunk.
Definition: mdbx.h++:2429
MDBX_CXX11_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++:1161
inline ::std::ostream & operator<<(::std::ostream &out, const to_hex &wrapper)
Definition: mdbx.h++:1293
fatal(const exception &src) noexcept
Definition: mdbx.h++:446
MDBX_error_t
Errors and return codes.
Definition: mdbx.h:1645
@ MDBX_APPENDDUP
Definition: mdbx.h:1506
MDBX_error_t put(const slice &key, slice *value, MDBX_put_flags_t flags) noexcept
Definition: mdbx.h++:5751
MDBX_CXX14_CONSTEXPR slice tail(size_t n) const noexcept
Returns the last "n" bytes of the slice.
Definition: mdbx.h++:4478
MDBX_NOTHROW_CONST_FUNCTION 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...
MDBX_CXX11_CONSTEXPR byte at(size_t n) const
Returns the nth byte in the referenced data with bounds checking.
Definition: mdbx.h++:4467
intptr_t pagesize
The database page size for new database creation or default_value otherwise.
Definition: mdbx.h++:2968
static constexpr bool is_moveable(T *, T &) noexcept
Definition: mdbx.h++:1007
buffer & assign_reference(const void *ptr, size_t bytes)
Definition: mdbx.h++:2248
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.
void reserve_headroom(size_t wanna_headroom)
Reserves space before the payload.
Definition: mdbx.h++:2243
@ write_file_io
Definition: mdbx.h++:2990
static MDBX_CXX20_CONSTEXPR void propagate(T *target, T &source) noexcept(is_nothrow())
Definition: mdbx.h++:1058
@ robust_synchronous
Definition: mdbx.h++:2996
MDBX_CXX11_CONSTEXPR ::mdbx::value_mode value_mode() const noexcept
Definition: mdbx.h++:4659
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++:5453
bool erase(bool whole_multivalue=false)
Removes single key-value pair or all multi-values at the current cursor position.
Definition: mdbx.h++:5852
MDBX_CXX11_CONSTEXPR byte operator[](size_t n) const noexcept
Accesses the specified byte of data chunk.
Definition: mdbx.h++:2441
MDBX_CXX20_CONSTEXPR ::std::basic_string< CHAR, T, A > as_string(const A &allocator=A()) const
Definition: mdbx.h++:2392
LIBMDBX_API int mdbx_env_set_flags(MDBX_env *env, MDBX_env_flags_t flags, bool onoff)
Set environment flags.
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++:4574
MDBX_db_flags_t
Database flags.
Definition: mdbx.h:1417
MDBX_CXX14_CONSTEXPR slice head(size_t n) const noexcept
Returns the first "n" bytes of the slice.
Definition: mdbx.h++:4473
LIBMDBX_API int mdbx_cursor_count(const MDBX_cursor *cursor, size_t *pcount)
Return count of duplicates for current key.
bool try_update(map_handle map, const slice &key, const slice &value)
Definition: mdbx.h++:5346
#define MDBX_STD_FILESYSTEM_PATH
Definition: mdbx.h++:329
#define __ORDER_BIG_ENDIAN__
Definition: mdbx.h++:98
const MDBX_CXX11_CONSTEXPR void * end() const noexcept
Return a pointer to the ending of the referenced data.
Definition: mdbx.h++:4376
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API size_t mdbx_default_pagesize(void)
Returns the default size of database page for the current system.
size_t value_min(value_mode mode) const noexcept
Returns the minimal value size in bytes for specified values mode.
Definition: mdbx.h++:3159
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:3060
MDBX_CXX20_CONSTEXPR bin(size_t capacity_bytes=0) noexcept
Definition: mdbx.h++:1611
MDBX_CXX14_CONSTEXPR byte at(size_t n) const
Accesses the specified byte of data chunk with bounds checking.
Definition: mdbx.h++:2455
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)
MDBX_txn_flags_t
Definition: mdbx.h:1371
@ MDBX_FIRST_LMDB_ERRCODE
Definition: mdbx.h:1659
slice update_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:5360
MDBX_env_flags_t get_flags() const
Returns environment flags.
Definition: mdbx.h++:4864
MDBX_NOTHROW_PURE_FUNCTION 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.
Information about the transaction.
Definition: mdbx.h:3295
bool on_last() const
Definition: mdbx.h++:5713
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++:5148
MDBX_CXX11_CONSTEXPR char * end_char_ptr() noexcept
Returns casted to pointer to char an end of data.
Definition: mdbx.h++:2051
key_mode
Kinds of the keys and corresponding modes of comparing it.
Definition: mdbx.h++:2746
@ first
Definition: mdbx.h++:3849
Transfers C++ exceptions thru C callbacks.
Definition: mdbx.h++:348
buffer(const void *ptr, size_t bytes, bool make_reference, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2126
MDBX_CXX20_CONSTEXPR buffer(const ::std::basic_string< CHAR, T, A > &str, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2164
buffer & append_producer(const PRODUCER &producer)
Definition: mdbx.h++:2536
uint64_t transaction_id
Definition: mdbx.h++:3361
void close_map(const map_handle &)
Close a key-value map (aka sub-database) handle. Normally unnecessary.
Definition: mdbx.h++:4930
string to_string(const ::mdbx::slice &value)
Definition: mdbx.h++:5881
void capture() noexcept
Definition: mdbx.h++:4132
buffer & append_decoded_base58(const struct slice &data, bool ignore_spaces=false)
Definition: mdbx.h++:2561
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:3015
#define MDBX_CONSTEXPR_ASSERT(expr)
Definition: mdbx.h++:149
static MDBX_CXX20_CONSTEXPR size_t advise_capacity(const size_t current, const size_t wanna)
Definition: mdbx.h++:1664
MDBX_CXX20_CONSTEXPR bin(bin &&ditto) noexcept
Definition: mdbx.h++:1626
MDBX_NOTHROW_CONST_FUNCTION LIBMDBX_API uint64_t mdbx_key_from_double(const double ieee754_64bit)
static buffer wrap(const POD &pod, bool make_reference=false, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2222
const MDBX_CXX11_CONSTEXPR char * char_ptr() const noexcept
Returns casted to pointer to char an address of data.
Definition: mdbx.h++:4356
bool eof() const
Definition: mdbx.h++:5705
buffer & assign_freestanding(const void *ptr, size_t bytes)
Definition: mdbx.h++:2254
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool ends_with(const slice &suffix) const noexcept
Checks if the data ends with the given suffix.
Definition: mdbx.h++:4448
static buffer key_from(const ::std::basic_string< CHAR, T, A > &src, bool make_reference=false)
Definition: mdbx.h++:2592
MDBX_CXX11_CONSTEXPR size_t size() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:4406
LIBMDBX_API int mdbx_txn_info(const MDBX_txn *txn, MDBX_txn_info *info, bool scan_rlt)
Return information about the MDBX transaction.
buffer & append_decoded_hex(const struct slice &data, bool ignore_spaces=false)
Definition: mdbx.h++:2556
@ MDBX_EINVAL
Definition: mdbx.h:1794
#define true
Definition: mdbx.h:382
MDBX_put_flags_t
Data changing flags.
Definition: mdbx.h:1472
MDBX_CXX11_CONSTEXPR from_base64(const slice &source, bool ignore_spaces=false) noexcept
Definition: mdbx.h++:1403
@ MDBX_FIRST
Definition: mdbx.h:1545
MDBX_CXX11_CONSTEXPR size_t length() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:4386
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_CONSTEXPR size_t headroom() const noexcept
Returns the number of bytes that available in currently allocated storage ahead the currently beginni...
Definition: mdbx.h++:1993
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:2567
txn_managed try_start_write()
Tries to start write (read-write) transaction without blocking.
Definition: mdbx.h++:5007
bool is_dirty(const void *ptr) const
Checks whether the given data is on a dirty page.
Definition: mdbx.h++:5045
MDBX_CXX11_CONSTEXPR size(intptr_t bytes) noexcept
Definition: mdbx.h++:2932
move_result to_previous_last_multi(bool throw_notfound=true)
Definition: mdbx.h++:5622
operator::mdbx::txn() const
Definition: mdbx.h++:3945
#define LIBMDBX_API_TYPE
Definition: mdbx.h:603
Implements error information and throwing corresponding exceptions.
Definition: mdbx.h++:363
size_t dbsize_min() const
Returns the minimal database size in bytes for the environment.
Definition: mdbx.h++:3151
::std::allocator_traits< allocator_type > allocator_traits
Definition: mdbx.h++:1456
slice & assign(const void *ptr, size_t bytes)
Definition: mdbx.h++:4289
size_t dbsize_max() const
Returns the maximal database size in bytes for the environment.
Definition: mdbx.h++:3153
txn_managed start_read() const
Starts read (read-only) transaction.
Definition: mdbx.h++:4983
void reserve_tailroom(size_t wanna_tailroom)
Reserves space after the payload.
Definition: mdbx.h++:2246
MDBX_CXX11_CONSTEXPR to_base64(const slice &source, unsigned wrap_width=0) noexcept
Definition: mdbx.h++:1245
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++:4616
value_result try_insert(map_handle map, const slice &key, slice value)
Definition: mdbx.h++:5288
MDBX_txn_flags_t flags() const
Returns transaction's flags.
Definition: mdbx.h++:5059
MDBX_NOTHROW_PURE_FUNCTION 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.
intptr_t bytes
Definition: mdbx.h++:2931
const MDBX_CXX11_CONSTEXPR void * end() const noexcept
Return a const pointer to the end of the referenced data.
Definition: mdbx.h++:2062
@ MDBX_NOOVERWRITE
Definition: mdbx.h:1477
mdbx_pid_t pid
The reader process ID.
Definition: mdbx.h++:3359
MDBX_CXX14_CONSTEXPR slice safe_head(size_t n) const
Returns the first "n" bytes of the slice.
Definition: mdbx.h++:4488
@ MDBX_MIN_PAGESIZE
Definition: mdbx.h:771
static constexpr bool is_nothrow() noexcept
Definition: mdbx.h++:1003
#define MDBX_CXX11_CONSTEXPR
Definition: mdbx.h:416
move_result to_current_next_multi(bool throw_notfound=true)
Definition: mdbx.h++:5638
void make_freestanding()
Makes buffer owning the data.
Definition: mdbx.h++:2106
static constexpr bool is_nothrow() noexcept
Definition: mdbx.h++:1055
Hexadecimal encoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1135
MDBX_CXX11_CONSTEXPR bool operator==(const error &a, const error &b) noexcept
Definition: mdbx.h++:4152
allocator_pointer ptr_
Definition: mdbx.h++:1521
LIBMDBX_API int mdbx_canary_get(const MDBX_txn *txn, MDBX_canary *canary)
Returns fours integers markers (aka "canary") associated with the environment.
buffer & append(const struct slice &chunk)
Definition: mdbx.h++:2510
LIBMDBX_API int mdbx_cursor_put(MDBX_cursor *cursor, const MDBX_val *key, MDBX_val *data, MDBX_put_flags_t flags)
Store by cursor.
Base58 encoder which satisfy SliceTranscoder concept.
Definition: mdbx.h++:1186
void reserve(size_t wanna_headroom, size_t wanna_tailroom)
Reserves storage space.
Definition: mdbx.h++:2228
Definition: mdbx.h++:1095
slice insert_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:5303
@ find_key
Definition: mdbx.h++:3865
map_handle::state state
Definition: mdbx.h++:2850
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++:4588
size_t get_pagesize() const
Returns pagesize of this MDBX environment.
Definition: mdbx.h++:3228
constexpr bool allocator_is_always_equal() noexcept
Definition: mdbx.h++:973
void throw_exception() const
size_t count_multivalue() const
Return count of duplicates for current key.
Definition: mdbx.h++:5699
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned string.
Definition: mdbx.h++:1317
MDBX_NOTHROW_CONST_FUNCTION 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...
const MDBX_CXX11_CONSTEXPR void * data() const noexcept
Return a pointer to the beginning of the referenced data.
Definition: mdbx.h++:4372
void safe_remove_prefix(size_t n)
Drops the first "n" bytes from this slice.
Definition: mdbx.h++:4425
@ MDBX_PREV
Definition: mdbx.h:1586
cursor_managed open_cursor(map_handle map)
Opens cursor for specified key-value map handle.
Definition: mdbx.h++:5085
slice & operator=(const slice &) noexcept=default
const MDBX_CXX11_CONSTEXPR byte * end_byte_ptr() const noexcept
Returns casted to pointer to byte an end of data.
Definition: mdbx.h++:4344
bool try_update(const slice &key, const slice &value)
Definition: mdbx.h++:5817
LIBMDBX_API int mdbx_get(MDBX_txn *txn, MDBX_dbi dbi, const MDBX_val *key, MDBX_val *data)
Get items from a database.
void bind(::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++:5734
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API int mdbx_txn_flags(const MDBX_txn *txn)
Return the transaction's flags.
void rethrow_captured() const
Definition: mdbx.h++:4137
static buffer key_from_jsonInteger(const int64_t json_integer)
Definition: mdbx.h++:2617
Combines pair of slices for key and value to represent result of certain operations.
Definition: mdbx.h++:2713
uint64_t sequence(map_handle map) const
Definition: mdbx.h++:5172
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.
slice upsert_reserve(map_handle map, const slice &key, size_t value_length)
Definition: mdbx.h++:5333
Managed database transaction.
Definition: mdbx.h++:3789
static MDBX_CXX14_CONSTEXPR slice wrap(const POD &pod)
Definition: mdbx.h++:620
MDBX_CXX11_CONSTEXPR bool operator!=(const error &a, const error &b) noexcept
Definition: mdbx.h++:4156
move_result to_next_first_multi(bool throw_notfound=true)
Definition: mdbx.h++:5646
static MDBX_CXX20_CONSTEXPR bool is_moveable(T *target, T &source) noexcept
Definition: mdbx.h++:991
env::mode get_mode() const
Returns current operation mode.
Definition: mdbx.h++:4818
MDBX_NOTHROW_PURE_FUNCTION bool is_base58(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a Base58 dump.
Definition: mdbx.h++:4627
static buffer key_from(const uint32_t unsigned_int32)
Definition: mdbx.h++:2629
unsigned max_maps() const
Returns the maximum number of named databases for the environment.
Definition: mdbx.h++:4876
static buffer key_from(const float ieee754_32bit)
Definition: mdbx.h++:2621
@ next
Definition: mdbx.h++:3851
buffer(size_t head_room, const buffer &src, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2203
void remove_prefix(size_t n) noexcept
Drops the first "n" bytes from the data chunk.
Definition: mdbx.h++:2425
@ MDBX_TXN_READWRITE
Definition: mdbx.h:1376
~env() noexcept
Definition: mdbx.h++:4678
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_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++:2000
@ MDBX_TXN_RDONLY
Definition: mdbx.h:1382
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_CONSTEXPR bool empty() const noexcept
Checks whether the string is empty.
Definition: mdbx.h++:2366
MDBX_CXX20_CONSTEXPR buffer(const ::std::basic_string_view< CHAR, T > &view, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2176
const MDBX_CXX11_CONSTEXPR void * data() const noexcept
Return a const pointer to the beginning of the referenced data.
Definition: mdbx.h++:2057
@ MDBX_REVERSEDUP
Definition: mdbx.h:1444
MDBX_CXX17_CONSTEXPR byte & lastbyte() noexcept
Definition: mdbx.h++:1565
size_t key_min(key_mode mode) const noexcept
Returns the minimal key size in bytes for specified keys mode.
Definition: mdbx.h++:3155
@ MDBX_SET
Definition: mdbx.h:1595
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++:5108
MDBX_NOTHROW_PURE_FUNCTION LIBMDBX_API MDBX_txn * mdbx_cursor_txn(const MDBX_cursor *cursor)
Return the cursor's transaction handle.
@ half_synchronous_weak_last
Definition: mdbx.h++:2997
constexpr bool is_inplace() const noexcept
Definition: mdbx.h++:1569
MDBX_CXX11_CONSTEXPR bool is_failure() const noexcept
Definition: mdbx.h++:4172
#define MDBX_UNLIKELY(cond)
Definition: mdbx.h++:167
MDBX_CXX14_CONSTEXPR buffer & set_length(size_t bytes)
Set length of data.
Definition: mdbx.h++:2090
MDBX_CXX11_CONSTEXPR from_base58(const slice &source, bool ignore_spaces=false) noexcept
Definition: mdbx.h++:1354
~cursor() noexcept
Definition: mdbx.h++:5525
struct MDBX_txn MDBX_txn
Opaque structure for a transaction handle.
Definition: mdbx.h:703
inline ::mdbx::txn txn() const
Returns the cursor's transaction.
Definition: mdbx.h++:5738
static buffer key_from(const uint64_t unsigned_int64)
Definition: mdbx.h++:2609
MDBX_CXX20_CONSTEXPR buffer() noexcept=default
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.
geometry & make_dynamic(intptr_t lower=minimal_value, intptr_t upper=maximal_value) noexcept
Definition: mdbx.h++:4706
canary get_canary() const
Returns fours integers markers (aka "canary") associated with the environment.
Definition: mdbx.h++:5166
const MDBX_CXX11_CONSTEXPR version_info & get_version() noexcept
Returns libmdbx version information.
Definition: mdbx.h++:4060
buffer< ALLOCATOR, CAPACITY_POLICY > as_buffer(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes hexadecimal dump from a passed slice to returned buffer.
Definition: mdbx.h++:1325
static void success_or_throw(int error_code)
Definition: mdbx.h++:409
void swap(slice &other) noexcept
Definition: mdbx.h++:4334
MDBX_CXX17_CONSTEXPR bin & operator=(const bin &ditto) noexcept
Definition: mdbx.h++:1639
move_result current(bool throw_notfound=true) const
Definition: mdbx.h++:5634
MDBX_CXX20_CONSTEXPR buffer(const void *ptr, size_t bytes, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2158
@ MDBX_RESULT_FALSE
Definition: mdbx.h:1650
MDBX_CXX11_CONSTEXPR from_hex(const slice &source, bool ignore_spaces=false) noexcept
Definition: mdbx.h++:1309
env & alter_flags(MDBX_env_flags_t flags, bool on_off)
Alter environment flags.
Definition: mdbx.h++:4905
intptr_t size_lower
The lower bound of database size in bytes.
Definition: mdbx.h++:2937
env::durability get_durability() const
Returns current durability mode.
Definition: mdbx.h++:4822
@ MDBX_TXN_RDONLY_PREPARE
Definition: mdbx.h:1391
MDBX_CXX11_CONSTEXPR error(MDBX_error_t error_code) noexcept
Definition: mdbx.h++:4144
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool operator<(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:4535
MDBX_CXX11_CONSTEXPR operate_parameters() noexcept
Definition: mdbx.h++:3048
void success_or_panic(const char *context_where, const char *func_who) const noexcept
Definition: mdbx.h++:4214
MDBX_STD_FILESYSTEM_PATH path
Definition: mdbx.h++:337
LIBMDBX_API int mdbx_dbi_sequence(MDBX_txn *txn, MDBX_dbi dbi, uint64_t *result, uint64_t increment)
Sequence generation for a database.
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++:4772
MDBX_CXX11_CONSTEXPR bool is_null() const noexcept
Checks whether the data pointer of the buffer is nullptr.
Definition: mdbx.h++:2371
@ MDBX_APPEND
Definition: mdbx.h:1501
LIBMDBX_API int mdbx_dbi_close(MDBX_env *env, MDBX_dbi dbi)
Close a database handle. Normally unnecessary.
Definition: mdbx.h++:1052
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_CONSTEXPR size_t capacity() const noexcept
Returns the number of bytes that can be held in currently allocated storage.
Definition: mdbx.h++:1986
intptr_t size_now
The size in bytes to setup the database size for now.
Definition: mdbx.h++:2942
@ MDBX_CURRENT
Definition: mdbx.h:1488
void drop_map(map_handle map)
Drops key-value map using handle.
Definition: mdbx.h++:5126
void success_or_throw() const
Definition: mdbx.h++:4195
buffer< ALLOCATOR, CAPACITY_POLICY > make_buffer(PRODUCER &producer, const ALLOCATOR &allocator=ALLOCATOR())
Definition: mdbx.h++:2641
@ MDBX_NEXT_NODUP
Definition: mdbx.h:1583
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Returns a string with a hexadecimal dump of a passed slice.
Definition: mdbx.h++:1147
LIBMDBX_API int mdbx_env_get_fd(const MDBX_env *env, mdbx_filehandle_t *fd)
Return the file descriptor for the given environment.
Database geometry for size management.
Definition: mdbx.h++:2910
buffer & operator=(struct slice &&src)
Definition: mdbx.h++:2343
void reset_reading()
Reset a read-only transaction.
Definition: mdbx.h++:5071
::std::ostream & output(::std::ostream &out) const
Output Base64 dump of passed slice to the std::ostream.
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.
env::operate_options get_options() const
Returns current operate options.
Definition: mdbx.h++:4830
static MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR intptr_t compare_lexicographically(const slice &a, const slice &b) noexcept
Three-way lexicographically comparison.
Definition: mdbx.h++:4518
LIBMDBX_API int mdbx_txn_reset(MDBX_txn *txn)
Reset a read-only transaction.
slice & assign(const ::std::basic_string_view< CHAR, T > &view)
Definition: mdbx.h++:641
MDBX_CXX11_CONSTEXPR slice(size_t invalid_length) noexcept
Definition: mdbx.h++:965
static MDBX_CXX20_CONSTEXPR void propagate(T *target, const T &source) noexcept(is_nothrow())
Definition: mdbx.h++:1035
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 ...
MDBX_NOTHROW_PURE_FUNCTION bool is_base64(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a Base64 dump.
Definition: mdbx.h++:4632
References a data located outside the slice.
Definition: mdbx.h++:564
Definition: mdbx.h++:1017
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...
cursor_managed & operator=(cursor_managed &&other)
Definition: mdbx.h++:4002
@ MDBX_INTEGERDUP
Definition: mdbx.h:1441
Additional parameters for creating a new database.
Definition: mdbx.h++:3464
LIBMDBX_API int mdbx_dbi_dupsort_depthmask(MDBX_txn *txn, MDBX_dbi dbi, uint32_t *mask)
Retrieve depth (bitmask) information of nested dupsort (multi-value) B+trees for given database.
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX20_CONSTEXPR size_t size() const noexcept
Returns the number of bytes.
Definition: mdbx.h++:2376
@ MDBX_GET_BOTH_RANGE
Definition: mdbx.h:1555
void upsert(const slice &key, const slice &value)
Definition: mdbx.h++:5800
const MDBX_CXX11_CONSTEXPR byte * byte_ptr() const noexcept
Returns casted to const pointer to byte an address of data.
Definition: mdbx.h++:2005
@ MDBX_RESULT_TRUE
Definition: mdbx.h:1653
pid_t mdbx_pid_t
Definition: mdbx.h:197
buffer & operator=(const struct slice &src)
Definition: mdbx.h++:2341
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++:3168
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++:4802
#define MDBX_CXX20_UNLIKELY
Definition: mdbx.h++:198
string< ALLOCATOR > as_string(const ALLOCATOR &allocator=ALLOCATOR()) const
Decodes Base64 dump from a passed slice to returned string.
Definition: mdbx.h++:1412
slice & assign(::std::basic_string_view< CHAR, T > &&view)
Definition: mdbx.h++:645
@ MDBX_KEYEXIST
Definition: mdbx.h:1656
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR size_t hash_value() const noexcept
Returns the hash value of referenced data.
Definition: mdbx.h++:4455
size_t size_max() const
Returns maximal write transaction size (i.e. limit for summary volume of dirty pages) in bytes.
Definition: mdbx.h++:3565
@ MDBX_ALLDUPS
Definition: mdbx.h:1493
#define MDBX_IF_CONSTEXPR
Definition: mdbx.h++:176
cursor & operator=(cursor &&other) noexcept
Definition: mdbx.h++:5515
buffer & append_hex(const struct slice &data, bool uppercase=false, unsigned wrap_width=0)
Definition: mdbx.h++:2543
static buffer clone(const buffer &src, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2267
LIBMDBX_API MDBX_cursor * mdbx_cursor_create(void *context)
Create a cursor handle but not bind it to transaction nor DBI handle.
bool done
Definition: mdbx.h++:2728
static constexpr byte inplace_lastbyte_mask() noexcept
Definition: mdbx.h++:1555
@ upsert
Insert or update.
Definition: mdbx.h++:2873
const MDBX_CXX11_CONSTEXPR char * end_char_ptr() const noexcept
Returns casted to pointer to char an end of data.
Definition: mdbx.h++:4360
MDBX_CXX14_CONSTEXPR void invalidate() noexcept
Depletes content of slice and make it invalid.
Definition: mdbx.h++:4412
@ MDBX_NEXT_DUP
Definition: mdbx.h:1575
@ MDBX_LAST_DUP
Definition: mdbx.h:1569
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++:5092
cursor_managed()
Creates a new managed cursor with underlying object.
Definition: mdbx.h++:3993
size_t capacity_bytes_
Definition: mdbx.h++:1522
@ MDBX_PREV_DUP
Definition: mdbx.h:1589
The libmdbx C API header file.
struct iovec MDBX_val
Generic structure used for passing keys and data in and out of the database.
Definition: mdbx.h:760
MDBX_CXX14_CONSTEXPR slice & set_length(size_t bytes)
Set slice length.
Definition: mdbx.h++:4388
::std::string::allocator_type legacy_allocator
Legacy default allocator but it is recommended to use polymorphic_allocator.
Definition: mdbx.h++:296
constexpr bool is_allocated() const noexcept
Definition: mdbx.h++:1572
LIBMDBX_API void throw_max_length_exceeded()
@ MDBX_FIRST_ADDED_ERRCODE
Definition: mdbx.h:1745
@ MDBX_BUSY
Definition: mdbx.h:1742
MDBX_NOTHROW_PURE_FUNCTION 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.
static buffer key_from(const double *ieee754_64bit)
Definition: mdbx.h++:2605
@ MDBX_FIRST_DUP
Definition: mdbx.h:1548
mode_t mdbx_mode_t
Definition: mdbx.h:199
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++:4602
move_result to_first(bool throw_notfound=true)
Definition: mdbx.h++:5614
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++:4561
LIBMDBX_API int mdbx_cursor_renew(MDBX_txn *txn, MDBX_cursor *cursor)
Renew a cursor handle.
const slice source
Definition: mdbx.h++:1242
@ MDBX_LAST_LMDB_ERRCODE
Definition: mdbx.h:1738
map_handle map() const
Definition: mdbx.h++:5744
LIBMDBX_API int mdbx_cursor_del(MDBX_cursor *cursor, MDBX_put_flags_t flags)
Delete current key/data pair.
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++:4595
move_result to_last(bool throw_notfound=true)
Definition: mdbx.h++:5654
const slice source
Definition: mdbx.h++:1136
MDBX_CXX14_CONSTEXPR slice safe_middle(size_t from, size_t n) const
Returns the middle "n" bytes of the slice.
Definition: mdbx.h++:4500
@ multi_prevkey_lastvalue
Definition: mdbx.h++:3855
static MDBX_CXX20_CONSTEXPR void propagate(T *target, const T &source) noexcept
Definition: mdbx.h++:1021
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++:1236
MDBX_NOTHROW_PURE_FUNCTION bool is_hex(bool ignore_spaces=false) const noexcept
Checks whether the content of the slice is a hexadecimal dump.
Definition: mdbx.h++:4622
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool operator<=(const slice &a, const slice &b) noexcept
Definition: mdbx.h++:4545
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++:4974
value_result try_insert_reserve(const slice &key, size_t value_length)
Definition: mdbx.h++:5784
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++:1155
void upsert(map_handle map, const slice &key, const slice &value)
Definition: mdbx.h++:5328
@ MDBX_INTEGERKEY
Definition: mdbx.h:1432
buffer & add_header(const struct slice &chunk)
Definition: mdbx.h++:2523
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++:1207
move_result find(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:5663
MDBX_CXX11_CONSTEXPR slice() noexcept
Create an empty slice.
Definition: mdbx.h++:4266
move_result lower_bound_multivalue(const slice &key, const slice &value, bool throw_notfound=false)
Definition: mdbx.h++:5684
@ MDBX_GET_BOTH
Definition: mdbx.h:1551
buffer(size_t head_room, const struct slice &src, size_t tail_room, const allocator_type &allocator=allocator_type())
Definition: mdbx.h++:2194
LIBMDBX_VERINFO_API const struct MDBX_version_info mdbx_version
libmdbx version information
#define MDBX_CXX20_CONSTEXPR
Definition: mdbx.h++:139
@ MDBX_DUPSORT
Definition: mdbx.h:1425
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++:1181
static size_t pagesize_min() noexcept
Returns the minimal database page size in bytes.
Definition: mdbx.h++:4724
mode
Operation mode.
Definition: mdbx.h++:2988
MDBX_CXX11_CONSTEXPR byte * end_byte_ptr() noexcept
Returns casted to pointer to byte an end of data.
Definition: mdbx.h++:2025
ptrdiff_t estimate_from_first(map_handle map, slice to) const
Definition: mdbx.h++:5497
move_result lower_bound(const slice &key, bool throw_notfound=true)
Definition: mdbx.h++:5667
The fours integers markers (aka "canary") associated with the environment.
Definition: mdbx.h:3581
env::reclaiming_options reclaiming
Definition: mdbx.h++:3045
bool is_empty() const noexcept
Checks whether a passed slice is empty, and therefore there will be no output bytes.
Definition: mdbx.h++:1342
static MDBX_CXX20_CONSTEXPR void propagate(T *target, T &source) noexcept(is_nothrow())
Definition: mdbx.h++:1080
Combines data slice with boolean flag to represent result of certain operations.
Definition: mdbx.h++:2698
void * get_context() const noexcept
Returns the application context associated with the environment.
Definition: mdbx.h++:4882
buffer & assign(::MDBX_val &&src, bool make_reference=false)
Definition: mdbx.h++:2295
MDBX_CXX14_CONSTEXPR slice middle(size_t from, size_t n) const noexcept
Returns the middle "n" bytes of the slice.
Definition: mdbx.h++:4483
MDBX_CXX11_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++:1331
LIBMDBX_API void throw_out_range()
Definition: mdbx.h++:3870
MDBX_NOTHROW_PURE_FUNCTION 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...
static size_t default_pagesize() noexcept
Returns default page size for current system/platform.
Definition: mdbx.h++:3094
MDBX_CXX14_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++:605
MDBX_CXX14_CONSTEXPR buffer & set_end(const void *ptr)
Sets the length by specifying the end of the data.
Definition: mdbx.h++:2098
env::operate_parameters get_operation_parameters() const
Returns current operation parameters.
Definition: mdbx.h++:4809
MDBX_log_level_t
Definition: mdbx.h:797
@ exit_loop
Definition: mdbx.h++:2743
Managed database environment.
Definition: mdbx.h++:3442
slice & operator=(::std::basic_string_view< CHAR, T > &&view)
Definition: mdbx.h++:664
env::geometry geometry
Definition: mdbx.h++:3465
bool is_erroneous() const noexcept
Checks whether the content of a passed slice is a valid Base64 dump, and therefore there could be dec...
MDBX_NOTHROW_CONST_FUNCTION 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.
@ MDBX_CREATE
Definition: mdbx.h:1447
MDBX_CXX11_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++:671
struct MDBX_cursor MDBX_cursor
Opaque structure for navigating through a database.
Definition: mdbx.h:722
const MDBX_CXX11_CONSTEXPR byte * end_byte_ptr() const noexcept
Returns casted to const pointer to byte an end of data.
Definition: mdbx.h++:2010
move_operation
Definition: mdbx.h++:3848
@ last
Definition: mdbx.h++:3850
static buffer key_from(const double ieee754_64bit)
Definition: mdbx.h++:2601
LIBMDBX_API int mdbx_estimate_range(MDBX_txn *txn, MDBX_dbi dbi, MDBX_val *begin_key, MDBX_val *begin_data, MDBX_val *end_key, MDBX_val *end_data, ptrdiff_t *distance_items)
Estimates the size of a range as a number of elements.
MDBX_CXX20_CONSTEXPR allocator_type get_allocator() const
Returns the associated allocator.
Definition: mdbx.h++:1964
value_result(const slice &value, bool done) noexcept
Definition: mdbx.h++:2701