forked from catboost/catboost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsplit.cpp
More file actions
24 lines (21 loc) · 711 Bytes
/
Copy pathsplit.cpp
File metadata and controls
24 lines (21 loc) · 711 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "split.h"
template <class TValue>
inline size_t Split(const char* ptr, const char* delim, TVector<TValue>& values) {
values.erase(values.begin(), values.end());
while (ptr && *ptr) {
ptr += strspn(ptr, delim);
if (ptr && *ptr) {
size_t epos = strcspn(ptr, delim);
assert(epos);
values.push_back(TValue(ptr, epos));
ptr += epos;
}
}
return values.size();
}
size_t Split(const char* ptr, const char* delim, TVector<TString>& values) {
return Split<TString>(ptr, delim, values);
}
size_t Split(const TString& in, const TString& delim, TVector<TString>& res) {
return Split(in.data(), delim.data(), res);
}