libmdbx  0.11.6.39 (2022-04-13T11:05:50+03:00)
One of the fastest compact embeddable key-value ACID database without WAL.
mdbx::slice Struct Reference

References a data located outside the slice. More...

#include <mdbx.h++>

Inherits MDBX_val.

Public Types

enum  { max_length = MDBX_MAXDATASIZE }
 

Public Member Functions

MDBX_CXX11_CONSTEXPR slice () noexcept
 Create an empty slice. More...
 
MDBX_CXX14_CONSTEXPR slice (const void *ptr, size_t bytes)
 Create a slice that refers to [0,bytes-1] of memory bytes pointed by ptr. More...
 
MDBX_CXX14_CONSTEXPR slice (const void *begin, const void *end)
 Create a slice that refers to [begin,end] of memory bytes. More...
 
template<size_t SIZE>
MDBX_CXX14_CONSTEXPR slice (const char(&text)[SIZE])
 Create a slice that refers to text[0,strlen(text)-1]. More...
 
MDBX_CXX17_CONSTEXPR slice (const char *c_str)
 Create a slice that refers to c_str[0,strlen(c_str)-1]. More...
 
template<class CHAR , class T , class A >
MDBX_CXX20_CONSTEXPR slice (const ::std::basic_string< CHAR, T, A > &str)
 Create a slice that refers to the contents of "str". More...
 
MDBX_CXX14_CONSTEXPR slice (const MDBX_val &src)
 
MDBX_CXX11_CONSTEXPR slice (const slice &) noexcept=default
 
MDBX_CXX14_CONSTEXPR slice (MDBX_val &&src)
 
MDBX_CXX14_CONSTEXPR slice (slice &&src) noexcept
 
template<class CHAR , class T >
MDBX_CXX14_CONSTEXPR slice (const ::std::basic_string_view< CHAR, T > &sv)
 Create a slice that refers to the same contents as "string_view". More...
 
template<class CHAR , class T >
 slice (::std::basic_string_view< CHAR, T > &&sv)
 
sliceassign (const void *ptr, size_t bytes)
 
sliceassign (const slice &src) noexcept
 
sliceassign (const ::MDBX_val &src)
 
sliceassign (slice &&src) noexcept
 
sliceassign (::MDBX_val &&src)
 
sliceassign (const void *begin, const void *end)
 
template<class CHAR , class T , class ALLOCATOR >
sliceassign (const ::std::basic_string< CHAR, T, ALLOCATOR > &str)
 
sliceassign (const char *c_str)
 
template<class CHAR , class T >
sliceassign (const ::std::basic_string_view< CHAR, T > &view)
 
template<class CHAR , class T >
sliceassign (::std::basic_string_view< CHAR, T > &&view)
 
sliceoperator= (const slice &) noexcept=default
 
sliceoperator= (slice &&src) noexcept
 
sliceoperator= (::MDBX_val &&src)
 
template<class CHAR , class T >
sliceoperator= (const ::std::basic_string_view< CHAR, T > &view)
 
template<class CHAR , class T >
sliceoperator= (::std::basic_string_view< CHAR, T > &&view)
 
template<class CHAR = char, class T = ::std::char_traits<CHAR>>
MDBX_CXX11_CONSTEXPR ::std::basic_string_view< CHAR, T > string_view () const noexcept
 Return a string_view that references the same data as this slice. More...
 
template<class CHAR , class T >
MDBX_CXX11_CONSTEXPR operator::std::basic_string_view () const noexcept
 Return a string_view that references the same data as this slice. More...
 
template<class CHAR = char, class T = ::std::char_traits<CHAR>, class ALLOCATOR = legacy_allocator>
MDBX_CXX20_CONSTEXPR ::std::basic_string< CHAR, T, ALLOCATOR > as_string (const ALLOCATOR &allocator=ALLOCATOR()) const
 
template<class CHAR , class T , class ALLOCATOR >
MDBX_CXX20_CONSTEXPR operator::std::basic_string () const
 
template<class ALLOCATOR = legacy_allocator>
string< ALLOCATOR > as_hex_string (bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a string with a hexadecimal dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator>
string< ALLOCATOR > as_base58_string (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a string with a Base58 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator>
string< ALLOCATOR > as_base64_string (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a string with a Base58 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > encode_hex (bool uppercase=false, unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a buffer with a hexadecimal dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > encode_base58 (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a buffer with a Base58 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > encode_base64 (unsigned wrap_width=0, const ALLOCATOR &allocator=ALLOCATOR()) const
 Returns a buffer with a Base64 dump of the slice content. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > hex_decode (bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
 Decodes hexadecimal dump from the slice content to returned buffer. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > base58_decode (bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
 Decodes Base58 dump from the slice content to returned buffer. More...
 
template<class ALLOCATOR = legacy_allocator, class CAPACITY_POLICY = default_capacity_policy>
buffer< ALLOCATOR, CAPACITY_POLICY > base64_decode (bool ignore_spaces=false, const ALLOCATOR &allocator=ALLOCATOR()) const
 Decodes Base64 dump from the slice content to returned buffer. More...
 
MDBX_NOTHROW_PURE_FUNCTION bool is_printable (bool disable_utf8=false) const noexcept
 Checks whether the content of the slice is printable. More...
 
MDBX_NOTHROW_PURE_FUNCTION bool is_hex (bool ignore_spaces=false) const noexcept
 Checks whether the content of the slice is a hexadecimal dump. More...
 
MDBX_NOTHROW_PURE_FUNCTION bool is_base58 (bool ignore_spaces=false) const noexcept
 Checks whether the content of the slice is a Base58 dump. More...
 
MDBX_NOTHROW_PURE_FUNCTION bool is_base64 (bool ignore_spaces=false) const noexcept
 Checks whether the content of the slice is a Base64 dump. More...
 
void swap (slice &other) noexcept
 
template<class CHAR , class T >
void swap (::std::basic_string_view< CHAR, T > &view) noexcept
 
const MDBX_CXX11_CONSTEXPR bytebyte_ptr () const noexcept
 Returns casted to pointer to byte an address of data. More...
 
MDBX_CXX11_CONSTEXPR bytebyte_ptr () noexcept
 
const MDBX_CXX11_CONSTEXPR byteend_byte_ptr () const noexcept
 Returns casted to pointer to byte an end of data. More...
 
MDBX_CXX11_CONSTEXPR byteend_byte_ptr () noexcept
 
const MDBX_CXX11_CONSTEXPR char * char_ptr () const noexcept
 Returns casted to pointer to char an address of data. More...
 
MDBX_CXX11_CONSTEXPR char * char_ptr () noexcept
 
const MDBX_CXX11_CONSTEXPR char * end_char_ptr () const noexcept
 Returns casted to pointer to char an end of data. More...
 
MDBX_CXX11_CONSTEXPR char * end_char_ptr () noexcept
 
const MDBX_CXX11_CONSTEXPR void * data () const noexcept
 Return a pointer to the beginning of the referenced data. More...
 
MDBX_CXX11_CONSTEXPR void * data () noexcept
 
const MDBX_CXX11_CONSTEXPR void * end () const noexcept
 Return a pointer to the ending of the referenced data. More...
 
MDBX_CXX11_CONSTEXPR void * end () noexcept
 
MDBX_CXX11_CONSTEXPR size_t length () const noexcept
 Returns the number of bytes. More...
 
MDBX_CXX14_CONSTEXPR sliceset_length (size_t bytes)
 Set slice length. More...
 
MDBX_CXX14_CONSTEXPR sliceset_end (const void *ptr)
 Sets the length by specifying the end of the slice data. More...
 
MDBX_CXX11_CONSTEXPR bool empty () const noexcept
 Checks whether the slice is empty. More...
 
MDBX_CXX11_CONSTEXPR bool is_null () const noexcept
 Checks whether the slice data pointer is nullptr. More...
 
MDBX_CXX11_CONSTEXPR size_t size () const noexcept
 Returns the number of bytes. More...
 
MDBX_CXX11_CONSTEXPR operator bool () const noexcept
 Returns true if slice is not empty. More...
 
MDBX_CXX14_CONSTEXPR void invalidate () noexcept
 Depletes content of slice and make it invalid. More...
 
MDBX_CXX14_CONSTEXPR void clear () noexcept
 Makes the slice empty and referencing to nothing. More...
 
void remove_prefix (size_t n) noexcept
 Drops the first "n" bytes from this slice. More...
 
void remove_suffix (size_t n) noexcept
 Drops the last "n" bytes from this slice. More...
 
void safe_remove_prefix (size_t n)
 Drops the first "n" bytes from this slice. More...
 
void safe_remove_suffix (size_t n)
 Drops the last "n" bytes from this slice. More...
 
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool starts_with (const slice &prefix) const noexcept
 Checks if the data starts with the given prefix. More...
 
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR bool ends_with (const slice &suffix) const noexcept
 Checks if the data ends with the given suffix. More...
 
MDBX_CXX11_CONSTEXPR byte operator[] (size_t n) const noexcept
 Returns the nth byte in the referenced data. More...
 
MDBX_CXX11_CONSTEXPR byte at (size_t n) const
 Returns the nth byte in the referenced data with bounds checking. More...
 
MDBX_CXX14_CONSTEXPR slice head (size_t n) const noexcept
 Returns the first "n" bytes of the slice. More...
 
MDBX_CXX14_CONSTEXPR slice tail (size_t n) const noexcept
 Returns the last "n" bytes of the slice. More...
 
MDBX_CXX14_CONSTEXPR slice middle (size_t from, size_t n) const noexcept
 Returns the middle "n" bytes of the slice. More...
 
MDBX_CXX14_CONSTEXPR slice safe_head (size_t n) const
 Returns the first "n" bytes of the slice. More...
 
MDBX_CXX14_CONSTEXPR slice safe_tail (size_t n) const
 Returns the last "n" bytes of the slice. More...
 
MDBX_CXX14_CONSTEXPR slice safe_middle (size_t from, size_t n) const
 Returns the middle "n" bytes of the slice. More...
 
MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR size_t hash_value () const noexcept
 Returns the hash value of referenced data. More...
 
MDBX_CXX11_CONSTEXPR bool is_valid () const noexcept
 Checks the slice is not refers to null address or has zero length. More...
 

Static Public Member Functions

template<size_t SIZE>
static MDBX_CXX14_CONSTEXPR slice wrap (const char(&text)[SIZE])
 
template<typename POD >
static MDBX_CXX14_CONSTEXPR slice wrap (const POD &pod)
 
static MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR intptr_t compare_fast (const slice &a, const slice &b) noexcept
 Three-way fast non-lexicographically length-based comparison. More...
 
static MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR intptr_t compare_lexicographically (const slice &a, const slice &b) noexcept
 Three-way lexicographically comparison. More...
 
static MDBX_CXX14_CONSTEXPR slice invalid () noexcept
 Build an invalid slice which non-zero length and refers to null address. More...
 

Protected Member Functions

MDBX_CXX11_CONSTEXPR slice (size_t invalid_length) noexcept
 

Friends

MDBX_CXX14_CONSTEXPR bool operator== (const slice &a, const slice &b) noexcept
 
MDBX_CXX14_CONSTEXPR bool operator< (const slice &a, const slice &b) noexcept
 
MDBX_CXX14_CONSTEXPR bool operator> (const slice &a, const slice &b) noexcept
 
MDBX_CXX14_CONSTEXPR bool operator<= (const slice &a, const slice &b) noexcept
 
MDBX_CXX14_CONSTEXPR bool operator>= (const slice &a, const slice &b) noexcept
 
MDBX_CXX14_CONSTEXPR bool operator!= (const slice &a, const slice &b) noexcept
 

Detailed Description

References a data located outside the slice.

The slice is similar in many ways to std::string_view, but it implements specific capabilities and manipulates with bytes but not a characters.

See also
mdbx::slice
mdbx::buffer

Values returned from the database are valid only until a subsequent update operation, or the end of the transaction. Do not modify or free them, they commonly point into the database itself.

Key sizes must be between 0 and mdbx_env_get_maxkeysize() inclusive. The same applies to data sizes in databases with the MDBX_DUPSORT flag. Other data items can in theory be from 0 to MDBX_MAXDATASIZE bytes long.

Note
The notable difference between MDBX and LMDB is that MDBX support zero length keys.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
Enumerator
max_length 

Constructor & Destructor Documentation

◆ slice() [1/13]

MDBX_CXX11_CONSTEXPR mdbx::slice::slice ( )
noexcept

Create an empty slice.

◆ slice() [2/13]

MDBX_CXX14_CONSTEXPR mdbx::slice::slice ( const void *  ptr,
size_t  bytes 
)

Create a slice that refers to [0,bytes-1] of memory bytes pointed by ptr.

◆ slice() [3/13]

MDBX_CXX14_CONSTEXPR mdbx::slice::slice ( const void *  begin,
const void *  end 
)

Create a slice that refers to [begin,end] of memory bytes.

◆ slice() [4/13]

template<size_t SIZE>
MDBX_CXX14_CONSTEXPR mdbx::slice::slice ( const char(&)  text[SIZE])
inline

Create a slice that refers to text[0,strlen(text)-1].

◆ slice() [5/13]

MDBX_CXX17_CONSTEXPR mdbx::slice::slice ( const char *  c_str)
explicit

Create a slice that refers to c_str[0,strlen(c_str)-1].

◆ slice() [6/13]

template<class CHAR , class T , class A >
MDBX_CXX20_CONSTEXPR mdbx::slice::slice ( const ::std::basic_string< CHAR, T, A > &  str)
inlineexplicit

Create a slice that refers to the contents of "str".

Note
'explicit' to avoid reference to the temporary std::string instance.

◆ slice() [7/13]

MDBX_CXX14_CONSTEXPR mdbx::slice::slice ( const MDBX_val src)

◆ slice() [8/13]

MDBX_CXX11_CONSTEXPR mdbx::slice::slice ( const slice )
defaultnoexcept

◆ slice() [9/13]

MDBX_CXX14_CONSTEXPR mdbx::slice::slice ( MDBX_val &&  src)

◆ slice() [10/13]

MDBX_CXX14_CONSTEXPR mdbx::slice::slice ( slice &&  src)
noexcept

◆ slice() [11/13]

template<class CHAR , class T >
MDBX_CXX14_CONSTEXPR mdbx::slice::slice ( const ::std::basic_string_view< CHAR, T > &  sv)
inline

Create a slice that refers to the same contents as "string_view".

◆ slice() [12/13]

template<class CHAR , class T >
mdbx::slice::slice ( ::std::basic_string_view< CHAR, T > &&  sv)
inline

◆ slice() [13/13]

MDBX_CXX11_CONSTEXPR mdbx::slice::slice ( size_t  invalid_length)
inlineprotectednoexcept

Member Function Documentation

◆ as_base58_string()

template<class ALLOCATOR >
string< ALLOCATOR > mdbx::slice::as_base58_string ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a string with a Base58 dump of the slice content.

◆ as_base64_string()

template<class ALLOCATOR >
string< ALLOCATOR > mdbx::slice::as_base64_string ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a string with a Base58 dump of the slice content.

◆ as_hex_string()

template<class ALLOCATOR >
string< ALLOCATOR > mdbx::slice::as_hex_string ( bool  uppercase = false,
unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Returns a string with a hexadecimal dump of the slice content.

◆ as_string()

template<class CHAR = char, class T = ::std::char_traits<CHAR>, class ALLOCATOR = legacy_allocator>
MDBX_CXX20_CONSTEXPR ::std::basic_string<CHAR, T, ALLOCATOR> mdbx::slice::as_string ( const ALLOCATOR &  allocator = ALLOCATOR()) const
inline

◆ assign() [1/10]

slice & mdbx::slice::assign ( ::MDBX_val &&  src)
inline

◆ assign() [2/10]

template<class CHAR , class T >
slice& mdbx::slice::assign ( ::std::basic_string_view< CHAR, T > &&  view)
inline

◆ assign() [3/10]

slice & mdbx::slice::assign ( const ::MDBX_val src)
inline

◆ assign() [4/10]

template<class CHAR , class T , class ALLOCATOR >
slice& mdbx::slice::assign ( const ::std::basic_string< CHAR, T, ALLOCATOR > &  str)
inline

◆ assign() [5/10]

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

◆ assign() [6/10]

slice & mdbx::slice::assign ( const char *  c_str)
inline

◆ assign() [7/10]

slice & mdbx::slice::assign ( const slice src)
inlinenoexcept

◆ assign() [8/10]

slice & mdbx::slice::assign ( const void *  begin,
const void *  end 
)
inline

◆ assign() [9/10]

slice & mdbx::slice::assign ( const void *  ptr,
size_t  bytes 
)
inline

◆ assign() [10/10]

slice & mdbx::slice::assign ( slice &&  src)
inlinenoexcept

◆ at()

MDBX_CXX11_CONSTEXPR byte mdbx::slice::at ( size_t  n) const

Returns the nth byte in the referenced data with bounds checking.

Exceptions
std::out_of_rangeif n >= size()

◆ base58_decode()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::base58_decode ( bool  ignore_spaces = false,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Decodes Base58 dump from the slice content to returned buffer.

◆ base64_decode()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::base64_decode ( bool  ignore_spaces = false,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Decodes Base64 dump from the slice content to returned buffer.

◆ byte_ptr() [1/2]

MDBX_CXX11_CONSTEXPR::mdbx::byte * mdbx::slice::byte_ptr ( ) const
noexcept

Returns casted to pointer to byte an address of data.

◆ byte_ptr() [2/2]

MDBX_CXX11_CONSTEXPR byte* mdbx::slice::byte_ptr ( )
noexcept

◆ char_ptr() [1/2]

MDBX_CXX11_CONSTEXPR char * mdbx::slice::char_ptr ( ) const
noexcept

Returns casted to pointer to char an address of data.

◆ char_ptr() [2/2]

MDBX_CXX11_CONSTEXPR char* mdbx::slice::char_ptr ( )
noexcept

◆ clear()

MDBX_CXX14_CONSTEXPR void mdbx::slice::clear ( )
noexcept

Makes the slice empty and referencing to nothing.

◆ compare_fast()

MDBX_CXX14_CONSTEXPR intptr_t mdbx::slice::compare_fast ( const slice a,
const slice b 
)
staticnoexcept

Three-way fast non-lexicographically length-based comparison.

Returns
value: == 0 if "a" == "b", < 0 if "a" shorter than "b",

0 if "a" longer than "b",

< 0 if "a" length-equal and lexicographically less than "b",

0 if "a" length-equal and lexicographically great than "b".

◆ compare_lexicographically()

MDBX_CXX14_CONSTEXPR intptr_t mdbx::slice::compare_lexicographically ( const slice a,
const slice b 
)
staticnoexcept

Three-way lexicographically comparison.

Returns
value: < 0 if "a" < "b", == 0 if "a" == "b",

0 if "a" > "b".

◆ data() [1/2]

MDBX_CXX11_CONSTEXPR void * mdbx::slice::data ( ) const
noexcept

Return a pointer to the beginning of the referenced data.

◆ data() [2/2]

MDBX_CXX11_CONSTEXPR void* mdbx::slice::data ( )
noexcept

◆ empty()

MDBX_CXX11_CONSTEXPR bool mdbx::slice::empty ( ) const
noexcept

Checks whether the slice is empty.

◆ encode_base58()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_base58 ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

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

◆ encode_base64()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_base64 ( unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

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

◆ encode_hex()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::encode_hex ( bool  uppercase = false,
unsigned  wrap_width = 0,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

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

◆ end() [1/2]

MDBX_CXX11_CONSTEXPR void * mdbx::slice::end ( ) const
noexcept

Return a pointer to the ending of the referenced data.

◆ end() [2/2]

MDBX_CXX11_CONSTEXPR void* mdbx::slice::end ( )
noexcept

◆ end_byte_ptr() [1/2]

MDBX_CXX11_CONSTEXPR::mdbx::byte * mdbx::slice::end_byte_ptr ( ) const
noexcept

Returns casted to pointer to byte an end of data.

◆ end_byte_ptr() [2/2]

MDBX_CXX11_CONSTEXPR byte* mdbx::slice::end_byte_ptr ( )
noexcept

◆ end_char_ptr() [1/2]

MDBX_CXX11_CONSTEXPR char * mdbx::slice::end_char_ptr ( ) const
noexcept

Returns casted to pointer to char an end of data.

◆ end_char_ptr() [2/2]

MDBX_CXX11_CONSTEXPR char* mdbx::slice::end_char_ptr ( )
noexcept

◆ ends_with()

MDBX_CXX14_CONSTEXPR bool mdbx::slice::ends_with ( const slice suffix) const
noexcept

Checks if the data ends with the given suffix.

◆ hash_value()

MDBX_NOTHROW_PURE_FUNCTION MDBX_CXX14_CONSTEXPR size_t mdbx::slice::hash_value ( ) const
noexcept

Returns the hash value of referenced data.

Attention
Function implementation and returned hash values may changed version to version, and in future the t1ha3 will be used here. Therefore values obtained from this function shouldn't be persisted anywhere.

◆ head()

MDBX_CXX14_CONSTEXPR slice mdbx::slice::head ( size_t  n) const
noexcept

Returns the first "n" bytes of the slice.

Precondition
REQUIRES: n <= size()

◆ hex_decode()

template<class ALLOCATOR , class CAPACITY_POLICY >
buffer< ALLOCATOR, CAPACITY_POLICY > mdbx::slice::hex_decode ( bool  ignore_spaces = false,
const ALLOCATOR &  allocator = ALLOCATOR() 
) const
inline

Decodes hexadecimal dump from the slice content to returned buffer.

◆ invalid()

static MDBX_CXX14_CONSTEXPR slice mdbx::slice::invalid ( )
inlinestaticnoexcept

Build an invalid slice which non-zero length and refers to null address.

◆ invalidate()

MDBX_CXX14_CONSTEXPR void mdbx::slice::invalidate ( )
noexcept

Depletes content of slice and make it invalid.

◆ is_base58()

MDBX_NOTHROW_PURE_FUNCTION bool mdbx::slice::is_base58 ( bool  ignore_spaces = false) const
inlinenoexcept

Checks whether the content of the slice is a Base58 dump.

Parameters
[in]ignore_spacesIf true function will skips spaces surrounding (before, between and after) a encoded bytes. However, spaces should not break a code group of characters.

◆ is_base64()

MDBX_NOTHROW_PURE_FUNCTION bool mdbx::slice::is_base64 ( bool  ignore_spaces = false) const
inlinenoexcept

Checks whether the content of the slice is a Base64 dump.

Parameters
[in]ignore_spacesIf true function will skips spaces surrounding (before, between and after) a encoded bytes. However, spaces should not break a code group of characters.

◆ is_hex()

MDBX_NOTHROW_PURE_FUNCTION bool mdbx::slice::is_hex ( bool  ignore_spaces = false) const
inlinenoexcept

Checks whether the content of the slice is a hexadecimal dump.

Parameters
[in]ignore_spacesIf true function will skips spaces surrounding (before, between and after) a encoded bytes. However, spaces should not break a pair of characters encoding a single byte.

◆ is_null()

MDBX_CXX11_CONSTEXPR bool mdbx::slice::is_null ( ) const
noexcept

Checks whether the slice data pointer is nullptr.

◆ is_printable()

MDBX_NOTHROW_PURE_FUNCTION bool mdbx::slice::is_printable ( bool  disable_utf8 = false) const
noexcept

Checks whether the content of the slice is printable.

Parameters
[in]disable_utf8By default if disable_utf8 is false function checks that content bytes are printable ASCII-7 characters or a valid UTF8 sequences. Otherwise, if if disable_utf8 is true function checks that content bytes are printable extended 8-bit ASCII codes.

◆ is_valid()

MDBX_CXX11_CONSTEXPR bool mdbx::slice::is_valid ( ) const
inlinenoexcept

Checks the slice is not refers to null address or has zero length.

◆ length()

MDBX_CXX11_CONSTEXPR size_t mdbx::slice::length ( ) const
noexcept

Returns the number of bytes.

◆ middle()

MDBX_CXX14_CONSTEXPR slice mdbx::slice::middle ( size_t  from,
size_t  n 
) const
noexcept

Returns the middle "n" bytes of the slice.

Precondition
REQUIRES: from + n <= size()

◆ operator bool()

MDBX_CXX11_CONSTEXPR mdbx::slice::operator bool ( ) const
noexcept

Returns true if slice is not empty.

◆ operator::std::basic_string()

template<class CHAR , class T , class ALLOCATOR >
MDBX_CXX20_CONSTEXPR mdbx::slice::operator::std::basic_string ( ) const
inlineexplicit

◆ operator::std::basic_string_view()

template<class CHAR , class T >
MDBX_CXX11_CONSTEXPR mdbx::slice::operator::std::basic_string_view ( ) const
inlineexplicitnoexcept

Return a string_view that references the same data as this slice.

◆ operator=() [1/5]

slice & mdbx::slice::operator= ( ::MDBX_val &&  src)
inline

◆ operator=() [2/5]

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

◆ operator=() [3/5]

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

◆ operator=() [4/5]

slice& mdbx::slice::operator= ( const slice )
defaultnoexcept

◆ operator=() [5/5]

slice & mdbx::slice::operator= ( slice &&  src)
inlinenoexcept

◆ operator[]()

MDBX_CXX11_CONSTEXPR byte mdbx::slice::operator[] ( size_t  n) const
noexcept

Returns the nth byte in the referenced data.

Precondition
REQUIRES: n < size()

◆ remove_prefix()

void mdbx::slice::remove_prefix ( size_t  n)
inlinenoexcept

Drops the first "n" bytes from this slice.

Precondition
REQUIRES: n <= size()

◆ remove_suffix()

void mdbx::slice::remove_suffix ( size_t  n)
inlinenoexcept

Drops the last "n" bytes from this slice.

Precondition
REQUIRES: n <= size()

◆ safe_head()

MDBX_CXX14_CONSTEXPR slice mdbx::slice::safe_head ( size_t  n) const

Returns the first "n" bytes of the slice.

Exceptions
std::out_of_rangeif n >= size()

◆ safe_middle()

MDBX_CXX14_CONSTEXPR slice mdbx::slice::safe_middle ( size_t  from,
size_t  n 
) const

Returns the middle "n" bytes of the slice.

Exceptions
std::out_of_rangeif from + n >= size()

◆ safe_remove_prefix()

void mdbx::slice::safe_remove_prefix ( size_t  n)
inline

Drops the first "n" bytes from this slice.

Exceptions
std::out_of_rangeif n > size()

◆ safe_remove_suffix()

void mdbx::slice::safe_remove_suffix ( size_t  n)
inline

Drops the last "n" bytes from this slice.

Exceptions
std::out_of_rangeif n > size()

◆ safe_tail()

MDBX_CXX14_CONSTEXPR slice mdbx::slice::safe_tail ( size_t  n) const

Returns the last "n" bytes of the slice.

Exceptions
std::out_of_rangeif n >= size()

◆ set_end()

MDBX_CXX14_CONSTEXPR slice & mdbx::slice::set_end ( const void *  ptr)

Sets the length by specifying the end of the slice data.

◆ set_length()

MDBX_CXX14_CONSTEXPR slice & mdbx::slice::set_length ( size_t  bytes)

Set slice length.

◆ size()

MDBX_CXX11_CONSTEXPR size_t mdbx::slice::size ( ) const
noexcept

Returns the number of bytes.

◆ starts_with()

MDBX_CXX14_CONSTEXPR bool mdbx::slice::starts_with ( const slice prefix) const
noexcept

Checks if the data starts with the given prefix.

◆ string_view()

template<class CHAR = char, class T = ::std::char_traits<CHAR>>
MDBX_CXX11_CONSTEXPR ::std::basic_string_view<CHAR, T> mdbx::slice::string_view ( ) const
inlinenoexcept

Return a string_view that references the same data as this slice.

◆ swap() [1/2]

template<class CHAR , class T >
void mdbx::slice::swap ( ::std::basic_string_view< CHAR, T > &  view)
inlinenoexcept

◆ swap() [2/2]

void mdbx::slice::swap ( slice other)
inlinenoexcept

◆ tail()

MDBX_CXX14_CONSTEXPR slice mdbx::slice::tail ( size_t  n) const
noexcept

Returns the last "n" bytes of the slice.

Precondition
REQUIRES: n <= size()

◆ wrap() [1/2]

template<size_t SIZE>
static MDBX_CXX14_CONSTEXPR slice mdbx::slice::wrap ( const char(&)  text[SIZE])
inlinestatic

◆ wrap() [2/2]

template<typename POD >
static MDBX_CXX14_CONSTEXPR slice mdbx::slice::wrap ( const POD &  pod)
inlinestatic

Friends And Related Function Documentation

◆ operator!=

MDBX_CXX14_CONSTEXPR bool operator!= ( const slice a,
const slice b 
)
friend

◆ operator<

MDBX_CXX14_CONSTEXPR bool operator< ( const slice a,
const slice b 
)
friend

◆ operator<=

MDBX_CXX14_CONSTEXPR bool operator<= ( const slice a,
const slice b 
)
friend

◆ operator==

MDBX_CXX14_CONSTEXPR bool operator== ( const slice a,
const slice b 
)
friend

◆ operator>

MDBX_CXX14_CONSTEXPR bool operator> ( const slice a,
const slice b 
)
friend

◆ operator>=

MDBX_CXX14_CONSTEXPR bool operator>= ( const slice a,
const slice b 
)
friend

The documentation for this struct was generated from the following file: