-
Notifications
You must be signed in to change notification settings - Fork 138
/
util.h
37 lines (30 loc) · 804 Bytes
/
util.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#ifndef UTIL_H_INCLUDED
#define UTIL_H_INCLUDED
#include <vector>
#include <sstream>
#include "debugTimer.h"
namespace Util
{
std::vector<std::string> Split(const std::string &s, char delim)
{
std::vector<std::string> elems;
const char* cstr = s.c_str();
unsigned int strLength = s.length();
unsigned int start = 0;
unsigned int end = 0;
while(end <= strLength)
{
while(end <= strLength)
{
if(cstr[end] == delim)
break;
end++;
}
elems.push_back(s.substr(start, end - start));
start = end + 1;
end = start;
}
return elems;
}
};
#endif // UTIL_H_INCLUDED