Hi, I have the following problem
Then I have some STL input string, let’s say inpStr and do sth like that
After such checking code becomes more and more redundant, however, I cannot find a way to do this smarter. I’m wondering if we can apply some casting to do this more less that simple (pseudo code)
Any help will be appreciated.
Code:
#define FIRST_OPTION 1
#define SECOND_OPTION 2
#define THIRD_OPTION 3
#define FOURTH_OPTION 4
…
Code:
if (inpStr == "FIRST_OPTION")
importantVariable = FIRST_OPTION;
else if (inpStr == "SECOND_OPTION")
importantVariable = SECOND_OPTION;
...
else
importantVariable = UNKNOWN_OPTION;
Code:
checkIfDefineExists(inpStr)
if YES:
importantVariable = (getIntegerValueFromDefinedHavingName)inpStr;
if NO:
importantVariable = -1