MySQL 9.6.0
Source Code Documentation
mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp > Class Template Reference

CRTP base class that provides a rich API for classes that behave like byte buffers. More...

#include <buffer_interface.h>

Inheritance diagram for mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >:
[legend]

Public Member Functions

 operator bool () const
 Return true if size() != 0. More...
 
bool operator! () const
 Return true if size() == 0. More...
 
bool empty () const
 Return true if size() == 0. More...
 
std::ptrdiff_t ssize () const
 Return the size as std::ptrdiff_t. More...
 
auto * udata ()
 Return the data buffer as unsigned char *. More...
 
auto * udata () const
 Return the data buffer as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const. More...
 
auto * bdata ()
 Return the data buffer as std::byte *. More...
 
auto * bdata () const
 Return the data buffer as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const. More...
 
std::string_view string_view () const
 
auto * begin ()
 Return the begin as char *. More...
 
auto * begin () const
 Return the begin as const char * or char *, const-ness inherited from Self_t::data() const. More...
 
auto * cbegin () const
 Return the begin as const char * or char *, const-ness inherited from Self_t::data() const. More...
 
auto * ubegin ()
 Return the begin as unsigned char *. More...
 
auto * ubegin () const
 Return the begin as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const. More...
 
auto * cubegin () const
 Return the begin as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const. More...
 
auto * bbegin ()
 Return the begin as std::byte *. More...
 
auto * bbegin () const
 Return the begin as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const. More...
 
auto * cbbegin () const
 Return the begin as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const. More...
 
auto * end ()
 Return the end as char *. More...
 
auto * end () const
 Return the end as const char * or char *, const-ness inherited from Self_t::data() const. More...
 
auto * cend () const
 Return the end as const char * or char *, const-ness inherited from Self_t::data() const. More...
 
auto * uend ()
 Return the end as unsigned char *. More...
 
auto * uend () const
 Return the end as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const. More...
 
auto * cuend () const
 Return the end as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const. More...
 
auto * bend ()
 Return the end as std::byte *. More...
 
auto * bend () const
 Return the end as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const. More...
 
auto * cbend () const
 Return the end as const std::byte * or or std::byte *, const-ness inherited from Self_t::data() const. More...
 
char & operator[] (std::ptrdiff_t n)
 Return reference the n'th element. More...
 
char operator[] (std::ptrdiff_t n) const
 Return the n'th element, const-ness inherited from Self_t::data() const. More...
 

Static Public Attributes

static constexpr auto equality_algorithm = equality_algorithm_tp
 
static constexpr bool equality_enabled
 
static constexpr bool hash_enabled = (enable_hash_tp == Enable_hash::yes)
 

Private Member Functions

Self_tp & self ()
 
const Self_tp & self () const
 

Detailed Description

template<class Self_tp, Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
class mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >

CRTP base class that provides a rich API for classes that behave like byte buffers.

This turns a subclass that implements size() and data() members into a std::ranges::range, defines the same members that std::view_interface defines, enables comparisons and hashes, and for any member that uses char *, provides alternative members that use unsigned char * and std::byte.

The subclass should implement the following member functions:

size_t size() const;
char *data();
const char *data() const;
size_t size(const char *const c)
Definition: base64.h:46

This class provides the members:

  • string_view: Return an std::string_view.
  • [u|b]data: Return data as unsigned char * or std::byte *.
  • [c][u|b]begin/[c][u|b]end: Return (const) begin/end pointers as char *, unsigned char *, or std::byte *.
  • operator[]: Return the n'th element.
  • ssize: Return the size as a signed integer (std::ptrdiff_t).
  • empty: Return size() == 0.
  • operator bool: return size() != 0. Optionally, the following free functions are provided:
  • operator==, operator!=, and operator<=>.
  • std::hash.

The following alternative prototypes are allowed:

char *data() const;

I.e., the data may be non-const even if the buffer object is const. This is useful when the buffer object does not own the data.

Template Parameters
Self_tpSubclass.
equality_algorithm_tpDetermines if and how operators ==, !=, <, >, <=, >=, and <=> are implemented: lexicographic compares strings lexicographically, for example, "a" < "aa" < "b"; fast compares the length first, and compares lexicographically only when the lengths are equal, for example, "a" < "b" < "aa"; none does not implement comparison at all. Default is lexicographic.
enable_hash_tpIf yes, enable std::hash<Self_tp>. Default is yes.

Member Function Documentation

◆ bbegin() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::bbegin ( )
inline

Return the begin as std::byte *.

◆ bbegin() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::bbegin ( ) const
inline

Return the begin as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const.

◆ bdata() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::bdata ( )
inline

Return the data buffer as std::byte *.

◆ bdata() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::bdata ( ) const
inline

Return the data buffer as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const.

◆ begin() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::begin ( )
inline

Return the begin as char *.

◆ begin() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::begin ( ) const
inline

Return the begin as const char * or char *, const-ness inherited from Self_t::data() const.

◆ bend() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::bend ( )
inline

Return the end as std::byte *.

◆ bend() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::bend ( ) const
inline

Return the end as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const.

◆ cbbegin()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::cbbegin ( ) const
inline

Return the begin as const std::byte * or std::byte *, const-ness inherited from Self_t::data() const.

◆ cbegin()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::cbegin ( ) const
inline

Return the begin as const char * or char *, const-ness inherited from Self_t::data() const.

◆ cbend()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::cbend ( ) const
inline

Return the end as const std::byte * or or std::byte *, const-ness inherited from Self_t::data() const.

◆ cend()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::cend ( ) const
inline

Return the end as const char * or char *, const-ness inherited from Self_t::data() const.

◆ cubegin()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::cubegin ( ) const
inline

Return the begin as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const.

◆ cuend()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::cuend ( ) const
inline

Return the end as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const.

◆ empty()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
bool mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::empty ( ) const
inline

Return true if size() == 0.

◆ end() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::end ( )
inline

Return the end as char *.

◆ end() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::end ( ) const
inline

Return the end as const char * or char *, const-ness inherited from Self_t::data() const.

◆ operator bool()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::operator bool ( ) const
inlineexplicit

Return true if size() != 0.

◆ operator!()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
bool mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::operator! ( ) const
inline

Return true if size() == 0.

◆ operator[]() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
char & mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::operator[] ( std::ptrdiff_t  n)
inline

Return reference the n'th element.

◆ operator[]() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
char mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::operator[] ( std::ptrdiff_t  n) const
inline

Return the n'th element, const-ness inherited from Self_t::data() const.

◆ self() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
Self_tp & mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::self ( )
inlineprivate

◆ self() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
const Self_tp & mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::self ( ) const
inlineprivate

◆ ssize()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
std::ptrdiff_t mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::ssize ( ) const
inline

Return the size as std::ptrdiff_t.

◆ string_view()

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
std::string_view mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::string_view ( ) const
inline

◆ ubegin() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::ubegin ( )
inline

Return the begin as unsigned char *.

◆ ubegin() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::ubegin ( ) const
inline

Return the begin as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const.

◆ udata() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::udata ( )
inline

Return the data buffer as unsigned char *.

◆ udata() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::udata ( ) const
inline

Return the data buffer as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const.

◆ uend() [1/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::uend ( )
inline

Return the end as unsigned char *.

◆ uend() [2/2]

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
auto * mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::uend ( ) const
inline

Return the end as const unsigned char * or unsigned char *, const-ness inherited from Self_t::data() const.

Member Data Documentation

◆ equality_algorithm

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
constexpr auto mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::equality_algorithm = equality_algorithm_tp
staticconstexpr

◆ equality_enabled

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
constexpr bool mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::equality_enabled
staticconstexpr
Initial value:
=
static constexpr auto equality_algorithm
Definition: buffer_interface.h:104

◆ hash_enabled

template<class Self_tp , Equality_algorithm equality_algorithm_tp = Equality_algorithm::lexicographic, Enable_hash enable_hash_tp = Enable_hash::yes>
constexpr bool mysql::ranges::Buffer_interface< Self_tp, equality_algorithm_tp, enable_hash_tp >::hash_enabled = (enable_hash_tp == Enable_hash::yes)
staticconstexpr

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