MCPcopy Create free account
hub / github.com/baidu/tera / SplitString

Function SplitString

src/leveldb/util/string_ext.cc:13–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11namespace leveldb {
12
13void SplitString(const std::string& full, const std::string& delim,
14 std::vector<std::string>* result) {
15 result->clear();
16 if (full.empty()) {
17 return;
18 }
19
20 std::string tmp;
21 std::string::size_type pos_begin = full.find_first_not_of(delim);
22 std::string::size_type comma_pos = 0;
23
24 while (pos_begin != std::string::npos) {
25 comma_pos = full.find(delim, pos_begin);
26 if (comma_pos != std::string::npos) {
27 tmp = full.substr(pos_begin, comma_pos - pos_begin);
28 pos_begin = comma_pos + delim.length();
29 } else {
30 tmp = full.substr(pos_begin);
31 pos_begin = comma_pos;
32 }
33
34 if (!tmp.empty()) {
35 result->push_back(tmp);
36 tmp.clear();
37 }
38 }
39}
40
41void SplitStringEnd(const std::string& full, std::string* begin_part, std::string* end_part,
42 std::string delim) {

Callers 4

CreateDirMethod · 0.70
CreateDirMethod · 0.70
MyCacheEnvMethod · 0.70
CreateDirectoryMethod · 0.70

Calls 3

push_backMethod · 0.80
clearMethod · 0.45
emptyMethod · 0.45

Tested by 1

MyCacheEnvMethod · 0.56