Utilities
-
class string_pool
This class implements a shared string pool with the ability to merge with other pools.
Note
This class is not copy-constructible, but is move-constructible.
Public Functions
-
string_pool(const string_pool&) = delete
-
string_pool &operator=(const string_pool&) = delete
-
string_pool()
-
string_pool(string_pool &&other)
-
~string_pool()
-
std::pair<std::string_view, bool> intern(std::string_view str)
Intern a string.
- Parameters:
str – string to intern.
- Returns:
pair whose first value is the interned string, and the second value specifies whether it is a newly created instance (true) or a reuse of an existing instance (false).
-
std::vector<std::string_view> get_interned_strings() const
Return all interned strings.
- Returns:
sequence of all interned strings. The sequence will be sorted.
-
void dump() const
Dump pool’s content to stdout.
- Todo:
This needs to be reworked to make it more generally usable.
-
void clear()
Clear pool’s content.
-
size_t size() const
Query the total number of strings stored in the pool.
- Returns:
size_t total number of strings in the pool.
-
void swap(string_pool &other)
Swap the content with another string-pool instance.
- Parameters:
other – string-pool instance to swap contents with.
-
void merge(string_pool &other)
Merge another string pool instance in. This will not invalidate any string references to the other pool.
The other string pool instance will become empty when this call returns.
- Parameters:
other – string pool instance to merge in.
-
string_pool(const string_pool&) = delete
-
class tokens
XML token store that provides mapping of integral token indentifiers and their original names. Instances of this class are typically used as global constants.
Note
The string values for the original token names should be static values whose values and memory addresses remain unchanged during the life cycle of the instance that references them.
Note
This class is not copy-constructible.
Public Functions
-
tokens() = delete
-
tokens(const char **token_names, size_t token_name_count)
-
~tokens()
-
bool is_valid_token(xml_token_t token) const
Check if a token returned from get_token() method is valid.
- Returns:
true if valid, false otherwise.
-
xml_token_t get_token(std::string_view name) const
Get token from a specified name.
- Parameters:
name – textural token name
- Returns:
token value representing the given textural token.
-
std::string_view get_token_name(xml_token_t token) const
Get textural token name from a token value.
- Parameters:
token – numeric token value
- Returns:
textural token name, or empty string in case the given token is not valid.
-
tokens() = delete
-
class cell_buffer
Temporary cell buffer used to decode encoded cell values. This is used in the sax, json and csv parsers.