111
This commit is contained in:
25
src/Tool.cpp
25
src/Tool.cpp
@@ -85,6 +85,31 @@ void Tool::Logger(std::string L)
|
||||
#endif
|
||||
}
|
||||
|
||||
void Tool::Split(const std::string &src, std::vector<std::string> &dest, const std::string &separator)
|
||||
{
|
||||
std::string str = src;
|
||||
std::string substring;
|
||||
std::string::size_type start = 0, index;
|
||||
dest.clear();
|
||||
index = str.find_first_of(separator, start);
|
||||
do
|
||||
{
|
||||
if (index != std::string::npos)
|
||||
{
|
||||
substring = str.substr(start, index - start);
|
||||
dest.push_back(substring);
|
||||
start = index + separator.size();
|
||||
index = str.find(separator, start);
|
||||
if (start == std::string::npos)
|
||||
break;
|
||||
}
|
||||
} while (index != std::string::npos);
|
||||
|
||||
// the last part
|
||||
substring = str.substr(start);
|
||||
dest.push_back(substring);
|
||||
}
|
||||
|
||||
long long Tool::get_cur_time()
|
||||
{
|
||||
// 获取操作系统当前时间点(精确到微秒)
|
||||
|
||||
Reference in New Issue
Block a user