MySQL 8.0.40
Source Code Documentation
|
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 = mysqlns::buffer::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_buffer & | operator= (Rw_buffer &)=delete |
Deleted copy assignment operator. More... | |
Rw_buffer & | operator= (Rw_buffer &&) noexcept=default |
Default move assignment operator. More... | |
virtual | ~Rw_buffer ()=default |
Default delete operator. More... | |
const Buffer_view_t & | read_part () const |
Return the read part. More... | |
Buffer_view_t & | read_part () |
Return the read part. More... | |
const Buffer_view_t & | write_part () const |
Return the write part. More... | |
Buffer_view_t & | write_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 |
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.
using mysqlns::buffer::Rw_buffer< Char_tp >::Buffer_view_t = mysqlns::buffer::Buffer_view<Char_t> |
using mysqlns::buffer::Rw_buffer< Char_tp >::Char_t = Char_tp |
using mysqlns::buffer::Rw_buffer< Char_tp >::Const_iterator_t = const Char_t * |
using mysqlns::buffer::Rw_buffer< Char_tp >::Difference_t = std::ptrdiff_t |
using mysqlns::buffer::Rw_buffer< Char_tp >::Iterator_t = Char_t * |
using mysqlns::buffer::Rw_buffer< Char_tp >::Size_t = std::size_t |
|
default |
|
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.
|
delete |
Deleted copy constructor.
|
defaultnoexcept |
Default move constructor.
|
virtualdefault |
Default delete operator.
|
inline |
Return the total size of the read part and the write part.
|
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().
|
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.
|
defaultnoexcept |
Default move assignment operator.
|
delete |
Deleted copy assignment operator.
|
inline |
Return the read part.
|
inline |
Return the read part.
|
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.
|
inline |
Return the write part.
|
inline |
Return the write part.
|
protected |
|
protected |