Skip to content
Snippets Groups Projects
Commit 354e6b8c authored by Stuart Clare's avatar Stuart Clare
Browse files

Added vector<int> and vector<float> types to string_to_T

parent 54e30d7a
No related branches found
No related tags found
No related merge requests found
......@@ -47,6 +47,28 @@ namespace Utilities {
return false;
}
bool string_to_T(vector<int>& vi, const string& s) {
string str=s+',';
vi.assign(0,0);
while(str.size()) {
float v = atof(str.substr(0,str.find(",")).c_str());
vi.push_back(v);
str = str.substr(str.find(",")+1,str.length()-str.find(",")-1);
}
return true;
}
bool string_to_T(vector<float>& vi, const string& s) {
string str=s+',';
vi.assign(0,0);
while(str.size()) {
float v = atof(str.substr(0,str.find(",")).c_str());
vi.push_back(v);
str = str.substr(str.find(",")+1,str.length()-str.find(",")-1);
}
return true;
}
ostream& operator<<(ostream &os, const BaseOption& o) {
return os <<
"\t" << o.key() <<
......
......@@ -14,7 +14,9 @@ namespace Utilities {
bool string_to_T(string& d, const string& s);
bool string_to_T(int& i, const string& s);
bool string_to_T(float& v, const string& s);
bool string_to_T(vector<int>& vi, const string& s);
bool string_to_T(vector<float>& vi, const string& s);
typedef enum argflag {
no_argument = 0, requires_argument, optional_argument
} ArgFlag;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment