Orcus
Loading...
Searching...
No Matches
orcus::tokens Class Reference

#include <tokens.hpp>

Public Member Functions

 tokens (const tokens &)=delete
 
 tokens (const char **token_names, size_t token_name_count)
 
bool is_valid_token (xml_token_t token) const
 
xml_token_t get_token (std::string_view name) const
 
std::string_view get_token_name (xml_token_t token) const
 

Detailed Description

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.
This class is not copy-constructible.

Member Function Documentation

◆ get_token()

xml_token_t orcus::tokens::get_token ( std::string_view name) const

Get token from a specified name.

Parameters
nametextural token name
Returns
token value representing the given textural token.

◆ get_token_name()

std::string_view orcus::tokens::get_token_name ( xml_token_t token) const

Get textural token name from a token value.

Parameters
tokennumeric token value
Returns
textural token name, or empty string in case the given token is not valid.

◆ is_valid_token()

bool orcus::tokens::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.