12 const int VariableMapCont::kDefaultInteger = 0;
13 const double VariableMapCont::kDefaultDouble = 0.;
14 const std::string VariableMapCont::kDefaultString =
"";
15 const bool VariableMapCont::kDefaultBool =
false;
21 VariableMapCont::VariableMapCont()
26 VariableMapCont::hasVariable (
string key)
28 lowercaseString (key);
30 if (m_integerMap.end() != m_integerMap.find (key))
return kInteger;
31 if (m_doubleMap.end() != m_doubleMap.find (key))
return kDouble;
32 if (m_stringMap.end() != m_stringMap.find (key))
return kString;
33 if (m_boolMap.end() != m_boolMap.find (key))
return kBool;
34 if (m_integerVecMap.end() != m_integerVecMap.find (key))
return kIntegerVector;
35 if (m_doubleVecMap.end() != m_doubleVecMap.find (key))
return kDoubleVector;
36 if (m_stringVecMap.end() != m_stringVecMap.find (key))
return kStringVector;
42 VariableMapCont::lowercaseString(
string&
arg)
45 std::for_each (arg.begin(), arg.end(), VariableMapCont::toLower);
52 VariableMapCont::toLower (
char& ch)
62 lowercaseString (key);
63 if ( m_variableModifiedMap.end() != m_variableModifiedMap.find (key) )
65 cerr <<
"VariableMapCont::addVariable() Error: Key '" << key
66 <<
"' has already been defined. Aborting." << endl;
69 m_variableModifiedMap[
key] =
false;
77 _checkKey (
key, description);
80 m_integerMap[
key] = kDefaultInteger;
85 m_doubleMap[
key] = kDefaultDouble;
90 m_stringMap[
key] = kDefaultString;
95 m_boolMap[
key] = kDefaultBool;
98 if (kIntegerVector ==
type)
100 m_integerVecMap[
key] = kEmptyIVec;
103 if (kDoubleVector ==
type)
105 m_doubleVecMap[
key] = kEmptyDVec;
108 if (kStringVector ==
type)
110 m_stringVecMap[
key] = kEmptySVec;
120 if (kInteger !=
type)
122 cerr <<
"VariableMapCont::addOption() Error: Key '" <<
key 123 <<
"' is not defined as an integer but has an integer " 124 <<
"default value. Aborting." << endl;
127 m_integerMap[
key] = defaultValue;
137 cerr <<
"VariableMapCont::addOption() Error: Key '" <<
key 138 <<
"' is not defined as an double but has an double " 139 <<
"default value. Aborting." << endl;
142 m_doubleMap[
key] = defaultValue;
148 const string &defaultValue)
153 cerr <<
"VariableMapCont::addOption() Error: Key '" <<
key 154 <<
"' is not defined as an string but has an string " 155 <<
"default value. Aborting." << endl;
158 m_stringMap[
key] = defaultValue;
164 const char* defaultValue)
176 cerr <<
"VariableMapCont::addOption() Error: Key '" <<
key 177 <<
"' is not defined as an bool but has an bool " 178 <<
"default value. Aborting." << endl;
181 m_boolMap[
key] = defaultValue;
188 lowercaseString (key);
189 SIMapIter iter = m_integerMap.find (key);
190 if (m_integerMap.end() == iter)
192 cerr <<
"VariableMapCont::integerValue() Error: key '" 193 << key <<
"' not found. Aborting." << endl;
202 lowercaseString (key);
204 if (m_doubleMap.end() == iter)
206 cerr <<
"VariableMapCont::doubleValue() Error: key '" 207 << key <<
"' not found. Aborting." << endl;
216 lowercaseString (key);
218 if (m_stringMap.end() == iter)
220 cerr <<
"VariableMapCont::stringValue() Error: key '" 221 << key <<
"' not found. Aborting." << endl;
230 lowercaseString (key);
232 if (m_boolMap.end() == iter)
234 cerr <<
"VariableMapCont::boolValue() Error: key '" 235 << key <<
"' not found. Aborting." << endl;
244 lowercaseString (key);
246 if (m_integerVecMap.end() == iter)
248 cerr <<
"VariableMapCont::integerVector() Error: key '" 249 << key <<
"' not found. Aborting." << endl;
258 lowercaseString (key);
260 if (m_doubleVecMap.end() == iter)
262 cerr <<
"VariableMapCont::doubleVector() Error: key '" 263 << key <<
"' not found. Aborting." << endl;
272 lowercaseString (key);
274 if (m_stringVecMap.end() == iter)
276 cerr <<
"VariableMapCont::stringVector() Error: key '" 277 << key <<
"' not found. Aborting." << endl;
284 VariableMapCont::_valueHasBeenModified (
const string &
key)
287 if (m_variableModifiedMap.end() == iter)
290 cerr <<
"VariableMapCont::valueHasBeenModfied () Error: '" 291 << key <<
"' is not a valid key." << endl;
SSMap::iterator SSMapIter
SBMap::iterator SBMapIter
std::vector< double > DVec
SIMap::iterator SIMapIter
std::vector< std::string > SVec
SBMap::const_iterator SBMapConstIter
SIVecMap::iterator SIVecMapIter
SSVecMap::iterator SSVecMapIter
SDVecMap::iterator SDVecMapIter
std::ostream & operator<<(std::ostream &out, const std::tuple< Types... > &value)
SDMap::iterator SDMapIter