MySQL 8.0.39
Source Code Documentation
mysqlns::buffer::Buffer_view< Char_tp > Class Template Reference

Non-owning view of a memory buffer with a fixed size. More...

#include <buffer_view.h>

Public Types

using Char_t = Char_tp
 
using Size_t = std::size_t
 The 'size' type. More...
 
using Iterator_t = Char_t *
 
using Const_iterator_t = const Char_t *
 

Public Member Functions

 Buffer_view (Char_t *data, Size_t size)
 Create a new Buffer_view with the specified size and data. More...
 
 Buffer_view ()=default
 Create a new "null Buffer_view": pointer is nullptr and size is 0. More...
 
 Buffer_view (const Buffer_view &)=default
 Shallow copy constructor. More...
 
 Buffer_view (Buffer_view &&) noexcept=default
 Default move constructor. More...
 
Buffer_viewoperator= (const Buffer_view &)=default
 Shallow copy assignment operator. More...
 
Buffer_viewoperator= (Buffer_view &&) noexcept=default
 Default move assignment operator. More...
 
virtual ~Buffer_view ()=default
 Default delete operator. More...
 
const Char_tdata () const
 Return const pointer to the data. More...
 
Char_tdata ()
 Return non-const pointer to the data. More...
 
Iterator_t begin ()
 Return pointer to the first character of the data. More...
 
Iterator_t end ()
 Return pointer to one-past-the-last character of the data. More...
 
Const_iterator_t begin () const
 Return pointer to the first character of the data. More...
 
Const_iterator_t end () const
 Return pointer to one-past-the-last character of the data. More...
 
Const_iterator_t cbegin () const
 Return const pointer to the first character of the data. More...
 
Const_iterator_t cend () const
 Return const pointer to one-past-the-last character of the data. More...
 
Size_t size () const
 Return the number of bytes. More...
 
template<class Str_char_t = char, class Str_traits_t = std::char_traits<Str_char_t>, class Str_allocator_t = std::allocator<Str_char_t>>
std::basic_string< Str_char_t, Str_traits_t, Str_allocator_t > str (const Str_allocator_t &allocator=Str_allocator_t()) const
 Return a copy of this object as a std::string. More...
 
std::string debug_string (bool show_contents=false) const
 In debug mode, return a string with debug info. More...
 

Private Attributes

Char_tm_data {nullptr}
 Pointer to the data. More...
 
Size_t m_size {0}
 The number of bytes. More...
 

Detailed Description

template<class Char_tp = unsigned char>
class mysqlns::buffer::Buffer_view< Char_tp >

Non-owning view of a memory buffer with a fixed size.

This is a minimal class holding just a pointer and a size. It does not have a read/write position (

See also
Rw_buffer_sequence). It does not have methods to grow the buffer (
Growable_buffer_sequence).

Member Typedef Documentation

◆ Char_t

template<class Char_tp = unsigned char>
using mysqlns::buffer::Buffer_view< Char_tp >::Char_t = Char_tp

◆ Const_iterator_t

template<class Char_tp = unsigned char>
using mysqlns::buffer::Buffer_view< Char_tp >::Const_iterator_t = const Char_t *

◆ Iterator_t

template<class Char_tp = unsigned char>
using mysqlns::buffer::Buffer_view< Char_tp >::Iterator_t = Char_t *

◆ Size_t

template<class Char_tp = unsigned char>
using mysqlns::buffer::Buffer_view< Char_tp >::Size_t = std::size_t

The 'size' type.

Keep this equal to buffer::Grow_calculator::Size_t

Constructor & Destructor Documentation

◆ Buffer_view() [1/4]

template<class Char_tp = unsigned char>
mysqlns::buffer::Buffer_view< Char_tp >::Buffer_view ( Char_t data,
Size_t  size 
)
inline

Create a new Buffer_view with the specified size and data.

◆ Buffer_view() [2/4]

template<class Char_tp = unsigned char>
mysqlns::buffer::Buffer_view< Char_tp >::Buffer_view ( )
default

Create a new "null Buffer_view": pointer is nullptr and size is 0.

◆ Buffer_view() [3/4]

template<class Char_tp = unsigned char>
mysqlns::buffer::Buffer_view< Char_tp >::Buffer_view ( const Buffer_view< Char_tp > &  )
default

Shallow copy constructor.

Note
The data pointer is copied but not the contents.

◆ Buffer_view() [4/4]

template<class Char_tp = unsigned char>
mysqlns::buffer::Buffer_view< Char_tp >::Buffer_view ( Buffer_view< Char_tp > &&  )
defaultnoexcept

Default move constructor.

◆ ~Buffer_view()

template<class Char_tp = unsigned char>
virtual mysqlns::buffer::Buffer_view< Char_tp >::~Buffer_view ( )
virtualdefault

Default delete operator.

Member Function Documentation

◆ begin() [1/2]

template<class Char_tp = unsigned char>
Iterator_t mysqlns::buffer::Buffer_view< Char_tp >::begin ( )
inline

Return pointer to the first character of the data.

◆ begin() [2/2]

template<class Char_tp = unsigned char>
Const_iterator_t mysqlns::buffer::Buffer_view< Char_tp >::begin ( ) const
inline

Return pointer to the first character of the data.

◆ cbegin()

template<class Char_tp = unsigned char>
Const_iterator_t mysqlns::buffer::Buffer_view< Char_tp >::cbegin ( ) const
inline

Return const pointer to the first character of the data.

◆ cend()

template<class Char_tp = unsigned char>
Const_iterator_t mysqlns::buffer::Buffer_view< Char_tp >::cend ( ) const
inline

Return const pointer to one-past-the-last character of the data.

◆ data() [1/2]

template<class Char_tp = unsigned char>
Char_t * mysqlns::buffer::Buffer_view< Char_tp >::data ( )
inline

Return non-const pointer to the data.

◆ data() [2/2]

template<class Char_tp = unsigned char>
const Char_t * mysqlns::buffer::Buffer_view< Char_tp >::data ( ) const
inline

Return const pointer to the data.

◆ debug_string()

template<class Char_tp = unsigned char>
std::string mysqlns::buffer::Buffer_view< Char_tp >::debug_string ( bool  show_contents = false) const
inline

In debug mode, return a string with debug info.

Parameters
show_contentsIf true, includes the buffer contents. Otherwise, just pointers and sizes.

◆ end() [1/2]

template<class Char_tp = unsigned char>
Iterator_t mysqlns::buffer::Buffer_view< Char_tp >::end ( )
inline

Return pointer to one-past-the-last character of the data.

◆ end() [2/2]

template<class Char_tp = unsigned char>
Const_iterator_t mysqlns::buffer::Buffer_view< Char_tp >::end ( ) const
inline

Return pointer to one-past-the-last character of the data.

◆ operator=() [1/2]

template<class Char_tp = unsigned char>
Buffer_view & mysqlns::buffer::Buffer_view< Char_tp >::operator= ( Buffer_view< Char_tp > &&  )
defaultnoexcept

Default move assignment operator.

◆ operator=() [2/2]

template<class Char_tp = unsigned char>
Buffer_view & mysqlns::buffer::Buffer_view< Char_tp >::operator= ( const Buffer_view< Char_tp > &  )
default

Shallow copy assignment operator.

Note
The data pointer is copied but not the contents.

◆ size()

template<class Char_tp = unsigned char>
Size_t mysqlns::buffer::Buffer_view< Char_tp >::size ( ) const
inline

Return the number of bytes.

◆ str()

template<class Char_tp = unsigned char>
template<class Str_char_t = char, class Str_traits_t = std::char_traits<Str_char_t>, class Str_allocator_t = std::allocator<Str_char_t>>
std::basic_string< Str_char_t, Str_traits_t, Str_allocator_t > mysqlns::buffer::Buffer_view< Char_tp >::str ( const Str_allocator_t &  allocator = Str_allocator_t()) const
inline

Return a copy of this object as a std::string.

Member Data Documentation

◆ m_data

template<class Char_tp = unsigned char>
Char_t* mysqlns::buffer::Buffer_view< Char_tp >::m_data {nullptr}
private

Pointer to the data.

◆ m_size

template<class Char_tp = unsigned char>
Size_t mysqlns::buffer::Buffer_view< Char_tp >::m_size {0}
private

The number of bytes.


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