feat add ToUpper,ToLower
Some checks failed
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 38s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 39s

This commit is contained in:
tqcq 2024-03-05 00:13:20 +08:00
parent fcce11249b
commit 4402688c9c
2 changed files with 33 additions and 0 deletions

View File

@ -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);

View File

@ -1,8 +1,39 @@
#include "sled/strings/utils.h"
#include <sstream>
#include <string.h>
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<std::string> &strings,
const std::string &delim,