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 @175231100024041331274340016225030343010210334250
typedef ::std::allocator_traits< allocator_type > allocator_traits
typedef typename ::std::allocator_traits< ALLOCATOR >::template rebind_alloc< uint64_t > allocator_type
typedef typename silo::copy_assign_alloc copy_assign_alloc
typedef slice inherited
enum modality
Data storage modality.
typedef typename silo::move_assign_alloc move_assign_alloc
typedef CAPACITY_POLICY reservation_policy
typedef typename silo::swap_alloc swap_alloc

Public Types inherited from mdbx::slice

See mdbx::slice

Type Name
enum size_t @257333234016247237045177161061253053363217153027

Public Functions

Type Name
buffer & add_header (const void * src, size_t bytes)
buffer & add_header (const struct slice & chunk)
buffer & append (const ::std::basic_string_view< CHAR, T > & view)
buffer & append (const ::std::basic_string< CHAR, T, A > & str)
buffer & append (const void * src, size_t bytes)
buffer & append (const byte c)
buffer & append (const struct slice & chunk)
buffer & append_base58 (const struct slice & data, unsigned wrap_width=0)
buffer & append_base64 (const struct slice & data, unsigned wrap_width=0)
buffer & append_byte (uint_fast8_t byte)
buffer & append_decoded_base58 (const struct slice & data, bool ignore_spaces=false)
buffer & append_decoded_base64 (const struct slice & data, bool ignore_spaces=false)
buffer & append_decoded_hex (const struct slice & data, bool ignore_spaces=false)
buffer & append_hex (const struct slice & data, bool uppercase=false, unsigned wrap_width=0)
buffer & append_producer (PRODUCER & producer)
buffer & append_producer (const PRODUCER & producer)
buffer & append_u16 (uint_fast16_t u16)
buffer & append_u24 (uint_fast32_t u24)
buffer & append_u32 (uint_fast32_t u32)
buffer & append_u48 (uint_fast64_t u48)
buffer & append_u64 (uint_fast64_t u64)
buffer & append_u8 (uint_fast8_t u8)
buffer & assign (size_t headroom, const buffer & src, size_t tailroom)
buffer & assign (const buffer & src, bool make_reference=false)
buffer & assign (buffer && src)
buffer & assign (const void * ptr, size_t bytes, bool make_reference=false)
buffer & assign (const struct slice & src, bool make_reference=false)
buffer & assign (const ::MDBX_val & src, bool make_reference=false)
buffer & assign (struct slice && src, bool make_reference=false)
buffer & assign (::MDBX_val && src, bool make_reference=false)
buffer & assign (const void * begin, const void * end, bool make_reference=false)
buffer & assign (const ::std::basic_string< CHAR, T, A > & str, bool make_reference=false)
buffer & assign (const char * c_str, bool make_reference=false)
buffer & assign_freestanding (const void * ptr, size_t bytes)
buffer & assign_reference (const void * ptr, size_t bytes)
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
constexpr buffer (const allocator_type & alloc) noexcept
constexpr buffer (const void * ptr, size_t bytes, bool make_reference, const allocator_type & alloc=allocator_type())
buffer (const char * c_str, bool make_reference, const allocator_type & alloc=allocator_type())
constexpr buffer (const ::std::basic_string_view< CHAR, T > & view, bool make_reference, const allocator_type & alloc=allocator_type())
constexpr buffer (const struct slice & src, const allocator_type & alloc=allocator_type())
constexpr buffer (const buffer & src)
constexpr buffer (const void * ptr, size_t bytes, const allocator_type & alloc=allocator_type())
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 ::std::basic_string< CHAR, T, A > && str, const allocator_type & alloc=allocator_type())
Move-constructs a buffer stealing the string's storage; the source string is left empty. Safe with temporaries (e.g. buffer(std::to_string(k)) ) since the storage ownership is transferred within the same full-expression.
constexpr buffer (const char * c_str, const allocator_type & alloc=allocator_type())
constexpr buffer (const ::std::basic_string_view< CHAR, T > & view, const allocator_type & alloc=allocator_type())
buffer (size_t head_room, size_t tail_room, const allocator_type & alloc=allocator_type())
buffer (size_t capacity, const allocator_type & alloc=allocator_type())
buffer (size_t head_room, const slice & src, size_t tail_room, const allocator_type & alloc=allocator_type())
buffer (const txn & transaction, const slice & src, const allocator_type & alloc=allocator_type())
buffer (buffer && src)
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
constexpr basic_string () const
buffer & operator= (const buffer & src)
buffer & operator= (buffer && src)
buffer & operator= (const struct slice & src)
buffer & operator= (struct slice && src)
buffer & operator= (const ::std::basic_string_view< CHAR, T > & view) noexcept
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
void swap (buffer & other)
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
int128_t as_int128_adapt () const
int16_t as_int16 () const
int16_t as_int16_adapt () const
int32_t as_int32 () const
int32_t as_int32_adapt () const
int64_t as_int64 () const
int64_t as_int64_adapt () const
int8_t as_int8 () const
int8_t as_int8_adapt () const
POD as_pod () const
::std::span< const POD > as_span () const
::std::span< POD > as_span ()
::std::basic_string< CHAR, T, ALLOCATOR > as_string (const ALLOCATOR & alloc=ALLOCATOR()) const
uint128_t as_uint128 () const
uint128_t as_uint128_adapt () const
uint16_t as_uint16 () const
uint16_t as_uint16_adapt () const
uint32_t as_uint32 () const
uint32_t as_uint32_adapt () const
uint64_t as_uint64 () const
uint64_t as_uint64_adapt () const
uint8_t as_uint8 () const
uint8_t as_uint8_adapt () const
slice & assign (const ::std::basic_string< CHAR, T, ALLOCATOR > & str)
slice & assign (const ::std::basic_string_view< CHAR, T > & view)
slice & assign (::std::basic_string_view< CHAR, T > && view)
byte back () noexcept const
Returns the last byte of the referenced data.
::std::span< const byte > bytes () const
::std::span< byte > bytes ()
::std::span< const char > chars () const
::std::span< char > chars ()
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
operator const MDBX_val * () noexcept const
constexpr basic_string () const
constexpr basic_string_view () noexcept const
Return a string_view that references the same data as this slice.
slice & operator= (const slice &) noexcept
slice & operator= (const ::std::basic_string_view< CHAR, T > & view)
slice & operator= (::std::basic_string_view< CHAR, T > && view)
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 &) noexcept
constexpr slice (const ::std::span< POD > & 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)
::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
void swap (slice & other) noexcept

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())
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
buffer key_from (const char(&) text, bool make_reference=true)
buffer key_from (const ::std::basic_string_view< CHAR, T > & src, bool make_reference=false)
buffer key_from (const char * src, bool make_reference=false)
buffer key_from (const ::std::basic_string< CHAR, T, A > & src, bool make_reference=false)
buffer key_from (buffer && src) noexcept
buffer key_from (const double ieee754_64bit)
buffer key_from (const double * ieee754_64bit)
buffer key_from (const uint64_t unsigned_int64)
buffer key_from (const int64_t signed_int64)
buffer key_from (const float ieee754_32bit)
buffer key_from (const float * ieee754_32bit)
buffer key_from (const uint32_t unsigned_int32)
buffer key_from (const int32_t signed_int32)
buffer key_from_double (const double ieee754_64bit)
buffer key_from_float (const float ieee754_32bit)
buffer key_from_i32 (const int32_t signed_int32)
buffer key_from_i64 (const int64_t signed_int64)
buffer key_from_jsonInteger (const int64_t json_integer)
buffer key_from_u32 (const uint32_t unsigned_int32)
buffer key_from_u64 (const uint64_t unsigned_int64)
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())

Public Static Functions inherited from mdbx::slice

See mdbx::slice

Type Name
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)
slice wrap (const POD & pod)

Protected Functions inherited from mdbx::slice

See mdbx::slice

Type Name
constexpr slice (size_t invalid_length) noexcept

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 @175231100024041331274340016225030343010210334250

enum mdbx::buffer::@175231100024041331274340016225030343010210334250 {
    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

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

typedef allocator_type

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

typedef copy_assign_alloc

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

typedef inherited

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

enum modality

Data storage modality.

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

typedef move_assign_alloc

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

typedef reservation_policy

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

typedef swap_alloc

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

Public Functions Documentation

function add_header [1/2]

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

function add_header [2/2]

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

function append [1/5]

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

function append [2/5]

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

function append [3/5]

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

function append [4/5]

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

function append [5/5]

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

function append_base58

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

function append_base64

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

function append_byte

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

function append_decoded_base58

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

function append_decoded_base64

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

function append_decoded_hex

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

function append_hex

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

function append_producer [1/2]

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

function append_producer [2/2]

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

function append_u16

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

function append_u24

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

function append_u32

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

function append_u48

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

function append_u64

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

function append_u8

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

function assign [1/11]

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

function assign [2/11]

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

function assign [3/11]

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

function assign [4/11]

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

function assign [5/11]

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

function assign [6/11]

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

function assign [7/11]

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

function assign [8/11]

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

function assign [9/11]

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

function assign [10/11]

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

function assign [11/11]

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

function assign_freestanding

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

function assign_reference

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

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

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

function buffer [1/18]

constexpr mdbx::buffer::buffer () noexcept

function buffer [2/18]

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

function buffer [3/18]

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

function buffer [4/18]

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

function buffer [5/18]

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 ()
) 

function buffer [6/18]

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

function buffer [7/18]

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

function buffer [8/18]

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

function buffer [9/18]

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 ()
) 

function buffer [10/18]

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 ()
) 

function buffer [11/18]

Move-constructs a buffer stealing the string's storage; the source string is left empty. Safe with temporaries (e.g. buffer(std::to_string(k)) ) since the storage ownership is transferred within the same full-expression.

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 ()
) 

function buffer [12/18]

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

function buffer [13/18]

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

function buffer [14/18]

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

function buffer [15/18]

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

function buffer [16/18]

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

function buffer [17/18]

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

function buffer [18/18]

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

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

function byte_ptr [2/2]

Returns casted to pointer to byte an address of data.

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

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

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

function char_ptr [2/2]

Returns casted to pointer to char an address of data.

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

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
) 

function const_data

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

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

function const_end

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

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

function content_modality

Returns current modality of buffer content.

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

function data [1/2]

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

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

function data [2/2]

Return a pointer to the beginning of the referenced data.

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

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

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

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

function end [1/2]

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

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

function end [2/2]

Return a pointer to the end of the referenced data.

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

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

function end_byte_ptr [2/2]

Returns casted to pointer to byte an end of data.

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

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

function end_char_ptr [2/2]

Returns casted to pointer to char an end of data.

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

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

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

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

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

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

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

function length

Returns the number of bytes.

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

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

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

function basic_string

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

function operator=

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

function operator=

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

function operator=

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

function operator=

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

function operator=

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

function reserve [1/2]

Reserves storage space.

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

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
) 

function reserve_headroom

Reserves space before the payload.

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

function reserve_tailroom

Reserves space after the payload.

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

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
) 

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
) 

function set_end

Sets the length by specifying the end of the data.

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

function set_length

Set length of data.

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

function shrink_to_fit

Reduces memory usage by freeing unused storage space.

inline void mdbx::buffer::shrink_to_fit () 

function slice

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

function swap [2/2]

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

function tailroom

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

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

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 ()
) 

function base58 [2/2]

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

template<typename POD>
static inline buffer mdbx::buffer::base58 (
    const POD & pod,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

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 ()
) 

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 ()
) 

function base64 [2/2]

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

template<typename POD>
static inline buffer mdbx::buffer::base64 (
    const POD & pod,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

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 ()
) 

function clone

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

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 ()
) 

function hex [2/2]

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

template<typename POD>
static inline buffer mdbx::buffer::hex (
    const POD & pod,
    bool uppercase=false,
    unsigned wrap_width=0,
    const allocator_type & alloc=allocator_type ()
) 

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 ()
) 

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

function is_swap_nothrow

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

function key_from [1/13]

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

function key_from [2/13]

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

function key_from [3/13]

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

function key_from [4/13]

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
) 

function key_from [5/13]

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

function key_from [6/13]

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

function key_from [7/13]

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

function key_from [8/13]

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

function key_from [9/13]

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

function key_from [10/13]

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

function key_from [11/13]

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

function key_from [12/13]

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

function key_from [13/13]

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

function key_from_double

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

function key_from_float

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

function key_from_i32

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

function key_from_i64

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

function key_from_jsonInteger

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

function key_from_u32

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

function key_from_u64

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

function null

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

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

function wrap

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

Friends Documentation

friend swap [1/2]

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


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