SuperSpaceInvaderTurboApoca.../doc/SAE102-SpaceInvaders/latex/d0/d65/config_management_8cpp_source.tex
2022-01-11 15:45:50 +01:00

329 lines
52 KiB
TeX

\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 <fstream>}}
\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<string> 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<string> 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<s.size();++i)\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00115}00115 \textcolor{keywordflow}{switch}(toupper(s[i]))\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00116}00116 \textcolor{keywordflow}{case} \textcolor{charliteral}{'A'}:\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00117}00117 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}[i].push\_back(\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018af9cc5a6eeda802023cbbfb4809d4ae0c}{InvaderType::TYPEA}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00118}00118 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00119}00119 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00120}00120 \textcolor{keywordflow}{case} \textcolor{charliteral}{'B'}:\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00121}00121 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}[i].push\_back(\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018a3d00348b8aeb5f4f889899e4100bd753}{InvaderType::TYPEB}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00122}00122 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00123}00123 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00124}00124 \textcolor{keywordflow}{case} \textcolor{charliteral}{'C'}:\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00125}00125 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}[i].push\_back(\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018a9c813ba69982157b4552ff797f00c3b7}{InvaderType::TYPEC}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00126}00126 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00127}00127 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00128}00128 \textcolor{keywordflow}{case} \textcolor{charliteral}{' '}:\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00129}00129 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}[i].push\_back(\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018ab50339a10e1de285ac99d4c3990b8693}{InvaderType::NONE}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00130}00130 \textcolor{keywordflow}{break};}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00131}00131 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00132}00132 \textcolor{keywordflow}{default}:\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00133}00133 \textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Invalid invader ID in grid definition : "{}}+ to\_string(s[i]));}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00134}00134 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00135}00135 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00136}00136 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00137}00137 \textcolor{keywordflow}{while}(i<maxSize)\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00138}00138 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a260272afae4d9a0cfdf683ce7b1bb5f0}{grid}}[i].push\_back(\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018ab50339a10e1de285ac99d4c3990b8693}{InvaderType::NONE}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00139}00139 ++i;}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00140}00140 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00141}00141 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00142}00142 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00143}00143 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00144}00144 \textcolor{keywordtype}{void} ConfigBuilder::readPlayer(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& baseKey, \mbox{\hyperlink{struct_player_def}{PlayerDef}}\& pdef) \{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00145}00145 getColor(baseKey+\textcolor{stringliteral}{"{}.color"{}}, pdef.\mbox{\hyperlink{struct_player_def_a6ccc9984941577b5558c3ac4e5e836bd}{color}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00146}00146 pdef.\mbox{\hyperlink{struct_player_def_a14c78616f6c709ed9501af8037e34158}{keys}}.\mbox{\hyperlink{struct_player_keys_a172b7298ef86eeecf4204b44fe26b282}{left}} = getChar(baseKey+\textcolor{stringliteral}{"{}.keys.left"{}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00147}00147 pdef.\mbox{\hyperlink{struct_player_def_a14c78616f6c709ed9501af8037e34158}{keys}}.\mbox{\hyperlink{struct_player_keys_adf098dd1a956a18445061be4a487c0dd}{right}} = getChar(baseKey+\textcolor{stringliteral}{"{}.keys.right"{}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00148}00148 pdef.\mbox{\hyperlink{struct_player_def_a14c78616f6c709ed9501af8037e34158}{keys}}.\mbox{\hyperlink{struct_player_keys_a3456fa7f1f858df81eb54c3f73fbeb78}{shoot}} = getChar(baseKey+\textcolor{stringliteral}{"{}.keys.shoot"{}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00149}00149 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00150}00150 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00151}00151 \textcolor{keywordtype}{void} ConfigBuilder::readInvaderType(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& baseKey, \mbox{\hyperlink{struct_invader_type_def}{InvaderTypeDef}}\& invDef) \{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00152}00152 invDef.\mbox{\hyperlink{struct_invader_type_def_a94f4e5e99dad7c0578f6e491dc1a0752}{points}} = getInt(baseKey+\textcolor{stringliteral}{"{}.points"{}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00153}00153 getColor(baseKey+\textcolor{stringliteral}{"{}.color"{}}, invDef.\mbox{\hyperlink{struct_invader_type_def_ad690c29255570978ede9da7c1c31ba8d}{color}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00154}00154 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00155}00155 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00156}\mbox{\hyperlink{class_config_builder_acd69e5a0777a3c9339aa96e8ce2e07a9}{00156}} \textcolor{keywordtype}{void} \mbox{\hyperlink{class_config_builder_acd69e5a0777a3c9339aa96e8ce2e07a9}{ConfigBuilder::readConfig}}() \{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00157}00157 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00158}00158 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a3c9baa529db8e439f903590f5a9bcce2}{theme}} = getString(\textcolor{stringliteral}{"{}general.theme"{}}, \textcolor{stringliteral}{"{}bad"{}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00159}00159 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_adb4b297d72ba060cbe54785d5791d6ea}{maxFPS}} = getInt(\textcolor{stringliteral}{"{}general.maxFPS"{}}, 30, 1, 60);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00160}00160 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00161}00161 readGrid(\textcolor{stringliteral}{"{}grid"{}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00162}00162 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00163}00163 \textcolor{keywordflow}{if} (\mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a3c9baa529db8e439f903590f5a9bcce2}{theme}} != \textcolor{stringliteral}{"{}bad"{}})\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00164}00164 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_ad8c5d2876699ea9e451e6b3a15618707}{playersWidth}} = 90;}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00165}00165 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} = 30;}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00166}00166 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a4f8e7615d2619a3b37e97465ac143fee}{missilesWidth}} = 32;}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00167}00167 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_aec2b163d49271a1a1654c903de9e45ff}{torpedosWidth}} = 11;}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00168}00168 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00169}00169 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00170}00170 \textcolor{keywordflow}{else}\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00171}00171 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_ad8c5d2876699ea9e451e6b3a15618707}{playersWidth}} = getInt(\textcolor{stringliteral}{"{}players.width"{}}, 100, 50, 500);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00172}00172 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_ada929ea4a462c0bde376adf9fa3f4810}{invadersSize}} = getInt(\textcolor{stringliteral}{"{}invaders.size"{}},30,10,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00173}00173 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a4f8e7615d2619a3b37e97465ac143fee}{missilesWidth}} = getInt(\textcolor{stringliteral}{"{}projectiles.missiles.width"{}},10,5,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00174}00174 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_aec2b163d49271a1a1654c903de9e45ff}{torpedosWidth}} = getInt(\textcolor{stringliteral}{"{}projectiles.torpedos.width"{}},10,1,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00175}00175 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00176}00176 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00177}00177 \textcolor{comment}{// players}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00178}00178 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00179}00179 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a002e3aaf06ba352a9ff4e2f50895a65f}{startXPosition}} = getInt(\textcolor{stringliteral}{"{}players.startXPosition"{}},600 ,0 ,1200);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00180}00180 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a199264aa6e6c3b267462f0a5427cd5db}{playersSpeed}} = getInt(\textcolor{stringliteral}{"{}players.speed"{}},1,1,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00181}00181 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a641d7b2133165ce2eccaea972265f557}{playersFireCooldown}} = getInt(\textcolor{stringliteral}{"{}players.fireCooldown"{}},10,1,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00182}00182 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a09170415d0a4c525e546d6fd0ecb354c}{playersLives}} = getInt(\textcolor{stringliteral}{"{}players.lives"{}},3,1,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00183}00183 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00184}00184 \textcolor{comment}{// the scalability behind the vector of players is only an illusion, because we force player count to be 1 or 2}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00185}00185 \textcolor{comment}{// It was done so the 2+ players implementation could be easier in the future, if wanted}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00186}00186 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a909ad90d692e87b2c93c3966d07ecc16}{playerDefs}}.resize(2);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00187}00187 readPlayer(\textcolor{stringliteral}{"{}players.user1"{}}, \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a909ad90d692e87b2c93c3966d07ecc16}{playerDefs}}[0]);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00188}00188 readPlayer(\textcolor{stringliteral}{"{}players.user2"{}}, \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a909ad90d692e87b2c93c3966d07ecc16}{playerDefs}}[1]);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00189}00189 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00190}00190 \textcolor{comment}{// invaders}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00191}00191 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00192}00192 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_ad057123e1f1b7283b873eed8a07ead3f}{invadersSpeed}} = getInt(\textcolor{stringliteral}{"{}invaders.speed"{}},7,1,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00193}00193 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_aadc245edaf3b28d82f9ce7b17c655943}{invadersDistance}} = getInt(\textcolor{stringliteral}{"{}invaders.distance"{}},15,5,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00194}00194 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a0a8ca410dbc6b6cd62d16d1fa19a83f9}{invadersFireCooldown}} = getInt(\textcolor{stringliteral}{"{}invaders.fireCooldown"{}},0,0,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00195}00195 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00196}00196 readInvaderType(\textcolor{stringliteral}{"{}invaders.typeA"{}}, \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_af0c88560ab28fe51ef1743219633cfdc}{invadersDef}}[\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018af9cc5a6eeda802023cbbfb4809d4ae0c}{InvaderType::TYPEA}}]);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00197}00197 readInvaderType(\textcolor{stringliteral}{"{}invaders.typeB"{}}, \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_af0c88560ab28fe51ef1743219633cfdc}{invadersDef}}[\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018a3d00348b8aeb5f4f889899e4100bd753}{InvaderType::TYPEB}}]);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00198}00198 readInvaderType(\textcolor{stringliteral}{"{}invaders.typeC"{}}, \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_af0c88560ab28fe51ef1743219633cfdc}{invadersDef}}[\mbox{\hyperlink{invaders_grid_8h_a28be5c0c3bae3518d94b2ede3633e018a9c813ba69982157b4552ff797f00c3b7}{InvaderType::TYPEC}}]);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00199}00199 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00200}00200 \textcolor{comment}{// projectiles}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00201}00201 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_ae736dc72056f45f4a3f0fef365bc54be}{missilesLength}} = \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a4f8e7615d2619a3b37e97465ac143fee}{missilesWidth}}*\mbox{\hyperlink{utils_8h_a1f75c733009cd39459a13c7cdbb5410d}{PROJ\_LENGTH\_FACTOR}};}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00202}00202 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_ae5efc1b5a2b95b1a9c7ff60eee480e71}{missilesSpeed}} = getInt(\textcolor{stringliteral}{"{}projectiles.missiles.speed"{}},10,5,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00203}00203 getColor(\textcolor{stringliteral}{"{}projectiles.missiles.color"{}}, \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_abb41165730c7e25dffe63d2fb08022f4}{missilesColor}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00204}00204 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00205}00205 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a5de633401856c45fb3b8c3333d38804c}{torpedosLength}} = \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_aec2b163d49271a1a1654c903de9e45ff}{torpedosWidth}}*\mbox{\hyperlink{utils_8h_a1f75c733009cd39459a13c7cdbb5410d}{PROJ\_LENGTH\_FACTOR}};}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00206}00206 \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_aa491de435feeca58c85652f4961ddece}{torpedosSpeed}} = getInt(\textcolor{stringliteral}{"{}projectiles.torpedos.speed"{}},10,1,100);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00207}00207 getColor(\textcolor{stringliteral}{"{}projectiles.torpedos.color"{}}, \mbox{\hyperlink{class_config_builder_a4b4df7371d8b2544f302219631f0b77f}{collectedData}}.\mbox{\hyperlink{struct_config_data_a7edb4693b5fb5036b09b95d314d29495}{torpedosColor}});}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00208}00208 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00209}00209 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00210}00210 \textcolor{keyword}{const} \textcolor{keywordtype}{string}\& ConfigBuilder::getString(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key, \textcolor{keyword}{const} \textcolor{keywordtype}{string}\& def)\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00211}00211 \textcolor{keywordflow}{try}\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00212}00212 \textcolor{keywordflow}{return} getString(key);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00213}00213 \}\textcolor{keywordflow}{catch}(\mbox{\hyperlink{classconfig__error}{config\_error}}\& e)\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00214}00214 cerr << e.what() << \textcolor{stringliteral}{"{} . Using default value"{}} << endl;}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00215}00215 \textcolor{keywordflow}{return} def;}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00216}00216 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00217}00217 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00218}00218 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00219}00219 \textcolor{keyword}{const} \textcolor{keywordtype}{string}\& ConfigBuilder::getString(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key)\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00220}00220 \mbox{\hyperlink{utils_8h_aa1bc11933ce4506010028d354b3364b4}{DEBUG\_MSG}}(\textcolor{stringliteral}{"{}Querying config key "{}} << key)}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00221}00221 \textcolor{keywordflow}{if}(internalValues.contains(key))\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00222}00222 \textcolor{comment}{// We don't really care about querying the key two time since we are... well, in debug mode}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00223}00223 \mbox{\hyperlink{utils_8h_aa1bc11933ce4506010028d354b3364b4}{DEBUG\_MSG}}(\textcolor{stringliteral}{"{}Got config value "{}} << internalValues.at(key))}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00224}00224 \textcolor{keywordflow}{return} internalValues.at(key);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00225}00225 \}\textcolor{keywordflow}{else}\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00226}00226 \textcolor{keywordflow}{throw} \mbox{\hyperlink{classconfig__error}{config\_error}}(\textcolor{stringliteral}{"{}Non-\/existent key requested : "{}}+key);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00227}00227 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00228}00228 \}}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00229}00229 }
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00230}00230 \textcolor{keywordtype}{int} ConfigBuilder::getInt(\textcolor{keyword}{const} \mbox{\hyperlink{config_data_8h_a7ca3f09edce68ced014650c382bb767c}{configKey}}\& key, \textcolor{keywordtype}{int} def, \textcolor{keywordtype}{int} min, \textcolor{keywordtype}{int} max)\textcolor{keyword}{ const }\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00231}00231 \textcolor{keywordflow}{try}\{}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00232}00232 \textcolor{keywordtype}{int} val = getInt(key);}
\DoxyCodeLine{\Hypertarget{config_management_8cpp_source_l00233}00233 \textcolor{keywordflow}{if}(val < min || val > 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<string>\& 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<string, string> 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}