refactor: make parsing sort-by more lenient
This commit is contained in:
parent
8ea2626de8
commit
8ce64ea784
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue