logic: Trim lines and remove empty ones when checking license key

This commit is contained in:
Eberhard Graether
2016-01-19 11:48:41 +01:00
parent cc2b74ccca
commit 46d9825454
6 changed files with 37 additions and 2 deletions
+7
View File
@@ -168,4 +168,11 @@ namespace utility
return str;
}
std::string trim(const std::string &str)
{
auto wsfront = std::find_if_not(str.begin(), str.end(), [](int c){ return std::isspace(c); });
auto wsback = std::find_if_not(str.rbegin(), str.rend(), [](int c){ return std::isspace(c); }).base();
return (wsback <= wsfront ? std::string() : std::string(wsfront, wsback));
}
}