24#ifndef MYSQL_STRCONV_FORMATS_ESCAPED_FORMAT_H
25#define MYSQL_STRCONV_FORMATS_ESCAPED_FORMAT_H
72template <
char quote_char_tp =
'"',
char escape_char_tp =
'\\',
77 requires(quote_char_tp >= 32 && (unsigned)quote_char_tp < 128 &&
78 escape_char_tp >= 32 && (
unsigned)escape_char_tp < 128)
81 static constexpr char quote_char = quote_char_tp;
82 static constexpr char escape_char = escape_char_tp;
84 preserve_high_characters_tp;
86 numeric_control_characters_tp;
88 using Table_t = std::array<std::string_view, 256>;
95 : m_with_quotes(with_quotes) {}
115 char hex[] =
"0123456789abcdef";
116 for (
int i = 0; i < 256; ++i) {
117 auto &sv = m_table[i];
118 auto &data = m_data_table[i];
122 data[0] = escape_char;
124 i >=
'\a' && i <=
'\r') {
126 data[1] =
"abtnvfr"[i -
'\a'];
131 data[2] =
hex[i >> 4];
132 data[3] =
hex[i & 0xf];
136 if (i == escape_char || i == quote_char) {
138 data[0] = escape_char;
147 sv = std::string_view(data.data(),
size);
void build_table(const std::string &schema, const std::string &table, const std::string &partition, bool is_tmp, bool convert, std::string &dict_name)
Definition: dict0dd.cc:7567
std::string hex(const Container &c)
Definition: hex.h:61
Definition: gtid_binary_format.h:41
Preserve_high_characters
Whether ascii 128..255 should be preserved or escaped: backslash-xff vs ascii 255.
Definition: escaped_format.h:49
Numeric_control_characters
Whether ascii 7..13 should use hex instead of mnemonics: backslash-x0a vs backslash-n.
Definition: escaped_format.h:53
With_quotes
Whether output string should be enclosed in quote characters: "foo" vs foo.
Definition: escaped_format.h:45
size_t size(const char *const c)
Definition: base64.h:46