blob: 2ec77c25cd74fafef6141d96dd957dd007f5e8ee (
plain)
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
|
#ifndef TYPE_HELPER_HPP__
#define TYPE_HELPER_HPP__
template<typename T1, typename T2>
T1 conv_t(T2 s){
T1 target;
std::stringstream conv;
conv << s;
conv >> target;
return target;
}
void string_split(std::string str, std::vector<std::string>& out, std::string split = ":") {
std::cout << str << std::endl;
auto pos = str.find(split);
while(pos != std::string::npos){
std::cout << str.substr(0, pos) << std::endl;
out.push_back(str.substr(0, pos));
if (str.size() > pos + split.size()){
str = str.substr(pos + split.size());
pos = str.find(split);
}else
return;
}
out.push_back(str.substr());
return;
}
#endif // TYPE_HELPER_HPP__
|