15 map<string, string>::const_iterator iter = charflag.find(flag);
16 if (iter != charflag.end())
20 cout <<
"PHFlag::getString: ERROR Unknown character Flag " << flag
21 <<
", The following are implemented: " << endl;
30 map<string, string>::const_iterator iter = charflag.find(flag);
31 if (iter != charflag.end())
37 set_CharFlag(flag, defaultval);
38 return get_CharFlag(flag);
45 charflag[flag] = charstr;
51 map<string, double>::const_iterator iter = doubleflag.find(name);
52 if (iter != doubleflag.end())
56 cout <<
"PHFlag::getFlag: ERROR Unknown Double Flag " << name
57 <<
", The following are implemented: " << endl;
65 map<string, double>::const_iterator iter = doubleflag.find(name);
66 if (iter != doubleflag.end())
72 set_DoubleFlag(name,defaultval);
73 return get_DoubleFlag(name);
79 doubleflag[name] = iflag;
85 map<string, float>::const_iterator iter = floatflag.find(name);
86 if (iter != floatflag.end())
90 cout <<
"PHFlag::getFlag: ERROR Unknown Float Flag " << name
91 <<
", The following are implemented: " << endl;
99 map<string, float>::const_iterator iter = floatflag.find(name);
100 if (iter != floatflag.end())
106 set_FloatFlag(name,defaultval);
107 return get_FloatFlag(name);
113 floatflag[name] = iflag;
119 map<string, int>::const_iterator iter = intflag.find(name);
120 if (iter != intflag.end())
124 cout <<
"PHFlag::getFlag: ERROR Unknown Int Flag " << name
125 <<
", The following are implemented: " << endl;
133 map<string, int>::const_iterator iter = intflag.find(name);
134 if (iter != intflag.end())
140 set_IntFlag(name,defaultval);
141 return get_IntFlag(name);
147 intflag[name] = iflag;
153 map<string, bool>::const_iterator iter = boolflag.find(name);
154 if (iter != boolflag.end())
158 cout <<
"PHFlag::getFlag: ERROR Unknown Bool Flag " << name
159 <<
", The following are implemented: " << endl;
167 map<string, bool>::const_iterator iter = boolflag.find(name);
168 if (iter != boolflag.end())
174 set_BoolFlag(name,defaultval);
175 return get_BoolFlag(name);
181 boolflag[name] = bflag;
198 cout << endl <<
"Integer Flags:" << endl;
199 map<string, int>::const_iterator intiter;
200 for (intiter = intflag.begin(); intiter != intflag.end(); ++intiter)
202 cout << intiter->first <<
" is " << intiter->second << endl;
210 cout << endl <<
"Double Flags:" << endl;
211 map<string, double>::const_iterator doubleiter;
212 for (doubleiter = doubleflag.begin(); doubleiter != doubleflag.end(); ++doubleiter)
214 cout << doubleiter->first <<
" is " << doubleiter->second << endl;
222 cout << endl <<
"Float Flags:" << endl;
223 map<string, float>::const_iterator floatiter;
224 for (floatiter = floatflag.begin(); floatiter != floatflag.end(); ++floatiter)
226 cout << floatiter->first <<
" is " << floatiter->second << endl;
234 cout << endl <<
"char* Flags:" << endl;
235 map<string, string>::const_iterator chariter;
236 for (chariter = charflag.begin(); chariter != charflag.end(); ++chariter)
238 cout << chariter->first <<
" is " << chariter->second << endl;
246 cout << endl <<
"Boolean Flags:" << endl;
247 map<string, bool>::const_iterator booliter;
248 for (booliter = boolflag.begin(); booliter != boolflag.end(); ++booliter)
250 cout << booliter->first <<
" is " << (booliter->second ?
"TRUE" :
"FALSE") << endl;
257 map<string, int>::const_iterator iter = intflag.find(name);
258 if (iter != intflag.end())
262 map<string, float>::const_iterator fiter = floatflag.find(name);
263 if (fiter != floatflag.end())
267 map<string, double>::const_iterator diter = doubleflag.find(name);
268 if (diter != doubleflag.end())
272 map<string, string>::const_iterator citer = charflag.find(name);
273 if (citer != charflag.end())
277 map<string, bool>::const_iterator biter = boolflag.find(name);
278 if (biter != boolflag.end())
301 ifstream infile(name.c_str());
304 if(verbose) cout<<
"Label "<<label;
305 if(label.substr(0,1)==
"C")
309 set_CharFlag(label.substr(1,label.size()-1), cvalue);
310 if(verbose) cout<<
" C read "<< cvalue << endl;
311 }
else if(label.substr(0,1)==
"F")
315 set_FloatFlag(label.substr(1,label.size()-1), fvalue);
316 if(verbose) cout<<
" F read "<< fvalue << endl;
317 }
else if(label.substr(0,1)==
"D")
321 set_DoubleFlag(label.substr(1,label.size()-1), dvalue);
322 if(verbose) cout<<
" D read "<< dvalue << endl;
323 }
else if(label.substr(0,1)==
"I")
327 set_IntFlag(label.substr(1,label.size()-1), ivalue);
328 if(verbose) cout<<
" I read "<< ivalue << endl;
329 }
else if(label.substr(0,1)==
"B")
333 set_BoolFlag(label.substr(1,label.size()-1), bvalue);
334 if(verbose) cout<<
" B read "<< ivalue << endl;
338 if(verbose) cout<<
" Junk read "<< junk << endl;
343 cout<<
"Read CharFlags("<< cvaluecount
344 <<
") FloatFlags(" << fvaluecount
345 <<
") DoubleFlags(" << dvaluecount
346 <<
") IntFlags(" << ivaluecount
347 <<
") BoolFlags(" << bvaluecount
348 <<
") JunkEntries(" << junkcount
349 <<
") from file "<< name <<endl;
356 ofstream outFile(name.c_str());
358 map<string, int>::const_iterator intiter;
359 for (intiter = intflag.begin(); intiter != intflag.end(); ++intiter)
361 outFile <<
"I\t" << intiter->first <<
"\t" << intiter->second << endl;
364 map<string, float>::const_iterator floatiter;
365 for (floatiter = floatflag.begin(); floatiter != floatflag.end(); ++floatiter)
367 outFile <<
"F\t" << floatiter->first <<
"\t" << floatiter->second << endl;
370 int oldprecision = outFile.precision(15);
371 map<string, double>::const_iterator doubleiter;
372 for (doubleiter = doubleflag.begin(); doubleiter != doubleflag.end(); ++doubleiter)
374 outFile <<
"D\t" << doubleiter->first <<
"\t" << doubleiter->second << endl;
376 outFile.precision(oldprecision);
378 map<string, string>::const_iterator chariter;
379 for (chariter = charflag.begin(); chariter != charflag.end(); ++chariter)
381 outFile <<
"C\t" << chariter->first <<
"\t" << chariter->second << endl;
384 map<string, bool>::const_iterator booliter;
385 for (booliter = boolflag.begin(); booliter != boolflag.end(); ++booliter)
387 outFile <<
"B\t" << booliter->first <<
"\t" << booliter->second << endl;
virtual double get_DoubleFlag(const std::string &name) const
virtual void PrintIntFlags() const
virtual int FlagExist(const std::string &name) const
virtual void set_IntFlag(const std::string &name, const int flag)
virtual void set_BoolFlag(const std::string &name, const bool flag)
virtual void PrintBoolFlags() const
virtual void set_DoubleFlag(const std::string &name, const double flag)
virtual void set_CharFlag(const std::string &name, const std::string &flag)
virtual void set_FloatFlag(const std::string &name, const float flag)
virtual void WriteToFile(const std::string &name)
virtual void PrintCharFlags() const
virtual int get_IntFlag(const std::string &name) const
virtual const std::string get_CharFlag(const std::string &flag) const
virtual void ReadFromFile(const std::string &name, bool verbose=false)
virtual void PrintDoubleFlags() const
virtual void PrintFloatFlags() const
virtual bool get_BoolFlag(const std::string &name) const
virtual void Print() const
virtual float get_FloatFlag(const std::string &name) const