29#ifndef MYSQL_CONTAINERS_BUFFERS_BUFFER_SEQUENCE_VIEW_H
30#define MYSQL_CONTAINERS_BUFFERS_BUFFER_SEQUENCE_VIEW_H
68template <
class Char_tp =
unsigned char,
69 template <
class Element_tp,
class Allocator_tp>
class Container_tp =
71 bool const_tp =
false>
78 using Container_t = Container_tp<Buffer_view_t, Buffer_allocator_t>;
82 typename Container_t::iterator>
::type;
87 std::numeric_limits<Size_t>::max();
139 template <
class Destination_
char_t>
140 void copy(Destination_char_t *destination)
const {
143 for (
const auto &
buffer : *
this) {
151 template <
class Str_char_t = char,
152 class Str_traits_t = std::char_traits<Str_char_t>,
153 class Str_allocator_t = std::allocator<Str_char_t>>
154 std::basic_string<Str_char_t, Str_traits_t, Str_allocator_t>
str(
155 const Str_allocator_t &allocator = Str_allocator_t()) {
156 std::basic_string<Str_char_t, Str_traits_t, Str_allocator_t> ret(
157 this->
size(),
'\0', allocator);
185 [[maybe_unused]]
int indent = 0)
const {
193 ws = std::string(
"\n") +
194 std::string(
static_cast<std::string::size_type
>(indent * 2),
' ');
198 std::string sep =
"," + ws;
200 std::string ws2 = (indent != 0) ? (ws +
" ") : ws;
201 std::string sep2 = (indent != 0) ? (sep +
" ") : sep;
203 ss <<
"Buffer_sequence_view(ptr=" << (
const void *)
this
204 << sep <<
"size=" <<
size()
205 << sep <<
"buffers.ptr=" << (
const void *)&*this->
begin()
206 << sep <<
"buffers=[";
209 for (
auto &
buffer : *
this) {
211 if (indent != 0) ss << ws2;
216 ss <<
buffer.debug_string(show_contents);
Class that groups a pointer+size as one object, without managing the memory for it.
Allocator using a Memory_resource to do the allocator.
Definition: allocator.h:54
Sequence of memory buffers.
Definition: buffer_sequence_view.h:72
Iterator_t begin()
Iterator to the first buffer.
Definition: buffer_sequence_view.h:116
typename std::conditional< const_tp, Const_iterator_t, typename Container_t::iterator >::type Iterator_t
Definition: buffer_sequence_view.h:82
Char_tp Char_t
Definition: buffer_sequence_view.h:74
Iterator_t end()
Iterator to the last buffer.
Definition: buffer_sequence_view.h:119
Buffer_sequence_view(Buffer_sequence_view &)=delete
Buffer_sequence_view(Buffer_sequence_view &&other) noexcept=default
Size_t size() const
Return the total size of all buffers.
Definition: buffer_sequence_view.h:163
std::string debug_string(bool show_contents=false, int indent=0) const
In debug mode, return a string that describes the internal structure of this object,...
Definition: buffer_sequence_view.h:184
Const_iterator_t end() const
Iterator to the last buffer.
Definition: buffer_sequence_view.h:125
Buffer_sequence_view(Iterator_t begin_arg, Iterator_t end_arg, Size_t size_arg=uninitialized_size)
Construct a Buffer_sequence_view with buffers in the range given by the iterators.
Definition: buffer_sequence_view.h:103
Container_tp< Buffer_view_t, Buffer_allocator_t > Container_t
Definition: buffer_sequence_view.h:78
static constexpr Size_t uninitialized_size
Indicates that m_size has not yet been computed.
Definition: buffer_sequence_view.h:86
Iterator_t m_begin
Iterator to beginning of buffer.
Definition: buffer_sequence_view.h:225
std::size_t Size_t
Definition: buffer_sequence_view.h:75
typename Container_t::const_iterator Const_iterator_t
Definition: buffer_sequence_view.h:79
void copy(Destination_char_t *destination) const
Copy all data to the given, contiguous output buffer.
Definition: buffer_sequence_view.h:140
Buffer_sequence_view & operator=(Buffer_sequence_view &&) noexcept=default
Buffer_sequence_view & operator=(Buffer_sequence_view &)=delete
Iterator_t m_end
Iterator to end of buffer.
Definition: buffer_sequence_view.h:228
Const_iterator_t cend() const
Const iterator pointing to the last buffer.
Definition: buffer_sequence_view.h:131
Size_t m_size
Total size of all buffers, cached.
Definition: buffer_sequence_view.h:231
Const_iterator_t begin() const
Iterator to the first buffer.
Definition: buffer_sequence_view.h:122
Const_iterator_t cbegin() const
Const iterator pointing to the first buffer.
Definition: buffer_sequence_view.h:128
std::basic_string< Str_char_t, Str_traits_t, Str_allocator_t > str(const Str_allocator_t &allocator=Str_allocator_t())
Return a copy of all the data in this object, as a std::string object.
Definition: buffer_sequence_view.h:154
void * data() const noexcept
Definition: buffer.h:119
size_t size() const noexcept
Definition: buffer.h:120
Allocator class that uses a polymorphic Memory_resource to allocate memory.
Definition: buffer_sequence_view.h:51
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
std::basic_ostringstream< char, std::char_traits< char >, ut::allocator< char > > ostringstream
Specialization of basic_ostringstream which uses ut::allocator.
Definition: ut0new.h:2872
std::vector< T, ut::allocator< T > > vector
Specialization of vector which uses allocator.
Definition: ut0new.h:2876
required string type
Definition: replication_group_member_actions.proto:34
static task_arg end_arg()
Definition: task.h:207
Contains wrapper functions for memory allocation and deallocation.
#define BAPI_TRACE
Definition: wrapper_functions.h:65