mirror of
https://github.com/drogonframework/drogon.git
synced 2025-08-29 00:02:44 -04:00
Use splitString in trantor (#413)
Co-authored-by: antao <antao2002@gmail.com>
This commit is contained in:
parent
17b8c337f9
commit
269acbc477
@ -27,6 +27,7 @@ set(INSTALL_DROGON_CMAKE_DIR
|
||||
CACHE PATH "Installation directory for cmake files")
|
||||
|
||||
if(BUILD_DROGON_SHARED)
|
||||
set(BUILD_TRANTOR_SHARED TRUE)
|
||||
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)
|
||||
list(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES
|
||||
"${CMAKE_INSTALL_PREFIX}/${INSTALL_LIB_DIR}" isSystemDir)
|
||||
|
@ -15,6 +15,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <trantor/utils/Date.h>
|
||||
#include <trantor/utils/Funcs.h>
|
||||
#include <drogon/utils/string_view.h>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
@ -45,8 +46,18 @@ std::string hexToBinaryString(const char *ptr, size_t length);
|
||||
std::vector<char> hexToBinaryVector(const char *ptr, size_t length);
|
||||
|
||||
/// Split the string into multiple separated strings.
|
||||
std::vector<std::string> splitString(const std::string &str,
|
||||
const std::string &separator);
|
||||
/**
|
||||
* @param acceptEmptyString if true, empty strings are accepted in the
|
||||
* result, for example, splitting the ",1,2,,3," by "," produces
|
||||
* ["","1","2","","3",""]
|
||||
*/
|
||||
inline std::vector<std::string> splitString(const std::string &str,
|
||||
const std::string &separator,
|
||||
bool acceptEmptyString = false)
|
||||
{
|
||||
return trantor::splitString(str, separator, acceptEmptyString);
|
||||
}
|
||||
|
||||
std::set<std::string> splitStringToSet(const std::string &str,
|
||||
const std::string &separator);
|
||||
|
||||
|
@ -248,30 +248,6 @@ std::string binaryStringToHex(const unsigned char *ptr, size_t length)
|
||||
}
|
||||
return idString;
|
||||
}
|
||||
std::vector<std::string> splitString(const std::string &str,
|
||||
const std::string &separator)
|
||||
{
|
||||
std::vector<std::string> ret;
|
||||
std::string::size_type pos1, pos2;
|
||||
pos2 = 0;
|
||||
pos1 = str.find(separator);
|
||||
while (pos1 != std::string::npos)
|
||||
{
|
||||
if (pos1 != 0)
|
||||
{
|
||||
std::string item = str.substr(pos2, pos1 - pos2);
|
||||
ret.push_back(item);
|
||||
}
|
||||
pos2 = pos1 + separator.length();
|
||||
while (pos2 < str.length() &&
|
||||
str.substr(pos2, separator.length()) == separator)
|
||||
pos2 += separator.length();
|
||||
pos1 = str.find(separator, pos2);
|
||||
}
|
||||
if (pos2 < str.length())
|
||||
ret.push_back(str.substr(pos2));
|
||||
return ret;
|
||||
}
|
||||
|
||||
std::set<std::string> splitStringToSet(const std::string &str,
|
||||
const std::string &separator)
|
||||
|
2
trantor
2
trantor
@ -1 +1 @@
|
||||
Subproject commit 82a61062acc94fca3114ff0d764f9961c2ae23aa
|
||||
Subproject commit a2878af4320eff14bd815e3b6b2fdf84fbc19ab1
|
Loading…
x
Reference in New Issue
Block a user