24#ifndef MYSQL_STRCONV_CONV_TEXT_PARSER_H
25#define MYSQL_STRCONV_CONV_TEXT_PARSER_H
56 static constexpr std::size_t max_len = 48;
57 static constexpr std::string_view here(
"[HERE]");
58 static constexpr std::size_t max_prefix_len = (max_len - here.size()) / 3;
59 static constexpr std::size_t max_suffix_len =
60 max_len - max_prefix_len - here.size();
61 static constexpr std::string_view ellipsis(
"...");
67 auto prefix = [&](std::size_t position) {
71 target.concat(
format,
" after ", position,
" characters, marked by ", here,
74 if (position > max_prefix_len) {
76 std::size_t
length = max_prefix_len - ellipsis.size();
77 target.write(
format, ellipsis);
83 target.write(
format, here);
88 auto suffix = [&](
const char *position) {
89 std::size_t remaining_size = obj.
end() - position;
90 if (remaining_size > max_suffix_len) {
93 {position, max_suffix_len - ellipsis.size()});
94 target.write(
format, ellipsis);
98 target.write(
format,
"\"");
102 target.write(
format,
"OK");
111 std::size_t position{0};
114 target.write(
format,
"Expected end of string");
119 target.write(
format,
"Expected ");
128 target.write(
format,
" at the beginning of the string: \"");
134 suffix(obj.
begin() + position);
Object used to parse strings.
Definition: parser.h:69
const char * end() const
Return pointer to the end of the underlying string.
Definition: parse_position.h:138
std::size_t int_pos() const
Return the current position as an integer.
Definition: parse_position.h:107
const char * begin() const
Return pointer to the beginning of the underlying string.
Definition: parse_position.h:125
Helper class that exports the internals from Parse_result.
Definition: parse_result.h:212
std::ptrdiff_t parse_error_position() const
Definition: parse_result.h:219
auto message_form() const
Definition: parse_result.h:225
std::string_view message() const
Definition: parse_result.h:229
bool is_fullmatch_error() const
Return true if the object was parsed successfully, but there were more characters after the end.
Definition: parse_result.h:133
@ expected_string
The message is a string that was expected but not found at the current position.
bool is_ok() const
Return true if the last operation succeeded, i.e., either a full match was requested and an object wa...
Definition: parse_result.h:97
bool is_store_error() const
Return true if an environment error occurred.
Definition: parse_result.h:121
Concept that holds for String_counter and String_writer.
Definition: string_target.h:111
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.h:41
void encode_impl(const Gtid_binary_format &format, Is_string_target auto &target, const mysql::gtids::Is_tag auto &tag)
Definition: gtid_binary_format_conv.h:48
Format tag to identify text format.
Definition: text_format.h:38