Indexed set of strings, allows converting strings to numbers and vice-versa. More...
Public Member Functions | |
istringset () | |
No argument constructor. | |
istringset (const char *str) | |
Constructor: str is a C string containing tokens separated by commas. More... | |
istringset (const std::string &str) | |
Constructor: str is a C++ string containing tokens separated by commas. More... | |
istringset (std::initializer_list< const char * > tokens) | |
Constructor: tokens is a sequence of tokens (each token is C string). More... | |
istringset (std::initializer_list< elem > tokens) | |
Constructor: tokens is a sequence of {token, ID} couples. More... | |
template<typename T > | |
istringset (const T &tokens) | |
Constructor: tokens is a container (vector, list, map) of tokens or {token, ID} couples. More... | |
const id_set & | ids () const |
Returns the internal set of IDs. | |
int | operator[] (const std::string &token) const |
Returns the ID of token or -1 if not found. | |
const std::string & | operator[] (unsigned int id) const |
Returns the token corresponding to this ID or istringset::none() if not found. | |
void | clear () |
Clears the istringset. | |
int | insert (const std::string &token) |
Inserts token in the istringset. More... | |
int | insert (const char *token) |
Inserts token in the istringset. More... | |
int | insert (const elem &e) |
Inserts a {token, ID} couple in the istringset. More... | |
template<typename T > | |
void | append (const T &cont) |
Inserts the elements of a container (vector, list, map) of tokens or {token, ID} couples. More... | |
bool | empty () const |
Tests whether the stringset is empty. | |
size_t | size () const |
Returns the size of the stringset. | |
const string_set & | elements () const |
Returns the internal set of elements (each containing a token and its IDs). | |
int | starts_with (const std::string &str) const |
Returns the ID of the token which starts with str. More... | |
int | insert (const elem &e) |
Inserts a {token, ID} couple in the stringset. More... | |
Static Public Member Functions | |
static const std::string & | none () |
returns an empty string. | |
Indexed set of strings, allows converting strings to numbers and vice-versa.
This class provides the same functionnalities as ccutty::stringset but also allows converting numbers to strings.
|
inlineexplicit |
Constructor: str is a C string containing tokens separated by commas.
Each token is associated with an ID which corresponds to its position in the list (starting from 0). Duplicate tokens are ignored.
|
inlineexplicit |
Constructor: str is a C++ string containing tokens separated by commas.
Each token is associated with an ID which corresponds to its position in the list (starting from 0). Duplicate tokens are ignored.
|
inlineexplicit |
Constructor: tokens is a sequence of tokens (each token is C string).
Each token is associated with an ID which corresponds to its position in the list (starting from 0). Duplicate tokens are ignored.
|
inline |
Constructor: tokens is a sequence of {token, ID} couples.
IDs must be >= 0. Multiple couples can use the same ID but not the same token (duplicate tokens are ignored).
|
inlineexplicit |
Constructor: tokens is a container (vector, list, map) of tokens or {token, ID} couples.
Duplicate tokens are ignored. IDs must be >= 0.
|
inline |
Inserts token in the istringset.
Duplicate tokens are ignored. Return the ID of token.
|
inline |
Inserts token in the istringset.
Duplicate tokens are ignored. Return the ID of token.
|
inline |
Inserts a {token, ID} couple in the istringset.
Duplicate tokens are ignored. Return the ID of token.
|
inline |
Inserts the elements of a container (vector, list, map) of tokens or {token, ID} couples.
Duplicate tokens are ignored. IDs must be >= 0.
|
inlineinherited |
Returns the ID of the token which starts with str.
Returns -1 if not found and -2 if several tokens match.
|
inlineinherited |
Inserts a {token, ID} couple in the stringset.
Duplicate tokens are ignored. Return the ID of token.