24#ifndef MYSQL_STRCONV_ENCODE_OUT_STR_H
25#define MYSQL_STRCONV_ENCODE_OUT_STR_H
220 std::derived_from<Test, Out_str_base> &&
221 requires(Test test, std::size_t new_size) {
222 { test.initial_capacity() } -> std::same_as<std::size_t>;
223 { test.size() } -> std::same_as<std::size_t>;
225 test.resize(new_size)
227 { test.data() } -> std::same_as<char *>;
228 { test.udata() } -> std::same_as<unsigned char *>;
229 { test.bdata() } -> std::same_as<std::byte *>;
230 { Test::resize_policy } -> std::convertible_to<Resize_policy>;
254template <
class String_tp>
265 [[nodiscard]]
char *
data()
const {
271 return m_str.capacity();
275 [[nodiscard]] std::size_t
size()
const {
return m_str.size(); }
295template <
class Self_tp,
class Ptr_tp>
327template <
class Ptr_tp>
340 std::size_t((capacity_end ==
nullptr ? last : capacity_end) -
343 if (capacity_end ==
nullptr)
344 assert(first <= last);
346 assert(first <= capacity_end);
372template <
class Ptr_tp, std::
integral Size_tp>
386 :
Base_t(first,
std::size_t(capacity == 0 ? size_arg : capacity)),
390 [[nodiscard]] std::size_t
size()
const {
return std::size_t(
m_size); }
414template <
class Representation_tp>
430 return mysql::utils::call_and_catch([&] { this->m_str.resize(
size); });
441template <
class Char_tp,
class Representation_tp,
454 template <
class... Args_t>
457 : Representation_tp(
std::forward<Args_t>(args)...) {}
461 template <
class... Args_t>
464 : Representation_tp(
std::forward<Args_t>(args)...),
479 if (size_arg > this->initial_capacity() || this->m_first ==
nullptr) {
480 auto *new_first =
reinterpret_cast<Char_tp *
>(
484 this->m_first = new_first;
486 this->store_size(size_arg);
488 Representation_tp::representation_type !=
490 this->data()[size_arg] =
'\0';
506template <
class Representation_tp, Null_terminated null_terminated_tp>
516 template <
class... Args_t>
519 : Representation_tp(
std::forward<Args_t>(args)...) {}
525 void resize(std::size_t size_arg)
const {
526 assert(size_arg <= this->initial_capacity());
527 this->store_size(size_arg);
529 Representation_tp::representation_type !=
531 this->data()[size_arg] =
'\0';
538template <
class String_tp>
542template <
class Size_tp>
546template <
class Size_tp>
550template <
class Char_tp>
554template <
class Char_tp>
558template <
class String_tp>
562template <mysql::meta::Is_
charlike Char_t, std::
integral Size_tp>
567template <mysql::meta::Is_
charlike Char_t, std::
integral Size_tp>
572template <mysql::meta::Is_
charlike Char_t>
577template <mysql::meta::Is_
charlike Char_t>
591template <
class String_tp>
601template <
class Char_tp>
607 template <
class... Args_t>
611 std::forward<Args_t>(args)...) {}
616template <
class Char_tp>
622 template <
class... Args_t>
626 std::forward<Args_t>(args)...) {}
631template <
class Size_tp>
637 template <
class... Args_t>
641 std::forward<Args_t>(args)...) {}
646template <
class Size_tp>
652 template <
class... Args_t>
656 std::forward<Args_t>(args)...) {}
662template <
class String_tp>
672template <mysql::meta::Is_
charlike Char_t, std::
integral Size_tp>
677 Char_t *&first, Size_tp &
size, Size_tp capacity,
680 memory_resource, first,
size, capacity) {}
685template <mysql::meta::Is_
charlike Char_t, std::
integral Size_tp>
690 Char_t *&first, Size_tp &
size, Size_tp capacity,
693 memory_resource, first,
size, capacity) {}
698template <mysql::meta::Is_
charlike Char_t>
703 Char_t *&first, Char_t *&last, Char_t *&capacity_end,
706 last, capacity_end) {}
711template <mysql::meta::Is_
charlike Char_t>
716 Char_t *&first, Char_t *&last, Char_t *&capacity_end,
719 last, capacity_end) {}
733template <mysql::meta::Is_specialization<std::basic_
string> String_t>
759template <std::
integral Size_t>
762 Size_t capacity = 0) {
796 Char_t *capacity_end =
nullptr) {
817template <std::
integral Size_t>
820 Size_t capacity = 0) {
853 Char_t *capacity_end =
nullptr) {
881template <std::
integral Size_t, std::ptrdiff_t array_size>
884 Size_t capacity = 0) {
886 assert(
length <= array_size - 1);
888 assert(capacity <= array_size - 1);
910template <mysql::meta::Is_
charlike Char_t, std::ptrdiff_t array_size>
912 Char_t *capacity_end =
nullptr) {
913 if (capacity_end ==
nullptr)
914 assert(last - first <= array_size - 1);
916 assert(capacity_end - first <= array_size - 1);
917 return out_str_fixed_z(
reinterpret_cast<Char_t *
>(first), last, capacity_end);
936template <std::
integral Size_t, std::ptrdiff_t array_size>
939 Size_t capacity = 0) {
941 assert(
length <= array_size);
943 assert(capacity <= array_size);
964template <mysql::meta::Is_
charlike Char_t, std::ptrdiff_t array_size>
966 Char_t *capacity_end =
nullptr) {
967 if (capacity_end ==
nullptr)
968 assert(last - first <= array_size);
970 assert(capacity_end - first <= array_size);
984template <mysql::meta::Is_specialization<std::basic_
string> String_t>
1015template <mysql::meta::Is_
charlike Char_t, std::
integral Size_t>
1017 Char_t *&first, Size_t &
length, Size_t capacity = 0,
1019 return Out_str_growable_ptrsize_z<Char_t, Size_t>(first,
length, capacity,
1049template <mysql::meta::Is_
charlike Char_t>
1051 Char_t *&first, Char_t *&last, Char_t *capacity_end =
nullptr,
1053 return Out_str_growable_ptrptr_z<Char_t>(first, last, capacity_end,
1081template <mysql::meta::Is_
charlike Char_t, std::
integral Size_t>
1083 Char_t *&first, Size_t &
length, Size_t capacity = 0,
1085 return Out_str_growable_ptrsize_nz<Char_t, Size_t>(first,
length, capacity,
1115template <mysql::meta::Is_
charlike Char_t>
1117 Char_t *&first, Char_t *&last, Char_t *capacity_end =
nullptr,
1119 return Out_str_growable_ptrptr_nz<Char_t>(first, last, capacity_end,
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
Polymorphism-free memory resource class with custom allocator and deallocator functions.
Definition: memory_resource.h:88
void * allocate(Size_t n) const
Allocate memory using the provided allocator.
Definition: memory_resource.h:113
void deallocate(Ptr_t p) const
Deallocate memory using the provided deallocator.
Definition: memory_resource.h:118
CRTP base class that provides a rich API for classes that behave like byte buffers.
Definition: buffer_interface.h:102
Top of the hierarchy.
Definition: out_str.h:194
Non-growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:618
Out_str_fixed_ptrptr_nz< Char_tp > This_t
Definition: out_str.h:619
Out_str_fixed_ptrptr_nz(Args_t &&...args)
Definition: out_str.h:624
Non-growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:603
Out_str_fixed_ptrptr_z< Char_tp > This_t
Definition: out_str.h:604
Out_str_fixed_ptrptr_z(Args_t &&...args)
Definition: out_str.h:609
Non-growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:648
Out_str_fixed_ptrsize_nz(Args_t &&...args)
Definition: out_str.h:654
Out_str_fixed_ptrsize_nz< Size_tp > This_t
Definition: out_str.h:649
Non-growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:633
Out_str_fixed_ptrsize_z(Args_t &&...args)
Definition: out_str.h:639
Out_str_fixed_ptrsize_z< Size_tp > This_t
Definition: out_str.h:634
Non-growable output buffer wrapper, represented as std::string.
Definition: out_str.h:593
Out_str_fixed_string(String_tp &str)
Definition: out_str.h:595
Growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:713
Out_str_growable_ptrptr_nz(Char_t *&first, Char_t *&last, Char_t *&capacity_end, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:715
Growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:700
Out_str_growable_ptrptr_z(Char_t *&first, Char_t *&last, Char_t *&capacity_end, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:702
Growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:687
Out_str_growable_ptrsize_nz(Char_t *&first, Size_tp &size, Size_tp capacity, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:689
Growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:674
Out_str_growable_ptrsize_z(Char_t *&first, Size_tp &size, Size_tp capacity, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:676
Growable output buffer wrapper, represented as std::string.
Definition: out_str.h:664
Out_str_growable_string(String_tp &str)
Definition: out_str.h:666
Base class for all Out_str_fixed* classes.
Definition: out_str.h:507
void resize(std::size_t size_arg) const
Assume that the character buffer has at least the given new size, and store the new size.
Definition: out_str.h:525
Policy_fixed(Args_t &&...args)
Construct a new object, forwarding all arguments to the base class.
Definition: out_str.h:518
Policy_fixed< Representation_tp, null_terminated_tp > This_t
Definition: out_str.h:509
static constexpr auto resize_policy
Definition: out_str.h:512
static constexpr auto null_terminated
Definition: out_str.h:513
Base class for all Out_str_growable_ptr* classes.
Definition: out_str.h:443
static constexpr auto resize_policy
Definition: out_str.h:450
Policy_growable_ptr< Char_tp, Representation_tp, null_terminated_tp > This_t
Definition: out_str.h:447
static constexpr size_t null_size
Definition: out_str.h:444
Policy_growable_ptr(Args_t &&...args)
Construct a new object, forwarding all arguments to the base class.
Definition: out_str.h:456
mysql::allocators::Memory_resource get_memory_resource() const
Return the Memory_resource.
Definition: out_str.h:468
static constexpr auto null_terminated
Definition: out_str.h:451
mysql::allocators::Memory_resource m_memory_resource
Definition: out_str.h:496
mysql::utils::Return_status resize(std::size_t size_arg) const
Resize the character buffer and store the new size.
Definition: out_str.h:478
Policy_growable_ptr(mysql::allocators::Memory_resource memory_resource, Args_t &&...args)
Construct a new object with the given Memory_resource, forwarding all remaining arguments to the base...
Definition: out_str.h:462
Base class for Out_str_growable_string.
Definition: out_str.h:415
Policy_growable_string(auto &...args)
Construct a new object, forwarding all arguments to the base class.
Definition: out_str.h:421
mysql::utils::Return_status resize(std::size_t size) const
Resize the std::string object.
Definition: out_str.h:429
static constexpr auto null_terminated
Definition: out_str.h:418
static constexpr auto resize_policy
Definition: out_str.h:417
Common CRTP base class for Representation_ptrptr and Representation_ptrsize.
Definition: out_str.h:297
char * data() const
Return pointer to the data.
Definition: out_str.h:304
std::size_t m_initial_capacity
Initial capacity.
Definition: out_str.h:316
Representation_ptr_base(Ptr_tp first, std::size_t capacity)
Construct a new object wrapping the buffer at the given position.
Definition: out_str.h:300
std::size_t initial_capacity() const
Before resize, return the value of the size field.
Definition: out_str.h:307
Ptr_tp m_first
Pointer to first character.
Definition: out_str.h:313
Represent a string as raw pointer to the beginning and raw pointer to the end.
Definition: out_str.h:329
static constexpr auto representation_type
Definition: out_str.h:333
void store_size(std::size_t size_arg) const
Alter the end pointer.
Definition: out_str.h:355
Representation_ptrptr(Ptr_tp first, Ptr_tp &last, Ptr_tp capacity_end)
Construct a new object from the given pointer to begin and pointer to end of capacity,...
Definition: out_str.h:337
std::size_t size() const
Definition: out_str.h:351
Ptr_tp & m_last
Reference to end pointer.
Definition: out_str.h:360
Represent a string as raw pointer to the beginning, and integer size.
Definition: out_str.h:375
void store_size(std::size_t size_arg) const
Alter the size field.
Definition: out_str.h:394
Size_tp & m_size
Reference to integral size.
Definition: out_str.h:397
std::size_t size() const
After resize, return the value of the size field.
Definition: out_str.h:390
static constexpr auto representation_type
Definition: out_str.h:380
Representation_ptrsize(Ptr_tp first, Size_tp &size_arg, Size_tp capacity)
Construct a new object from the given begin pointer, reference to size, and capacity.
Definition: out_str.h:384
Represent a string as an object, typically std::string.
Definition: out_str.h:257
std::size_t initial_capacity() const
Before resize, return the capacity of the string.
Definition: out_str.h:270
String_tp & m_str
Reference to string storage.
Definition: out_str.h:282
char * data() const
Return a raw pointer to the data.
Definition: out_str.h:265
void store_size(std::size_t size_arg) const
Store the string size.
Definition: out_str.h:279
std::size_t size() const
After resize, return the size of the string.
Definition: out_str.h:275
Representation_string(String_tp &str)
Construct a new object wrapping the given str object.
Definition: out_str.h:262
static constexpr auto representation_type
Definition: out_str.h:259
True if Test is an Output String Wrapper with Resize_policy fixed.
Definition: out_str.h:235
True if Test is an Output String Wrapper with Resize_policy growable.
Definition: out_str.h:240
True if Test is an Output String Wrapper, i.e., derived from Out_str_base.
Definition: out_str.h:219
Class that wraps resources in a polymorphic manner.
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
Definition: fts0fts.cc:236
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Definition: gtid_binary_format_conv.h:252
Policy_growable_ptr< Char_t, Representation_ptrsize< Char_t *&, Size_tp >, Null_terminated::no > Out_str_growable_ptrsize_nz_alias
Definition: out_str.h:570
Policy_fixed< Representation_string< String_tp >, Null_terminated::yes > Out_str_fixed_string_alias
Definition: out_str.h:540
Policy_growable_ptr< Char_t, Representation_ptrsize< Char_t *&, Size_tp >, Null_terminated::yes > Out_str_growable_ptrsize_z_alias
Definition: out_str.h:565
Policy_growable_string< Representation_string< String_tp > > Out_str_growable_string_alias
Definition: out_str.h:560
Policy_fixed< Representation_ptrptr< Char_tp * >, Null_terminated::yes > Out_str_fixed_ptrptr_z_alias
Definition: out_str.h:552
Policy_fixed< Representation_ptrsize< char *, Size_tp >, Null_terminated::yes > Out_str_fixed_ptrsize_z_alias
Definition: out_str.h:544
Policy_fixed< Representation_ptrsize< char *, Size_tp >, Null_terminated::no > Out_str_fixed_ptrsize_nz_alias
Definition: out_str.h:548
Policy_growable_ptr< Char_t, Representation_ptrptr< Char_t *& >, Null_terminated::no > Out_str_growable_ptrptr_nz_alias
Definition: out_str.h:580
Policy_growable_ptr< Char_t, Representation_ptrptr< Char_t *& >, Null_terminated::yes > Out_str_growable_ptrptr_z_alias
Definition: out_str.h:575
Policy_fixed< Representation_ptrptr< Char_tp * >, Null_terminated::no > Out_str_fixed_ptrptr_nz_alias
Definition: out_str.h:556
Definition: gtid_binary_format.h:41
Representation_type
Indicates the type of string represention used by an Output String Wrapper.
Definition: out_str.h:206
@ ptrptr
String represented using raw pointer to beginning and raw pointer to end.
@ string
String represented as std::string
@ ptrsize
String represented using raw pointer to beginning and integral size.
auto out_str_fixed_nz(mysql::meta::Is_pointer_to_charlike auto first, Size_t &length, Size_t capacity=0)
Return a wrapper around a non-growable, non-null-terminated output buffer, represented using a raw po...
Definition: out_str.h:818
Resize_policy
Indicates whether an Ouput String Wrapper is growable or fixed-size.
Definition: out_str.h:199
auto out_str_fixed(String_t &str)
Return a wrapper around a non-growable output buffer, represented as a std::string or similar type.
Definition: out_str.h:734
auto out_str_growable_nz(Char_t *&first, Size_t &length, Size_t capacity=0, const mysql::allocators::Memory_resource &memory_resource={})
Return a wrapper around a growable, non-null-terminated output buffer, represented using a reference ...
Definition: out_str.h:1082
auto out_str_growable_z(Char_t *&first, Size_t &length, Size_t capacity=0, const mysql::allocators::Memory_resource &memory_resource={})
Return a wrapper around a growable, null-terminated output buffer, represented using a reference to a...
Definition: out_str.h:1016
auto out_str_fixed_z(mysql::meta::Is_pointer_to_charlike auto first, Size_t &length, Size_t capacity=0)
Return a wrapper around a non-growable, null-terminated output buffer, represented using a raw pointe...
Definition: out_str.h:760
Null_terminated
Indicates whether an Output String Wrapper requires that the string shall be null-terminated or not.
Definition: out_str.h:203
auto out_str_growable(String_t &str)
Return a wrapper around a growable output buffer, represented as a std::string or similar type.
Definition: out_str.h:985
Return_status
Simple, strongly-typed enumeration to indicate internal status: ok, error.
Definition: return_status.h:40
Char_t & char_cast(mysql::meta::Is_charlike auto &ref)
Definition: char_cast.h:41
size_t size(const char *const c)
Definition: base64.h:46
Define std::hash<Gtid>.
Definition: gtid.h:355