MySQL 9.1.0
Source Code Documentation
|
Non-owning manager for a fixed sequence of memory buffers, which is split into a read part and a write part, with a movable split position. More...
#include <rw_buffer_sequence.h>
Public Types | |
using | Buffer_sequence_view_t = Buffer_sequence_view< Char_tp, Container_tp > |
using | Char_t = typename Buffer_sequence_view_t::Char_t |
using | Size_t = typename Buffer_sequence_view_t::Size_t |
using | Difference_t = std::ptrdiff_t |
using | Buffer_view_t = typename Buffer_sequence_view_t::Buffer_view_t |
using | Buffer_allocator_t = typename Buffer_sequence_view_t::Buffer_allocator_t |
using | Container_t = typename Buffer_sequence_view_t::Container_t |
using | Iterator_t = typename Buffer_sequence_view_t::Iterator_t |
using | Const_iterator_t = typename Buffer_sequence_view_t::Const_iterator_t |
using | Const_buffer_sequence_view_t = Buffer_sequence_view< Char_tp, Container_tp, true > |
Public Member Functions | |
Rw_buffer_sequence (Iterator_t begin_arg, Iterator_t end_arg) | |
Construct a new Rw_buffer_sequence from given endpoint iterators, with position 0. More... | |
Rw_buffer_sequence (Rw_buffer_sequence &)=delete | |
Rw_buffer_sequence (Rw_buffer_sequence &&)=delete | |
Rw_buffer_sequence & | operator= (Rw_buffer_sequence &)=delete |
Rw_buffer_sequence & | operator= (Rw_buffer_sequence &&)=delete |
virtual | ~Rw_buffer_sequence ()=default |
void | set_position (Size_t new_position) |
Set the specified absolute position. More... | |
void | increase_position (Size_t delta) |
Move the position right, relative to the current position. More... | |
void | move_position (Difference_t delta) |
Move the position left or right, relative to the current position. More... | |
Size_t | capacity () const |
Return the current size, i.e., total size of all buffers. More... | |
const Buffer_sequence_view_t & | read_part () const |
Return a const reference to the read part. More... | |
Buffer_sequence_view_t & | read_part () |
Return a non-const reference to the read part. More... | |
const Buffer_sequence_view_t & | write_part () const |
Return a const reference to the write part. More... | |
Buffer_sequence_view_t & | write_part () |
Return a non-const reference to the write part. More... | |
virtual std::string | debug_string (bool show_contents, int indent) const |
In debug mode, return a string that describes the internal structure of this object, to use for debugging. More... | |
std::string | debug_string (bool show_contents=false) const |
In debug mode, return a string that describes the internal structure of this object, to use for debugging. More... | |
Static Protected Member Functions | |
static void | set_position (Size_t new_position, Buffer_sequence_view_t &left, Buffer_sequence_view_t &right) |
Move the position to the given, absolute position. More... | |
static Size_t | merge_if_split (Buffer_sequence_view_t &left, Buffer_sequence_view_t &right) |
If a buffer is split between the read and write parts, glue the pieces together again and include them in the read part. More... | |
static Size_t | move_position_one_buffer_left (Buffer_sequence_view_t &left, Buffer_sequence_view_t &right) |
Move the position exactly one buffer left, assuming no buffer is split. More... | |
static Size_t | move_position_at_most_one_buffer_right (Buffer_sequence_view_t &left, Buffer_sequence_view_t &right, Size_t limit) |
Move the position right by whatever is smaller: the given number, or one buffer; splits the buffer if the number is smaller than the buffer. More... | |
static std::tuple< Iterator_t, Iterator_t, Size_t > | get_boundaries (Buffer_sequence_view_t &buffer_sequence_view) |
Return the beginning, end, and size of the read and write parts. More... | |
Private Attributes | |
Buffer_sequence_view_t | m_read_part |
buffer_sequence_view for the (leading) read segment. More... | |
Buffer_sequence_view_t | m_write_part |
buffer_sequence_view for the (trailing) write segment. More... | |
Non-owning manager for a fixed sequence of memory buffers, which is split into a read part and a write part, with a movable split position.
This has a read/write position (which Buffer_sequence
does not have). It does not have functionailty to grow the buffer sequence (as Managed_buffer_sequence
has).
Objects have one internal contiguous container (vector or list), which is split into two parts, each of which is a Buffer_sequence_view: the first part is the read part and the second part is the write part. API clients typically 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.
The position that defines the end of the read part and the beginning of the write part has byte granularity. Therefore, it does not have to be at a buffer boundary. When it is not on a buffer boundary, a buffer has to be split. When a buffer is split, the sequence needs one more element than the actual number of (contiguous) buffers. When the position is moved from a buffer boundary to a non-boundary, the number of used elements increases by one. To avoid having to shift all the buffers for the write part one step right when the container is a vector, there is always one more element than the actual number of contiguous buffers. So when the position is at a buffer boundary, an unused "null buffer" is stored between the read part and the write part. In other words, the buffer sequence has one of the following forms:
Char_tp | the type of elements stored in the buffer: typically unsigned char. |
Container_tp | the type of container: either std::vector or std::list . |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Buffer_allocator_t = typename Buffer_sequence_view_t::Buffer_allocator_t |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Buffer_sequence_view_t = Buffer_sequence_view<Char_tp, Container_tp> |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Buffer_view_t = typename Buffer_sequence_view_t::Buffer_view_t |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Char_t = typename Buffer_sequence_view_t::Char_t |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Const_buffer_sequence_view_t = Buffer_sequence_view<Char_tp, Container_tp, true> |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Const_iterator_t = typename Buffer_sequence_view_t::Const_iterator_t |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Container_t = typename Buffer_sequence_view_t::Container_t |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Difference_t = std::ptrdiff_t |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Iterator_t = typename Buffer_sequence_view_t::Iterator_t |
using mysql::containers::buffers::Rw_buffer_sequence< Char_tp, Container_tp >::Size_t = typename Buffer_sequence_view_t::Size_t |
|
inline |
Construct a new Rw_buffer_sequence from given endpoint iterators, with position 0.
The provided sequence of buffers must start with one null buffer, followed by zero or more non-null buffers.
begin_arg | Iterator to the beginning of the sequence. |
end_arg | Iterator to one-past-the-end of the sequence. |
|
delete |
|
delete |
|
virtualdefault |
|
inline |
Return the current size, i.e., total size of all buffers.
|
inlinevirtual |
In debug mode, return a string that describes the internal structure of this object, to use for debugging.
show_contents | If true, includes the buffer contents. Otherwise, just pointers and sizes. |
indent | If 0, put all info on one line. Otherwise, put each field on its own line and indent the given number of two-space levels. |
Reimplemented in mysql::containers::buffers::Managed_buffer_sequence< Char_tp, Container_tp >.
|
inline |
In debug mode, return a string that describes the internal structure of this object, to use for debugging.
show_contents | If true, includes the buffer contents. Otherwise, just pointers and sizes. |
|
inlinestaticprotected |
Return the beginning, end, and size of the read and write parts.
buffer_sequence_view | The buffer sequence view. |
|
inline |
Move the position right, relative to the current position.
"Position" is a synonym for "size of the read part".
delta | The number of bytes to add to the position. The resulting size must be within bounds; otherwise an assertion is raised in debug build, or the position forced to the beginning/end in non-debug build. |
|
inlinestaticprotected |
If a buffer is split between the read and write parts, glue the pieces together again and include them in the read part.
If no buffer is split (the position is at a buffer boundary), does nothing.
Graphically, the operation is as follows:
left | The left buffer sequence. |
right | The right buffer sequence. |
|
inline |
Move the position left or right, relative to the current position.
"Position" is a synonym for "size of the read part".
delta | The number of bytes to add to the position. The resulting size must be within bounds; otherwise an assertion is raised in debug build, or the position forced to the beginning/end in non-debug build. |
|
inlinestaticprotected |
Move the position right by whatever is smaller: the given number, or one buffer; splits the buffer if the number is smaller than the buffer.
left | The left buffer sequence. |
right | The right buffer sequence. |
limit | Move the position at most this number of bytes right. |
|
inlinestaticprotected |
Move the position exactly one buffer left, assuming no buffer is split.
Graphically, the operation is as follows:
left | The left buffer sequence. |
right | The right buffer sequence. |
|
delete |
|
delete |
|
inline |
Return a non-const reference to the read part.
|
inline |
Return a const reference to the read part.
|
inline |
Set the specified absolute position.
"Position" is a synonym for "size of the read part".
new_position | The new size of the read part. This must be within bounds; otherwise an assertion is raised in debug build, or the position forced to the end in non-debug build. |
|
inlinestaticprotected |
Move the position to the given, absolute position.
new_position | The new position. This must be within bounds. Otherwise an assertion is raised in debug build; in non-debug build, the position is forced to the end. |
left | The left buffer sequence. |
right | The right buffer sequence. |
|
inline |
Return a non-const reference to the write part.
|
inline |
Return a const reference to the write part.
|
private |
buffer_sequence_view for the (leading) read segment.
|
private |
buffer_sequence_view for the (trailing) write segment.