diff --git a/src/osuparser.cpp b/src/osuparser.cpp index 3f72697..c7a4805 100644 --- a/src/osuparser.cpp +++ b/src/osuparser.cpp @@ -6,13 +6,20 @@ #include #include +inline std::string trimString(const std::string &str) { + std::string ret(str); + ret.erase(0, ret.find_first_not_of(" \n\r\t")); + ret.erase(ret.find_last_not_of(" \n\r\t") + 1); + return ret; +} + inline std::string checkAndRemove(const std::string &str, const std::string &prefix) { if (!str.starts_with(prefix)) { std::cerr << "failure parsing difficulty file on:\n" << str << "\n"; std::exit(EXIT_FAILURE); } - return str.substr(prefix.length()); + return trimString(str.substr(prefix.length())); } inline void toLower(std::string &str) { @@ -50,7 +57,7 @@ inline void toLower(std::string &str) { #define VAR_GENERIC(section, name, ...) \ namePascalCased = #name;\ namePascalCased[0] = std::toupper(namePascalCased[0]);\ - namePascalCased.append(": ");\ + namePascalCased.append(":");\ if (line.starts_with(namePascalCased)) {\ __VA_ARGS__\ ret section.name = value;\