MySQL 9.6.0
Source Code Documentation
mysql::strconv Namespace Reference

Namespaces

namespace  detail
 
namespace  throwing
 

Classes

struct  Binary_format
 Format tag to identify binary format. More...
 
struct  Boundary_set_text_format
 Tag to identify the formatting algorithm for boundary sets of integrals, and provide the separator strings and logic to skip whitespace around tokens. More...
 
class  Checker
 Class holding a checker function, used to check the validity of a parsed value. More...
 
struct  Compound_parse_options
 Represents parse options consisting of a tuple where each of the following elements occurs optionally: Format, Repeat, Checker. More...
 
struct  Concat_object
 Helper type that wraps the varargs of concat in a struct containing a tuple. More...
 
struct  Debug_format
 Format tag to identify debug format. More...
 
class  Escaped_format
 Format class to encode ascii strings. More...
 
struct  Fixint_binary_format
 Format tag to identify fixed-length-integer binary format. More...
 
struct  Fixstr_binary_format
 Format tag to identify fixed-length-string binary format. More...
 
class  Fluent_parser
 Fluent API for parsing strings. More...
 
struct  Format_base
 Top of the hierarchy. More...
 
struct  Gtid_binary_format
 
struct  Gtid_text_format
 
struct  Hex_format
 Format tag to identify hex format when encoding and decoding strings. More...
 
struct  Nested_set_text_format
 Tag to identify the formatting algorithm for nested sets, using the given format tags for the key type and the mapped type, respectively. More...
 
class  Out_str_base
 Top of the hierarchy. More...
 
class  Out_str_fixed_ptrptr_nz
 Non-growable output buffer wrapper, represented as raw pointers to the beginning and end, non-null-terminated. More...
 
class  Out_str_fixed_ptrptr_z
 Non-growable output buffer wrapper, represented as raw pointers to the beginning and end, null-terminated. More...
 
class  Out_str_fixed_ptrsize_nz
 Non-growable output buffer wrapper, represented as raw pointer to the beginning, and integer size, non-null-terminated. More...
 
class  Out_str_fixed_ptrsize_z
 Non-growable output buffer wrapper, represented as raw pointer to the beginning, and integer size, null-terminated. More...
 
class  Out_str_fixed_string
 Non-growable output buffer wrapper, represented as std::string. More...
 
class  Out_str_growable_ptrptr_nz
 Growable output buffer wrapper, represented as raw pointers to the beginning and end, non-null-terminated. More...
 
class  Out_str_growable_ptrptr_z
 Growable output buffer wrapper, represented as raw pointers to the beginning and end, null-terminated. More...
 
class  Out_str_growable_ptrsize_nz
 Growable output buffer wrapper, represented as raw pointer to the beginning, and integer size, non-null-terminated. More...
 
class  Out_str_growable_ptrsize_z
 Growable output buffer wrapper, represented as raw pointer to the beginning, and integer size, null-terminated. More...
 
class  Out_str_growable_string
 Growable output buffer wrapper, represented as std::string. More...
 
class  Parser
 Object used to parse strings. More...
 
class  Repeat
 Represents a range of integers specifying the number of times a token or pattern should be repeated when parsing a string. More...
 
class  Repeat_optional
 Represents a range of integers for which the lower bound is 0, representing the number of repetitions of a token when parsing a string. More...
 
class  Streamable
 Wrapper around an std::optional<std::string> object returned from encode, intended to be passed to operator<<, allowing it to implement ostream-idiomatic error handling. More...
 
class  String_counter
 Class that serves as the target for encode(..., Is_string_target), which never writes anything and only stores the size. More...
 
class  String_writer
 Class that serves as the target for encode(..., Is_string_target), which writes to a char * buffer without bounds checking. More...
 
struct  Text_format
 Format tag to identify text format. More...
 

Concepts

concept  Is_nested_set_text_format
 
concept  Is_checker_function
 True for types that are invocable without arguments.
 
concept  Is_checker
 True for all Checker specializations.
 
concept  Is_compound_parse_options
 True if Test is a Compound_parse_options object with at most one Format element, at most one Repeat element, and at most one other element.
 
concept  Is_parse_options
 True for any kind of parse options: Format, Repeat, Checker, or Compound_parse_options.
 
concept  Is_parse_options_nocheck
 True for any kind of parse options: Format, Repeat, Checker, or Compound_parse_options.
 
concept  Is_parse_options_optional
 True for any kind of parse options for which get_repeat() returns Repeat_optional, i.e., it is known at compile-time that a string of length 0 matches, and thus parse error is impossible.
 
concept  Is_repeat
 True if Test is either Repeat or Repeat_optional.
 
concept  Is_out_str
 True if Test is an Output String Wrapper, i.e., derived from Out_str_base.
 
concept  Is_out_str_fixed
 True if Test is an Output String Wrapper with Resize_policy fixed.
 
concept  Is_out_str_growable
 True if Test is an Output String Wrapper with Resize_policy growable.
 
concept  Is_string_producer_counter
 True if Test can be invoked with a String_counter & argument and returns void or Return_status.
 
concept  Is_string_producer_writer
 True if Test can be invoked with a String_writer & argument and returns void or Return_status.
 
concept  Is_string_producer_pair
 True for pairs of string producer counters/writers that can be used with out_str_write, i.e., the counter accepts a String_counter &, the writer accepts a String_writer &, and the return types are either void or Return_status.
 
concept  Is_string_producer
 True for invocables that can be used with out_str_write, i.e., which accept either a String_writer & or a String_counter & argument, and the return type is either void or Return_status.
 
concept  Is_string_target
 Concept that holds for String_counter and String_writer.
 
concept  Is_format
 True if Test is a format.
 

Typedefs

using Empty_parse_options = Compound_parse_options< std::tuple<> >
 

Enumerations

enum class  Skip_whitespace { no , yes }
 
enum class  Allow_redundant_separators { no , yes }
 
enum class  Allow_empty { no , yes }
 
enum class  Allow_repeated_separators { no , yes }
 Used in read_repeated_with_separators: if yes, the separator may be repeated more than once whenever it occurs. More...
 
enum class  Leading_separators { no , yes , optional }
 Used in read_repeated_with_separators: if yes, the string must start with a separator; if no, the string must not start with a separator; if optional, the string may or may not start with a separator. More...
 
enum class  Trailing_separators { no , yes , optional }
 Used in read_repeated_with_separators: if yes, the string must end with a separator; if no, the string must not end with a separator; if optional, the string may or may not end with a separator. More...
 
enum class  Resize_policy { growable , fixed }
 Indicates whether an Ouput String Wrapper is growable or fixed-size. More...
 
enum class  Null_terminated { no , yes }
 Indicates whether an Output String Wrapper requires that the string shall be null-terminated or not. More...
 
enum class  Representation_type { string , ptrptr , ptrsize }
 Indicates the type of string represention used by an Output String Wrapper. More...
 
enum class  Target_type { counter , writer }
 
enum class  With_quotes { no , yes }
 Whether output string should be enclosed in quote characters: "foo" vs foo. More...
 
enum class  Preserve_high_characters { no , yes }
 Whether ascii 128..255 should be preserved or escaped: backslash-xff vs ascii 255. More...
 
enum class  Numeric_control_characters { no , yes }
 Whether ascii 7..13 should use hex instead of mnemonics: backslash-x0a vs backslash-n. More...
 
enum class  Hex_case { lower , upper , lower_only , upper_only }
 Policy for using uppercase/lowercase in hex conversion. More...
 

Functions

template<class Object_t >
requires mysql::gtids::Is_tag<Object_t> || mysql::gtids::Is_gtid<Object_t> || mysql::gtids::Is_tsid<Object_t> || mysql::gtids::Is_gtid_set<Object_t>
auto get_default_format (const Binary_format &, const Object_t &)
 
void encode_impl (const Gtid_binary_format &format, Is_string_target auto &target, const mysql::gtids::Is_tag auto &tag)
 
void decode_impl (const Gtid_binary_format &format, Parser &parser, mysql::gtids::Is_tag auto &tag)
 
void encode_impl (const Gtid_binary_format &format, Is_string_target auto &string_target, const mysql::gtids::Is_tsid auto &tsid)
 
void decode_impl (const Gtid_binary_format &format, Parser &parser, mysql::gtids::Is_tsid auto &tsid)
 
void encode_impl (const Gtid_binary_format &format, Is_string_target auto &string_target, const mysql::gtids::Is_gtid auto &gtid)
 
void decode_impl (const Gtid_binary_format &format, Parser &parser, mysql::gtids::Is_gtid auto &gtid)
 
void encode_impl (const Gtid_binary_format &format, Is_string_target auto &string_target, const mysql::gtids::detail::Gtid_set_header &header)
 
void decode_impl (const Gtid_binary_format &format, Parser &parser, mysql::gtids::detail::Gtid_set_header &out)
 
void encode_impl (const Gtid_binary_format &format, Is_string_target auto &string_target, const mysql::gtids::Is_gtid_set auto &gtid_set)
 
void decode_impl (const Gtid_binary_format &format, Parser &parser, mysql::gtids::Is_gtid_set auto &gtid_set)
 
template<class Object_t >
requires mysql::gtids::Is_tag<Object_t> || mysql::gtids::Is_gtid<Object_t> || mysql::gtids::Is_tsid<Object_t>
auto get_default_format (const Text_format &, const Object_t &)
 
template<class Object_t >
requires mysql::sets::Is_nested_set<Object_t> && mysql::gtids::Is_gtid_set<Object_t>
auto get_default_format (const Text_format &, const Object_t &)
 
void encode_impl (const Gtid_text_format &format, Is_string_target auto &target, const mysql::gtids::Is_tag auto &tag)
 
void decode_impl (const Gtid_text_format &, Parser &parser, mysql::gtids::Is_tag auto &tag)
 
void encode_impl (const Gtid_text_format &format, Is_string_target auto &target, const mysql::gtids::Is_tsid auto &tsid)
 
void decode_impl (const Gtid_text_format &format, Parser &parser, mysql::gtids::Is_tsid auto &tsid)
 
void encode_impl (const Gtid_text_format &format, Is_string_target auto &target, const mysql::gtids::Is_gtid auto &gtid)
 
void decode_impl (const Gtid_text_format &format, Parser &parser, mysql::gtids::Is_gtid auto &gtid)
 
void encode_impl (const Gtid_text_format &format, Is_string_target auto &target, const mysql::gtids::Is_gtid_set auto &gtid_set)
 
template<mysql::gtids::Is_gtid_set Gtid_set_t>
void decode_impl (const Gtid_text_format &format, Parser &parser, Gtid_set_t &gtid_set)
 
template<class Object_t >
requires mysql::meta::Is_specialization<Object_t, mysql::sets::Interval> || mysql::sets::Is_boundary_set<Object_t> || mysql::sets::Is_interval_set<Object_t>
auto get_default_format (const Text_format &, const Object_t &)
 Make mysql::strconv::encode_text (and encode(Text_format{}, ...) use Boundary_set_text_format when the object to format is an Interval, Boundary sets, or Interval set. More...
 
template<mysql::sets::Is_discrete_set_traits Set_traits_t>
void decode_impl (const Boundary_set_text_format &format, mysql::strconv::Parser &parser, mysql::sets::detail::Relaxed_interval< Set_traits_t > &out)
 Enable mysql::strconv::decode(Text_format, Relaxed_interval), for boundary containers whose Set traits that are discrete. More...
 
template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_set_traits< typename Boundary_container_t::Set_traits_t>
void decode_impl (const Boundary_set_text_format &format, mysql::strconv::Parser &parser, const std::pair< Boundary_container_t &, typename Boundary_container_t::Iterator_t & > &out)
 Enable mysql::strconv::decode(Text_format, std::pair<Boundary_container, cursor>), for boundary containers whose Set traits that are discrete. More...
 
template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_set_traits< typename Boundary_container_t::Set_traits_t>
void decode_impl (const Boundary_set_text_format &format, mysql::strconv::Parser &parser, Boundary_container_t &out)
 Enable mysql::strconv::decode(Text_format, Boundary_container), for boundary containers whose Set traits that are discrete. More...
 
template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_metric_set_traits< typename Boundary_container_t::Set_traits_t>
void decode_impl (const Binary_format &format, mysql::strconv::Parser &parser, Boundary_container_t &out)
 Enable mysql::strconv::decode(Binary_format, Boundary_container), for boundary containers that are discrete and metric. More...
 
template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_set_traits< typename Boundary_container_t::Set_traits_t>
void decode_impl (const Fixint_binary_format &format, mysql::strconv::Parser &parser, Boundary_container_t &out)
 Enable mysql::strconv::decode(Fixint_binary_format, Boundary_container), for boundary containers that are discrete. More...
 
template<mysql::sets::Is_interval_container Interval_container_t>
void decode_impl (const Is_format auto &format, mysql::strconv::Parser &parser, Interval_container_t &out)
 Enable mysql::strconv::decode(/*Format*‍/, Interval_container), by reading the boundaries in the given format. More...
 
template<mysql::sets::Is_bounded_set_traits Set_traits_t>
void encode_impl (const Boundary_set_text_format &format, Is_string_target auto &target, const mysql::sets::Interval< Set_traits_t > &interval)
 Enable mysql::strconv::encode(Boundary_set_text_format, Interval), for intervals whose Set traits that are discrete. More...
 
template<mysql::sets::Is_boundary_set Boundary_set_t>
void encode_impl (const Boundary_set_text_format &format, Is_string_target auto &target, const Boundary_set_t &boundary_set)
 Enable mysql::strconv::encode(Boundary_set_text_format, Interval), for boundary sets whose Set traits that are discrete. More...
 
template<mysql::sets::Is_boundary_set Boundary_set_t>
void encode_impl (const Fixint_binary_format &format, Is_string_target auto &target, const Boundary_set_t &boundary_set)
 Enable mysql::strconv::encode(Fixint_binary_format, Boundary_set), for boundary sets whose Set traits that are discrete. More...
 
template<mysql::sets::Is_boundary_set Boundary_set_t>
requires mysql::sets::Is_discrete_metric_set_traits< typename Boundary_set_t::Set_traits_t>
void encode_impl (const Binary_format &format, Is_string_target auto &target, const Boundary_set_t &boundary_set)
 Enable mysql::strconv::encode(Binary_format, Boundary_set), for boundary sets whose Set traits that are discrete and metric. More...
 
void encode_impl (const Is_format auto &format, Is_string_target auto &target, const mysql::sets::Is_interval_set auto &interval_set)
 Enable mysql::strconv::encode(/*Format*‍/, Interval_set), by writing the boundaries in the given format. More...
 
void encode_impl (const mysql::strconv::Is_nested_set_text_format auto &format, Is_string_target auto &target, const mysql::sets::Is_nested_set auto &nested_set)
 Enable mysql::strconv::encode(/*Format*‍/, Nested_set), by writing the boundaries in the given format. More...
 
auto get_default_format (const Text_format &, const mysql::sets::Is_nested_set auto &)
 Make mysql::strconv::encode_text (and encode(Text_format{}, ...) use Nested_set_text_format when the object to format is a Nested set. More...
 
template<Is_string_target Target_t>
void encode_impl (const Binary_format &format, Target_t &target, const std::integral auto &value)
 Format an integer in variable-length, binary format. More...
 
void encode_impl (const Binary_format &format, Is_string_target auto &target, const std::string_view &sv)
 Format a string using variable-length, binary format for the length. More...
 
void decode_impl (const Binary_format &format, Parser &parser, std::integral auto &out)
 Parse an integral in variable-width integer format type into out, advance the position, and return the status. More...
 
void decode_impl (const Binary_format &format, Parser &parser, std::string_view &out)
 Parse a string in binary format, using variable-length integer format for the length; store the result by making the given std::string_view & point directly into the input string. More...
 
void decode_impl (const Binary_format &format, Parser &parser, Is_string_target auto &out)
 Parse a string in binary format, using variable-length integer format for the length; make the given std::string_ref & refer to the corresponding segment of the input buffer; advance the position; and return the status. More...
 
void encode_impl (const Debug_format &format, Is_string_target auto &target, const detail::Parse_status &status)
 Enable encode(Debug_format, Parse_status), to help debugging. More...
 
void encode (const Debug_format &format, Is_string_target auto &target, const Repeat &repeat)
 
void encode_impl (const mysql::meta::Is_nontype_specialization< Escaped_format > auto &format, Is_string_target auto &target, const std::string_view &sv)
 
template<Is_string_target Target_t>
void encode_impl (const Fixint_binary_format &format, Target_t &target, const std::integral auto &value)
 Format an integer in fixed-length, binary format. More...
 
template<std::integral Value_t>
void decode_impl (const Fixint_binary_format &format, Parser &parser, Value_t &out)
 Parse an integral in fixed-width integer format type into out, advance the position, and return the status. More...
 
void decode_impl (const Fixstr_binary_format &format, Parser &parser, std::string_view &out)
 Parse a string in fixed-length format into out, advance the position, and return the status. More...
 
void decode_impl (const Fixstr_binary_format &format, Parser &parser, Is_string_target auto &out)
 Parse a string in fixed-length format into out, advance the position, and return the status. More...
 
template<Is_string_target Target_t>
void encode_impl (const mysql::meta::Is_nontype_specialization< Hex_format > auto &format, Target_t &target, const std::string_view &sv)
 Format the given char buffer in hex format. More...
 
void decode_impl (const mysql::meta::Is_nontype_specialization< Hex_format > auto &format, Parser &parser, Is_string_target auto &target)
 Read into a single character from a string of two hex digits. More...
 
template<std::integral Value_t>
constexpr void encode_impl (const Text_format &format, String_counter &counter, Value_t value)
 Compute the length of a text-formatted integer. More...
 
template<std::integral Value_t>
constexpr void encode_impl (const Text_format &format, String_writer &writer, Value_t value)
 Write a text-formatted integer to a String_writer. More...
 
void encode_impl (const Text_format &format, Is_string_target auto &target, const std::string_view &sv)
 Format the given string_view in text format, by copying the string data literally to the output buffer. More...
 
template<std::integral Value_t>
void decode_impl (const Text_format &format, Parser &parser, Value_t &out)
 Parse an integer in text format into out. More...
 
void encode_impl (const Text_format &format, Is_string_target auto &target, const Parser &obj)
 Enable encode(Text_format, Parse_result). More...
 
void encode_impl (const Text_format &format, Is_string_target auto &target, const std::source_location &source_location)
 Enable conversion from std::source_location to string. More...
 
Parser decode (const Is_parse_options_nocheck auto &opt, const std::string_view &in_sv, auto &out)
 Parse from a string into the given object, according to the parse options. More...
 
Parser test_decode (const Is_parse_options_nocheck auto &opt, const std::string_view &in_sv)
 Test for success when parsing (decoding) a string from a string, without producing output. More...
 
std::ptrdiff_t compute_decoded_length (const Is_parse_options_nocheck auto &opt, const std::string_view &in_sv)
 Compute the output length when parsing a string from a string. More...
 
Parser decode (const Is_parse_options_nocheck auto &opt, const std::string_view &in_sv, const Is_out_str auto &out_str)
 Parse from a string into an Is_out_str object. More...
 
Parser decode (const Is_parse_options_nocheck auto &opt, const std::string_view &in_sv, mysql::meta::Is_specialization< std::basic_string > auto &out)
 Parse from a string into an std::string object. More...
 
Parser decode_text (const std::string_view &in_sv, auto &out)
 Parse from a string into the given object in text format. More...
 
template<class... Args_t>
 Compound_parse_options (std::tuple< Args_t... >) -> Compound_parse_options< std::tuple< Args_t... > >
 Deduction guide. More...
 
auto get_format (const Is_parse_options auto &)
 Return the Format component of any parse options that has one. More...
 
auto get_format (const Is_format auto &format)
 
template<Is_compound_parse_options Compound_parse_options_t>
requires Compound_parse_options_t
::has_format auto get_format (const Compound_parse_options_t &opt)
 
auto get_repeat (const Is_parse_options auto &)
 Return the Repeat component of any parse options, if it exists; otherwise a default-constructed Repeat object. More...
 
auto get_repeat (const Is_repeat auto &repeat)
 
template<Is_compound_parse_options Compound_parse_options_t>
requires Compound_parse_options_t
::has_repeat auto get_repeat (const Compound_parse_options_t &opt)
 
void invoke_checker (const Is_parse_options auto &)
 Invoke the Checker member of any parse options, if it exists; otherwise do nothing. More...
 
void invoke_checker (const Is_checker auto &checker)
 
template<Is_compound_parse_options Compound_parse_options_t>
requires Compound_parse_options_t
::has_checker void invoke_checker (const Compound_parse_options_t &opt)
 
template<Is_parse_options Opt1, Is_parse_options Opt2>
auto operator| (const Opt1 &opt1, const Opt2 &opt2)
 Combine two Parse Options objects into one. More...
 
constexpr bool is_space (int x)
 Return true if the given character is a space character, i.e., ascii 9, 10, 11, 12, 13, or 32. More...
 
void skip_whitespace (Parser &parser)
 Move the position forward until end or non-whitespace. More...
 
template<std::size_t index = 0, class... Args_t>
void encode_impl (const Is_format auto &format, Is_string_target auto &target, const Concat_object< Args_t... > &concat_object)
 
template<Is_format Format_t, class... Args_t>
auto concat_length (const Format_t &format, const Args_t &...args) noexcept
 Compute the length of the concatenation of the string representations of the objects. More...
 
template<Is_format Format_t, Is_out_str Out_str_t, class... Args_t>
auto concat (const Format_t &format, const Out_str_t &out, const Args_t &...args) noexcept
 Concatenate the string representations of the objects into the output string wrapper. More...
 
template<class String_t = std::string, Is_format Format_t, class... Args_t>
auto concat (const Format_t &format, const Args_t &...args) noexcept
 Concatenate the string representations of the objects and return a std::optional<std::string> object holding the result. More...
 
std::size_t compute_encoded_length (const Is_format auto &format, const auto &object)
 Return the string length of the object. More...
 
void encode (const Is_format auto &format, const Is_out_str_fixed auto &out_str, const auto &object)
 Write the string representation of the object to the given string output wrapper. More...
 
auto encode (const Is_format auto &format, const Is_out_str_growable auto &out_str, const auto &object)
 Write the string representation of the object to the given string output wrapper. More...
 
template<class String_t = std::string>
std::optional< String_t > encode (const Is_format auto &format, const auto &object)
 Return an std::optional<std::string> object holding the string representation of the object. More...
 
template<class String_t = std::string>
Streamable< String_t > encode_to_streamable (const Is_format auto &format, const auto &object)
 Return a Streamable object holding the result from encode(format, object). More...
 
std::ostream & operator<< (std::ostream &out, const mysql::meta::Is_specialization< Streamable > auto &streamable)
 Use output operator to write the string representation of a format-tagged object to the given ostream. More...
 
template<class Object_t >
std::size_t compute_encoded_length_debug (const Object_t &object)
 Return the string length of the object, using Debug_format. More...
 
template<Is_out_str_fixed Out_str_t, class Object_t >
auto encode_debug (Out_str_t out_str, const Object_t &object)
 Write the string representation of the object to the given string output wrapper, using Debug_format. More...
 
template<class String_t = std::string, class Object_t >
std::optional< String_t > encode_debug (const Object_t &object)
 Return an std::optional<std::string> object holding the string representation of the object, using Debug_format. More...
 
template<class String_t = std::string, class... Objects_t>
auto concat_debug (const Objects_t &...objects)
 Return an std::optional<std::string> object holding the concatenated string representations of the objects, using Debug_format. More...
 
template<class Object_t >
std::size_t compute_encoded_length_text (const Object_t &object)
 Return the string length of the object, using Text_format. More...
 
template<Is_out_str_fixed Out_str_t, class Object_t >
auto encode_text (Out_str_t out_str, const Object_t &object)
 Write the string representation of the object to the given string output wrapper, using Text_format. More...
 
template<class String_t = std::string, class Object_t >
auto encode_text (const Object_t &object)
 Return an std::optional<std::string> object holding the string representation of the object, using Text_format. More...
 
template<class String_t = std::string, class... Objects_t>
auto concat_text (const Objects_t &...objects)
 Return an std::optional<std::string> object holding the concatenated string representations of the objects, using Text_format. More...
 
template<mysql::meta::Is_specialization< std::basic_string > String_t>
auto out_str_fixed (String_t &str)
 Return a wrapper around a non-growable output buffer, represented as a std::string or similar type. More...
 
template<std::integral Size_t>
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 pointer to the beginning and a reference to an integral size. More...
 
template<mysql::meta::Is_charlike Char_t, mysql::meta::Is_pointer_to< Char_t > Charptr_t>
auto out_str_fixed_z (Charptr_t first, Char_t *&last, Char_t *capacity_end=nullptr)
 Return a wrapper around a non-growable, null-terminated output buffer, represented using raw a pointer to the beginning and a reference to a raw pointer to the end. More...
 
template<std::integral Size_t>
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 pointer to the beginning and a reference to an integral size. More...
 
template<mysql::meta::Is_charlike Char_t, mysql::meta::Is_pointer_to< Char_t > Charptr_t>
auto out_str_fixed_nz (Charptr_t first, Char_t *&last, Char_t *capacity_end=nullptr)
 Return a wrapper around a non-growable, non-null-terminated output buffer, represented using raw a pointer to the beginning and a reference to a raw pointer to the end. More...
 
template<std::integral Size_t, std::ptrdiff_t array_size>
auto out_str_fixed_z (mysql::meta::Is_charlike auto(&first)[array_size], Size_t &length, Size_t capacity=0)
 Return a wrapper around a non-growable, null-terminated output buffer, represented as an array and a reference to an integral size. More...
 
template<mysql::meta::Is_charlike Char_t, std::ptrdiff_t array_size>
auto out_str_fixed_z (Char_t(&first)[array_size], Char_t *&last, Char_t *capacity_end=nullptr)
 Return a wrapper around a non-growable, null-terminated output buffer, represented as an array and a reference to a raw pointer to the end. More...
 
template<std::integral Size_t, std::ptrdiff_t array_size>
auto out_str_fixed_nz (mysql::meta::Is_charlike auto(&first)[array_size], Size_t &length, Size_t capacity=0)
 Return a wrapper around a non-growable, non-null-terminated output buffer, represented as an array and a reference to an integral size. More...
 
template<mysql::meta::Is_charlike Char_t, std::ptrdiff_t array_size>
auto out_str_fixed_nz (Char_t(&first)[array_size], Char_t *&last, Char_t *capacity_end=nullptr)
 Return a wrapper around a non-growable, non-null-terminated output buffer, represented as an array and a reference to a raw pointer to the end. More...
 
template<mysql::meta::Is_specialization< std::basic_string > String_t>
auto out_str_growable (String_t &str)
 Return a wrapper around a growable output buffer, represented as a std::string or similar type. More...
 
template<mysql::meta::Is_charlike Char_t, std::integral Size_t>
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 raw pointer to the beginning and a reference to an integral size. More...
 
template<mysql::meta::Is_charlike Char_t>
auto out_str_growable_z (Char_t *&first, Char_t *&last, Char_t *capacity_end=nullptr, const mysql::allocators::Memory_resource &memory_resource={})
 Return a wrapper around a growable, null-terminated output buffer, represented using reference to a raw a pointer to the beginning and a reference to a raw pointer to the end. More...
 
template<mysql::meta::Is_charlike Char_t, std::integral Size_t>
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 to a raw pointer to the beginning and a reference to an integral size. More...
 
template<mysql::meta::Is_charlike Char_t>
auto out_str_growable_nz (Char_t *&first, Char_t *&last, Char_t *capacity_end=nullptr, const mysql::allocators::Memory_resource &memory_resource={})
 Return a wrapper around a growable, non-null-terminated output buffer, represented using reference to a raw a pointer to the beginning and a reference to a raw pointer to the end. More...
 
template<Is_out_str Out_str_t, class Producer_counter_t , class Producer_writer_t , std::invocable Oom_action_t = detail::Nop_t>
requires Is_string_producer_pair<Producer_counter_t, Producer_writer_t>
mysql::utils::Return_status out_str_write (const Out_str_t &out_str, const Producer_counter_t &producer_counter, const Producer_writer_t &producer_writer, const Oom_action_t &oom_action=detail::nop)
 Given an Is_out_str object, a String_producer_counter, and a String_producer_writer, resizes the object as needed and then writes to it. More...
 
template<Is_out_str_fixed Out_str_t, class Producer_counter_t , class Producer_writer_t , std::invocable Oom_action_t = detail::Nop_t>
requires Is_string_producer_pair<Producer_counter_t, Producer_writer_t> && (std::same_as< std::invoke_result_t<Producer_counter_t, String_counter &>, void>) && (std::same_as< std::invoke_result_t<Producer_writer_t, String_writer &>, void>)
void out_str_write (const Out_str_t &out_str, const Producer_counter_t &producer_counter, const Producer_writer_t &producer_writer, const Oom_action_t &oom_action=detail::nop)
 Given an Is_out_str object, a String_producer_counter, and a String_producer_writer, resizes the object as needed and then writes to it. More...
 
template<std::invocable Oom_action_t = detail::Nop_t>
auto out_str_write (const Is_out_str auto &out_str, const Is_string_producer auto &producer, const Oom_action_t &oom_action=detail::nop)
 Given an Is_out_str object and an Is_string_producer, resize the object as needed and then write to it. More...
 
template<std::invocable Oom_action_t = detail::Nop_t>
auto out_str_copy (const Is_out_str auto &out_str, const std::string_view &sv, const Oom_action_t &oom_action=detail::nop)
 Copy the given string_view to the Output String Wrapper, resizing as needed. More...
 
template<Is_string_target Target_t>
void encode_impl (const Text_format &format, Target_t &target, const mysql::uuids::Uuid &uuid)
 Enable encode_text(Uuid). More...
 
void decode_impl (const Text_format &format, Parser &parser, mysql::uuids::Uuid &uuid)
 Enable decode(Text_format, string, Uuid). More...
 
void encode_impl (const Binary_format &, Is_string_target auto &target, const mysql::uuids::Uuid &uuid)
 Enable encode(Binary_format, Uuid). More...
 
void decode_impl (const Binary_format &, Parser &parser, mysql::uuids::Uuid &uuid)
 Enable decode(Binary_format, Uuid). More...
 

Typedef Documentation

◆ Empty_parse_options

Enumeration Type Documentation

◆ Allow_empty

enum class mysql::strconv::Allow_empty
strong
Enumerator
no 
yes 

◆ Allow_redundant_separators

Enumerator
no 
yes 

◆ Allow_repeated_separators

Used in read_repeated_with_separators: if yes, the separator may be repeated more than once whenever it occurs.

Enumerator
no 
yes 

◆ Hex_case

enum class mysql::strconv::Hex_case
strong

Policy for using uppercase/lowercase in hex conversion.

Enumerator
lower 
upper 
lower_only 
upper_only 

◆ Leading_separators

Used in read_repeated_with_separators: if yes, the string must start with a separator; if no, the string must not start with a separator; if optional, the string may or may not start with a separator.

Enumerator
no 
yes 
optional 

◆ Null_terminated

Indicates whether an Output String Wrapper requires that the string shall be null-terminated or not.

Enumerator
no 
yes 

◆ Numeric_control_characters

Whether ascii 7..13 should use hex instead of mnemonics: backslash-x0a vs backslash-n.

Enumerator
no 
yes 

◆ Preserve_high_characters

Whether ascii 128..255 should be preserved or escaped: backslash-xff vs ascii 255.

Enumerator
no 
yes 

◆ Representation_type

Indicates the type of string represention used by an Output String Wrapper.

Enumerator
string 

String represented as std::string

ptrptr 

String represented using raw pointer to beginning and raw pointer to end.

ptrsize 

String represented using raw pointer to beginning and integral size.

◆ Resize_policy

enum class mysql::strconv::Resize_policy
strong

Indicates whether an Ouput String Wrapper is growable or fixed-size.

Enumerator
growable 
fixed 

◆ Skip_whitespace

Enumerator
no 
yes 

◆ Target_type

enum class mysql::strconv::Target_type
strong
Enumerator
counter 
writer 

◆ Trailing_separators

Used in read_repeated_with_separators: if yes, the string must end with a separator; if no, the string must not end with a separator; if optional, the string may or may not end with a separator.

Enumerator
no 
yes 
optional 

◆ With_quotes

enum class mysql::strconv::With_quotes
strong

Whether output string should be enclosed in quote characters: "foo" vs foo.

Enumerator
no 
yes 

Function Documentation

◆ Compound_parse_options()

template<class... Args_t>
mysql::strconv::Compound_parse_options ( std::tuple< Args_t... >  ) -> Compound_parse_options< std::tuple< Args_t... > >

Deduction guide.

◆ compute_decoded_length()

std::ptrdiff_t mysql::strconv::compute_decoded_length ( const Is_parse_options_nocheck auto &  opt,
const std::string_view &  in_sv 
)

Compute the output length when parsing a string from a string.

If this succeeds, it is guaranteed that a subsequent invocation of decode will not produce a parse_error. But note that it is possible for it to fail with an out-of-memory error.

This is an API wrapper for objects/formats for which decode_impl(opt, pos, Is_string_target) has been implemented.

Parameters
optParse options, which should include the format, and may include a number of repetitions.
in_svInput represented as string_view.
Returns
The length, or -1 on parse error.

◆ compute_encoded_length()

std::size_t mysql::strconv::compute_encoded_length ( const Is_format auto &  format,
const auto &  object 
)

Return the string length of the object.

Parameters
formatDescription of output format.
objectObject for which the size of the string representation shall be computed.
Note
If you plan to allocate memory for a null-terminated string, remember to add 1 byte for the trailing '\0'.
Returns
Size of the string representation of object, not counting any trailing '\0' characters.

◆ compute_encoded_length_debug()

template<class Object_t >
std::size_t mysql::strconv::compute_encoded_length_debug ( const Object_t &  object)

Return the string length of the object, using Debug_format.

Note
If you plan to allocate memory for a null-terminated string, remember to add 1 byte for the trailing '\0'.

◆ compute_encoded_length_text()

template<class Object_t >
std::size_t mysql::strconv::compute_encoded_length_text ( const Object_t &  object)

Return the string length of the object, using Text_format.

Note
If you plan to allocate memory for a null-terminated string, remember to add 1 byte for the trailing '\0'.

◆ concat() [1/2]

template<class String_t = std::string, Is_format Format_t, class... Args_t>
auto mysql::strconv::concat ( const Format_t &  format,
const Args_t &...  args 
)
noexcept

Concatenate the string representations of the objects and return a std::optional<std::string> object holding the result.

Template Parameters
String_tOutput string type. Defaults to std::string.
Format_tType of format.
Args_tTypes of objects.
Parameters
formatFormat object.
argsObjects.
Returns
std::optional holding a String_t object on success, or no value on out-of-memory.

◆ concat() [2/2]

template<Is_format Format_t, Is_out_str Out_str_t, class... Args_t>
auto mysql::strconv::concat ( const Format_t &  format,
const Out_str_t &  out,
const Args_t &...  args 
)
noexcept

Concatenate the string representations of the objects into the output string wrapper.

Template Parameters
Format_tType of format.
Out_str_tType of output string wrapper.
Args_tTypes of objects.
Parameters
formatFormat object.
outOutput String Wrapper in which the result will be saved.
argsObjects.
Returns
Return_status::ok on success, Return_status::error on out-of-memory.

◆ concat_debug()

template<class String_t = std::string, class... Objects_t>
auto mysql::strconv::concat_debug ( const Objects_t &...  objects)

Return an std::optional<std::string> object holding the concatenated string representations of the objects, using Debug_format.

Template Parameters
String_tOutput string type. Defaults to std::string.
Objects_tTypes of objects.
Parameters
objectsObjects to write.
Returns
std::optional<std::string> object holding the concatenated string representations of objects, or holding no value if an out-of-memory condition occurred.

◆ concat_length()

template<Is_format Format_t, class... Args_t>
auto mysql::strconv::concat_length ( const Format_t &  format,
const Args_t &...  args 
)
noexcept

Compute the length of the concatenation of the string representations of the objects.

Template Parameters
Format_tType of format.
Args_tTypes of objects.
Parameters
formatFormat object.
argsObjects.

◆ concat_text()

template<class String_t = std::string, class... Objects_t>
auto mysql::strconv::concat_text ( const Objects_t &...  objects)

Return an std::optional<std::string> object holding the concatenated string representations of the objects, using Text_format.

Template Parameters
String_tOutput string type. Defaults to std::string.
Objects_tTypes of objects.
Parameters
objectsObjects to write.
Returns
std::optional<std::string> object holding the concatenated string representations of objects, or holding no value if an out-of-memory condition occurred.

◆ decode() [1/3]

Parser mysql::strconv::decode ( const Is_parse_options_nocheck auto &  opt,
const std::string_view &  in_sv,
auto &  out 
)

Parse from a string into the given object, according to the parse options.

Parameters
optParse options, which should include the format, and may include a number of repetitions.
in_svInput represented as string_view.
[out]outReference to object to read into. In case of error, this may be in a "half-parsed" state.
Returns
Parser that can be queried for success and error messages.

◆ decode() [2/3]

Parser mysql::strconv::decode ( const Is_parse_options_nocheck auto &  opt,
const std::string_view &  in_sv,
const Is_out_str auto &  out_str 
)

Parse from a string into an Is_out_str object.

This is an API wrapper for objects/formats for which decode_impl(opt, pos, Is_string_target) has been implemented.

Parameters
optParse options, which should include the format, and may include a number of repetitions.
in_svInput represented as string_view.
[out]out_strOutput string wrapper to read into. In case of errors, this is unchanged.
Returns
Parser that can be queried for success and error messages.

◆ decode() [3/3]

Parser mysql::strconv::decode ( const Is_parse_options_nocheck auto &  opt,
const std::string_view &  in_sv,
mysql::meta::Is_specialization< std::basic_string > auto &  out 
)

Parse from a string into an std::string object.

This is an API wrapper for objects/formats for which decode_impl(opt, pos, Is_string_target) has been implemented.

Parameters
optParse options, which should include the format, and may include a number of repetitions.
in_svInput represented as string_view.
[out]outReference to string to read into. In case of errors, this is unchanged.
Returns
Parser that can be queried for success and error messages.

◆ decode_impl() [1/25]

void mysql::strconv::decode_impl ( const Binary_format ,
Parser parser,
mysql::uuids::Uuid uuid 
)
inline

Enable decode(Binary_format, Uuid).

◆ decode_impl() [2/25]

template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_metric_set_traits< typename Boundary_container_t::Set_traits_t>
void mysql::strconv::decode_impl ( const Binary_format format,
mysql::strconv::Parser parser,
Boundary_container_t &  out 
)

Enable mysql::strconv::decode(Binary_format, Boundary_container), for boundary containers that are discrete and metric.

◆ decode_impl() [3/25]

void mysql::strconv::decode_impl ( const Binary_format format,
Parser parser,
Is_string_target auto &  out 
)
inline

Parse a string in binary format, using variable-length integer format for the length; make the given std::string_ref & refer to the corresponding segment of the input buffer; advance the position; and return the status.

Parameters
formatType tag to identify that this relates to binary format.
[in,out]parserParser position and parser.
[out]outDestination string_view which will be set to point directly into the input string.

The possible error states are:

  • not found: The position was at end-of-string, or the first character was a non-number.
  • parse_error: The number was out of range.

◆ decode_impl() [4/25]

void mysql::strconv::decode_impl ( const Binary_format format,
Parser parser,
std::integral auto &  out 
)

Parse an integral in variable-width integer format type into out, advance the position, and return the status.

The format is as given by the serialization library.

Parameters
formatType tag to identify that this relates to binary format with variable-width integers.
[in,out]parserParser position and parser.
[out]outVariable of integral type to read into.

The possible error states are:

  • not found: The position was at end-of-string, or the first character was a non-number.
  • parse_error: The number was out of range.

◆ decode_impl() [5/25]

void mysql::strconv::decode_impl ( const Binary_format format,
Parser parser,
std::string_view &  out 
)
inline

Parse a string in binary format, using variable-length integer format for the length; store the result by making the given std::string_view & point directly into the input string.

Parameters
formatType tag to identify that this relates to binary format.
[in,out]parserParser position and parser.
[out]outReference to std::string_view which will be set to point directly into the input string.

The possible error states are:

  • not found: The position was at end-of-string, or the first character was a non-number, or the remaining input is shorter than the string length.
  • parse_error: The number was out of range.

◆ decode_impl() [6/25]

template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_set_traits< typename Boundary_container_t::Set_traits_t>
void mysql::strconv::decode_impl ( const Boundary_set_text_format format,
mysql::strconv::Parser parser,
Boundary_container_t &  out 
)

Enable mysql::strconv::decode(Text_format, Boundary_container), for boundary containers whose Set traits that are discrete.

◆ decode_impl() [7/25]

template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_set_traits< typename Boundary_container_t::Set_traits_t>
void mysql::strconv::decode_impl ( const Boundary_set_text_format format,
mysql::strconv::Parser parser,
const std::pair< Boundary_container_t &, typename Boundary_container_t::Iterator_t & > &  out 
)

Enable mysql::strconv::decode(Text_format, std::pair<Boundary_container, cursor>), for boundary containers whose Set traits that are discrete.

◆ decode_impl() [8/25]

template<mysql::sets::Is_discrete_set_traits Set_traits_t>
void mysql::strconv::decode_impl ( const Boundary_set_text_format format,
mysql::strconv::Parser parser,
mysql::sets::detail::Relaxed_interval< Set_traits_t > &  out 
)

Enable mysql::strconv::decode(Text_format, Relaxed_interval), for boundary containers whose Set traits that are discrete.

◆ decode_impl() [9/25]

template<mysql::sets::Is_boundary_container Boundary_container_t>
requires mysql::sets::Is_discrete_set_traits< typename Boundary_container_t::Set_traits_t>
void mysql::strconv::decode_impl ( const Fixint_binary_format format,
mysql::strconv::Parser parser,
Boundary_container_t &  out 
)

Enable mysql::strconv::decode(Fixint_binary_format, Boundary_container), for boundary containers that are discrete.

◆ decode_impl() [10/25]

template<std::integral Value_t>
void mysql::strconv::decode_impl ( const Fixint_binary_format format,
Parser parser,
Value_t &  out 
)

Parse an integral in fixed-width integer format type into out, advance the position, and return the status.

The format is 8 byte, little-endian.

Template Parameters
Value_tUnsigned integral type to read.
Parameters
formatType tag to identify that this relates to binary format with fixed-width integers.
[in,out]parserParser position and parser.
[out]outDestination value.

The possible error states are:

  • not found: The position was at end-of-string, or the first character was a non-number.
  • parse_error: The number was out of range.

◆ decode_impl() [11/25]

void mysql::strconv::decode_impl ( const Fixstr_binary_format format,
Parser parser,
Is_string_target auto &  out 
)

Parse a string in fixed-length format into out, advance the position, and return the status.

The length is not encoded in the input string; it is a nonstatic member of the format.

Parameters
formatType tag to identify that this relates to fixed-width binary format
[in,out]parserParser position and parser.
[out]outOutput string wrapper to store into.

◆ decode_impl() [12/25]

void mysql::strconv::decode_impl ( const Fixstr_binary_format format,
Parser parser,
std::string_view &  out 
)
inline

Parse a string in fixed-length format into out, advance the position, and return the status.

The length is not encoded in the input string; it is a nonstatic member of the format.

Parameters
formatType tag to identify that this relates to fixed-width binary format
[in,out]parserParser position and parser.
[out]outReference to string_view, which will be altered to point directly into the input string.

◆ decode_impl() [13/25]

void mysql::strconv::decode_impl ( const Gtid_binary_format format,
Parser parser,
mysql::gtids::detail::Gtid_set_header out 
)
inline

◆ decode_impl() [14/25]

void mysql::strconv::decode_impl ( const Gtid_binary_format format,
Parser parser,
mysql::gtids::Is_gtid auto &  gtid 
)

◆ decode_impl() [15/25]

void mysql::strconv::decode_impl ( const Gtid_binary_format format,
Parser parser,
mysql::gtids::Is_gtid_set auto &  gtid_set 
)

◆ decode_impl() [16/25]

void mysql::strconv::decode_impl ( const Gtid_binary_format format,
Parser parser,
mysql::gtids::Is_tag auto &  tag 
)

◆ decode_impl() [17/25]

void mysql::strconv::decode_impl ( const Gtid_binary_format format,
Parser parser,
mysql::gtids::Is_tsid auto &  tsid 
)

◆ decode_impl() [18/25]

void mysql::strconv::decode_impl ( const Gtid_text_format ,
Parser parser,
mysql::gtids::Is_tag auto &  tag 
)

◆ decode_impl() [19/25]

template<mysql::gtids::Is_gtid_set Gtid_set_t>
void mysql::strconv::decode_impl ( const Gtid_text_format format,
Parser parser,
Gtid_set_t &  gtid_set 
)

◆ decode_impl() [20/25]

void mysql::strconv::decode_impl ( const Gtid_text_format format,
Parser parser,
mysql::gtids::Is_gtid auto &  gtid 
)

◆ decode_impl() [21/25]

void mysql::strconv::decode_impl ( const Gtid_text_format format,
Parser parser,
mysql::gtids::Is_tsid auto &  tsid 
)

◆ decode_impl() [22/25]

template<mysql::sets::Is_interval_container Interval_container_t>
void mysql::strconv::decode_impl ( const Is_format auto &  format,
mysql::strconv::Parser parser,
Interval_container_t &  out 
)

Enable mysql::strconv::decode(/*Format*‍/, Interval_container), by reading the boundaries in the given format.

◆ decode_impl() [23/25]

void mysql::strconv::decode_impl ( const mysql::meta::Is_nontype_specialization< Hex_format > auto &  format,
Parser parser,
Is_string_target auto &  target 
)

Read into a single character from a string of two hex digits.

Parameters
formatType tag to identify that this is hex format. Also holds the minimum and maximum allowed length of the resulting plaintext string.
[in,out]parserreference to Parser
targetString target object to write to.

◆ decode_impl() [24/25]

void mysql::strconv::decode_impl ( const Text_format format,
Parser parser,
mysql::uuids::Uuid uuid 
)
inline

Enable decode(Text_format, string, Uuid).

◆ decode_impl() [25/25]

template<std::integral Value_t>
void mysql::strconv::decode_impl ( const Text_format format,
Parser parser,
Value_t &  out 
)

Parse an integer in text format into out.

Parameters
formatType tag to identify that this relates to text format.
[in,out]parserParser position.
[out]outDestination value.

The possible error states are:

  • not found: The position was at end-of-string, or the first character was a non-number.
  • parse_error: The number was out of range.

◆ decode_text()

Parser mysql::strconv::decode_text ( const std::string_view &  in_sv,
auto &  out 
)

Parse from a string into the given object in text format.

Parameters
in_svInput represented as string_view.
[out]outReference to object to read into. In case of error, this may be in a "half-parsed" state.
Returns
Parser that can be queried for success and error messages.

◆ encode() [1/4]

void mysql::strconv::encode ( const Debug_format format,
Is_string_target auto &  target,
const Repeat repeat 
)

◆ encode() [2/4]

template<class String_t = std::string>
std::optional< String_t > mysql::strconv::encode ( const Is_format auto &  format,
const auto &  object 
)

Return an std::optional<std::string> object holding the string representation of the object.

Template Parameters
String_tOutput string type. Defaults to std::string.
Parameters
formatDescription of the output format.
objectObject to write.
Returns
std::optional<std::string> object holding the string representation of object, or holding no value if an out-of-memory condition occurred.

◆ encode() [3/4]

void mysql::strconv::encode ( const Is_format auto &  format,
const Is_out_str_fixed auto &  out_str,
const auto &  object 
)

Write the string representation of the object to the given string output wrapper.

This overload is for the case that the output wrapper's resize policy is fixed, i.e., the caller guarantees that the output buffer has enough space to store the output. Therefore, this function cannot fail and returns void.

param format Description of output format.

param[in,out] out_str Output string wrapper to write to.

param object Object to write.

Note
The caller must ensure that out is big enough. The length can be determined using compute_encoded_length(object).

◆ encode() [4/4]

auto mysql::strconv::encode ( const Is_format auto &  format,
const Is_out_str_growable auto &  out_str,
const auto &  object 
)

Write the string representation of the object to the given string output wrapper.

This overload is for the case that the output wrapper's resize policy is growable. Therefore, this function can fail to allocate memory and has the [[nodiscard]] attribute.

Parameters
formatDescription of output format.
[in,out]out_strOutput string wrapper to write to.
objectObject to write.
Returns
Return_status::ok on success, Return_status::error on out-of-memory error.
Note
The caller must ensure that out is big enough. The length can be determined using compute_encoded_length(object).

◆ encode_debug() [1/2]

template<class String_t = std::string, class Object_t >
std::optional< String_t > mysql::strconv::encode_debug ( const Object_t &  object)

Return an std::optional<std::string> object holding the string representation of the object, using Debug_format.

Template Parameters
String_tOutput string type. Defaults to std::string.
Object_tType of object.
Parameters
objectObject to write.
Returns
std::optional<std::string> object holding the string representation of object, or holding no value if an out-of-memory condition occurred.

◆ encode_debug() [2/2]

template<Is_out_str_fixed Out_str_t, class Object_t >
auto mysql::strconv::encode_debug ( Out_str_t  out_str,
const Object_t &  object 
)

Write the string representation of the object to the given string output wrapper, using Debug_format.

This overload is for the case that the output wrapper's resize policy is fixed, i.e., the caller guarantees that the output buffer has enough space to store the output. Therefore, this function cannot fail and does not have the [[nodiscard]] attribute.

Template Parameters
Out_str_tType of output string wrapper to write to.
Object_tType of object.

param[in,out] out_str Output string wrapper to write to.

param object Object to write.

Returns
Return_status::ok on success, Return_status::error on allocation failure.
Note
The caller must ensure that out is big enough. The length can be determined using compute_encoded_length(object).

This overload is for the case that the output wrapper's resize policy is growable. Therefore, this function can fail to allocate memory and has the [[nodiscard]] attribute.

Template Parameters
Out_str_tOutput string wrapper to write to.
Object_tType of object.
Parameters
[in,out]out_strOutput string wrapper to write to.
objectObject to write.
Returns
Return_status::ok on success, Return_status::error on allocation failure.
Note
The caller must ensure that out is big enough. The length can be determined using compute_encoded_length(object).

◆ encode_impl() [1/29]

void mysql::strconv::encode_impl ( const Binary_format ,
Is_string_target auto &  target,
const mysql::uuids::Uuid uuid 
)

Enable encode(Binary_format, Uuid).

◆ encode_impl() [2/29]

template<mysql::sets::Is_boundary_set Boundary_set_t>
requires mysql::sets::Is_discrete_metric_set_traits< typename Boundary_set_t::Set_traits_t>
void mysql::strconv::encode_impl ( const Binary_format format,
Is_string_target auto &  target,
const Boundary_set_t &  boundary_set 
)

Enable mysql::strconv::encode(Binary_format, Boundary_set), for boundary sets whose Set traits that are discrete and metric.

◆ encode_impl() [3/29]

void mysql::strconv::encode_impl ( const Binary_format format,
Is_string_target auto &  target,
const std::string_view &  sv 
)

Format a string using variable-length, binary format for the length.

The format is the length followed by the string data. The length is in the varint format defined in the serialization library.

Parameters
formatType tag to identify that this relates to variable-length, binary format.
[out]targetTarget object to which the string will be written.
svstring_view to write.

◆ encode_impl() [4/29]

template<Is_string_target Target_t>
void mysql::strconv::encode_impl ( const Binary_format format,
Target_t &  target,
const std::integral auto &  value 
)

Format an integer in variable-length, binary format.

The format is the varint format defined in the serialization library.

Template Parameters
Target_tType of target.
Parameters
formatType tag to identify that this relates to binary format with variable-length integers.
[out]targetTarget object to which the string will be written.
valueThe value to write.

◆ encode_impl() [5/29]

template<mysql::sets::Is_boundary_set Boundary_set_t>
void mysql::strconv::encode_impl ( const Boundary_set_text_format format,
Is_string_target auto &  target,
const Boundary_set_t &  boundary_set 
)

Enable mysql::strconv::encode(Boundary_set_text_format, Interval), for boundary sets whose Set traits that are discrete.

◆ encode_impl() [6/29]

template<mysql::sets::Is_bounded_set_traits Set_traits_t>
void mysql::strconv::encode_impl ( const Boundary_set_text_format format,
Is_string_target auto &  target,
const mysql::sets::Interval< Set_traits_t > &  interval 
)

Enable mysql::strconv::encode(Boundary_set_text_format, Interval), for intervals whose Set traits that are discrete.

◆ encode_impl() [7/29]

void mysql::strconv::encode_impl ( const Debug_format format,
Is_string_target auto &  target,
const detail::Parse_status status 
)

Enable encode(Debug_format, Parse_status), to help debugging.

◆ encode_impl() [8/29]

template<mysql::sets::Is_boundary_set Boundary_set_t>
void mysql::strconv::encode_impl ( const Fixint_binary_format format,
Is_string_target auto &  target,
const Boundary_set_t &  boundary_set 
)

Enable mysql::strconv::encode(Fixint_binary_format, Boundary_set), for boundary sets whose Set traits that are discrete.

◆ encode_impl() [9/29]

template<Is_string_target Target_t>
void mysql::strconv::encode_impl ( const Fixint_binary_format format,
Target_t &  target,
const std::integral auto &  value 
)

Format an integer in fixed-length, binary format.

The format is 8-byte, little endian.

Template Parameters
Target_tType of target.
Parameters
formatType tag to identify that this relates to binary format with fixed-length integers.
[out]targetTarget object to which the string will be written.
valueThe value to write.

◆ encode_impl() [10/29]

void mysql::strconv::encode_impl ( const Gtid_binary_format format,
Is_string_target auto &  string_target,
const mysql::gtids::detail::Gtid_set_header header 
)

◆ encode_impl() [11/29]

void mysql::strconv::encode_impl ( const Gtid_binary_format format,
Is_string_target auto &  string_target,
const mysql::gtids::Is_gtid auto &  gtid 
)

◆ encode_impl() [12/29]

void mysql::strconv::encode_impl ( const Gtid_binary_format format,
Is_string_target auto &  string_target,
const mysql::gtids::Is_gtid_set auto &  gtid_set 
)

◆ encode_impl() [13/29]

void mysql::strconv::encode_impl ( const Gtid_binary_format format,
Is_string_target auto &  string_target,
const mysql::gtids::Is_tsid auto &  tsid 
)

◆ encode_impl() [14/29]

void mysql::strconv::encode_impl ( const Gtid_binary_format format,
Is_string_target auto &  target,
const mysql::gtids::Is_tag auto &  tag 
)

◆ encode_impl() [15/29]

void mysql::strconv::encode_impl ( const Gtid_text_format format,
Is_string_target auto &  target,
const mysql::gtids::Is_gtid auto &  gtid 
)

◆ encode_impl() [16/29]

void mysql::strconv::encode_impl ( const Gtid_text_format format,
Is_string_target auto &  target,
const mysql::gtids::Is_gtid_set auto &  gtid_set 
)

◆ encode_impl() [17/29]

void mysql::strconv::encode_impl ( const Gtid_text_format format,
Is_string_target auto &  target,
const mysql::gtids::Is_tag auto &  tag 
)

◆ encode_impl() [18/29]

void mysql::strconv::encode_impl ( const Gtid_text_format format,
Is_string_target auto &  target,
const mysql::gtids::Is_tsid auto &  tsid 
)

◆ encode_impl() [19/29]

template<std::size_t index = 0, class... Args_t>
void mysql::strconv::encode_impl ( const Is_format auto &  format,
Is_string_target auto &  target,
const Concat_object< Args_t... > &  concat_object 
)

◆ encode_impl() [20/29]

void mysql::strconv::encode_impl ( const Is_format auto &  format,
Is_string_target auto &  target,
const mysql::sets::Is_interval_set auto &  interval_set 
)

Enable mysql::strconv::encode(/*Format*‍/, Interval_set), by writing the boundaries in the given format.

◆ encode_impl() [21/29]

void mysql::strconv::encode_impl ( const mysql::meta::Is_nontype_specialization< Escaped_format > auto &  format,
Is_string_target auto &  target,
const std::string_view &  sv 
)

◆ encode_impl() [22/29]

template<Is_string_target Target_t>
void mysql::strconv::encode_impl ( const mysql::meta::Is_nontype_specialization< Hex_format > auto &  format,
Target_t &  target,
const std::string_view &  sv 
)

Format the given char buffer in hex format.

Parameters
formatType tag to identify that this relates to hex format.
[out]targetTarget object to which the string will be written.
svInput string.

◆ encode_impl() [23/29]

void mysql::strconv::encode_impl ( const mysql::strconv::Is_nested_set_text_format auto &  format,
Is_string_target auto &  target,
const mysql::sets::Is_nested_set auto &  nested_set 
)

Enable mysql::strconv::encode(/*Format*‍/, Nested_set), by writing the boundaries in the given format.

◆ encode_impl() [24/29]

void mysql::strconv::encode_impl ( const Text_format format,
Is_string_target auto &  target,
const Parser obj 
)

Enable encode(Text_format, Parse_result).

This produces an error message that describes the Parse_result object to humans.

Parameters
formatType tag to identify that this relates to text format.
targetString target to which the string will be appended.
objObject to write.

◆ encode_impl() [25/29]

void mysql::strconv::encode_impl ( const Text_format format,
Is_string_target auto &  target,
const std::source_location &  source_location 
)

Enable conversion from std::source_location to string.

◆ encode_impl() [26/29]

void mysql::strconv::encode_impl ( const Text_format format,
Is_string_target auto &  target,
const std::string_view &  sv 
)

Format the given string_view in text format, by copying the string data literally to the output buffer.

Note that neither the string length nor any delimiter is written to the output, so a parser cannot in general compute the end in case the written string is followed by other text. Therefore there is no corresponding decode_impl function.

Parameters
formatType tag to identify that this relates to text format.
[out]targetTarget object to which the string will be written.
svInput string.

◆ encode_impl() [27/29]

template<std::integral Value_t>
constexpr void mysql::strconv::encode_impl ( const Text_format format,
String_counter counter,
Value_t  value 
)
constexpr

Compute the length of a text-formatted integer.

Template Parameters
Value_tType of the value.
Parameters
formatType tag to identify that this relates to text format.
[out]counterString_counter object to which the string will be written.
valueThe value to compute the text representation length for.

◆ encode_impl() [28/29]

template<std::integral Value_t>
constexpr void mysql::strconv::encode_impl ( const Text_format format,
String_writer writer,
Value_t  value 
)
constexpr

Write a text-formatted integer to a String_writer.

Template Parameters
Value_tType of the value.
Parameters
formatType tag to identify that this relates to text format.
[out]writerString_writer object to which the string will be written.
valueThe value to write.

◆ encode_impl() [29/29]

template<Is_string_target Target_t>
void mysql::strconv::encode_impl ( const Text_format format,
Target_t &  target,
const mysql::uuids::Uuid uuid 
)

Enable encode_text(Uuid).

◆ encode_text() [1/2]

template<class String_t = std::string, class Object_t >
auto mysql::strconv::encode_text ( const Object_t &  object)

Return an std::optional<std::string> object holding the string representation of the object, using Text_format.

Template Parameters
String_tOutput string type. Defaults to std::string.
Object_tType of object.
Parameters
objectObject to write.
Returns
std::optional<std::string> object holding the string representation of object, or holding no value if an out-of-memory condition occurred.

◆ encode_text() [2/2]

template<Is_out_str_fixed Out_str_t, class Object_t >
auto mysql::strconv::encode_text ( Out_str_t  out_str,
const Object_t &  object 
)

Write the string representation of the object to the given string output wrapper, using Text_format.

This overload is for the case that the output wrapper's resize policy is fixed, i.e., the caller guarantees that the output buffer has enough space to store the output. Therefore, this function cannot fail and does not have the [[nodiscard]] attribute.

Template Parameters
Out_str_tType of output string wrapper to write to.
Object_tType of object.

param[in,out] out_str Output string wrapper to write to.

param object Object to write.

Returns
Return_status::ok on success, Return_status::error on allocation failure.

This overload is for the case that the output wrapper's resize policy is growable. Therefore, this function can fail to allocate memory and has the [[nodiscard]] attribute.

Template Parameters
Out_str_tOutput string wrapper to write to.
Object_tType of object.
Parameters
[in,out]out_strOutput string wrapper to write to.
objectObject to write.
Returns
Return_status::ok on success, Return_status::error on allocation failure.

◆ encode_to_streamable()

template<class String_t = std::string>
Streamable< String_t > mysql::strconv::encode_to_streamable ( const Is_format auto &  format,
const auto &  object 
)

Return a Streamable object holding the result from encode(format, object).

If the Streamable object is passed to operator<<, it will write the string if any, or handle the allocation error according to the stream's policy, if the allocation in encode failed.

Template Parameters
String_tOutput string type. Defaults to std::string.
Parameters
formatDescription of the output format.
objectObject to write.
Returns
Streamable object that wraps the std::optional<std::string> returned from encode.

Example:

// If allocation fails while allocating a temporary string to hold the
// text form of `object`, set the stream status accordingly.
Streamable< String_t > encode_to_streamable(const Is_format auto &format, const auto &object)
Return a Streamable object holding the result from encode(format, object).
Definition: encode.h:206
Format tag to identify text format.
Definition: text_format.h:38

◆ get_default_format() [1/5]

template<class Object_t >
requires mysql::gtids::Is_tag<Object_t> || mysql::gtids::Is_gtid<Object_t> || mysql::gtids::Is_tsid<Object_t> || mysql::gtids::Is_gtid_set<Object_t>
auto mysql::strconv::get_default_format ( const Binary_format ,
const Object_t &   
)

◆ get_default_format() [2/5]

auto mysql::strconv::get_default_format ( const Text_format ,
const mysql::sets::Is_nested_set auto &   
)

Make mysql::strconv::encode_text (and encode(Text_format{}, ...) use Nested_set_text_format when the object to format is a Nested set.

◆ get_default_format() [3/5]

template<class Object_t >
requires mysql::gtids::Is_tag<Object_t> || mysql::gtids::Is_gtid<Object_t> || mysql::gtids::Is_tsid<Object_t>
auto mysql::strconv::get_default_format ( const Text_format ,
const Object_t &   
)

◆ get_default_format() [4/5]

template<class Object_t >
requires mysql::sets::Is_nested_set<Object_t> && mysql::gtids::Is_gtid_set<Object_t>
auto mysql::strconv::get_default_format ( const Text_format ,
const Object_t &   
)

◆ get_default_format() [5/5]

template<class Object_t >
requires mysql::meta::Is_specialization<Object_t, mysql::sets::Interval> || mysql::sets::Is_boundary_set<Object_t> || mysql::sets::Is_interval_set<Object_t>
auto mysql::strconv::get_default_format ( const Text_format ,
const Object_t &   
)

Make mysql::strconv::encode_text (and encode(Text_format{}, ...) use Boundary_set_text_format when the object to format is an Interval, Boundary sets, or Interval set.

◆ get_format() [1/3]

template<Is_compound_parse_options Compound_parse_options_t>
requires Compound_parse_options_t
::has_format auto mysql::strconv::get_format ( const Compound_parse_options_t &  opt)

◆ get_format() [2/3]

auto mysql::strconv::get_format ( const Is_format auto &  format)

◆ get_format() [3/3]

auto mysql::strconv::get_format ( const Is_parse_options auto &  )

Return the Format component of any parse options that has one.

◆ get_repeat() [1/3]

template<Is_compound_parse_options Compound_parse_options_t>
requires Compound_parse_options_t
::has_repeat auto mysql::strconv::get_repeat ( const Compound_parse_options_t &  opt)

◆ get_repeat() [2/3]

auto mysql::strconv::get_repeat ( const Is_parse_options auto &  )

Return the Repeat component of any parse options, if it exists; otherwise a default-constructed Repeat object.

◆ get_repeat() [3/3]

auto mysql::strconv::get_repeat ( const Is_repeat auto &  repeat)

◆ invoke_checker() [1/3]

template<Is_compound_parse_options Compound_parse_options_t>
requires Compound_parse_options_t
::has_checker void mysql::strconv::invoke_checker ( const Compound_parse_options_t &  opt)

◆ invoke_checker() [2/3]

void mysql::strconv::invoke_checker ( const Is_checker auto &  checker)

◆ invoke_checker() [3/3]

void mysql::strconv::invoke_checker ( const Is_parse_options auto &  )

Invoke the Checker member of any parse options, if it exists; otherwise do nothing.

◆ is_space()

constexpr bool mysql::strconv::is_space ( int  x)
constexpr

Return true if the given character is a space character, i.e., ascii 9, 10, 11, 12, 13, or 32.

This is derived from ctype_utf8mb3 and agrees with my_isspace(&my_charset_utf8mb3_general_ci, x).

◆ operator<<()

std::ostream & mysql::strconv::operator<< ( std::ostream &  out,
const mysql::meta::Is_specialization< Streamable > auto &  streamable 
)

Use output operator to write the string representation of a format-tagged object to the given ostream.

Parameters
[out]outostream to write to.
streamableStreamable object to write.
Returns
out.
Exceptions
std::ios_base::failureif streamable does not hold a value and out.exceptions() has the badbit set.
Note
If streamable does not hold a value, this sets badbit in out (regardless if it throws or not), and it does not write to the output.

◆ operator|()

template<Is_parse_options Opt1, Is_parse_options Opt2>
auto mysql::strconv::operator| ( const Opt1 &  opt1,
const Opt2 &  opt2 
)

Combine two Parse Options objects into one.

◆ out_str_copy()

template<std::invocable Oom_action_t = detail::Nop_t>
auto mysql::strconv::out_str_copy ( const Is_out_str auto &  out_str,
const std::string_view &  sv,
const Oom_action_t &  oom_action = detail::nop 
)

Copy the given string_view to the Output String Wrapper, resizing as needed.

Parameters
out_strOutput String Wrapper to write to.
svstring_view to write.
oom_actionOptional callback function. If given, will be invoked in case an out-of-memory condition occurs.
Returns
If out_str is growable, return Return_status::ok on success and Return_status::error on out-of-memory error; if out_str is fixed-size, return void.

◆ out_str_fixed()

template<mysql::meta::Is_specialization< std::basic_string > String_t>
auto mysql::strconv::out_str_fixed ( String_t &  str)

Return a wrapper around a non-growable output buffer, represented as a std::string or similar type.

Parameters
[in,out]strReference to std::string, or other type that provides similar capacity, resize, and data members.
Returns
Object of subclass of Out_str_base, which wraps str.

◆ out_str_fixed_nz() [1/4]

template<mysql::meta::Is_charlike Char_t, std::ptrdiff_t array_size>
auto mysql::strconv::out_str_fixed_nz ( Char_t(&)  first[array_size],
Char_t *&  last,
Char_t *  capacity_end = nullptr 
)

Return a wrapper around a non-growable, non-null-terminated output buffer, represented as an array and a reference to a raw pointer to the end.

Functions accepting this type as argument will typically write to the character buffer and alter last to the past-the-end character.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lastReference to raw pointer, which writers may update to point to one-past-the-last character written.
capacity_endPointer to one-past-the-last character that may be written. May be omitted, in which case this value is taken from last instead.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_fixed_nz() [2/4]

template<mysql::meta::Is_charlike Char_t, mysql::meta::Is_pointer_to< Char_t > Charptr_t>
auto mysql::strconv::out_str_fixed_nz ( Charptr_t  first,
Char_t *&  last,
Char_t *  capacity_end = nullptr 
)

Return a wrapper around a non-growable, non-null-terminated output buffer, represented using raw a pointer to the beginning and a reference to a raw pointer to the end.

Functions accepting this type as argument will typically write to the character buffer and alter last to the past-the-end character.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lastReference to raw pointer, which writers may update to point to one-past-the-last character written.
capacity_endPointer to one-past-the-last character that may be written. May be omitted, in which case this value is taken from last instead.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_fixed_nz() [3/4]

template<std::integral Size_t, std::ptrdiff_t array_size>
auto mysql::strconv::out_str_fixed_nz ( mysql::meta::Is_charlike auto(&)  first[array_size],
Size_t &  length,
Size_t  capacity = 0 
)

Return a wrapper around a non-growable, non-null-terminated output buffer, represented as an array and a reference to an integral size.

Functions accepting this type as argument will typically write to the character buffer and alter length to the past-the-end character.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lengthReference to integer, which writers may update to the number of string characters written.
capacityAvailable capacity to write string characters. May be omitted, in which case this value is taken from length instead.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_fixed_nz() [4/4]

template<std::integral Size_t>
auto mysql::strconv::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 pointer to the beginning and a reference to an integral size.

Functions accepting this type as argument will typically write to the character buffer and alter length to the past-the-end character.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lengthReference to integer, which writers may update to the number of string characters written. May be omitted, in which case this value is taken from length instead.
capacityAvailable capacity to write string characters.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_fixed_z() [1/4]

template<mysql::meta::Is_charlike Char_t, std::ptrdiff_t array_size>
auto mysql::strconv::out_str_fixed_z ( Char_t(&)  first[array_size],
Char_t *&  last,
Char_t *  capacity_end = nullptr 
)

Return a wrapper around a non-growable, null-terminated output buffer, represented as an array and a reference to a raw pointer to the end.

Functions accepting this type as argument will typically write to the character buffer and alter last to point to the zero byte.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lastReference to raw pointer, which writers may update to point to the null-termination character.
capacity_endPointer to the last character that may be used for the null-termination character. Note that this is the last character included in the buffer, not one-past-the-last buffer character. May be omitted, in which case this value is taken from last instead.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_fixed_z() [2/4]

template<mysql::meta::Is_charlike Char_t, mysql::meta::Is_pointer_to< Char_t > Charptr_t>
auto mysql::strconv::out_str_fixed_z ( Charptr_t  first,
Char_t *&  last,
Char_t *  capacity_end = nullptr 
)

Return a wrapper around a non-growable, null-terminated output buffer, represented using raw a pointer to the beginning and a reference to a raw pointer to the end.

Functions accepting this type as argument will typically write to the character buffer and alter last to point to the zero byte.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lastReference to raw pointer, which writers may update to point to the null-termination character.
capacity_endPointer to the last character that may be used for the null-termination character. Note that this is the last character included in the buffer, not one-past-the-last buffer character. May be omitted, in which case this value is taken from last instead.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_fixed_z() [3/4]

template<std::integral Size_t, std::ptrdiff_t array_size>
auto mysql::strconv::out_str_fixed_z ( mysql::meta::Is_charlike auto(&)  first[array_size],
Size_t &  length,
Size_t  capacity = 0 
)

Return a wrapper around a non-growable, null-terminated output buffer, represented as an array and a reference to an integral size.

Functions accepting this type as argument will typically write to the character buffer and alter length to point to the zero byte.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lengthReference to integer, which writers may update to the number of string characters not counting the null-termination character.
capacityAvailable capacity to write string characters, not counting the null-termination character. Note that this should be one less than the actual buffer size. May be omitted, in which case this value is taken from length instead.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_fixed_z() [4/4]

template<std::integral Size_t>
auto mysql::strconv::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 pointer to the beginning and a reference to an integral size.

Functions accepting this type as argument will typically write to the character buffer and alter length to point to the zero byte.

Parameters
[in,out]firstRaw pointer to the beginning of a character buffer.
[out]lengthReference to integer, which writers may update to the number of string characters not counting the null-termination character.
capacityAvailable capacity to write string characters, not counting the null-termination character. Note that this should be one less than the actual buffer size. May be omitted, in which case this value is taken from length instead.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_growable()

template<mysql::meta::Is_specialization< std::basic_string > String_t>
auto mysql::strconv::out_str_growable ( String_t &  str)

Return a wrapper around a growable output buffer, represented as a std::string or similar type.

Parameters
[in,out]strReference to std::string, or other type that provides similar capacity, reserve, resize, and data members.
Returns
Object of subclass of Out_str_base, which wraps str.

◆ out_str_growable_nz() [1/2]

template<mysql::meta::Is_charlike Char_t>
auto mysql::strconv::out_str_growable_nz ( Char_t *&  first,
Char_t *&  last,
Char_t *  capacity_end = nullptr,
const mysql::allocators::Memory_resource memory_resource = {} 
)

Return a wrapper around a growable, non-null-terminated output buffer, represented using reference to a raw a pointer to the beginning and a reference to a raw pointer to the end.

Functions accepting this type as argument will typically allocate a new buffer and replace first by it if the given one is too small; then write to the character buffer and alter last to point to the past-the-end character.

Parameters
[in,out]firstReference to raw pointer to the beginning of a character buffer. May be nullptr if last is nullptr; otherwise must be a valid pointer.
[out]lastReference to raw pointer, which writers may update to point to one-past-the-last character written.
capacity_endPointer to one-past-the-last character that may be written. May be omitted, in which case this value is taken from last instead.
memory_resourceMemory_resource to allocate bytes. If omitted, uses the default-constructed Memory_resource, which uses std::malloc and std::free.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_growable_nz() [2/2]

template<mysql::meta::Is_charlike Char_t, std::integral Size_t>
auto mysql::strconv::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 to a raw pointer to the beginning and a reference to an integral size.

Functions accepting this type as argument will typically allocate a new buffer and replace first by it if the given one is too small; then write to the character buffer and alter length to the past-the-end character.

Parameters
[in,out]firstReference to raw pointer to the beginning of a character buffer. May be nullptr if length is 0; otherwise must be a valid pointer.
[out]lengthReference to integer, which writers may update to the number of string characters written.
capacityAvailable capacity to write string characters. May be omitted, in which case this value is taken from length instead.
memory_resourceMemory_resource to allocate bytes. If omitted, uses the default-constructed Memory_resource, which uses std::malloc and std::free.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_growable_z() [1/2]

template<mysql::meta::Is_charlike Char_t>
auto mysql::strconv::out_str_growable_z ( Char_t *&  first,
Char_t *&  last,
Char_t *  capacity_end = nullptr,
const mysql::allocators::Memory_resource memory_resource = {} 
)

Return a wrapper around a growable, null-terminated output buffer, represented using reference to a raw a pointer to the beginning and a reference to a raw pointer to the end.

Functions accepting this type as argument will typically allocate a new buffer and replace first by it if the given one is too small; then write to the character buffer and alter last to point to the zero byte.

Parameters
[in,out]firstReference to raw pointer to the beginning of a character buffer. May be nullptr if last is nullptr; otherwise must be a valid pointer.
[out]lastReference to raw pointer, which writers may update to point to the null-termination character.
capacity_endPointer to the last character that may be used for the null-termination character. Note that this is the last character included in the buffer, not one-past-the-last buffer character. May be omitted, in which case this value is taken from last instead.
memory_resourceMemory_resource to allocate bytes. If omitted, uses the default-constructed Memory_resource, which uses std::malloc and std::free.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_growable_z() [2/2]

template<mysql::meta::Is_charlike Char_t, std::integral Size_t>
auto mysql::strconv::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 raw pointer to the beginning and a reference to an integral size.

Functions accepting this type as argument will typically allocate a new buffer and replace first by it if the given one is too small; then write to the character buffer and alter length to point to the zero byte.

Parameters
[in,out]firstReference to raw pointer to the beginning of a character buffer. May be nullptr if length is 0; otherwise must be a valid pointer.
[out]lengthReference to integer, which writers may update to the number of string characters not counting the null-termination character.
capacityAvailable capacity to write string characters, not counting the null-termination character. Note that this should be one less than the actual buffer size. May be omitted, in which case this value is taken from length instead.
memory_resourceMemory_resource to allocate bytes. If omitted, uses the default-constructed Memory_resource, which uses std::malloc and std::free.
Returns
Object of subclass of Out_str_base, which wraps the given range of characters.

◆ out_str_write() [1/3]

template<std::invocable Oom_action_t = detail::Nop_t>
auto mysql::strconv::out_str_write ( const Is_out_str auto &  out_str,
const Is_string_producer auto &  producer,
const Oom_action_t &  oom_action = detail::nop 
)

Given an Is_out_str object and an Is_string_producer, resize the object as needed and then write to it.

Parameters
out_strWrapper around the output, typically obtained from one of the out_str_* functions.
producerFunction that writes to its Is_string_target parameter, and returns either Return_status indicating success or failure, or (if it can't fail) void.
oom_actionOptional callback function. If given, will be invoked in case an out-of-memory condition occurs.
Returns
If out_str is growable or producer returns non-void, returns Return_status to indicate success or failure; otherwise returns void.

◆ out_str_write() [2/3]

template<Is_out_str Out_str_t, class Producer_counter_t , class Producer_writer_t , std::invocable Oom_action_t = detail::Nop_t>
requires Is_string_producer_pair<Producer_counter_t, Producer_writer_t>
mysql::utils::Return_status mysql::strconv::out_str_write ( const Out_str_t &  out_str,
const Producer_counter_t &  producer_counter,
const Producer_writer_t &  producer_writer,
const Oom_action_t &  oom_action = detail::nop 
)

Given an Is_out_str object, a String_producer_counter, and a String_producer_writer, resizes the object as needed and then writes to it.

This overload is for when there are error cases, i.e., when either the producer can return errors, or the Output String Wrapper is growable.

Template Parameters
Out_str_tType of Output String Wrapper.
Producer_counter_tType of the producer counter function.
Producer_writer_tType of the producer writer function. Producer_counter_t and Producer_writer_t must satisfy Is_string_producer_pair (including the semantic requirements).
Parameters
out_strWrapper around the output, typically obtained from one of the out_str_* functions.
producer_counterFunction that writes to its String_counter & parameter, and returns either Return_status indicating success or failure, or void (if it can't fail).
producer_writerFunction that writes to its String_writer & parameter, and returns either Return_status indicating success or failure, or void (if it can't fail).
oom_actionOptional callback function. If given, will be invoked in case an out-of-memory condition occurs.
Returns
Return_status::error if either write or out_str.resize returns Return_status::error; otherwise Return_status::ok.

◆ out_str_write() [3/3]

template<Is_out_str_fixed Out_str_t, class Producer_counter_t , class Producer_writer_t , std::invocable Oom_action_t = detail::Nop_t>
requires Is_string_producer_pair<Producer_counter_t, Producer_writer_t> && (std::same_as< std::invoke_result_t<Producer_counter_t, String_counter &>, void>) && (std::same_as< std::invoke_result_t<Producer_writer_t, String_writer &>, void>)
void mysql::strconv::out_str_write ( const Out_str_t &  out_str,
const Producer_counter_t &  producer_counter,
const Producer_writer_t &  producer_writer,
const Oom_action_t &  oom_action = detail::nop 
)

Given an Is_out_str object, a String_producer_counter, and a String_producer_writer, resizes the object as needed and then writes to it.

This overload is for when there are no error cases, i.e., when the producer returns void and the Output String Wrapper is fixed-size.

Template Parameters
Out_str_tType of output wrapper.
Producer_counter_tType of the producer counter function.
Producer_writer_tType of the producer writer function. Producer_counter_t and Producer_writer_t must satisfy Is_string_producer_pair (including the semantic requirements).
Parameters
out_strWrapper around the output, typically obtained from one of the out_str_* functions.
producer_counterFunction that writes to its String_counter & parameter, and returns either Return_status indicating success or failure, or void (if it can't fail).
producer_writerFunction that writes to its String_writer & parameter, and returns either Return_status indicating success or failure, or void (if it can't fail).
oom_actionOptional callback function. If given, will be invoked in case an out-of-memory condition occurs.

◆ skip_whitespace()

void mysql::strconv::skip_whitespace ( Parser parser)
inline

Move the position forward until end or non-whitespace.

◆ test_decode()

Parser mysql::strconv::test_decode ( const Is_parse_options_nocheck auto &  opt,
const std::string_view &  in_sv 
)

Test for success when parsing (decoding) a string from a string, without producing output.

If this succeeds, it is guaranteed that a subsequent invocation of decode will not produce a parse_error. But note that it is possible for it to fail with an out-of-memory error.

This is an API wrapper for objects/formats for which decode_impl(opt, pos, Is_string_target) has been implemented.

Parameters
optParse options, which should include the format, and may include a number of repetitions.
in_svInput represented as string_view.
Returns
Parser that can be queried for success and error messages.