diff --git a/include/sled/strings/utils.h b/include/sled/strings/utils.h index b5e8aeb..790c2ad 100644 --- a/include/sled/strings/utils.h +++ b/include/sled/strings/utils.h @@ -6,6 +6,8 @@ namespace sled { +char ToLower(char c); +char ToUpper(char c); std::string ToLower(const std::string &str); std::string ToUpper(const std::string &str); std::string ToHex(const std::string &str); diff --git a/src/strings/utils.cc b/src/strings/utils.cc index a5c981a..6a419a7 100644 --- a/src/strings/utils.cc +++ b/src/strings/utils.cc @@ -1,8 +1,39 @@ #include "sled/strings/utils.h" #include +#include namespace sled { +char +ToLower(char c) +{ + return ::tolower(c); +} + +char +ToUpper(char c) +{ + return ::toupper(c); +} + +std::string +ToLower(const std::string &str) +{ + std::string result; + std::transform(str.begin(), str.end(), std::back_inserter(result), + ::tolower); + return result; +} + +std::string +ToUpper(const std::string &str) +{ + std::string result; + std::transform(str.begin(), str.end(), std::back_inserter(result), + ::toupper); + return result; +} + std::string StrJoin(const std::vector &strings, const std::string &delim,