You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and dots ('.'), can be up to 35 characters long. Letters must be lowercase.
 
 
 

34 lines
986 B

#include "http_tools.h"
std::string string_to_upper(std::string& str)
{
for (int i = 0; i < str.length(); i++)
{
str[i] = std::toupper(str[i]);
}
return str;
}
std::unique_ptr<std::vector<std::string>> string_split(std::string s, std::string delimiter, int cpt)
{
std::unique_ptr<std::vector<std::string>> splits(new std::vector<std::string>(0));
size_t pos = 0;
while (((pos = s.find(delimiter)) != std::string::npos) && cpt-- != 0) {
splits->push_back(s.substr(0, pos));
s.erase(0, pos + delimiter.length());
}
splits->push_back(s);
return splits;
}
std::string string_trim(const std::string& str, const std::string& whitespace)
{
const auto strBegin = str.find_first_not_of(whitespace);
if (strBegin == std::string::npos)
return ""; // no content
const auto strEnd = str.find_last_not_of(whitespace);
const auto strRange = strEnd - strBegin + 1;
return str.substr(strBegin, strRange);
}