The solution is very simple. You need an enumeration and a std::map , and that’s it. The enumeration defines the numeric values use in the switch statement. The std::map contains the link between the valid string values you want to compare some runtime data against, and the numeric enum values you can make a switchon.