ccuty  1.0
 All Classes Namespaces Files Functions Enumerations Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
ccuty::istringset Class Reference

Indexed set of strings, allows converting strings to numbers and vice-versa. More...

Inheritance diagram for ccuty::istringset:
ccuty::stringset

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

ccuty::istringset::istringset ( const char *  str)
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.

ccuty::istringset::istringset ( const std::string &  str)
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.

ccuty::istringset::istringset ( std::initializer_list< const char * >  tokens)
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.

ccuty::istringset::istringset ( std::initializer_list< elem >  tokens)
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).

Note
if several couples use the same ID, operator[](unsigned int id) will return the first token with this ID.
template<typename T >
ccuty::istringset::istringset ( const T &  tokens)
inlineexplicit

Constructor: tokens is a container (vector, list, map) of tokens or {token, ID} couples.

Duplicate tokens are ignored. IDs must be >= 0.

Member Function Documentation

int ccuty::istringset::insert ( const std::string &  token)
inline

Inserts token in the istringset.

Duplicate tokens are ignored. Return the ID of token.

int ccuty::istringset::insert ( const char *  token)
inline

Inserts token in the istringset.

Duplicate tokens are ignored. Return the ID of token.

int ccuty::istringset::insert ( const elem &  e)
inline

Inserts a {token, ID} couple in the istringset.

Duplicate tokens are ignored. Return the ID of token.

template<typename T >
void ccuty::istringset::append ( const T &  cont)
inline

Inserts the elements of a container (vector, list, map) of tokens or {token, ID} couples.

Duplicate tokens are ignored. IDs must be >= 0.

int ccuty::stringset::starts_with ( const std::string &  str) const
inlineinherited

Returns the ID of the token which starts with str.

Returns -1 if not found and -2 if several tokens match.

int ccuty::stringset::insert ( const elem &  e)
inlineinherited

Inserts a {token, ID} couple in the stringset.

Duplicate tokens are ignored. Return the ID of token.


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