Skip to content

Class mdbx::buffer

template <class ALLOCATOR, typename CAPACITY_POLICY>

ClassList > mdbx > buffer

The chunk of data stored inside the buffer or located outside it. More...

  • #include <mdbx.h++>

Inherits the following classes: mdbx::slice, mdbx::buffer_tag

Public Types

Type Name
enum size_t @314256227132342347124375117343310276307137366216
typedef ::std::allocator_traits< allocator_type > allocator_traits
The allocator_type traits.
typedef typename ::std::allocator_traits< ALLOCATOR >::template rebind_alloc< uint64_t > allocator_type
The allocator type rebound for the internal storage.
typedef typename silo::copy_assign_alloc copy_assign_alloc
The copy-assignment allocator-propagation helper (internal use).
typedef slice inherited
The base slice class.
enum modality
Data storage modality.
typedef typename silo::move_assign_alloc move_assign_alloc
The move-assignment allocator-propagation helper (internal use).
typedef CAPACITY_POLICY reservation_policy
The capacity policy type, see default_capacity_policy .
typedef typename silo::swap_alloc swap_alloc
The swap allocator-propagation helper (internal use).

Public Types inherited from mdbx::slice

See mdbx::slice

Type Name
enum size_t @145120015325042373144130173373163042370340165246

Public Functions

Type Name
buffer & add_header (const void * src, size_t bytes)
Prepends a memory range to the beginning of the buffer (into the headroom).
buffer & add_header (const struct slice & chunk)
Prepends a slice to the beginning of the buffer (into the headroom).
buffer & append (const ::std::basic_string_view< CHAR, T > & view)
Appends a string view to the end of the buffer.
buffer & append (const ::std::basic_string< CHAR, T, A > & str)
Appends a string to the end of the buffer.
buffer & append (const void * src, size_t bytes)
Appends a memory range to the end of the buffer.
buffer & append (const byte c)
Appends a single byte to the end of the buffer.
buffer & append (const struct slice & chunk)
Appends a slice to the end of the buffer.
buffer & append_base58 (const struct slice & data, unsigned wrap_width=0)
Appends a Base58 dump of the given data to the buffer.
buffer & append_base64 (const struct slice & data, unsigned wrap_width=0)
Appends a Base64 dump of the given data to the buffer.
buffer & append_byte (uint_fast8_t byte)
Appends a single byte.
buffer & append_decoded_base58 (const struct slice & data, bool ignore_spaces=false)
Appends data decoded from a Base58 dump to the buffer.
buffer & append_decoded_base64 (const struct slice & data, bool ignore_spaces=false)
Appends data decoded from a Base64 dump to the buffer.
buffer & append_decoded_hex (const struct slice & data, bool ignore_spaces=false)
Appends data decoded from a hexadecimal dump to the buffer.
buffer & append_hex (const struct slice & data, bool uppercase=false, unsigned wrap_width=0)
Appends a hexadecimal dump of the given data to the buffer.
buffer & append_producer (PRODUCER & producer)
Appends the bytes produced by the given producer to the end of the buffer.
buffer & append_producer (const PRODUCER & producer)
Appends the bytes produced by the given immutable producer, see the overload above.
buffer & append_u16 (uint_fast16_t u16)
Appends a 16-bit value in little-endian order.
buffer & append_u24 (uint_fast32_t u24)
Appends a 24-bit value in little-endian order.
buffer & append_u32 (uint_fast32_t u32)
Appends a 32-bit value in little-endian order.
buffer & append_u48 (uint_fast64_t u48)
Appends a 48-bit value in little-endian order.
buffer & append_u64 (uint_fast64_t u64)
Appends a 64-bit value in little-endian order.
buffer & append_u8 (uint_fast8_t u8)
Appends an 8-bit value in little-endian order.
buffer & assign (size_t headroom, const buffer & src, size_t tailroom)
Assigns a copy of the source buffer with the given headroom/tailroom.
buffer & assign (const buffer & src, bool make_reference=false)
Assigns from another buffer, either copying or referencing it.
buffer & assign (buffer && src)
Move-assigns from another buffer; the source is invalidated.
buffer & assign (const void * ptr, size_t bytes, bool make_reference=false)
Assigns the buffer from a memory range, either copying or referencing it.
buffer & assign (const char * ptr, INT bytes, bool make_reference=false)
Assigns the buffer from a char-pointer and an integral length.
buffer & assign (::std::nullptr_t, INT bytes, bool make_reference=false)
Assigns the buffer to a null pointer; only a zero length is accepted.
buffer & assign (const struct slice & src, bool make_reference=false)
Assigns the buffer from a slice, either copying or referencing it.
buffer & assign (const ::MDBX_val & src, bool make_reference=false)
Assigns the buffer from a MDBX_val , either copying or referencing it.
buffer & assign (struct slice && src, bool make_reference=false)
Move-assigns the buffer from a slice; the source is invalidated.
buffer & assign (::MDBX_val && src, bool make_reference=false)
Takes over a temporary MDBX_val instance.
buffer & assign (const void * begin, const void * end, bool make_reference=false)
Assigns the buffer from a [begin,end) memory range.
buffer & assign (const ::std::basic_string< CHAR, T, A > & str, bool make_reference=false)
Assigns the buffer from a string, either copying or referencing it.
buffer & assign (const char * c_str, bool make_reference=false)
Assigns the buffer from a null-terminated string.
buffer & assign_freestanding (const void * ptr, size_t bytes)
Assigns the buffer to own a copy of an external memory range.
buffer & assign_reference (const void * ptr, size_t bytes)
Assigns the buffer to reference an external memory range without copying.
buffer base58_decode (bool ignore_spaces=false, const allocator_type & alloc=allocator_type()) const
Decodes Base58 dump from the buffer content to new returned buffer.
buffer base64_decode (bool ignore_spaces=false, const allocator_type & alloc=allocator_type()) const
Decodes Base64 dump from the buffer content to new returned buffer.
constexpr buffer () noexcept
Constructs an empty buffer.
constexpr buffer (const allocator_type & alloc) noexcept
Constructs an empty buffer with the given allocator.
constexpr buffer (const void * ptr, size_t bytes, bool make_reference, const allocator_type & alloc=allocator_type())
Constructs a buffer from a memory range, either copying or referencing it.
buffer (const char * c_str, bool make_reference, const allocator_type & alloc=allocator_type())
Constructs a buffer from a null-terminated string, either copying or referencing it.
constexpr buffer (const ::std::basic_string_view< CHAR, T > & view, bool make_reference, const allocator_type & alloc=allocator_type())
Constructs a buffer from a string view, either copying or referencing it.
constexpr buffer (const struct slice & src, const allocator_type & alloc=allocator_type())
Constructs a buffer storing a copy of the given slice; empty or null slices are referenced instead of copied.
constexpr buffer (const buffer & src)
Copy constructor.
constexpr buffer (const void * ptr, size_t bytes, const allocator_type & alloc=allocator_type())
Constructs a buffer storing a copy of the given memory range.
constexpr buffer (const char * ptr, INT bytes, const allocator_type & alloc=allocator_type())
Copies bytes fromptr ; keeps an integer length away frombuffer(const char *, bool) .
constexpr buffer (::std::nullptr_t, INT bytes, const allocator_type & alloc=allocator_type())
Takes nullptr , so that a literal0 orNULL is ambiguous instead of a nullconst char * .
constexpr buffer (::std::nullptr_t, INT bytes, bool make_reference)
Null pointer with an explicit make_reference flag.
constexpr buffer (const ::std::basic_string< CHAR, T, A > & str, const allocator_type & alloc=allocator_type())
Creates a buffer that stores a copy of the string's content. The source string may be a temporary: the bytes are copied immediately, so there are no lifetime requirements (unlike mdbx::slice ).
constexpr buffer (const ::std::basic_string< CHAR, T, A > & str, bool make_reference, const allocator_type & alloc=allocator_type())
Creates a buffer that either stores a copy of the string's content (make_reference=false, the default choice) or just refers to it (make_reference=true, then the string must outlive the buffer — the same lifetime rules as for mdbx::slice ).
constexpr buffer (const char * c_str, const allocator_type & alloc=allocator_type())
Constructs a buffer storing a copy of a null-terminated string.
constexpr buffer (const ::std::basic_string_view< CHAR, T > & view, const allocator_type & alloc=allocator_type())
Constructs a buffer storing a copy of a string view.
buffer (size_t head_room, size_t tail_room, const allocator_type & alloc=allocator_type())
Constructs an empty buffer with the given headroom and tailroom.
buffer (size_t capacity, const allocator_type & alloc=allocator_type())
Constructs an empty buffer with the given capacity.
buffer (size_t head_room, const slice & src, size_t tail_room, const allocator_type & alloc=allocator_type())
Constructs a buffer storing a copy of the slice with reserved headroom/tailroom.
buffer (const txn & transaction, const slice & src, const allocator_type & alloc=allocator_type())
Constructs a buffer owning a copy of the slice when its data is dirty within the given transaction, otherwise a reference to it.
buffer (buffer && src)
Move constructor: the source buffer is invalidated.
const byte * byte_ptr () noexcept const
Returns casted to const pointer to byte an address of data.
byte * byte_ptr () noexcept
Returns casted to pointer to byte an address of data.
size_t capacity () noexcept const
Returns the number of bytes that can be held in currently allocated storage.
const char * char_ptr () noexcept const
Returns casted to const pointer to char an address of data.
char * char_ptr () noexcept
Returns casted to pointer to char an address of data.
void clear () noexcept
Clears the contents and storage.
void clear_and_reserve (size_t whole_capacity, size_t headroom=0)
Clears the contents and reserve storage.
const void * const_data () noexcept const
Return a const pointer to the beginning of the referenced data.
const void * const_end () noexcept const
Return a const pointer to the end of the referenced data.
modality content_modality () noexcept const
Returns current modality of buffer content.
const void * data () noexcept const
Return a const pointer to the beginning of the referenced data.
void * data () noexcept
Return a pointer to the beginning of the referenced data.
buffer encode_base58 (unsigned wrap_width=0, const allocator_type & alloc=allocator_type()) const
Returns a new buffer with a Base58 dump of the slice content.
buffer encode_base64 (unsigned wrap_width=0, const allocator_type & alloc=allocator_type()) const
Returns a new buffer with a Base64 dump of the slice content.
buffer encode_hex (bool uppercase=false, unsigned wrap_width=0, const allocator_type & alloc=allocator_type()) const
Returns a new buffer with a hexadecimal dump of the slice content.
const byte * end () noexcept const
Return a const pointer to the end of the referenced data.
byte * end () noexcept
Return a pointer to the end of the referenced data.
const byte * end_byte_ptr () noexcept const
Returns casted to const pointer to byte an end of data.
byte * end_byte_ptr () noexcept
Returns casted to pointer to byte an end of data.
const char * end_char_ptr () noexcept const
Returns casted to const pointer to char an end of data.
char * end_char_ptr () noexcept
Returns casted to pointer to char an end of data.
allocator_type get_allocator () const
Returns the associated allocator.
size_t headroom () noexcept const
Returns the number of bytes available in the currently allocated storage in front of the data.
buffer hex_decode (bool ignore_spaces=false, const allocator_type & alloc=allocator_type()) const
Decodes hexadecimal dump from the buffer content to new returned buffer.
bool is_freestanding () noexcept const
Checks whether data chunk stored inside the buffer, otherwise buffer just refers to data located outside the buffer.
bool is_inplace () noexcept const
Checks whether data chunk stored in place within the buffer instance itself, without reference outside nor allocating additional memory resources, which also implies buffer is freestanding.
bool is_reference () noexcept const
Checks whether the buffer just refers to data located outside the buffer, rather than stores it.
size_t length () noexcept const
Returns the number of bytes.
void make_freestanding ()
Makes buffer owning the data.
buffer make_inplace_or_reference () const
Makes a lightweight copy: inplace when this buffer is inplace, otherwise a reference to the same data.
constexpr basic_string () const
Converts the buffer content to a std::basic_string .
buffer & operator= (const buffer & src)
Copy assignment operator.
buffer & operator= (buffer && src)
Move assignment operator; the source is invalidated.
buffer & operator= (const struct slice & src)
Assigns from a slice, copying its content.
buffer & operator= (struct slice && src)
Move-assigns from a slice; the source is invalidated.
buffer & operator= (const ::std::basic_string_view< CHAR, T > & view)
Assigns from a string view, copying its content.
void reserve (size_t wanna_headroom, size_t wanna_tailroom)
Reserves storage space.
void reserve (size_t size)
Reserves storage space for at least size bytes of payload, without changing the current length. STL-compatible counterpart ofreserve(size_t, size_t) that keeps the headroom unchanged.
void reserve_headroom (size_t wanna_headroom)
Reserves space before the payload.
void reserve_tailroom (size_t wanna_tailroom)
Reserves space after the payload.
void resize (size_t size)
Resizes the buffer to contain size bytes, filling the added space with zeroes. STL-compatible counterpart ofset_length() .
void resize (size_t size, byte value)
Resizes the buffer to contain size bytes, filling the added space withvalue . STL-compatible counterpart ofset_length() .
buffer & set_end (const void * ptr)
Sets the length by specifying the end of the data.
buffer & set_length (size_t bytes)
Set length of data.
void shrink_to_fit ()
Reduces memory usage by freeing unused storage space.
const slice & slice () noexcept const
Returns the base slice view of this buffer.
void swap (buffer & other)
Swaps this buffer with another one.
size_t tailroom () noexcept const
Returns the number of bytes that available in currently allocated storage after the data.

Public Functions inherited from mdbx::slice

See mdbx::slice

Type Name
int128_t as_int128 () const
Reinterprets the slice as a 128-bit signed integer.
int128_t as_int128_adapt () const
Reinterprets the slice as a 128-bit signed integer, adapting the value when the slice is shorter than 16 bytes.
int16_t as_int16 () const
Reinterprets the slice as a 16-bit signed integer.
int16_t as_int16_adapt () const
Reinterprets the slice as a 16-bit signed integer, adapting the value when the slice is shorter than 2 bytes.
int32_t as_int32 () const
Reinterprets the slice as a 32-bit signed integer.
int32_t as_int32_adapt () const
Reinterprets the slice as a 32-bit signed integer, adapting the value when the slice is shorter than 4 bytes.
int64_t as_int64 () const
Reinterprets the slice as a 64-bit signed integer.
int64_t as_int64_adapt () const
Reinterprets the slice as a 64-bit signed integer, adapting the value when the slice is shorter than 8 bytes.
int8_t as_int8 () const
Reinterprets the slice as an 8-bit signed integer.
int8_t as_int8_adapt () const
Reinterprets the slice as an 8-bit signed integer.
POD as_pod () const
Reinterprets the slice content as an object of a standard-layout type.
::std::span< const POD > as_span () const
Returns a read-only std::span view of the referenced data.
::std::span< POD > as_span ()
Returns a mutable std::span view of the referenced data.
::std::basic_string< CHAR, T, ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
Copies the slice content into a std::basic_string .
uint128_t as_uint128 () const
Reinterprets the slice as a 128-bit unsigned integer.
uint128_t as_uint128_adapt () const
Reinterprets the slice as a 128-bit unsigned integer, adapting the value when the slice is shorter than 16 bytes.
uint16_t as_uint16 () const
Reinterprets the slice as a 16-bit unsigned integer.
uint16_t as_uint16_adapt () const
Reinterprets the slice as a 16-bit unsigned integer, adapting the value when the slice is shorter than 2 bytes.
uint32_t as_uint32 () const
Reinterprets the slice as a 32-bit unsigned integer.
uint32_t as_uint32_adapt () const
Reinterprets the slice as a 32-bit unsigned integer, adapting the value when the slice is shorter than 4 bytes.
uint64_t as_uint64 () const
Reinterprets the slice as a 64-bit unsigned integer.
uint64_t as_uint64_adapt () const
Reinterprets the slice as a 64-bit unsigned integer, adapting the value when the slice is shorter than 8 bytes.
uint8_t as_uint8 () const
Reinterprets the slice as an 8-bit unsigned integer.
uint8_t as_uint8_adapt () const
Reinterprets the slice as an 8-bit unsigned integer.
slice & assign (const ::std::basic_string< CHAR, T, ALLOCATOR > & str)
Assigns the slice to reference the contents of the given string.
slice & assign (const ::std::basic_string_view< CHAR, T > & view)
Assigns the slice to reference the contents of the given string view.
slice & assign (::std::basic_string_view< CHAR, T > && view)
Takes over a temporary string view and assigns the slice to its contents.
byte back () noexcept const
Returns the last byte of the referenced data.
::std::span< const byte > bytes () const
Returns a read-only std::span of bytes of the referenced data.
::std::span< byte > bytes ()
Returns a mutable std::span of bytes of the referenced data.
::std::span< const char > chars () const
Returns a read-only std::span of chars of the referenced data.
::std::span< char > chars ()
Returns a mutable std::span of chars of the referenced data.
intptr_t compare (const slice & other) noexcept const
Lexicographical three-way comparison with another slice.
bool contains (const slice & needle) noexcept const
Checks whether the referenced data contains needle as a sub-slice.
byte front () noexcept const
Returns the first byte of the referenced data.
bool is_printable (bool disable_utf8=false) noexcept const
Checks whether the content of the slice is printable.
bool is_valid () noexcept const
Checks the slice is valid: returns false only if it has a null data pointer and a non-zero length.
operator MDBX_val * () noexcept
Returns the pointer to the underlying MDBX_val instance.
operator const MDBX_val * () noexcept const
Returns the pointer to the underlying MDBX_val instance.
constexpr basic_string () const
Copies the slice content into a std::basic_string .
constexpr basic_string_view () noexcept const
Return a string_view that references the same data as this slice.
slice & operator= (const slice &) noexcept
Copy assignment operator.
slice & operator= (const ::std::basic_string_view< CHAR, T > & view)
Assigns the slice to reference the contents of the given string view.
slice & operator= (::std::basic_string_view< CHAR, T > && view)
Takes over a temporary string view and assigns the slice to its contents.
constexpr slice (const char(&) text)
Create a slice that refers to text[0,strlen(text)-1].
constexpr slice (const ::std::basic_string< CHAR, T, A > & str)
Create a slice that refers to the contents of "str".
constexpr slice (const slice & src) noexcept
Copy constructor.
constexpr slice (const ::std::span< POD > & span)
Create a slice that refers to the contents of the given std::span .
constexpr slice (const ::std::basic_string_view< CHAR, T > & sv)
Create a slice that refers to the same contents as "string_view".
slice (::std::basic_string_view< CHAR, T > && sv)
Takes over a temporary string view: the slice refers to its data and the moved-from view is emptied.
::std::basic_string_view< CHAR, T > string_view () noexcept const
Return a string_view that references the same data as this slice.
slice substr (size_t pos, size_t count=npos) const
Returns a sub-slice of [pos, pos+count) clamped to the end.
void swap (::std::basic_string_view< CHAR, T > & view) noexcept
Swaps the slice content with the given string view.
void swap (slice & other) noexcept
Swaps this slice with another one.
::std::optional< POD > try_as_pod () const
Non-throwing counterpart of as_pod() : returnsstd::nullopt when the slice length does not exactly matchsizeof(POD) .

Public Static Functions

Type Name
buffer base58 (const slice & source, unsigned wrap_width=0, const allocator_type & alloc=allocator_type())
Returns a new buffer with a Base58 dump of the slice content.
buffer base58 (const POD & pod, unsigned wrap_width=0, const allocator_type & alloc=allocator_type())
Returns a new buffer with a Base58 dump of the given pod.
buffer base58_decode (const slice & source, bool ignore_spaces=false, const allocator_type & alloc=allocator_type())
Decodes Base58 dump from the slice content to returned buffer.
buffer base64 (const slice & source, unsigned wrap_width=0, const allocator_type & alloc=allocator_type())
Returns a new buffer with a Base64 dump of the slice content.
buffer base64 (const POD & pod, unsigned wrap_width=0, const allocator_type & alloc=allocator_type())
Returns a new buffer with a Base64 dump of the given pod.
buffer base64_decode (const slice & source, bool ignore_spaces=false, const allocator_type & alloc=allocator_type())
Decodes Base64 dump from the slice content to returned buffer.
buffer clone (const buffer & src, const allocator_type & alloc=allocator_type())
Makes a deep copy of the given buffer preserving headroom/tailroom.
buffer hex (const slice & source, bool uppercase=false, unsigned wrap_width=0, const allocator_type & alloc=allocator_type())
Returns a new buffer with a hexadecimal dump of the slice content.
buffer hex (const POD & pod, bool uppercase=false, unsigned wrap_width=0, const allocator_type & alloc=allocator_type())
Returns a new buffer with a hexadecimal dump of the given pod.
buffer hex_decode (const slice & source, bool ignore_spaces=false, const allocator_type & alloc=allocator_type())
Decodes hexadecimal dump from the slice content to returned buffer.
buffer invalid () noexcept
Builds an invalid buffer that has a non-zero length and refers to a null address.
bool is_swap_nothrow () noexcept
Checks whether the swap operation is noexcept for this allocator.
buffer key_from (const char(&) text, bool make_reference=true)
Makes a key buffer from a C string literal.
buffer key_from (const ::std::basic_string_view< CHAR, T > & src, bool make_reference=false)
Makes a key buffer from a std::basic_string_view .
buffer key_from (const char * src, bool make_reference=false)
Makes a key buffer from a null-terminated C string.
buffer key_from (const ::std::basic_string< CHAR, T, A > & src, bool make_reference=false)
Makes a key buffer from a std::basic_string .
buffer key_from (buffer && src) noexcept
Makes a key buffer by moving the given buffer.
buffer key_from (const double ieee754_64bit)
Makes a comparable key from a double IEEE754 value.
buffer key_from (const double * ieee754_64bit)
Makes a comparable key from a double IEEE754 value by a pointer.
buffer key_from (const uint64_t unsigned_int64)
Makes a comparable key from an unsigned uint64_t value.
buffer key_from (const int64_t signed_int64)
Makes a comparable key from a signed int64_t value.
buffer key_from (const float ieee754_32bit)
Makes a comparable key from a float IEEE754 value.
buffer key_from (const float * ieee754_32bit)
Makes a comparable key from a float IEEE754 value by a pointer.
buffer key_from (const uint32_t unsigned_int32)
Makes a comparable key from an unsigned uint32_t value.
buffer key_from (const int32_t signed_int32)
Makes a comparable key from a signed int32_t value.
buffer key_from_double (const double ieee754_64bit)
Makes a comparable key from a double IEEE754 value.
buffer key_from_float (const float ieee754_32bit)
Makes a comparable key from a float IEEE754 value.
buffer key_from_i32 (const int32_t signed_int32)
Makes a comparable key from a signed int32_t value.
buffer key_from_i64 (const int64_t signed_int64)
Makes a comparable key from a signed int64_t value.
buffer key_from_jsonInteger (const int64_t json_integer)
Makes a comparable key from a signed int64_t JSON-number value.
buffer key_from_u32 (const uint32_t unsigned_int32)
Makes a comparable key from an unsigned uint32_t value.
buffer key_from_u64 (const uint64_t unsigned_int64)
Makes a comparable key from an unsigned uint64_t value.
buffer null () noexcept
Build a null buffer which zero length and refers to null address.
buffer wrap (const POD & pod, bool make_reference=false, const allocator_type & alloc=allocator_type())
Wraps an object of a standard-layout type into a buffer.

Public Static Functions inherited from mdbx::slice

See mdbx::slice

Type Name
slice blank_for_put_reserve (size_t length)
Builds a "blank" slice for a MDBX_RESERVE allocation: it has a null data pointer but the requested non-zero length, which the C API fills in on return fromtxn::insert_reserve() ,txn::upsert_reserve() and friends.
slice invalid () noexcept
Builds an invalid slice that has a non-zero length and refers to a null address.
slice null () noexcept
Build a null slice which zero length and refers to null address.
slice wrap (const char(&) text)
Wraps a null-terminated string literal into a slice.
slice wrap (const POD & pod)
Wraps an object of a standard-layout type into a slice.

Protected Functions inherited from mdbx::slice

See mdbx::slice

Type Name
constexpr slice (size_t invalid_length) noexcept
A special constructor without length checking, for invalid() andblank_for_put_reserve() .

Detailed Description

Note:

Unlike the base slice, a buffer by default owns its content: the constructors from strings/views copy the bytes (freestanding modality), so there are no lifetime requirements on the source. The make_reference=true overloads switch to slice-like behavior: the buffer just refers to external data, which must outlive the buffer (the same temporary-lifetime rules as for slice apply). The rvalue-string constructor steals the string's storage and leaves the source empty.

Public Types Documentation

enum @314256227132342347124375117343310276307137366216

enum mdbx::buffer::@314256227132342347124375117343310276307137366216 {
    max_length = MDBX_MAXDATASIZE,
    max_capacity = (max_length / 3u * 4u + 1023u) & ~size_t(1023),
    extra_inplace_storage = reservation_policy::extra_inplace_storage,
    inplace_storage_size_rounding =
        (alignof(max_align_t) * 2 > size_t(reservation_policy::inplace_storage_size_rounding))
            ? alignof(max_align_t) * 2
            : size_t(reservation_policy::inplace_storage_size_rounding),
    pettiness_threshold = reservation_policy::pettiness_threshold
};

typedef allocator_traits

The allocator_type traits.

using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_traits = ::std::allocator_traits<allocator_type>;

typedef allocator_type

The allocator type rebound for the internal storage.

using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::allocator_type = typename ::std::allocator_traits<ALLOCATOR>::template rebind_alloc<uint64_t>;

typedef copy_assign_alloc

The copy-assignment allocator-propagation helper (internal use).

using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::copy_assign_alloc = typename silo::copy_assign_alloc;

typedef inherited

The base slice class.

using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::inherited = slice;

enum modality

Data storage modality.

enum mdbx::buffer::modality {
    reference,
    inplace,
    allocated
};

typedef move_assign_alloc

The move-assignment allocator-propagation helper (internal use).

using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::move_assign_alloc = typename silo::move_assign_alloc;

typedef reservation_policy

The capacity policy type, see default_capacity_policy .

using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::reservation_policy = CAPACITY_POLICY;

typedef swap_alloc

The swap allocator-propagation helper (internal use).

using mdbx::buffer< ALLOCATOR, CAPACITY_POLICY >::swap_alloc = typename silo::swap_alloc;

Public Functions Documentation

function add_header [1/2]

Prepends a memory range to the beginning of the buffer (into the headroom).

inline buffer & mdbx::buffer::add_header (
    const void * src,
    size_t bytes
) 

Parameters:

  • src The address of the data to prepend.
  • bytes The number of bytes to prepend.

Returns:

A reference to this instance.


function add_header [2/2]

Prepends a slice to the beginning of the buffer (into the headroom).

inline buffer & mdbx::buffer::add_header (
    const struct slice & chunk
) 

Parameters:

  • chunk The data chunk to prepend.

Returns:

A reference to this instance.


function append [1/5]

Appends a string view to the end of the buffer.

template<class CHAR, class T>
inline buffer & mdbx::buffer::append (
    const ::std::basic_string_view< CHAR, T > & view
) 

Parameters:

  • view The string view to append.

Returns:

A reference to this instance.


function append [2/5]

Appends a string to the end of the buffer.

template<class CHAR, class T, class A>
inline buffer & mdbx::buffer::append (
    const ::std::basic_string< CHAR, T, A > & str
) 

Parameters:

  • str The string to append.

Returns:

A reference to this instance.


function append [3/5]

Appends a memory range to the end of the buffer.

inline buffer & mdbx::buffer::append (
    const void * src,
    size_t bytes
) 

Parameters:

  • src The address of the data to append.
  • bytes The number of bytes to append.

Returns:

A reference to this instance.


function append [4/5]

Appends a single byte to the end of the buffer.

inline buffer & mdbx::buffer::append (
    const byte c
) 

Parameters:

  • c The byte to append.

Returns:

A reference to this instance.


function append [5/5]

Appends a slice to the end of the buffer.

inline buffer & mdbx::buffer::append (
    const struct slice & chunk
) 

Parameters:

  • chunk The data chunk to append.

Returns:

A reference to this instance.


function append_base58

Appends a Base58 dump of the given data to the buffer.

inline buffer & mdbx::buffer::append_base58 (
    const struct slice & data,
    unsigned wrap_width=0
) 

Parameters:

  • data The data to be encoded.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.

Returns:

A reference to this instance.


function append_base64

Appends a Base64 dump of the given data to the buffer.

inline buffer & mdbx::buffer::append_base64 (
    const struct slice & data,
    unsigned wrap_width=0
) 

Parameters:

  • data The data to be encoded.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.

Returns:

A reference to this instance.


function append_byte

Appends a single byte.

inline buffer & mdbx::buffer::append_byte (
    uint_fast8_t byte
) 

Parameters:

  • byte The byte to append.

Returns:

A reference to this instance.


function append_decoded_base58

Appends data decoded from a Base58 dump to the buffer.

inline buffer & mdbx::buffer::append_decoded_base58 (
    const struct slice & data,
    bool ignore_spaces=false
) 

Parameters:

  • data The Base58 dump to be decoded.
  • ignore_spaces Skip whitespaces while decoding.

Returns:

A reference to this instance.


function append_decoded_base64

Appends data decoded from a Base64 dump to the buffer.

inline buffer & mdbx::buffer::append_decoded_base64 (
    const struct slice & data,
    bool ignore_spaces=false
) 

Parameters:

  • data The Base64 dump to be decoded.
  • ignore_spaces Skip whitespaces while decoding.

Returns:

A reference to this instance.


function append_decoded_hex

Appends data decoded from a hexadecimal dump to the buffer.

inline buffer & mdbx::buffer::append_decoded_hex (
    const struct slice & data,
    bool ignore_spaces=false
) 

Parameters:

  • data The hexadecimal dump to be decoded.
  • ignore_spaces Skip whitespaces while decoding.

Returns:

A reference to this instance.


function append_hex

Appends a hexadecimal dump of the given data to the buffer.

inline buffer & mdbx::buffer::append_hex (
    const struct slice & data,
    bool uppercase=false,
    unsigned wrap_width=0
) 

Parameters:

  • data The data to be encoded.
  • uppercase Use uppercase letters for hexadecimal digits.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.

Returns:

A reference to this instance.


function append_producer [1/2]

Appends the bytes produced by the given producer to the end of the buffer.

template<MutableByteProducer PRODUCER>
inline buffer & mdbx::buffer::append_producer (
    PRODUCER & producer
) 

Precondition:

The producer must not read from the destination region [ end_char_ptr() , silo_end()) while producing: when the result fits the tailroom, it is written in place, at end_char_ptr(), so a source overlapping the own tailroom would be overwritten before being read (the dest argument of write_bytes() is __restrict). The append_hex(), append_base58(), append_base64() and the append_decoded_*() methods handle a slice source that reaches the own tailroom themselves (by copying it out first); for a custom producer, avoiding such an overlap is the caller's responsibility.

Parameters:

  • producer A mutable or immutable byte producer, e.g. to_hex, from_base64, or a user-provided one; it may refer into this buffer, but only into the content or the headroom.

Returns:

A reference to this buffer.


function append_producer [2/2]

Appends the bytes produced by the given immutable producer, see the overload above.

template<ImmutableByteProducer PRODUCER>
inline buffer & mdbx::buffer::append_producer (
    const PRODUCER & producer
) 

Precondition:

The same: the producer must not read from [ end_char_ptr() , silo_end()) while producing.

Parameters:

  • producer An immutable byte producer, e.g. to_hex or from_base64.

Returns:

A reference to this buffer.


function append_u16

Appends a 16-bit value in little-endian order.

inline buffer & mdbx::buffer::append_u16 (
    uint_fast16_t u16
) 

Parameters:

  • u16 The value to append.

Returns:

A reference to this instance.


function append_u24

Appends a 24-bit value in little-endian order.

inline buffer & mdbx::buffer::append_u24 (
    uint_fast32_t u24
) 

Parameters:

  • u24 The value to append.

Returns:

A reference to this instance.


function append_u32

Appends a 32-bit value in little-endian order.

inline buffer & mdbx::buffer::append_u32 (
    uint_fast32_t u32
) 

Parameters:

  • u32 The value to append.

Returns:

A reference to this instance.


function append_u48

Appends a 48-bit value in little-endian order.

inline buffer & mdbx::buffer::append_u48 (
    uint_fast64_t u48
) 

Parameters:

  • u48 The value to append.

Returns:

A reference to this instance.


function append_u64

Appends a 64-bit value in little-endian order.

inline buffer & mdbx::buffer::append_u64 (
    uint_fast64_t u64
) 

Parameters:

  • u64 The value to append.

Returns:

A reference to this instance.


function append_u8

Appends an 8-bit value in little-endian order.

inline buffer & mdbx::buffer::append_u8 (
    uint_fast8_t u8
) 

Parameters:

  • u8 The value to append.

Returns:

A reference to this instance.


function assign [1/13]

Assigns a copy of the source buffer with the given headroom/tailroom.

inline buffer & mdbx::buffer::assign (
    size_t headroom,
    const buffer & src,
    size_t tailroom
) 

Parameters:

  • headroom The number of bytes to reserve in front of the data.
  • src The source buffer.
  • tailroom The number of bytes to reserve after the data.

Returns:

A reference to this instance.


function assign [2/13]

Assigns from another buffer, either copying or referencing it.

inline buffer & mdbx::buffer::assign (
    const buffer & src,
    bool make_reference=false
) 

Parameters:

  • src The source buffer.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [3/13]

Move-assigns from another buffer; the source is invalidated.

inline buffer & mdbx::buffer::assign (
    buffer && src
) 

Parameters:

  • src The source buffer to be moved from.

Returns:

A reference to this instance.


function assign [4/13]

Assigns the buffer from a memory range, either copying or referencing it.

inline buffer & mdbx::buffer::assign (
    const void * ptr,
    size_t bytes,
    bool make_reference=false
) 

Parameters:

  • ptr The address of the source data.
  • bytes The number of bytes of the source data.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [5/13]

Assigns the buffer from a char-pointer and an integral length.

template<typename INT, typename ::std::enable_if<::std::is_integral< INT >::value &&!::std::is_same< INT, bool >::value, int >::type>
inline buffer & mdbx::buffer::assign (
    const char * ptr,
    INT bytes,
    bool make_reference=false
) 

Parameters:

  • ptr The address of the source data.
  • bytes The number of bytes of the source data.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [6/13]

Assigns the buffer to a null pointer; only a zero length is accepted.

template<typename INT, typename ::std::enable_if<::std::is_integral< INT >::value &&!::std::is_same< INT, bool >::value, int >::type>
inline buffer & mdbx::buffer::assign (
    ::std::nullptr_t,
    INT bytes,
    bool make_reference=false
) 

Parameters:

  • bytes The number of bytes, must be zero.
  • make_reference Make the buffer a reference instead of copying.

Returns:

A reference to this instance.


function assign [7/13]

Assigns the buffer from a slice, either copying or referencing it.

inline buffer & mdbx::buffer::assign (
    const struct slice & src,
    bool make_reference=false
) 

Parameters:

  • src The source slice.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [8/13]

Assigns the buffer from a MDBX_val , either copying or referencing it.

inline buffer & mdbx::buffer::assign (
    const ::MDBX_val & src,
    bool make_reference=false
) 

Parameters:

  • src The source MDBX_val instance.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [9/13]

Move-assigns the buffer from a slice; the source is invalidated.

inline buffer & mdbx::buffer::assign (
    struct slice && src,
    bool make_reference=false
) 

Parameters:

  • src The source slice to be moved from.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [10/13]

Takes over a temporary MDBX_val instance.

inline buffer & mdbx::buffer::assign (
    ::MDBX_val && src,
    bool make_reference=false
) 

Parameters:

  • src The source MDBX_val to be moved from.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [11/13]

Assigns the buffer from a [begin,end) memory range.

inline buffer & mdbx::buffer::assign (
    const void * begin,
    const void * end,
    bool make_reference=false
) 

Parameters:

  • begin The address of the first byte.
  • end The address just after the last byte.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [12/13]

Assigns the buffer from a string, either copying or referencing it.

template<class CHAR, class T, class A>
inline buffer & mdbx::buffer::assign (
    const ::std::basic_string< CHAR, T, A > & str,
    bool make_reference=false
) 

Parameters:

  • str The source string.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign [13/13]

Assigns the buffer from a null-terminated string.

inline buffer & mdbx::buffer::assign (
    const char * c_str,
    bool make_reference=false
) 

Parameters:

  • c_str The source null-terminated string.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

A reference to this instance.


function assign_freestanding

Assigns the buffer to own a copy of an external memory range.

inline buffer & mdbx::buffer::assign_freestanding (
    const void * ptr,
    size_t bytes
) 

Parameters:

  • ptr The address of the source data.
  • bytes The number of bytes of the source data.

Returns:

A reference to this instance.


function assign_reference

Assigns the buffer to reference an external memory range without copying.

inline buffer & mdbx::buffer::assign_reference (
    const void * ptr,
    size_t bytes
) 

Parameters:

  • ptr The address of the source data.
  • bytes The number of bytes of the source data.

Returns:

A reference to this instance.


function base58_decode [2/2]

Decodes Base58 dump from the buffer content to new returned buffer.

inline buffer mdbx::buffer::base58_decode (
    bool ignore_spaces=false,
    const allocator_type & alloc=allocator_type ()
) const

Parameters:

  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the buffer storage.

Returns:

The resulting buffer.


function base64_decode [2/2]

Decodes Base64 dump from the buffer content to new returned buffer.

inline buffer mdbx::buffer::base64_decode (
    bool ignore_spaces=false,
    const allocator_type & alloc=allocator_type ()
) const

Parameters:

  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the buffer storage.

Returns:

The resulting buffer.


function buffer [1/20]

Constructs an empty buffer.

constexpr mdbx::buffer::buffer () noexcept

function buffer [2/20]

Constructs an empty buffer with the given allocator.

inline constexpr mdbx::buffer::buffer (
    const allocator_type & alloc
) noexcept

Parameters:

  • alloc The allocator for the buffer storage.

function buffer [3/20]

Constructs a buffer from a memory range, either copying or referencing it.

inline constexpr mdbx::buffer::buffer (
    const void * ptr,
    size_t bytes,
    bool make_reference,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • ptr The address of the source data.
  • bytes The number of bytes of the source data.
  • make_reference Make the buffer a reference to the source data instead of copying it.
  • alloc The allocator for the buffer storage.

function buffer [4/20]

Constructs a buffer from a null-terminated string, either copying or referencing it.

inline mdbx::buffer::buffer (
    const char * c_str,
    bool make_reference,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • c_str The source null-terminated string.
  • make_reference Make the buffer a reference to the source data instead of copying it.
  • alloc The allocator for the buffer storage.

function buffer [5/20]

Constructs a buffer from a string view, either copying or referencing it.

template<class CHAR, class T>
inline constexpr mdbx::buffer::buffer (
    const ::std::basic_string_view< CHAR, T > & view,
    bool make_reference,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • view The source string view.
  • make_reference Make the buffer a reference to the source data instead of copying it.
  • alloc The allocator for the buffer storage.

function buffer [6/20]

Constructs a buffer storing a copy of the given slice; empty or null slices are referenced instead of copied.

inline constexpr mdbx::buffer::buffer (
    const struct slice & src,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • src The source slice.
  • alloc The allocator for the buffer storage.

function buffer [7/20]

Copy constructor.

inline explicit constexpr mdbx::buffer::buffer (
    const buffer & src
) 

Parameters:

  • src The source buffer.

function buffer [8/20]

Constructs a buffer storing a copy of the given memory range.

inline constexpr mdbx::buffer::buffer (
    const void * ptr,
    size_t bytes,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • ptr The address of the source data.
  • bytes The number of bytes of the source data.
  • alloc The allocator for the buffer storage.

function buffer [9/20]

Copies bytes fromptr ; keeps an integer length away frombuffer(const char *, bool) .

template<typename INT, typename ::std::enable_if<::std::is_integral< INT >::value &&!::std::is_same< INT, bool >::value, int >::type>
inline constexpr mdbx::buffer::buffer (
    const char * ptr,
    INT bytes,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • ptr The address of the source data.
  • bytes The number of bytes of the source data.
  • alloc The allocator for the buffer storage.

function buffer [10/20]

Takes nullptr , so that a literal0 orNULL is ambiguous instead of a nullconst char * .

template<typename INT, typename ::std::enable_if<::std::is_integral< INT >::value &&!::std::is_same< INT, bool >::value, int >::type>
inline constexpr mdbx::buffer::buffer (
    ::std::nullptr_t,
    INT bytes,
    const allocator_type & alloc=allocator_type ()
) 

Note:

A null pointer with a non-zero length would dereference address zero; only nullptr with zero bytes (an empty buffer) is accepted.

Parameters:

  • bytes The number of bytes of the source data.
  • alloc The allocator for the buffer storage.

function buffer [11/20]

Null pointer with an explicit make_reference flag.

template<typename INT, typename ::std::enable_if<::std::is_integral< INT >::value &&!::std::is_same< INT, bool >::value, int >::type>
inline constexpr mdbx::buffer::buffer (
    ::std::nullptr_t,
    INT bytes,
    bool make_reference
) 

Note:

Exists to keep buffer(nullptr, N, false) unambiguous on the Windows compilers where the generic (const void *, size_t, bool) overload and the integral-length templates otherwise collide on the bool third argument (#142).

Parameters:

  • bytes The number of bytes of the source data.
  • make_reference Make the buffer a reference to the source data instead of copying it.

function buffer [12/20]

Creates a buffer that stores a copy of the string's content. The source string may be a temporary: the bytes are copied immediately, so there are no lifetime requirements (unlike mdbx::slice ).

template<class CHAR, class T, class A>
inline explicit constexpr mdbx::buffer::buffer (
    const ::std::basic_string< CHAR, T, A > & str,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • str The source string.
  • alloc The allocator for the buffer storage.

function buffer [13/20]

Creates a buffer that either stores a copy of the string's content (make_reference=false, the default choice) or just refers to it (make_reference=true, then the string must outlive the buffer — the same lifetime rules as for mdbx::slice ).

template<class CHAR, class T, class A>
inline explicit constexpr mdbx::buffer::buffer (
    const ::std::basic_string< CHAR, T, A > & str,
    bool make_reference,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • str The source string.
  • make_reference Make the buffer a reference to the source data instead of copying it.
  • alloc The allocator for the buffer storage.

function buffer [14/20]

Constructs a buffer storing a copy of a null-terminated string.

inline constexpr mdbx::buffer::buffer (
    const char * c_str,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • c_str The source null-terminated string.
  • alloc The allocator for the buffer storage.

function buffer [15/20]

Constructs a buffer storing a copy of a string view.

template<class CHAR, class T>
inline constexpr mdbx::buffer::buffer (
    const ::std::basic_string_view< CHAR, T > & view,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • view The source string view.
  • alloc The allocator for the buffer storage.

function buffer [16/20]

Constructs an empty buffer with the given headroom and tailroom.

inline mdbx::buffer::buffer (
    size_t head_room,
    size_t tail_room,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • head_room The number of bytes to reserve in front of the data.
  • tail_room The number of bytes to reserve after the data.
  • alloc The allocator for the buffer storage.

function buffer [17/20]

Constructs an empty buffer with the given capacity.

inline mdbx::buffer::buffer (
    size_t capacity,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • capacity The capacity in bytes to allocate.
  • alloc The allocator for the buffer storage.

function buffer [18/20]

Constructs a buffer storing a copy of the slice with reserved headroom/tailroom.

inline mdbx::buffer::buffer (
    size_t head_room,
    const slice & src,
    size_t tail_room,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • head_room The number of bytes to reserve in front of the data.
  • src The source slice.
  • tail_room The number of bytes to reserve after the data.
  • alloc The allocator for the buffer storage.

function buffer [19/20]

Constructs a buffer owning a copy of the slice when its data is dirty within the given transaction, otherwise a reference to it.

inline mdbx::buffer::buffer (
    const txn & transaction,
    const slice & src,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • transaction The transaction to check the data dirtiness against.
  • src The source slice.
  • alloc The allocator for the buffer storage.

function buffer [20/20]

Move constructor: the source buffer is invalidated.

inline mdbx::buffer::buffer (
    buffer && src
) 

Parameters:

  • src The source buffer to be moved from.

function byte_ptr [1/2]

Returns casted to const pointer to byte an address of data.

inline const byte * mdbx::buffer::byte_ptr () noexcept const

Returns:

The read-only pointer to the first byte.


function byte_ptr [2/2]

Returns casted to pointer to byte an address of data.

inline byte * mdbx::buffer::byte_ptr () noexcept

Returns:

The mutable pointer to the first byte.

Precondition:

REQUIRES: The buffer should store data chunk, but not referenced to an external one.


function capacity

Returns the number of bytes that can be held in currently allocated storage.

inline size_t mdbx::buffer::capacity () noexcept const

Returns:

The capacity in bytes, zero for a referencing buffer.


function char_ptr [1/2]

Returns casted to const pointer to char an address of data.

inline const char * mdbx::buffer::char_ptr () noexcept const

Returns:

The read-only pointer to the first byte.


function char_ptr [2/2]

Returns casted to pointer to char an address of data.

inline char * mdbx::buffer::char_ptr () noexcept

Returns:

The mutable pointer to the first byte.

Precondition:

REQUIRES: The buffer should store data chunk, but not referenced to an external one.


function clear

Clears the contents and storage.

inline void mdbx::buffer::clear () noexcept

function clear_and_reserve

Clears the contents and reserve storage.

inline void mdbx::buffer::clear_and_reserve (
    size_t whole_capacity,
    size_t headroom=0
) 

Parameters:

  • whole_capacity The whole capacity to reserve.
  • headroom The number of bytes to reserve in front of the data.

function const_data

Return a const pointer to the beginning of the referenced data.

inline const void * mdbx::buffer::const_data () noexcept const

Returns:

The read-only pointer to the data.


function const_end

Return a const pointer to the end of the referenced data.

inline const void * mdbx::buffer::const_end () noexcept const

Returns:

The read-only pointer just after the last byte.


function content_modality

Returns current modality of buffer content.

inline modality mdbx::buffer::content_modality () noexcept const

Returns:

The modality of the content storage.


function data [1/2]

Return a const pointer to the beginning of the referenced data.

inline const void * mdbx::buffer::data () noexcept const

Returns:

The read-only pointer to the data.


function data [2/2]

Return a pointer to the beginning of the referenced data.

inline void * mdbx::buffer::data () noexcept

Returns:

The mutable pointer to the data.

Precondition:

REQUIRES: The buffer should store data chunk, but not referenced to an external one.


function encode_base58

Returns a new buffer with a Base58 dump of the slice content.

inline buffer mdbx::buffer::encode_base58 (
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) const

Parameters:

  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a Base58 dump of the slice content.


function encode_base64

Returns a new buffer with a Base64 dump of the slice content.

inline buffer mdbx::buffer::encode_base64 (
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) const

Parameters:

  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a Base64 dump of the slice content.


function encode_hex

Returns a new buffer with a hexadecimal dump of the slice content.

inline buffer mdbx::buffer::encode_hex (
    bool uppercase=false,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) const

Parameters:

  • uppercase Use uppercase letters for hexadecimal digits.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a hexadecimal dump of the slice content.


function end [1/2]

Return a const pointer to the end of the referenced data.

inline const byte * mdbx::buffer::end () noexcept const

Returns:

The read-only pointer just after the last byte.


function end [2/2]

Return a pointer to the end of the referenced data.

inline byte * mdbx::buffer::end () noexcept

Returns:

The mutable pointer just after the last byte.

Precondition:

REQUIRES: The buffer should store data chunk, but not referenced to an external one.


function end_byte_ptr [1/2]

Returns casted to const pointer to byte an end of data.

inline const byte * mdbx::buffer::end_byte_ptr () noexcept const

Returns:

The read-only pointer just after the last byte.


function end_byte_ptr [2/2]

Returns casted to pointer to byte an end of data.

inline byte * mdbx::buffer::end_byte_ptr () noexcept

Returns:

The mutable pointer just after the last byte.

Precondition:

REQUIRES: The buffer should store data chunk, but not referenced to an external one.


function end_char_ptr [1/2]

Returns casted to const pointer to char an end of data.

inline const char * mdbx::buffer::end_char_ptr () noexcept const

Returns:

The read-only pointer just after the last byte.


function end_char_ptr [2/2]

Returns casted to pointer to char an end of data.

inline char * mdbx::buffer::end_char_ptr () noexcept

Returns:

The mutable pointer just after the last byte.

Precondition:

REQUIRES: The buffer should store data chunk, but not referenced to an external one.


function get_allocator

Returns the associated allocator.

inline allocator_type mdbx::buffer::get_allocator () const

Returns:

A copy of the allocator associated with the buffer.


function headroom

Returns the number of bytes available in the currently allocated storage in front of the data.

inline size_t mdbx::buffer::headroom () noexcept const

Returns:

The headroom in bytes, zero for a referencing buffer.


function hex_decode [2/2]

Decodes hexadecimal dump from the buffer content to new returned buffer.

inline buffer mdbx::buffer::hex_decode (
    bool ignore_spaces=false,
    const allocator_type & alloc=allocator_type ()
) const

Parameters:

  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the buffer storage.

Returns:

The resulting buffer.


function is_freestanding

Checks whether data chunk stored inside the buffer, otherwise buffer just refers to data located outside the buffer.

inline bool mdbx::buffer::is_freestanding () noexcept const

Returns:

true if the buffer owns its data.


function is_inplace

Checks whether data chunk stored in place within the buffer instance itself, without reference outside nor allocating additional memory resources, which also implies buffer is freestanding.

inline bool mdbx::buffer::is_inplace () noexcept const

Returns:

true if the data is stored inplace.


function is_reference

Checks whether the buffer just refers to data located outside the buffer, rather than stores it.

inline bool mdbx::buffer::is_reference () noexcept const

Returns:

true if the buffer refers to external data.


function length

Returns the number of bytes.

inline size_t mdbx::buffer::length () noexcept const

Returns:

The length of the data in bytes.


function make_freestanding

Makes buffer owning the data.

inline void mdbx::buffer::make_freestanding () 

If buffer refers to an external data, then makes it the owner of clone by allocating storage and copying the data.


function make_inplace_or_reference

Makes a lightweight copy: inplace when this buffer is inplace, otherwise a reference to the same data.

inline buffer mdbx::buffer::make_inplace_or_reference () const

Returns:

The new buffer instance.


function basic_string

Converts the buffer content to a std::basic_string .

template<class CHAR, class T, class A>
inline explicit constexpr mdbx::buffer::basic_string () const

Returns:

The string with a copy of the buffer content.


function operator=

Copy assignment operator.

inline buffer & mdbx::buffer::operator= (
    const buffer & src
) 

Parameters:

  • src The source buffer.

Returns:

A reference to this instance.


function operator=

Move assignment operator; the source is invalidated.

inline buffer & mdbx::buffer::operator= (
    buffer && src
) 

Parameters:

  • src The source buffer to be moved from.

Returns:

A reference to this instance.


function operator=

Assigns from a slice, copying its content.

inline buffer & mdbx::buffer::operator= (
    const struct slice & src
) 

Parameters:

  • src The source slice.

Returns:

A reference to this instance.


function operator=

Move-assigns from a slice; the source is invalidated.

inline buffer & mdbx::buffer::operator= (
    struct slice && src
) 

Parameters:

  • src The source slice to be moved from.

Returns:

A reference to this instance.


function operator=

Assigns from a string view, copying its content.

template<class CHAR, class T>
inline buffer & mdbx::buffer::operator= (
    const ::std::basic_string_view< CHAR, T > & view
) 

Parameters:

  • view The source string view.

Returns:

A reference to this instance.


function reserve [1/2]

Reserves storage space.

inline void mdbx::buffer::reserve (
    size_t wanna_headroom,
    size_t wanna_tailroom
) 

Parameters:

  • wanna_headroom The desired headroom in bytes.
  • wanna_tailroom The desired tailroom in bytes.

function reserve [2/2]

Reserves storage space for at least size bytes of payload, without changing the current length. STL-compatible counterpart ofreserve(size_t, size_t) that keeps the headroom unchanged.

inline void mdbx::buffer::reserve (
    size_t size
) 

Parameters:

  • size The new length of the data.

function reserve_headroom

Reserves space before the payload.

inline void mdbx::buffer::reserve_headroom (
    size_t wanna_headroom
) 

Parameters:

  • wanna_headroom The desired headroom in bytes.

function reserve_tailroom

Reserves space after the payload.

inline void mdbx::buffer::reserve_tailroom (
    size_t wanna_tailroom
) 

Parameters:

  • wanna_tailroom The desired tailroom in bytes.

function resize [1/2]

Resizes the buffer to contain size bytes, filling the added space with zeroes. STL-compatible counterpart ofset_length() .

inline void mdbx::buffer::resize (
    size_t size
) 

Parameters:

  • size The new length of the data.

function resize [2/2]

Resizes the buffer to contain size bytes, filling the added space withvalue . STL-compatible counterpart ofset_length() .

inline void mdbx::buffer::resize (
    size_t size,
    byte value
) 

Parameters:

  • size The new length of the data.
  • value The byte to fill the added space with.

function set_end

Sets the length by specifying the end of the data.

inline buffer & mdbx::buffer::set_end (
    const void * ptr
) 

Parameters:

  • ptr The address just after the last byte of the data.

Returns:

A reference to this instance.


function set_length

Set length of data.

inline buffer & mdbx::buffer::set_length (
    size_t bytes
) 

Parameters:

  • bytes The new length of the data.

Returns:

A reference to this instance.


function shrink_to_fit

Reduces memory usage by freeing unused storage space.

inline void mdbx::buffer::shrink_to_fit () 

function slice

Returns the base slice view of this buffer.

inline const slice & mdbx::buffer::slice () noexcept const

Returns:

A constant reference to this buffer as a slice.


function swap [2/2]

Swaps this buffer with another one.

inline void mdbx::buffer::swap (
    buffer & other
) 

Parameters:

  • other The buffer to swap with.

function tailroom

Returns the number of bytes that available in currently allocated storage after the data.

inline size_t mdbx::buffer::tailroom () noexcept const

Returns:

The tailroom in bytes, zero for a referencing buffer.


Public Static Functions Documentation

function base58 [1/2]

Returns a new buffer with a Base58 dump of the slice content.

static inline buffer mdbx::buffer::base58 (
    const slice & source,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • source The source object.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a Base58 dump of the slice content.


function base58 [2/2]

Returns a new buffer with a Base58 dump of the given pod.

template<typename POD, typename ::std::enable_if<!::std::is_constructible< slice , const POD & >::value, int >::type>
static inline buffer mdbx::buffer::base58 (
    const POD & pod,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • pod The object of a standard-layout type.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a Base58 dump of the given pod.


function base58_decode [1/2]

Decodes Base58 dump from the slice content to returned buffer.

static inline buffer mdbx::buffer::base58_decode (
    const slice & source,
    bool ignore_spaces=false,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • source The source object.
  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the buffer storage.

Returns:

The resulting buffer.


function base64 [1/2]

Returns a new buffer with a Base64 dump of the slice content.

static inline buffer mdbx::buffer::base64 (
    const slice & source,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • source The source object.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a Base64 dump of the slice content.


function base64 [2/2]

Returns a new buffer with a Base64 dump of the given pod.

template<typename POD, typename ::std::enable_if<!::std::is_constructible< slice , const POD & >::value, int >::type>
static inline buffer mdbx::buffer::base64 (
    const POD & pod,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • pod The object of a standard-layout type.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a Base64 dump of the given pod.


function base64_decode [1/2]

Decodes Base64 dump from the slice content to returned buffer.

static inline buffer mdbx::buffer::base64_decode (
    const slice & source,
    bool ignore_spaces=false,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • source The source object.
  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the buffer storage.

Returns:

The resulting buffer.


function clone

Makes a deep copy of the given buffer preserving headroom/tailroom.

static inline buffer mdbx::buffer::clone (
    const buffer & src,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • src The source buffer.
  • alloc The allocator for the new buffer storage.

Returns:

The cloned buffer.


function hex [1/2]

Returns a new buffer with a hexadecimal dump of the slice content.

static inline buffer mdbx::buffer::hex (
    const slice & source,
    bool uppercase=false,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • source The source object.
  • uppercase Use uppercase letters for hexadecimal digits.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a hexadecimal dump of the slice content.


function hex [2/2]

Returns a new buffer with a hexadecimal dump of the given pod.

template<typename POD, typename ::std::enable_if<!::std::is_constructible< slice , const POD & >::value, int >::type>
static inline buffer mdbx::buffer::hex (
    const POD & pod,
    bool uppercase=false,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • pod The object of a standard-layout type.
  • uppercase Use uppercase letters for hexadecimal digits.
  • wrap_width The width to wrap lines with a newline, zero means no wrapping.
  • alloc The allocator for the buffer storage.

Returns:

A new buffer with a hexadecimal dump of the given pod.


function hex_decode [1/2]

Decodes hexadecimal dump from the slice content to returned buffer.

static inline buffer mdbx::buffer::hex_decode (
    const slice & source,
    bool ignore_spaces=false,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • source The source object.
  • ignore_spaces Skip whitespaces while decoding.
  • alloc The allocator for the buffer storage.

Returns:

The resulting buffer.


function invalid

Builds an invalid buffer that has a non-zero length and refers to a null address.

static inline buffer mdbx::buffer::invalid () noexcept

Returns:

The invalid buffer instance.


function is_swap_nothrow

Checks whether the swap operation is noexcept for this allocator.

static inline bool mdbx::buffer::is_swap_nothrow () noexcept

Returns:

true if swapping never throws.


function key_from [1/13]

Makes a key buffer from a C string literal.

template<size_t SIZE>
static inline buffer mdbx::buffer::key_from (
    const char(&) text,
    bool make_reference=true
) 

Parameters:

  • text The null-terminated string literal.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

The key buffer.


function key_from [2/13]

Makes a key buffer from a std::basic_string_view .

template<class CHAR, class T>
static inline buffer mdbx::buffer::key_from (
    const ::std::basic_string_view< CHAR, T > & src,
    bool make_reference=false
) 

Parameters:

  • src The source string view.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

The key buffer.


function key_from [3/13]

Makes a key buffer from a null-terminated C string.

static inline buffer mdbx::buffer::key_from (
    const char * src,
    bool make_reference=false
) 

Parameters:

  • src The source null-terminated string.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

The key buffer.


function key_from [4/13]

Makes a key buffer from a std::basic_string .

template<class CHAR, class T, class A>
static inline buffer mdbx::buffer::key_from (
    const ::std::basic_string< CHAR, T, A > & src,
    bool make_reference=false
) 

Parameters:

  • src The source string.
  • make_reference Make the buffer a reference to the source data instead of copying it.

Returns:

The key buffer.


function key_from [5/13]

Makes a key buffer by moving the given buffer.

static inline buffer mdbx::buffer::key_from (
    buffer && src
) noexcept

Parameters:

  • src The source buffer to be moved.

Returns:

The key buffer.


function key_from [6/13]

Makes a comparable key from a double IEEE754 value.

static inline buffer mdbx::buffer::key_from (
    const double ieee754_64bit
) 

Parameters:

  • ieee754_64bit The value to be converted.

Returns:

The key buffer.


function key_from [7/13]

Makes a comparable key from a double IEEE754 value by a pointer.

static inline buffer mdbx::buffer::key_from (
    const double * ieee754_64bit
) 

Parameters:

  • ieee754_64bit The address of the value to be converted.

Returns:

The key buffer.


function key_from [8/13]

Makes a comparable key from an unsigned uint64_t value.

static inline buffer mdbx::buffer::key_from (
    const uint64_t unsigned_int64
) 

Parameters:

  • unsigned_int64 The value to be wrapped.

Returns:

The key buffer.


function key_from [9/13]

Makes a comparable key from a signed int64_t value.

static inline buffer mdbx::buffer::key_from (
    const int64_t signed_int64
) 

Parameters:

  • signed_int64 The value to be converted.

Returns:

The key buffer.


function key_from [10/13]

Makes a comparable key from a float IEEE754 value.

static inline buffer mdbx::buffer::key_from (
    const float ieee754_32bit
) 

Parameters:

  • ieee754_32bit The value to be converted.

Returns:

The key buffer.


function key_from [11/13]

Makes a comparable key from a float IEEE754 value by a pointer.

static inline buffer mdbx::buffer::key_from (
    const float * ieee754_32bit
) 

Parameters:

  • ieee754_32bit The address of the value to be converted.

Returns:

The key buffer.


function key_from [12/13]

Makes a comparable key from an unsigned uint32_t value.

static inline buffer mdbx::buffer::key_from (
    const uint32_t unsigned_int32
) 

Parameters:

  • unsigned_int32 The value to be wrapped.

Returns:

The key buffer.


function key_from [13/13]

Makes a comparable key from a signed int32_t value.

static inline buffer mdbx::buffer::key_from (
    const int32_t signed_int32
) 

Parameters:

  • signed_int32 The value to be converted.

Returns:

The key buffer.


function key_from_double

Makes a comparable key from a double IEEE754 value.

static inline buffer mdbx::buffer::key_from_double (
    const double ieee754_64bit
) 

Parameters:

  • ieee754_64bit The value to be converted.

Returns:

The key buffer.


function key_from_float

Makes a comparable key from a float IEEE754 value.

static inline buffer mdbx::buffer::key_from_float (
    const float ieee754_32bit
) 

Parameters:

  • ieee754_32bit The value to be converted.

Returns:

The key buffer.


function key_from_i32

Makes a comparable key from a signed int32_t value.

static inline buffer mdbx::buffer::key_from_i32 (
    const int32_t signed_int32
) 

Parameters:

  • signed_int32 The value to be converted.

Returns:

The key buffer.


function key_from_i64

Makes a comparable key from a signed int64_t value.

static inline buffer mdbx::buffer::key_from_i64 (
    const int64_t signed_int64
) 

Parameters:

  • signed_int64 The value to be converted.

Returns:

The key buffer.


function key_from_jsonInteger

Makes a comparable key from a signed int64_t JSON-number value.

static inline buffer mdbx::buffer::key_from_jsonInteger (
    const int64_t json_integer
) 

Parameters:

  • json_integer The value to be converted.

Returns:

The key buffer, comparable with keys from double values.


function key_from_u32

Makes a comparable key from an unsigned uint32_t value.

static inline buffer mdbx::buffer::key_from_u32 (
    const uint32_t unsigned_int32
) 

Parameters:

  • unsigned_int32 The value to be wrapped.

Returns:

The key buffer.


function key_from_u64

Makes a comparable key from an unsigned uint64_t value.

static inline buffer mdbx::buffer::key_from_u64 (
    const uint64_t unsigned_int64
) 

Parameters:

  • unsigned_int64 The value to be wrapped.

Returns:

The key buffer.


function null

Build a null buffer which zero length and refers to null address.

static inline buffer mdbx::buffer::null () noexcept

Returns:

The null buffer instance.


function wrap

Wraps an object of a standard-layout type into a buffer.

template<typename POD>
static inline buffer mdbx::buffer::wrap (
    const POD & pod,
    bool make_reference=false,
    const allocator_type & alloc=allocator_type ()
) 

Parameters:

  • pod The object to be wrapped.
  • make_reference Make the buffer a reference to the object instead of copying it.
  • alloc The allocator for the buffer storage.

Returns:

The buffer wrapping the object.


Friends Documentation

friend swap [1/2]

Swaps two buffers (the ADL-friendly free function).

inline friend void mdbx::buffer::swap (
    buffer & left,
    buffer & right
) 

Parameters:

  • left The left-hand buffer.
  • right The right-hand buffer.


The documentation for this class was generated from the following file mdbx.h++