MySQL 9.1.0
Source Code Documentation
mysql::containers::buffers::Rw_buffer< Char_tp > Class Template Reference

Non-owning read/write memory buffer manager with a fixed size. More...

#include <rw_buffer.h>

Public Types

using Char_t = Char_tp
 
using Size_t = std::size_t
 
using Difference_t = std::ptrdiff_t
 
using Iterator_t = Char_t *
 
using Const_iterator_t = const Char_t *
 
using Buffer_view_t = mysql::containers::buffers::Buffer_view< Char_t >
 

Public Member Functions

 Rw_buffer ()=default
 
 Rw_buffer (Buffer_view_t buffer)
 Create a new Rw_buffer from the specified size and buffer. More...
 
 Rw_buffer (Rw_buffer &)=delete
 Deleted copy constructor. More...
 
 Rw_buffer (Rw_buffer &&) noexcept=default
 Default move constructor. More...
 
Rw_bufferoperator= (Rw_buffer &)=delete
 Deleted copy assignment operator. More...
 
Rw_bufferoperator= (Rw_buffer &&) noexcept=default
 Default move assignment operator. More...
 
virtual ~Rw_buffer ()=default
 Default delete operator. More...
 
const Buffer_view_tread_part () const
 Return the read part. More...
 
Buffer_view_tread_part ()
 Return the read part. More...
 
const Buffer_view_twrite_part () const
 Return the write part. More...
 
Buffer_view_twrite_part ()
 Return the write part. More...
 
Size_t capacity () const
 Return the total size of the read part and the write part. More...
 
void set_position (Size_t new_position)
 Set the position to a fixed number. More...
 
void increase_position (Size_t increment)
 Increase the position right, relative to the currrent position. More...
 
void move_position (Difference_t delta)
 Move the position left or right, relative to the current position. More...
 

Protected Attributes

Buffer_view_t m_read_part
 
Buffer_view_t m_write_part
 

Detailed Description

template<class Char_tp = unsigned char>
class mysql::containers::buffers::Rw_buffer< Char_tp >

Non-owning read/write memory buffer manager with a fixed size.

This has a read/write position (which Buffer_view does not have). It does not have functionailty to grow the buffer (as Managed_buffer has).

Objects have one internal contiguous buffer which is split into two parts, each of which is a Buffer_view: the first part is the read part and the second part is the write part. API clients may write to the write part and then move the position forwards: this will increase the read part so that API clients can read what was just written, and decrease the write part so that next write will happen after the position that was just written.

Generally, std::stringstream is a safer interface for buffers and should be preferred when possible. This class is intended for interaction with C-like APIs that request a (possibly uninitialized) memory buffer which they write to.

Member Typedef Documentation

◆ Buffer_view_t

template<class Char_tp = unsigned char>
using mysql::containers::buffers::Rw_buffer< Char_tp >::Buffer_view_t = mysql::containers::buffers::Buffer_view<Char_t>

◆ Char_t

template<class Char_tp = unsigned char>
using mysql::containers::buffers::Rw_buffer< Char_tp >::Char_t = Char_tp

◆ Const_iterator_t

template<class Char_tp = unsigned char>
using mysql::containers::buffers::Rw_buffer< Char_tp >::Const_iterator_t = const Char_t *

◆ Difference_t

template<class Char_tp = unsigned char>
using mysql::containers::buffers::Rw_buffer< Char_tp >::Difference_t = std::ptrdiff_t

◆ Iterator_t

template<class Char_tp = unsigned char>
using mysql::containers::buffers::Rw_buffer< Char_tp >::Iterator_t = Char_t *

◆ Size_t

template<class Char_tp = unsigned char>
using mysql::containers::buffers::Rw_buffer< Char_tp >::Size_t = std::size_t

Constructor & Destructor Documentation

◆ Rw_buffer() [1/4]

template<class Char_tp = unsigned char>
mysql::containers::buffers::Rw_buffer< Char_tp >::Rw_buffer ( )
default

◆ Rw_buffer() [2/4]

template<class Char_tp = unsigned char>
mysql::containers::buffers::Rw_buffer< Char_tp >::Rw_buffer ( Buffer_view_t  buffer)
inlineexplicit

Create a new Rw_buffer from the specified size and buffer.

The read part will be 0 bytes at the beginning of the buffer, and the write part will be the full buffer.

◆ Rw_buffer() [3/4]

template<class Char_tp = unsigned char>
mysql::containers::buffers::Rw_buffer< Char_tp >::Rw_buffer ( Rw_buffer< Char_tp > &  )
delete

Deleted copy constructor.

◆ Rw_buffer() [4/4]

template<class Char_tp = unsigned char>
mysql::containers::buffers::Rw_buffer< Char_tp >::Rw_buffer ( Rw_buffer< Char_tp > &&  )
defaultnoexcept

Default move constructor.

◆ ~Rw_buffer()

template<class Char_tp = unsigned char>
virtual mysql::containers::buffers::Rw_buffer< Char_tp >::~Rw_buffer ( )
virtualdefault

Default delete operator.

Member Function Documentation

◆ capacity()

template<class Char_tp = unsigned char>
Size_t mysql::containers::buffers::Rw_buffer< Char_tp >::capacity ( ) const
inline

Return the total size of the read part and the write part.

◆ increase_position()

template<class Char_tp = unsigned char>
void mysql::containers::buffers::Rw_buffer< Char_tp >::increase_position ( Size_t  increment)
inline

Increase the position right, relative to the currrent position.

The position is the same as the size of the read part.

This adjusts the read part and the write part, so that the read part size becomes equal to position, and the write part begins where the read part ends.

The resulting new position must be less than or equal to capacity().

Note
This alters the end iterator for the read part and the begin iterator for the write part.

◆ move_position()

template<class Char_tp = unsigned char>
void mysql::containers::buffers::Rw_buffer< Char_tp >::move_position ( Difference_t  delta)
inline

Move the position left or right, relative to the current position.

The position is the same as the size of the read part.

This increments the right end of the read part by delta, and increments the left end of the write part by delta.

The resulting new position must be between 0 and capacity(), inclusive.

Note
This alters the end iterator for the read part and the begin iterator for the write part.

◆ operator=() [1/2]

template<class Char_tp = unsigned char>
Rw_buffer & mysql::containers::buffers::Rw_buffer< Char_tp >::operator= ( Rw_buffer< Char_tp > &&  )
defaultnoexcept

Default move assignment operator.

◆ operator=() [2/2]

template<class Char_tp = unsigned char>
Rw_buffer & mysql::containers::buffers::Rw_buffer< Char_tp >::operator= ( Rw_buffer< Char_tp > &  )
delete

Deleted copy assignment operator.

◆ read_part() [1/2]

template<class Char_tp = unsigned char>
Buffer_view_t & mysql::containers::buffers::Rw_buffer< Char_tp >::read_part ( )
inline

Return the read part.

◆ read_part() [2/2]

template<class Char_tp = unsigned char>
const Buffer_view_t & mysql::containers::buffers::Rw_buffer< Char_tp >::read_part ( ) const
inline

Return the read part.

◆ set_position()

template<class Char_tp = unsigned char>
void mysql::containers::buffers::Rw_buffer< Char_tp >::set_position ( Size_t  new_position)
inline

Set the position to a fixed number.

The position is the same as the size of the read part.

This adjusts the read part and the write part, so that the read part size becomes equal to position, and the write part begins where the read part ends.

The specified position must be between 0 and capacity(), inclusive.

Note
This alters the end iterator for the read part and the begin iterator for the write part.

◆ write_part() [1/2]

template<class Char_tp = unsigned char>
Buffer_view_t & mysql::containers::buffers::Rw_buffer< Char_tp >::write_part ( )
inline

Return the write part.

◆ write_part() [2/2]

template<class Char_tp = unsigned char>
const Buffer_view_t & mysql::containers::buffers::Rw_buffer< Char_tp >::write_part ( ) const
inline

Return the write part.

Member Data Documentation

◆ m_read_part

template<class Char_tp = unsigned char>
Buffer_view_t mysql::containers::buffers::Rw_buffer< Char_tp >::m_read_part
protected

◆ m_write_part

template<class Char_tp = unsigned char>
Buffer_view_t mysql::containers::buffers::Rw_buffer< Char_tp >::m_write_part
protected

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