Use pointers inside ini loop to retain references to ini files

This commit is contained in:
Jussi Virtanen 2017-04-01 17:52:25 +03:00
parent 22fa199caf
commit 92ad1b9c4d
1 changed files with 4 additions and 4 deletions

View File

@ -17,10 +17,10 @@ std::vector<GeckoCode> LoadCodes(const IniFile& globalIni, const IniFile& localI
{ {
std::vector<GeckoCode> gcodes; std::vector<GeckoCode> gcodes;
for (const IniFile& ini : {globalIni, localIni}) for (const IniFile* ini : {&globalIni, &localIni})
{ {
std::vector<std::string> lines; std::vector<std::string> lines;
ini.GetLines("Gecko", &lines, false); ini->GetLines("Gecko", &lines, false);
GeckoCode gcode; GeckoCode gcode;
@ -42,7 +42,7 @@ std::vector<GeckoCode> LoadCodes(const IniFile& globalIni, const IniFile& localI
gcodes.push_back(gcode); gcodes.push_back(gcode);
gcode = GeckoCode(); gcode = GeckoCode();
gcode.enabled = (1 == ss.tellg()); // silly gcode.enabled = (1 == ss.tellg()); // silly
gcode.user_defined = (&ini == &localIni); gcode.user_defined = (ini == &localIni);
ss.seekg(1, std::ios_base::cur); ss.seekg(1, std::ios_base::cur);
// read the code name // read the code name
std::getline(ss, gcode.name, '['); // stop at [ character (beginning of contributor name) std::getline(ss, gcode.name, '['); // stop at [ character (beginning of contributor name)
@ -75,7 +75,7 @@ std::vector<GeckoCode> LoadCodes(const IniFile& globalIni, const IniFile& localI
gcodes.push_back(gcode); gcodes.push_back(gcode);
} }
ini.GetLines("Gecko_Enabled", &lines, false); ini->GetLines("Gecko_Enabled", &lines, false);
for (const std::string& line : lines) for (const std::string& line : lines)
{ {