MySQL 9.1.0
Source Code Documentation
mysql::gtid::Tsid Class Reference

Represents Transaction Source Identifier which is composed of source UUID and transaction tag. More...

#include <tsid.h>

Classes

struct  Hash
 Structure to compute hash function of a given Tag object. More...
 

Public Member Functions

 Tsid (const Uuid &uuid, const Tag &tag)
 Constructs TSID from a given uuid and a tag. More...
 
 Tsid (const Uuid &uuid)
 Constructs TSID from a given uuid, tag is empty. More...
 
 Tsid (const Tsid_plain &arg)
 Construct from Tsid_plain object. More...
 
 Tsid ()=default
 Constructs empty TSID. More...
 
 Tsid (Tsid const &)=default
 
 Tsid (Tsid &&)=default
 
Tsidoperator= (Tsid const &)=default
 
Tsidoperator= (Tsid &&)=default
 
std::string to_string () const
 Returns textual representation of Transaction Source Identifier. More...
 
std::size_t to_string (char *out) const
 Obtains textual representation of TSID and writes it to out. More...
 
std::size_t to_string (char *out, const char *tag_sid_separator) const
 Obtains textual representation of TSID and writes it to out. More...
 
std::size_t from_cstring (const char *text)
 Fills Tsid with data from text. More...
 
bool operator== (const Tsid &other) const
 Operator ==. More...
 
bool operator!= (const Tsid &other) const
 Operator !=. More...
 
bool operator< (const Tsid &other) const
 Operator <. More...
 
const Tagget_tag () const
 Tag accessor. More...
 
Tagget_tag_ref ()
 Tag accessor, non const (serialization) More...
 
void set_tag (const Tag &tag)
 Sets internal tag to a given tag object. More...
 
const Uuidget_uuid () const
 UUID accessor. More...
 
Uuidget_uuid ()
 Non const getter is needed in some functions (copy data) More...
 
bool is_tagged () const
 Checks whether this TSID contains tag. More...
 
void clear ()
 Clears data - uuid and tag. More...
 
std::size_t encode_tsid (unsigned char *buf, const Gtid_format &gtid_format) const
 stores TSID in buffer More...
 
std::size_t decode_tsid (const unsigned char *stream, std::size_t stream_len, const Gtid_format &gtid_format)
 reads TSID from the buffer More...
 

Static Public Member Functions

static constexpr std::size_t get_max_encoded_length ()
 Obtains maximum length of encoded TSID (compile time) More...
 

Static Public Attributes

static constexpr auto tsid_separator = ":"
 Default TSID separator. More...
 

Private Attributes

Uuid m_uuid = {0}
 GTID UUID. More...
 
Tag m_tag
 GTID Tag. More...
 

Friends

struct Hash
 

Detailed Description

Represents Transaction Source Identifier which is composed of source UUID and transaction tag.

Transaction tag may be empty.

Constructor & Destructor Documentation

◆ Tsid() [1/6]

mysql::gtid::Tsid::Tsid ( const Uuid uuid,
const Tag tag 
)

Constructs TSID from a given uuid and a tag.

Parameters
[in]uuidUUID component
[in]tagTag component

◆ Tsid() [2/6]

mysql::gtid::Tsid::Tsid ( const Uuid uuid)

Constructs TSID from a given uuid, tag is empty.

Parameters
[in]uuidUUID component

◆ Tsid() [3/6]

mysql::gtid::Tsid::Tsid ( const Tsid_plain arg)
explicit

Construct from Tsid_plain object.

Parameters
argSource to copy from

◆ Tsid() [4/6]

mysql::gtid::Tsid::Tsid ( )
default

Constructs empty TSID.

◆ Tsid() [5/6]

mysql::gtid::Tsid::Tsid ( Tsid const &  )
default

◆ Tsid() [6/6]

mysql::gtid::Tsid::Tsid ( Tsid &&  )
default

Member Function Documentation

◆ clear()

void mysql::gtid::Tsid::clear ( )

Clears data - uuid and tag.

◆ decode_tsid()

std::size_t mysql::gtid::Tsid::decode_tsid ( const unsigned char *  stream,
std::size_t  stream_len,
const Gtid_format gtid_format 
)

reads TSID from the buffer

Parameters
streamStream to read tsid from
stream_lenLength of the stream
gtid_formatGtid format expected in the stream
Returns
The number of bytes read or 0. 0 means that an error occurred (e.g. not enough bytes in the buffer to read the tsid - corrupted bytes in the buffer).

◆ encode_tsid()

std::size_t mysql::gtid::Tsid::encode_tsid ( unsigned char *  buf,
const Gtid_format gtid_format 
) const

stores TSID in buffer

Parameters
bufBuffer to store bytes
Returns
the number of bytes written into the buf
Parameters
gtid_formatFormat 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.

◆ from_cstring()

std::size_t mysql::gtid::Tsid::from_cstring ( const char *  text)

Fills Tsid with data from text.

Parameters
[in]textEncoded TSID representation terminated with null sign, GTID separator or UUID set separator if part of the GTID set encoding
Returns
The number of bytes read, or 0 on error

◆ get_max_encoded_length()

static constexpr std::size_t mysql::gtid::Tsid::get_max_encoded_length ( )
inlinestaticconstexpr

Obtains maximum length of encoded TSID (compile time)

Returns
Maximum length of encoded tag in bytes

◆ get_tag()

const Tag & mysql::gtid::Tsid::get_tag ( ) const
inline

Tag accessor.

Returns
Const reference to Tag object

◆ get_tag_ref()

Tag & mysql::gtid::Tsid::get_tag_ref ( )
inline

Tag accessor, non const (serialization)

Returns
Non-const Reference to Tag object

◆ get_uuid() [1/2]

Uuid & mysql::gtid::Tsid::get_uuid ( )
inline

Non const getter is needed in some functions (copy data)

Returns
Reference to internal UUID

◆ get_uuid() [2/2]

const Uuid & mysql::gtid::Tsid::get_uuid ( ) const
inline

UUID accessor.

Returns
Const reference to UUID component of TSID

◆ is_tagged()

bool mysql::gtid::Tsid::is_tagged ( ) const
inline

Checks whether this TSID contains tag.

Return values
trueThis TSID contains tag
falseThis TSID contains empty tag

◆ operator!=()

bool mysql::gtid::Tsid::operator!= ( const Tsid other) const

Operator !=.

Parameters
otherpattern to compare against
Returns
Result of comparison !=

◆ operator<()

bool mysql::gtid::Tsid::operator< ( const Tsid other) const

Operator <.

Compares uuid first. If uuids are equal, compares tags

Parameters
otherpattern to compare against
Returns
Result of comparison this < other

◆ operator=() [1/2]

Tsid & mysql::gtid::Tsid::operator= ( Tsid &&  )
default

◆ operator=() [2/2]

Tsid & mysql::gtid::Tsid::operator= ( Tsid const &  )
default

◆ operator==()

bool mysql::gtid::Tsid::operator== ( const Tsid other) const

Operator ==.

Parameters
otherpattern to compare against
Returns
Result of comparison ==

◆ set_tag()

void mysql::gtid::Tsid::set_tag ( const Tag tag)
inline

Sets internal tag to a given tag object.

Parameters
tagSource to copy from

◆ to_string() [1/3]

string mysql::gtid::Tsid::to_string ( ) const

Returns textual representation of Transaction Source Identifier.

◆ to_string() [2/3]

std::size_t mysql::gtid::Tsid::to_string ( char *  out) const

Obtains textual representation of TSID and writes it to out.

Parameters
[out]outOutput string
Returns
Number of characters written to out

◆ to_string() [3/3]

std::size_t mysql::gtid::Tsid::to_string ( char *  out,
const char *  tag_sid_separator 
) const

Obtains textual representation of TSID and writes it to out.

version with a custom tag-sid separator

Parameters
[out]outOutput string
[in]tag_sid_separatorTag-sid separator
Returns
Number of characters written to out

Friends And Related Function Documentation

◆ Hash

friend struct Hash
friend

Member Data Documentation

◆ m_tag

Tag mysql::gtid::Tsid::m_tag
private

GTID Tag.

◆ m_uuid

Uuid mysql::gtid::Tsid::m_uuid = {0}
private

GTID UUID.

◆ tsid_separator

constexpr auto mysql::gtid::Tsid::tsid_separator = ":"
staticconstexpr

Default TSID separator.


The documentation for this class was generated from the following files: