\hypertarget{config_management_8cpp_source}{}\doxysection{config\+Management.\+cpp} \label{config_management_8cpp_source}\index{src/configManagement.cpp@{src/configManagement.cpp}} \mbox{\hyperlink{config_management_8cpp}{Go to the documentation of this file.}} \begin{DoxyCode}{0} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00001}00001 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00012}00012 \textcolor{preprocessor}{\#include }} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00013}00013 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{game_8h}{game.h}}"{}}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00014}00014 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{config_management_8h}{configManagement.h}}"{}}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00015}00015 \textcolor{preprocessor}{\#include "{}\mbox{\hyperlink{errors_8h}{errors.h}}"{}}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00016}00016 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00017}00017 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00018}\mbox{\hyperlink{config_management_8cpp_a1c7782a08b7ba0d847c257bf3d42bca7}{00018}} \textcolor{keywordtype}{void} \mbox{\hyperlink{config_management_8cpp_a1c7782a08b7ba0d847c257bf3d42bca7}{trimSpaces}}(\textcolor{keywordtype}{string}\& str)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00019}00019 str.erase(0, str.find\_first\_not\_of(\textcolor{charliteral}{' '}));} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00020}00020 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00021}00021 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00022}\mbox{\hyperlink{config_management_8cpp_a3f46c4d5619bf4116121148193c0e34c}{00022}} \textcolor{keywordtype}{void} \mbox{\hyperlink{config_management_8cpp_a3f46c4d5619bf4116121148193c0e34c}{sanitizeValue}}(\textcolor{keywordtype}{string}\& val) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00023}00023 \mbox{\hyperlink{config_management_8cpp_a1c7782a08b7ba0d847c257bf3d42bca7}{trimSpaces}}(val);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00024}00024 \textcolor{keywordflow}{for} (\textcolor{keywordtype}{char} c: \{\textcolor{charliteral}{'\(\backslash\)''}, \textcolor{charliteral}{'"{}'}\}) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00025}00025 \textcolor{keywordflow}{if} (val[0] == c \&\& val[val.size() -\/ 1] == c) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00026}00026 val.erase(val.begin());} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00027}00027 val.pop\_back();} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00028}00028 \textcolor{keywordflow}{break};} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00029}00029 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00030}00030 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00031}00031 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00032}00032 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00033}\mbox{\hyperlink{class_config_builder_aab791290aa2d314788fcd9f2c44bf79e}{00033}} \textcolor{keywordtype}{void} \mbox{\hyperlink{class_config_builder_aab791290aa2d314788fcd9f2c44bf79e}{ConfigBuilder::dumpInternalValues}}()\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00034}00034 \textcolor{keywordflow}{for}(\textcolor{keyword}{const} \textcolor{keyword}{auto}\& ite : internalValues)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00035}00035 cerr << ite.first << \textcolor{stringliteral}{"{} -\/> "{}} << ite.second << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00036}00036 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00037}00037 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00038}00038 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00039}00039 \textcolor{comment}{/* WARNING : This implementation of YAML is not meant to be complete, but to work with our specific needs}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00040}00040 \textcolor{comment}{ * It also can't detect and report errors in a non-\/YAML-\/compliant file*/}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00041}00041 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00042}\mbox{\hyperlink{class_config_builder_a408e15906e88336cbc53f19afec65cd6}{00042}} \textcolor{keywordtype}{void} \mbox{\hyperlink{class_config_builder_a408e15906e88336cbc53f19afec65cd6}{ConfigBuilder::parseFile}}(\textcolor{keyword}{const} \textcolor{keywordtype}{string}\& fname) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00043}00043 ifstream file(fname);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00044}00044 \textcolor{keywordflow}{if}(!file.is\_open())\textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Error while opening config.yml. Check file location ?"{}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00045}00045 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00046}00046 vector keyParts;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00047}00047 \textcolor{keywordtype}{unsigned} listIndex;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00048}00048 \textcolor{keywordtype}{unsigned} lineno = 0; \textcolor{comment}{// for error handling purposes}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00049}00049 \textcolor{keywordflow}{while} (!file.eof()) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00050}00050 \textcolor{keywordtype}{string} line;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00051}00051 getline(file, line);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00052}00052 ++lineno;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00053}00053 \textcolor{keyword}{auto} match = line.find(\textcolor{charliteral}{'\#'});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00054}00054 \textcolor{keywordflow}{if} (match != string::npos)line.erase(match);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00055}00055 \textcolor{keywordflow}{if} (line.find\_first\_not\_of(\textcolor{charliteral}{' '})==string::npos)\textcolor{keywordflow}{continue};} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00056}00056 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00057}00057 \textcolor{keywordtype}{unsigned} currentIndent = 0;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00058}00058 \textcolor{keywordflow}{while} (line[currentIndent] == \textcolor{charliteral}{' '})++currentIndent;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00059}00059 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00060}00060 \textcolor{keywordflow}{if}(line[currentIndent]==\textcolor{charliteral}{'-\/'})\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00061}00061 \textcolor{keywordtype}{string} value = line.substr(currentIndent+1);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00062}00062 \mbox{\hyperlink{config_management_8cpp_a3f46c4d5619bf4116121148193c0e34c}{sanitizeValue}}(value);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00063}00063 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00064}00064 \textcolor{keywordtype}{string} fullKey;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00065}00065 \textcolor{keywordflow}{for} (\textcolor{keywordtype}{unsigned} i = 0; i < currentIndent; ++i) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00066}00066 fullKey.append(keyParts[i]);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00067}00067 fullKey.append(\textcolor{stringliteral}{"{}."{}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00068}00068 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00069}00069 \textcolor{comment}{// lists are just treated as sections with key 0,1,2...}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00070}00070 fullKey.append(to\_string((listIndex)));} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00071}00071 ++listIndex;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00072}00072 internalValues[fullKey] = value;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00073}00073 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00074}00074 \}\textcolor{keywordflow}{else}\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00075}00075 match = line.find(\textcolor{charliteral}{':'});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00076}00076 \textcolor{keywordflow}{if} (match == string::npos)\textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Line "{}}+ to\_string(lineno)+\textcolor{stringliteral}{"{} invalid : |"{}}+line+\textcolor{stringliteral}{"{}|"{}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00077}00077 \textcolor{keywordtype}{string} key = line.substr(0, match);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00078}00078 \textcolor{keywordtype}{string} value = line.substr(match + 1);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00079}00079 \mbox{\hyperlink{config_management_8cpp_a1c7782a08b7ba0d847c257bf3d42bca7}{trimSpaces}}(key);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00080}00080 \mbox{\hyperlink{config_management_8cpp_a3f46c4d5619bf4116121148193c0e34c}{sanitizeValue}}(value);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00081}00081 \textcolor{keywordflow}{if} (value.empty()) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00082}00082 keyParts.resize(currentIndent);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00083}00083 keyParts.push\_back(key);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00084}00084 listIndex = 0;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00085}00085 \} \textcolor{keywordflow}{else} \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00086}00086 \textcolor{keywordtype}{string} fullKey;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00087}00087 \textcolor{keywordflow}{for} (\textcolor{keywordtype}{unsigned} i = 0; i < currentIndent; ++i) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00088}00088 fullKey.append(keyParts[i]);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00089}00089 fullKey.append(\textcolor{stringliteral}{"{}."{}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00090}00090 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00091}00091 fullKey.append(key);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00092}00092 internalValues[fullKey] = value;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00093}00093 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00094}00094 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00095}00095 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00096}00096 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00097}00097 file.close();} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00098}00098 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00099}00099 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00100}00100 \textcolor{keywordtype}{void} ConfigBuilder::readGrid(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& baseKey) \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00101}00101 vector tmp;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00102}00102 getList(\textcolor{stringliteral}{"{}grid"{}}, tmp);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00103}00103 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00104}00104 \textcolor{comment}{// we are essentially going to translate a line-\/oriented config to a column-\/oriented grid}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00105}00105 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00106}00106 \textcolor{keywordtype}{unsigned} maxSize = 0;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00107}00107 \textcolor{keywordflow}{for}(\textcolor{keywordtype}{string}\& s : tmp)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00108}00108 \textcolor{keywordflow}{if}(s.size()>maxSize)maxSize = s.size();} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00109}00109 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00110}00110 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}.resize(maxSize);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00111}00111 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00112}00112 \textcolor{keywordflow}{for}(\textcolor{keywordtype}{string}\& s : tmp)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00113}00113 \textcolor{keywordtype}{unsigned} i=0;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00114}00114 \textcolor{keywordflow}{for}(;i max)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00234}00234 \textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Value for key "{}} + key + \textcolor{stringliteral}{"{} do not follow preconditions : "{}} +} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00235}00235 to\_string(min) + \textcolor{stringliteral}{"{}<="{}} + to\_string(val) + \textcolor{stringliteral}{"{}<="{}} + to\_string(max));} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00236}00236 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00237}00237 \textcolor{keywordflow}{return} val;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00238}00238 \}\textcolor{keywordflow}{catch}(\mbox{\hyperlink{classconfig__error}{config\_error}}\& e)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00239}00239 cerr << e.what() << \textcolor{stringliteral}{"{} . Using default value"{}} << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00240}00240 \textcolor{keywordflow}{return} def;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00241}00241 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00242}00242 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00243}00243 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00244}00244 \textcolor{keywordtype}{int} ConfigBuilder::getInt(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key)\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00245}00245 \textcolor{keywordflow}{try}\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00246}00246 \textcolor{keywordflow}{return} stoi(getString(key));} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00247}00247 \}\textcolor{keywordflow}{catch}(invalid\_argument\& e)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00248}00248 \textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Invalid int data for key "{}}+key+\textcolor{stringliteral}{"{} : |"{}}+getString(key)+\textcolor{stringliteral}{"{}|"{}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00249}00249 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00250}00250 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00251}00251 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00252}00252 \textcolor{keywordtype}{char} ConfigBuilder::getChar(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key, \textcolor{keywordtype}{char} def)\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00253}00253 \textcolor{keywordflow}{try}\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00254}00254 \textcolor{keywordflow}{return} getChar(key);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00255}00255 \}\textcolor{keywordflow}{catch}(\mbox{\hyperlink{classconfig__error}{config\_error}}\& e)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00256}00256 cerr << e.what() << \textcolor{stringliteral}{"{} . Using default value"{}} << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00257}00257 \textcolor{keywordflow}{return} def;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00258}00258 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00259}00259 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00260}00260 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00261}00261 \textcolor{keywordtype}{char} ConfigBuilder::getChar(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key)\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00262}00262 \textcolor{keywordtype}{string} s = getString(key);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00263}00263 \textcolor{keywordflow}{if}(s.size()!=1)\textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Invalid char data for key "{}}+key+\textcolor{stringliteral}{"{} : |"{}}+s+\textcolor{stringliteral}{"{}|"{}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00264}00264 \textcolor{keywordflow}{return} s[0];} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00265}00265 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00266}00266 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00267}00267 \textcolor{keywordtype}{void} ConfigBuilder::getColor(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key, nsGraphics::RGBAcolor\& color, \textcolor{keyword}{const} nsGraphics::RGBAcolor\& def)\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00268}00268 \textcolor{keywordflow}{try}\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00269}00269 getColor(key, color);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00270}00270 \}\textcolor{keywordflow}{catch}(\mbox{\hyperlink{classconfig__error}{config\_error}}\& e)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00271}00271 cerr << e.what() << \textcolor{stringliteral}{"{} . Using default value"{}} << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00272}00272 color = def;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00273}00273 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00274}00274 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00275}00275 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00276}00276 \textcolor{keywordtype}{void} ConfigBuilder::getColor(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key, nsGraphics::RGBAcolor\& color)\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00277}00277 \textcolor{comment}{// switch do not work with strings, and I don't want to implement a constexpr hash function}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00278}00278 \textcolor{keywordtype}{string} colorStr = getString(key);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00279}00279 \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}black"{}})color = nsGraphics::KBlack;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00280}00280 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}white"{}})color = nsGraphics::KWhite;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00281}00281 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}red"{}})color = nsGraphics::KRed;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00282}00282 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}lime"{}})color = nsGraphics::KLime;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00283}00283 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}blue"{}})color = nsGraphics::KBlue;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00284}00284 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}yellow"{}})color = nsGraphics::KYellow;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00285}00285 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}cyan"{}})color = nsGraphics::KCyan;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00286}00286 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}magenta"{}})color = nsGraphics::KMagenta;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00287}00287 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}silver"{}})color = nsGraphics::KSilver;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00288}00288 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}gray"{}})color = nsGraphics::KGray;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00289}00289 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}maroon"{}})color = nsGraphics::KMaroon;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00290}00290 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}olive"{}})color = nsGraphics::KOlive;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00291}00291 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}green"{}})color = nsGraphics::KGreen;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00292}00292 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}purple"{}})color = nsGraphics::KPurple;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00293}00293 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}teal"{}})color = nsGraphics::KTeal;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00294}00294 \textcolor{keywordflow}{else} \textcolor{keywordflow}{if} (colorStr == \textcolor{stringliteral}{"{}navy"{}})color = nsGraphics::KNavy;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00295}00295 \textcolor{keywordflow}{else} \textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Invalid color string : "{}}+colorStr);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00296}00296 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00297}00297 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00298}00298 \textcolor{keywordtype}{void} ConfigBuilder::getList(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& baseKey, vector\& toPopulate)\textcolor{keyword}{ const }\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00299}00299 \textcolor{keywordtype}{unsigned} i=0;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00300}00300 \textcolor{keywordtype}{string} fullKey = baseKey + \textcolor{stringliteral}{"{}.0"{}};} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00301}00301 \textcolor{keywordflow}{if}(!internalValues.contains(fullKey))\textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Non-\/existent list baseKey requested : "{}} + baseKey);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00302}00302 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00303}00303 \textcolor{keywordflow}{do}\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00304}00304 toPopulate.push\_back(internalValues.at(fullKey));} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00305}00305 ++i;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00306}00306 fullKey = baseKey + \textcolor{stringliteral}{"{}."{}} + to\_string(i);} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00307}00307 \}\textcolor{keywordflow}{while}(internalValues.contains(baseKey + \textcolor{stringliteral}{"{}."{}} + to\_string(i)));} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00308}00308 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00309}00309 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00310}00310 } \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00311}\mbox{\hyperlink{class_game_ac6c18f49964d49c3c5c826ef678f0792}{00311}} \textcolor{keywordtype}{bool} \mbox{\hyperlink{class_game_ac6c18f49964d49c3c5c826ef678f0792}{Game::reloadConfig}}() \{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00312}00312 map strValues;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00313}00313 \mbox{\hyperlink{class_config_builder}{ConfigBuilder}} builder;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00314}00314 \textcolor{keywordtype}{bool} parsed = \textcolor{keyword}{false};} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00315}00315 \textcolor{keywordflow}{try}\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00316}00316 builder.\mbox{\hyperlink{class_config_builder_a408e15906e88336cbc53f19afec65cd6}{parseFile}}(\textcolor{stringliteral}{"{}config.yml"{}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00317}00317 parsed = \textcolor{keyword}{true};} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00318}00318 builder.\mbox{\hyperlink{class_config_builder_acd69e5a0777a3c9339aa96e8ce2e07a9}{readConfig}}();} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00319}00319 \}\textcolor{keywordflow}{catch}(\mbox{\hyperlink{classconfig__error}{config\_error}}\& e)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00320}00320 \textcolor{keywordflow}{if}(parsed)cerr << \textcolor{stringliteral}{"{}An error occured while reading the configuration :"{}} << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00321}00321 \textcolor{keywordflow}{else} cerr << \textcolor{stringliteral}{"{}An error occured while parsing the configuration :"{}} << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00322}00322 cerr << e.what() << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00323}00323 \textcolor{keywordflow}{if}(parsed)\{} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00324}00324 cerr << \textcolor{stringliteral}{"{}Parsed keys :"{}} << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00325}00325 builder.\mbox{\hyperlink{class_config_builder_aab791290aa2d314788fcd9f2c44bf79e}{dumpInternalValues}}();} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00326}00326 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00327}00327 cerr << \textcolor{stringliteral}{"{}(The old configuration was kept in memory)"{}} << endl;} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00328}00328 \textcolor{keywordflow}{return} \textcolor{keyword}{false};} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00329}00329 \}} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00330}00330 confData = move(builder.\mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}});} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00331}00331 \textcolor{keywordflow}{return} \textcolor{keyword}{true};} \DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00332}00332 \}} \end{DoxyCode}