utils: split: Rename all splitBy*() variants to split()

Este commit está contenido en:
Albert S. 2021-04-17 12:41:22 +02:00
padre b995362d1f
commit 4dc688f9eb
Se han modificado 5 ficheros con 13 adiciones y 11 borrados

Ver fichero

@ -159,7 +159,7 @@ std::vector<std::string> PageDaoSqlite::fetchCategories(std::string pagename, Qu
std::string PageDaoSqlite::ftsEscape(std::string input)
{
std::string result = "";
for(auto &str : utils::splitByChar(input, ' '))
for(auto &str : utils::split(input, ' '))
{
std::string tmp = utils::strreplace(str, "\"", "\"\"");
tmp = "\"" + tmp + "\"" + " ";

Ver fichero

@ -86,7 +86,7 @@ std::string Parser::processLink(const PageDao &pageDao, UrlProvider &urlProvider
std::string linktag = match.str(1);
std::string inside = match.str(2);
std::vector<std::string> splitted = utils::splitByChar(inside, '|');
std::vector<std::string> splitted = utils::split(inside, '|');
HtmlLink htmllink;
if(splitted.size() == 2)
{

Ver fichero

@ -47,7 +47,7 @@ std::pair<std::string, std::string> Request::createPairFromVar(std::string var)
void Request::initMultiMap(std::multimap<std::string, std::string> &map, const std::string &url)
{
auto splitted = utils::splitByChar(url, '&');
auto splitted = utils::split(url, '&');
for(const std::string &part : splitted)
{
auto pair = createPairFromVar(part);
@ -75,7 +75,8 @@ void Request::initPostMap(const std::string &url)
void Request::initCookies(const std::string &cookiestr)
{
// TODO: find out what it really should be, ";" or "; "?
auto cookiesplitted = utils::splitByRegex(cookiestr, ";+\\s?");
std::regex regex { ";+\\s?" };
auto cookiesplitted = utils::split(cookiestr, regex);
for(const std::string &part : cookiesplitted)
{
auto pair = createPairFromVar(part);

Ver fichero

@ -78,7 +78,7 @@ std::string utils::urldecode(std::string_view str)
return result;
}
std::vector<std::string> utils::splitByChar(const std::string &str, char delim)
std::vector<std::string> utils::split(const std::string &str, char delim)
{
std::vector<std::string> result;
std::stringstream stream(str);
@ -91,12 +91,13 @@ std::vector<std::string> utils::splitByChar(const std::string &str, char delim)
}
// TODO: can easily break if we pass a regex here
std::vector<std::string> utils::splitByString(const std::string &str, const std::string &delim)
std::vector<std::string> utils::split(const std::string &str, const std::string &delim)
{
return splitByRegex(str, delim + "+");
std::regex regex { delim + "+" };
return split(str, regex);
}
std::vector<std::string> utils::splitByRegex(const std::string &str, const std::string &regex)
std::vector<std::string> utils::split(const std::string &str, std::regex &regex)
{
std::vector<std::string> result;
std::regex reg(regex);

Ver fichero

@ -11,9 +11,9 @@
namespace utils
{
std::vector<std::string> splitByChar(const std::string &str, char delim);
std::vector<std::string> splitByString(const std::string &str, const std::string &delim);
std::vector<std::string> splitByRegex(const std::string &str, const std::string &regex);
std::vector<std::string> split(const std::string &str, char delim);
std::vector<std::string> split(const std::string &str, const std::string &delim);
std::vector<std::string> split(const std::string &str, std::regex &regex);
std::string urldecode(std::string_view str);
std::string strreplace(const std::string &str, const std::string &search, const std::string &replace);