34 #include "../include/inputParser.h"
50 std::ifstream infile(filename.c_str());
51 if ((!infile) || (!infile.good()))
59 while (!infile.getline(tmp, lineSize).eof())
62 std::string line(tmp);
77 std::map<std::string, _parameter<int> >::iterator intIt;
78 std::map<std::string, _parameter<unsigned int> >::iterator uIntIt;
79 std::map<std::string, _parameter<float> >::iterator floatIt;
80 std::map<std::string, _parameter<double> >::iterator doubleIt;
81 std::map<std::string, _parameter<bool> >::iterator boolIt;
82 std::map<std::string, _parameter<std::string> >::iterator stringIt;
85 size_t pos = str.find_first_of(
"#");
88 if (pos != str.npos) str.erase(pos, str.find_first_of(
'\n'));
91 size_t eqPos = str.find(
"=");
92 std::string whitespaces (
" \t\f\v\n\r");
97 if (eqPos != str.npos)
99 name = str.substr(0, eqPos);
100 name.erase(name.find_last_not_of(whitespaces)+1);
101 val = str.substr(eqPos+1);
102 val.erase(0, val.find_first_not_of(whitespaces));
103 val.erase(val.find_last_not_of(whitespaces)+1);
106 if (name.length() > 0 && val.length() > 0)
111 intIt->second._found =
true;
112 *(intIt->second._val) = atoi(val.c_str());
118 uIntIt->second._found =
true;
119 *(uIntIt->second._val) = atoi(val.c_str());
125 floatIt->second._found =
true;
126 *(floatIt->second._val) = atof(val.c_str());
132 doubleIt->second._found =
true;
133 *(doubleIt->second._val) = atof(val.c_str());
139 boolIt->second._found =
true;
140 *(boolIt->second._val) = atoi(val.c_str());
146 stringIt->second._found =
true;
147 *(stringIt->second._val) = val;
193 std::map<std::string, _parameter<int> >::iterator intIt;
194 std::map<std::string, _parameter<unsigned int> >::iterator uIntIt;
195 std::map<std::string, _parameter<float> >::iterator floatIt;
196 std::map<std::string, _parameter<double> >::iterator doubleIt;
197 std::map<std::string, _parameter<bool> >::iterator boolIt;
198 std::map<std::string, _parameter<std::string> >::iterator stringIt;
199 out <<
"#########################################" << std::endl;
200 out <<
"PARAMETER:\t\tVALUE:" << std::endl;
201 out <<
"#########################################" << std::endl;
202 out <<
"-----------------------------------------" << std::endl;
205 intIt->second.printParameterInfo();
206 out <<
"-----------------------------------------" << std::endl;
210 uIntIt->second.printParameterInfo();
211 out <<
"-----------------------------------------" << std::endl;
215 floatIt->second.printParameterInfo();
216 out <<
"-----------------------------------------" << std::endl;
220 doubleIt->second.printParameterInfo();
221 out <<
"-----------------------------------------" << std::endl;
225 boolIt->second.printParameterInfo();
226 out <<
"-----------------------------------------" << std::endl;
230 stringIt->second.printParameterInfo();
231 out <<
"-----------------------------------------" << std::endl;
233 out <<
"#########################################" << std::endl;
239 int nCriticalMissing = 0;
241 std::map<std::string, _parameter<int> >::iterator intIt;
242 std::map<std::string, _parameter<float> >::iterator floatIt;
243 std::map<std::string, _parameter<double> >::iterator doubleIt;
244 std::map<std::string, _parameter<bool> >::iterator boolIt;
248 if (!intIt->second._found)
250 if (intIt->second._required)
252 errOut <<
"Could not find parameter: " << intIt->second._name <<
" which is required. Please specify this parameter in the config file!" << std::endl;
259 if (!floatIt->second._found)
261 if (floatIt->second._required)
263 errOut <<
"Could not find parameter: " << floatIt->second._name <<
" which is required. Please specify this parameter in the config file!" << std::endl;
270 if (!doubleIt->second._found)
272 if (doubleIt->second._required)
274 errOut <<
"Could not find parameter: " << doubleIt->second._name <<
" which is required. Please specify this parameter in the config file!" << std::endl;
281 if (!boolIt->second._found)
283 if (boolIt->second._required)
285 errOut <<
"Could not find parameter: " << boolIt->second._name <<
" which is required. Please specify this parameter in the config file!" << std::endl;
290 if(nCriticalMissing > 0)
return false;