#include "util/enum.hpp" #include // for std::transform #include // for std::toupper #include #include #include #include #include "modules/hyprland/workspaces.hpp" #include "util/string.hpp" namespace waybar::util { template EnumParser::EnumParser() = default; template EnumParser::~EnumParser() = default; template EnumType EnumParser::parseStringToEnum(const std::string& str, const std::map& enumMap) { // Convert the input string to uppercase std::string uppercaseStr = capitalize(str); // Capitalize the map keys before searching std::map capitalizedEnumMap; std::transform( enumMap.begin(), enumMap.end(), std::inserter(capitalizedEnumMap, capitalizedEnumMap.end()), [this](const auto& pair) { return std::make_pair(capitalize(pair.first), pair.second); }); // Return enum match of string auto it = capitalizedEnumMap.find(uppercaseStr); if (it != capitalizedEnumMap.end()) return it->second; // Throw error if it doesn't return throw std::invalid_argument("Invalid string representation for enum"); } // Explicit instantiations for specific EnumType types you intend to use // Add explicit instantiations for all relevant EnumType types template struct EnumParser; } // namespace waybar::util