MySQL 9.0.0
Source Code Documentation
xa::XID_extractor Class Reference

Processes a string and extracts XIDs of the form X'...',X'...',0-9. More...

#include <xid_extract.h>

Public Types

using xid_list = std::vector< xid_t >
 

Public Member Functions

 XID_extractor ()=default
 
 XID_extractor (std::string const &source, size_t max_extractions=std::numeric_limits< size_t >::max())
 Constructs a new instance and tries to extract XIDs from the given string. More...
 
virtual ~XID_extractor ()=default
 
size_t extract (std::string const &source, size_t max_extractions=std::numeric_limits< size_t >::max())
 Processes the given string and extracts well-formed XIDs. More...
 
xid_list::iterator begin ()
 Retrieves an iterator pointing to the beginning of the extracted XID list. More...
 
xid_list::iterator end ()
 Retrieves an iterator pointing to the end of the extracted XID list. More...
 
size_t size ()
 Retrieves the size of the extracted XID list. More...
 
xid_toperator[] (size_t idx)
 Retrieves the nth XID in the list of extracted XIDs. More...
 

Private Attributes

xid_list m_xids
 List of extracted XIDs. More...
 

Detailed Description

Processes a string and extracts XIDs of the form X'...',X'...',0-9.

Extracted XIDs are stored internally and are iterable through either iterator or direct access semantics:

  XID_extractor tokenizer;
  tokenizer.extract("XA COMMIT X'1234',X'123456',1;"
                    "XA ROLLBACK X'1234',X'123456',1;");
  for (auto xid : tokenizer)
    std::cout << xid << std::endl << std::flush;

  if (tokenizer.size() != 0)
    std::cout << tokenizer[0] << std::endl << std::flush

At each extraction, the internal list of extracted XIDs is cleared.

Member Typedef Documentation

◆ xid_list

using xa::XID_extractor::xid_list = std::vector<xid_t>

Constructor & Destructor Documentation

◆ XID_extractor() [1/2]

xa::XID_extractor::XID_extractor ( )
default

◆ XID_extractor() [2/2]

xa::XID_extractor::XID_extractor ( std::string const &  source,
size_t  max_extractions = std::numeric_limits<size_t>::max() 
)

Constructs a new instance and tries to extract XIDs from the given string.

The extracted XID will be stored internally and iterable either through iterator or direct access semantics.

Parameters
sourceThe string containing XID to be extracted.
max_extractionsThe maximum number of XIDs to be extracted from the string.

◆ ~XID_extractor()

virtual xa::XID_extractor::~XID_extractor ( )
virtualdefault

Member Function Documentation

◆ begin()

xa::XID_extractor::xid_list::iterator xa::XID_extractor::begin ( void  )

Retrieves an iterator pointing to the beginning of the extracted XID list.

Returns
an iterator to the beginning of the XID list.

◆ end()

xa::XID_extractor::xid_list::iterator xa::XID_extractor::end ( void  )

Retrieves an iterator pointing to the end of the extracted XID list.

Returns
an iterator to the end of the XID list.

◆ extract()

size_t xa::XID_extractor::extract ( std::string const &  source,
size_t  max_extractions = std::numeric_limits<size_t>::max() 
)

Processes the given string and extracts well-formed XIDs.

The extracted XID will be stored internally and iterable either through iterator or direct access semantics. Per each invocatian of this method, the internal list of extracted XIDs is cleared.

Parameters
sourceThe string containing XID to be extracted.
max_extractionsThe maximum number of XIDs to be extracted from the string.
Returns
the number of XIDs that were actually extracted.

◆ operator[]()

xid_t & xa::XID_extractor::operator[] ( size_t  idx)

Retrieves the nth XID in the list of extracted XIDs.

Parameters
idxThe index of the XID to be retrieved
Returns
a reference to the XID at index idx.

◆ size()

size_t xa::XID_extractor::size ( )

Retrieves the size of the extracted XID list.

Returns
an the size of the XID list.

Member Data Documentation

◆ m_xids

xid_list xa::XID_extractor::m_xids
private

List of extracted XIDs.


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