MySQL 9.0.0
Source Code Documentation
|
Representation of the GTID tag. More...
#include <tag.h>
Classes | |
struct | Hash |
Structure to compute hash function of a given Tag object. More... | |
Public Types | |
using | Tag_data = std::string |
Public Member Functions | |
Tag ()=default | |
Constructs an empty, valid tag. More... | |
Tag (const Tag_plain &tag) | |
Construct from Tag_plain object. More... | |
Tag (const std::string &text) | |
Constructs tag from a given text. More... | |
std::string | to_string () const |
Obtains textual representation of internal tag. More... | |
std::size_t | to_string (char *out) const |
Obtains textual representation of internal tag and writes it to out. More... | |
std::size_t | from_string (const std::string &text) |
Creates Tag object from a given text. More... | |
std::size_t | from_cstring (const char *text) |
Creates Tag object from a given text. More... | |
bool | is_empty () const |
Indicates whether transaction tag is empty. More... | |
bool | is_defined () const |
Indicates whether transaction tag is defined (is not empty) More... | |
bool | operator== (const Tag &other) const |
Operator ==. More... | |
bool | operator!= (const Tag &other) const |
Operator !=. More... | |
bool | operator< (const Tag &other) const |
Compares this tag with other, <. More... | |
std::size_t | encode_tag (unsigned char *buf, const Gtid_format >id_format) const |
stores Tag in buffer More... | |
std::size_t | get_encoded_length (const Gtid_format >id_format) const |
returns length of encoded tag, based on defined format More... | |
std::size_t | get_length () const |
returns length of tag More... | |
std::size_t | decode_tag (const unsigned char *buf, std::size_t buf_len, const Gtid_format >id_format) |
Reads Tag data from the buffer. More... | |
const Tag_data & | get_data () const |
Internal data accessor. More... | |
Tag_data & | get_data () |
Internal data accessor, non const (serialization) More... | |
Static Public Member Functions | |
static constexpr std::size_t | get_max_encoded_length () |
Obtains maximum length of encoded tag (compile time) More... | |
Protected Member Functions | |
void | replace (const char *text, std::size_t len) |
Replaces internal tag data with a given text, includes text normalization. More... | |
Static Protected Member Functions | |
static bool | is_valid_end_char (const char &character) |
Checks whether current character is a valid ending of a Tag string. More... | |
static bool | is_character_valid (const char &character, std::size_t pos) |
Checks whether current character is a valid Tag character. More... | |
Protected Attributes | |
Tag_data | m_data = "" |
internal tag representation More... | |
Representation of the GTID tag.
Tag format: [a-z_]{a-z0-9_}{0,31} Tag may be created from a given text. Text may contain leading and trailing spaces which will be omitted during Tag creation. Text may also contain uppercase characters. Acceptable format for text is as follows: [:space:][a-zA-Z_][a-zA-Z0-9_]{0,31}[:space:]
using mysql::gtid::Tag::Tag_data = std::string |
|
default |
Constructs an empty, valid tag.
|
explicit |
Construct from Tag_plain object.
tag | pattern |
mysql::gtid::Tag::Tag | ( | const std::string & | text | ) |
Constructs tag from a given text.
If passed text is not a valid tag representation, object remains empty (empty tag)
[in] | text | Textual representation of a tag |
std::size_t mysql::gtid::Tag::decode_tag | ( | const unsigned char * | buf, |
std::size_t | buf_len, | ||
const Gtid_format & | gtid_format | ||
) |
Reads Tag data from the buffer.
buf | Buffer to read tag from |
buf_len | Number of bytes in the buffer |
gtid_format | Gtid format read from stream, if untagged, tag information is assumed to be empty. If tagged, gtid tag length will be read from the stream both for untagged and tagged GTIDs |
std::size_t mysql::gtid::Tag::encode_tag | ( | unsigned char * | buf, |
const Gtid_format & | gtid_format | ||
) | const |
stores Tag in buffer
buf | Buffer to store bytes, must contain at least get_encoded_length() bytes |
gtid_format | Format of encoded GTID. If tag is not defined for this GTID and tagged format is used, 0 will be encoded as length of the string. In case "untagged" format is requested, function won't encode additional tag information for untagged GTIDs. When using untagged, tag is required to be empty. |
size_t mysql::gtid::Tag::from_cstring | ( | const char * | text | ) |
Creates Tag object from a given text.
If passed text is not a valid tag representation, object remains empty (empty tag) Since length of text is unknown, it is expected to be null terminated
[in] | text | Textual representation of a tag |
size_t mysql::gtid::Tag::from_string | ( | const std::string & | text | ) |
Creates Tag object from a given text.
If passed text is not a valid tag representation, object remains empty (empty tag). Text must end with a null character or a gtid separator
[in] | text | Textual representation of a tag |
|
inline |
Internal data accessor, non const (serialization)
|
inline |
Internal data accessor.
size_t mysql::gtid::Tag::get_encoded_length | ( | const Gtid_format & | gtid_format | ) | const |
returns length of encoded tag, based on defined format
gtid_format | Format of encoded GTID. If tag is not defined for this GTID and tagged format is used, 0 will be encoded as length of the string. In case "untagged" format is requested, function won't encode additional tag information for untagged GTIDs. When using untagged, tag is required to be empty. |
Note that in case encoded format is "tagged" and tag is empty, we still to encode tag length (1 byte for length equal to 0).
std::size_t mysql::gtid::Tag::get_length | ( | ) | const |
returns length of tag
|
inlinestaticconstexpr |
Obtains maximum length of encoded tag (compile time)
|
staticprotected |
Checks whether current character is a valid Tag character.
[in] | character | A character under test |
[in] | pos | Position within a tag |
|
inline |
Indicates whether transaction tag is defined (is not empty)
|
inline |
Indicates whether transaction tag is empty.
|
staticprotected |
Checks whether current character is a valid ending of a Tag string.
[in] | character | A character under test |
bool mysql::gtid::Tag::operator!= | ( | const Tag & | other | ) | const |
Operator !=.
other | pattern to compare against |
|
inline |
Compares this tag with other, <.
true | This tag is before other (alphabetical order) |
false | Other tag is before this (alphabetical order) |
bool mysql::gtid::Tag::operator== | ( | const Tag & | other | ) | const |
Operator ==.
other | pattern to compare against |
|
protected |
Replaces internal tag data with a given text, includes text normalization.
[in] | text | Pattern to copy from, valid tag string |
[in] | len | Number of characters to copy |
std::string mysql::gtid::Tag::to_string | ( | ) | const |
Obtains textual representation of internal tag.
std::size_t mysql::gtid::Tag::to_string | ( | char * | out | ) | const |
Obtains textual representation of internal tag and writes it to out.
[out] | out | Output string |
|
protected |
internal tag representation