refactor: make parsing sort-by more lenient

pull/2486/head
Austin Horstman 2023-09-09 09:38:03 -05:00
parent 8ea2626de8
commit 8ce64ea784
No known key found for this signature in database
1 changed files with 7 additions and 1 deletions

View File

@ -12,10 +12,16 @@ struct EnumParser {
enum SORT_METHOD { ID, NAME, NUMBER, DEFAULT };
SORT_METHOD sortStringToEnum(const std::string& str) {
// Convert the input string to uppercase (make it lenient on config input)
std::string uppercaseStr;
for (char c : str) {
uppercaseStr += std::toupper(c);
}
static const std::map<std::string, SORT_METHOD> enumMap = {
{"ID", ID}, {"NAME", NAME}, {"NUMBER", NUMBER}, {"DEFAULT", DEFAULT}};
auto it = enumMap.find(str);
auto it = enumMap.find(uppercaseStr);
if (it != enumMap.end()) {
return it->second;
} else {