3 #include <boost/stacktrace.hpp>
15 map<string, string>::const_iterator iter = charflag.find(name);
16 if (iter != charflag.end())
20 cout <<
"PHFlag::getString: ERROR Unknown character Flag " << name << endl;
22 cout <<
"The following flags are implemented: " << endl;
30 map<string, string>::const_iterator iter = charflag.find(name);
31 if (iter != charflag.end())
37 set_CharFlag(name, defaultval);
38 return get_CharFlag(name);
44 charflag[
name] = charstr;
50 map<string, double>::const_iterator iter = doubleflag.find(name);
51 if (iter != doubleflag.end())
55 cout <<
"PHFlag::getFlag: ERROR Unknown Double Flag " << name << endl;
57 cout <<
"The following flags are implemented: " << endl;
64 map<string, double>::const_iterator iter = doubleflag.find(name);
65 if (iter != doubleflag.end())
71 set_DoubleFlag(name, defaultval);
72 return get_DoubleFlag(name);
78 doubleflag[
name] = iflag;
84 map<string, float>::const_iterator iter = floatflag.find(name);
85 if (iter != floatflag.end())
89 cout <<
"PHFlag::getFlag: ERROR Unknown Float Flag " << name << endl;
91 cout <<
"The following flags are implemented: " << endl;
98 map<string, float>::const_iterator iter = floatflag.find(name);
99 if (iter != floatflag.end())
105 set_FloatFlag(name, defaultval);
106 return get_FloatFlag(name);
112 floatflag[
name] = iflag;
118 map<string, int>::const_iterator iter = intflag.find(name);
119 if (iter != intflag.end())
123 cout <<
"PHFlag::getFlag: ERROR Unknown Int Flag " << name << endl;
125 cout <<
"The following flags are implemented: " << endl;
132 map<string, int>::const_iterator iter = intflag.find(name);
133 if (iter != intflag.end())
139 set_IntFlag(name, defaultval);
140 return get_IntFlag(name);
146 intflag[
name] = iflag;
163 <<
"Integer Flags:" << endl;
164 map<string, int>::const_iterator intiter;
165 for (intiter = intflag.begin(); intiter != intflag.end(); ++intiter)
167 cout << intiter->first <<
" is " << intiter->second << endl;
176 <<
"Double Flags:" << endl;
177 map<string, double>::const_iterator doubleiter;
178 for (doubleiter = doubleflag.begin(); doubleiter != doubleflag.end(); ++doubleiter)
180 cout << doubleiter->first <<
" is " << doubleiter->second << endl;
189 <<
"Float Flags:" << endl;
190 map<string, float>::const_iterator floatiter;
191 for (floatiter = floatflag.begin(); floatiter != floatflag.end(); ++floatiter)
193 cout << floatiter->first <<
" is " << floatiter->second << endl;
202 <<
"char* Flags:" << endl;
203 map<string, string>::const_iterator chariter;
204 for (chariter = charflag.begin(); chariter != charflag.end(); ++chariter)
206 cout << chariter->first <<
" is " << chariter->second << endl;
213 map<string, int>::const_iterator iter = intflag.find(name);
214 if (iter != intflag.end())
218 map<string, float>::const_iterator fiter = floatflag.find(name);
219 if (fiter != floatflag.end())
223 map<string, double>::const_iterator diter = doubleflag.find(name);
224 if (diter != doubleflag.end())
228 map<string, string>::const_iterator citer = charflag.find(name);
229 if (citer != charflag.end())
250 ifstream infile(name.c_str());
251 while (infile >> label)
253 cout <<
"Label" << label;
254 if (label.substr(0, 1) ==
"C")
258 set_CharFlag(label.substr(1, label.size() - 1), cvalue);
259 cout <<
" C read " << cvalue << endl;
261 else if (label.substr(0, 1) ==
"F")
265 set_FloatFlag(label.substr(1, label.size() - 1), fvalue);
266 cout <<
" F read " << fvalue << endl;
268 else if (label.substr(0, 1) ==
"D")
272 set_DoubleFlag(label.substr(1, label.size() - 1), dvalue);
273 cout <<
" D read " << dvalue << endl;
275 else if (label.substr(0, 1) ==
"I")
279 set_IntFlag(label.substr(1, label.size() - 1), ivalue);
280 cout <<
" I read " << ivalue << endl;
286 cout <<
" Junk read " << junk << endl;
290 cout <<
"Read CharFlags(" << cvaluecount
291 <<
") FloatFlags(" << fvaluecount
292 <<
") DoubleFlags(" << dvaluecount
293 <<
") IntFlags(" << ivaluecount
294 <<
") JunkEntries(" << junkcount
295 <<
") from file " << name << endl;
302 ofstream outFile(name.c_str());
304 map<string, int>::const_iterator intiter;
305 for (intiter = intflag.begin(); intiter != intflag.end(); ++intiter)
307 outFile <<
"I" << intiter->first <<
"\t" << intiter->second << endl;
310 map<string, float>::const_iterator floatiter;
311 for (floatiter = floatflag.begin(); floatiter != floatflag.end(); ++floatiter)
313 outFile <<
"F" << floatiter->first <<
"\t" << floatiter->second << endl;
316 int oldprecision = outFile.precision(15);
317 map<string, double>::const_iterator doubleiter;
318 for (doubleiter = doubleflag.begin(); doubleiter != doubleflag.end(); ++doubleiter)
320 outFile <<
"D" << doubleiter->first <<
"\t" << doubleiter->second << endl;
322 outFile.precision(oldprecision);
324 map<string, string>::const_iterator chariter;
325 for (chariter = charflag.begin(); chariter != charflag.end(); ++chariter)
327 outFile <<
"C" << chariter->first <<
"\t" << chariter->second << endl;
335 cout <<
"Called by #3 or #4 in this list: " << endl;
336 cout << boost::stacktrace::stacktrace();
338 cout <<
"DO NOT PANIC - this is not a segfault" << endl;