#pragma once #include #include #include #include #include namespace waybar::util { template struct EnumParser { EnumParser() {} EnumType parseStringToEnum(const std::string& str, const std::map& enumMap) { // Convert the input string to uppercase std::string uppercaseStr = str; std::transform(uppercaseStr.begin(), uppercaseStr.end(), uppercaseStr.begin(), [](unsigned char c) { return std::toupper(c); }); // Return enum match of string auto it = enumMap.find(uppercaseStr); if (it != enumMap.end()) return it->second; // Throw error if it doesnt return throw std::invalid_argument("Invalid string representation for enum"); } ~EnumParser() = default; }; } // namespace waybar::util