MySQL 9.6.0
Source Code Documentation
gtid_text_format.h
Go to the documentation of this file.
1// Copyright (c) 2025, Oracle and/or its affiliates.
2//
3// This program is free software; you can redistribute it and/or modify
4// it under the terms of the GNU General Public License, version 2.0,
5// as published by the Free Software Foundation.
6//
7// This program is designed to work with certain software (including
8// but not limited to OpenSSL) that is licensed under separate terms,
9// as designated in a particular file or component or in included license
10// documentation. The authors of MySQL hereby grant you an additional
11// permission to link the program and your derivative works with the
12// separately licensed software that they have either included with
13// the program or referenced in the documentation.
14//
15// This program is distributed in the hope that it will be useful,
16// but WITHOUT ANY WARRANTY; without even the implied warranty of
17// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18// GNU General Public License, version 2.0, for more details.
19//
20// You should have received a copy of the GNU General Public License
21// along with this program; if not, write to the Free Software
22// Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23
24#ifndef MYSQL_GTIDS_STRCONV_GTID_TEXT_FORMAT_H
25#define MYSQL_GTIDS_STRCONV_GTID_TEXT_FORMAT_H
26
27/// @file
28/// Experimental API header
29
30#include <string_view> // string_view
31#include "mysql/gtids/gtid.h" // Is_gtid
32#include "mysql/gtids/gtid_set.h" // Is_gtid_set
33#include "mysql/gtids/tag.h" // Is_tag
34#include "mysql/gtids/tsid.h" // Is_tsid
35#include "mysql/sets/nested_set_meta.h" // Is_nested_set
36#include "mysql/sets/strconv/boundary_set_text_format.h" // Boundary_set_text_format
37#include "mysql/strconv/strconv.h" // Format_base
38
39/// @addtogroup GroupLibsMysqlGtids
40/// @{
41
42namespace mysql::strconv {
43
45 // Separator after the set associated with one UUID, before the following
46 // UUID.
47 static constexpr std::string_view m_uuid_uuid_separator{","};
48
49 // Separator after the set associated with one UUID, before the following
50 // UUID. This is used when formatting an object into a string and may contain
51 // redundant whitespace.
52 static constexpr std::string_view m_uuid_uuid_separator_for_output{",\n"};
53
54 // Separator between UUID and tag, between UUID and interval, between tag and
55 // interval, or between interval and interval.
56 static constexpr std::string_view m_uuid_tag_number_separator{":"};
57
58 // Separator between UUID and tag, between UUID and interval, between tag and
59 // interval, or between interval and interval. This is used when formatting an
60 // object into string and may contain redundant whitespace.
61 static constexpr std::string_view m_uuid_tag_number_separator_for_output{":"};
62
63 // Format object to generate/parse interval sets.
67
68 // Make the parser auto-skip whitespace before every token.
70
71 // Make the parser auto-skip whitespace after every token.
73
74 // Fall back on m_boundary_set_text_format when writing primitive types.
75 [[nodiscard]] auto parent() const { return m_boundary_set_text_format; }
76};
77
78template <class Object_t>
81auto get_default_format(const Text_format &, const Object_t &) {
82 return Gtid_text_format{};
83}
84
85// Must use the redundant `Is_nested_set` constraint just to force this to be
86// more constrained than `get_default_format(Text_format, Is_nested_set)` which
87// is defined for all nested sets.
88template <class Object_t>
91auto get_default_format(const Text_format &, const Object_t &) {
92 return Gtid_text_format{};
93}
94
95} // namespace mysql::strconv
96
97// addtogroup GroupLibsMysqlGtids
98/// @}
99
100#endif // ifndef MYSQL_GTIDS_STRCONV_GTID_TEXT_FORMAT_H
Experimental API header.
Object used to parse strings.
Definition: parser.h:69
True for all Gtid set types.
Definition: gtid_set.h:178
Definition: gtid.h:53
True if Test is one of the tag classes.
Definition: tag.h:192
Definition: tsid.h:50
True if Test is a nested set.
Definition: nested_set_meta.h:110
Experimental API header.
Experimental API header.
Experimental API header.
Experimental API header.
Experimental API header.
struct Parser parser
Definition: gtid_binary_format.h:41
void skip_whitespace(Parser &parser)
Move the position forward until end or non-whitespace.
Definition: whitespace.h:47
auto get_default_format(const Binary_format &, const Object_t &)
Definition: gtid_binary_format.h:114
Experimental API header.
Tag to identify the formatting algorithm for boundary sets of integrals, and provide the separator st...
Definition: boundary_set_text_format.h:51
Top of the hierarchy.
Definition: format.h:38
Definition: gtid_text_format.h:44
static constexpr std::string_view m_uuid_uuid_separator
Definition: gtid_text_format.h:47
static constexpr std::string_view m_uuid_uuid_separator_for_output
Definition: gtid_text_format.h:52
static const Boundary_set_text_format m_boundary_set_text_format
Definition: gtid_text_format.h:64
auto parent() const
Definition: gtid_text_format.h:75
static void after_token(Parser &parser)
Definition: gtid_text_format.h:72
static constexpr std::string_view m_uuid_tag_number_separator_for_output
Definition: gtid_text_format.h:61
static void before_token(Parser &parser)
Definition: gtid_text_format.h:69
static constexpr std::string_view m_uuid_tag_number_separator
Definition: gtid_text_format.h:56
Format tag to identify text format.
Definition: text_format.h:38