mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-09 03:58:15 +03:00
src: Move certain headers in common
This commit is contained in:
parent
6e28ac711f
commit
17aefc1aef
73 changed files with 98 additions and 106 deletions
23
src/common/string_util.cpp
Normal file
23
src/common/string_util.cpp
Normal file
|
@ -0,0 +1,23 @@
|
|||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include "common/string_util.h"
|
||||
|
||||
namespace StringUtil {
|
||||
|
||||
std::vector<std::string> split_string(const std::string &str, char delimiter) {
|
||||
std::stringstream str_stream(str);
|
||||
std::string segment;
|
||||
std::vector<std::string> seglist;
|
||||
|
||||
const size_t num_segments = std::count_if(str.begin(), str.end(), [&](char c) { return c == delimiter; }) + (str.empty() ? 1 : 0);
|
||||
|
||||
seglist.reserve(num_segments);
|
||||
|
||||
while (std::getline(str_stream, segment, delimiter)) {
|
||||
seglist.push_back(segment);
|
||||
}
|
||||
return seglist;
|
||||
}
|
||||
|
||||
} // namespace StringUtil
|
Loading…
Add table
Add a link
Reference in a new issue