-
Notifications
You must be signed in to change notification settings - Fork 1
/
FuncLib.cpp
63 lines (52 loc) · 1.2 KB
/
FuncLib.cpp
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include "FuncLib.h"
// template<class T>
// string IntToStr( const T& t )
string IntToStr( int t )
{
// Convert from a T to a string
// Type T must support << operator
std::ostringstream ost;
ost << t;
return ost.str();
}
vector<int> StrToIntVect(string In, char sep)
{
vector<int> Output;
vector<string>TmpList = StrToStrVect(In, sep);
for(vector<string>::iterator T=TmpList.begin(); T != TmpList.end(); T++)
Output.push_back(atoi( (*T).c_str() ));
return Output;
}
vector<float> StrToFloatVect(string In, char sep)
{
vector<float> Output;
vector<string>TmpList = StrToStrVect(In, sep);
for(vector<string>::iterator T=TmpList.begin(); T != TmpList.end(); T++)
Output.push_back(atof( (*T).c_str() ));
return Output;
}
vector<string> StrToStrVect(string In, char sep)
{
vector<string> Output;
while (In.find(sep, 0) != string::npos)
{
Output.push_back(In.substr( 0, In.find(sep, 0)));
In = In.substr( In.find(sep, 0)+1);
}
Output.push_back(In);
return Output;
}
string ReadParam( string Regexp, string InStr)
{
boost::regex e(Regexp);
boost::smatch what;
if(boost::regex_search(InStr, what, e, boost::match_default))
{
string Tmp = what[1];
return Tmp;
}
else
{
return "";
}
}