ccuty  1.0
 All Classes Namespaces Files Functions Enumerations Macros Pages
Classes | Namespaces | Constant Groups | Macros
ccstringset.hpp File Reference

String set and indexed string set (strings have a numeric ID that can be used in switch statements) More...

Go to the source code of this file.

Classes

class  ccuty::stringset
 Set of strings, allows converting strings to numbers. More...
 
class  ccuty::istringset
 Indexed set of strings, allows converting strings to numbers and vice-versa. More...
 

Namespaces

 ccuty
 C++ Utilities.
 

Constant Groups

 ccuty
 C++ Utilities.
 

Macros

#define STRINGIFY(s)   _STRINGIFY(s)
 Stringify a symbol.
 
#define STRING_SWITCH(str,...)
 Allows comparing strings in switch statements. More...
 

Detailed Description

String set and indexed string set (strings have a numeric ID that can be used in switch statements)

Macros: STRINGIFY and stringswitch
Classes: ccuty::stringset and ccuty::istringset

Author
Eric Lecolinet 2017 - https://www.telecom-paristech.fr/~elc

Macro Definition Documentation

#define STRING_SWITCH (   str,
  ... 
)
Value:
enum {__VA_ARGS__}; \
static const ccuty::stringset _stringset_ ## __LINE__(#__VA_ARGS__); \
switch(_stringset_ ## __LINE__[str])

Allows comparing strings in switch statements.

Example:

int getRGB(const std::string& color) {
STRING_SWITCH(color, red, blue, green) {
case red: return 0xf00;
case blue: return 0x0f0;
case green: return 0x00f;
default: return 0;
}
}

This macro relies on ccuty::stringset.