1
2
3
4
5
6 #ifndef SOULNG_UTIL_UTIL_INCLUDED
7 #define SOULNG_UTIL_UTIL_INCLUDED
8 #include <vector>
9 #include <stdint.h>
10 #include <string>
11
12 namespace soulng { namespace util {
13
14 template<typename StringT>
15 std::std::vector<StringT>Split(constStringT&s, typename StringT::value_typec)
16 {
17 std::vector<StringT> v;
18 int start = 0;
19 int n = int(s.length());
20 for (int i = 0; i < n; ++i)
21 {
22 if (s[i] == c)
23 {
24 v.push_back(s.substr(start, i - start));
25 start = i + 1;
26 }
27 }
28 if (start < n)
29 {
30 v.push_back(s.substr(start, n - start));
31 }
32 return v;
33 }
34
35 inline uint64_t Align(uint64_t n, uint64_t alignment)
36 {
37 return (n + alignment - 1u) & -alignment;
38 }
39
40 } }
41
42 #endif // SOULNG_UTIL_UTIL_INCLUDED