ini: use reference to avoid copies. simplify
This commit is contained in:
parent
6ab8b185c8
commit
834082519d
|
@ -7,7 +7,7 @@ namespace emucfg {
|
||||||
|
|
||||||
/* ConfigEntry */
|
/* ConfigEntry */
|
||||||
|
|
||||||
string ConfigEntry::get_string()
|
const string& ConfigEntry::get_string() const
|
||||||
{
|
{
|
||||||
return this->value;
|
return this->value;
|
||||||
}
|
}
|
||||||
|
@ -269,19 +269,17 @@ void ConfigFile::parse(FILE* file)
|
||||||
|
|
||||||
void ConfigFile::save(FILE* file)
|
void ConfigFile::save(FILE* file)
|
||||||
{
|
{
|
||||||
for(std::map<string, ConfigSection>::iterator section_it = this->sections.begin();
|
for (const auto& section_it : this->sections)
|
||||||
section_it != this->sections.end(); section_it++)
|
|
||||||
{
|
{
|
||||||
string section_name = section_it->first;
|
const string& section_name = section_it.first;
|
||||||
ConfigSection section = section_it->second;
|
const ConfigSection& section = section_it.second;
|
||||||
|
|
||||||
fprintf(file, "[%s]\n", section_name.c_str());
|
fprintf(file, "[%s]\n", section_name.c_str());
|
||||||
|
|
||||||
for(std::map<string, ConfigEntry>::iterator entry_it = section.entries.begin();
|
for (const auto& entry_it : section.entries)
|
||||||
entry_it != section.entries.end(); entry_it++)
|
|
||||||
{
|
{
|
||||||
string entry_name = entry_it->first;
|
const string& entry_name = entry_it.first;
|
||||||
ConfigEntry entry = entry_it->second;
|
const ConfigEntry& entry = entry_it.second;
|
||||||
fprintf(file, "%s = %s\n", entry_name.c_str(), entry.get_string().c_str());
|
fprintf(file, "%s = %s\n", entry_name.c_str(), entry.get_string().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ namespace emucfg {
|
||||||
|
|
||||||
struct ConfigEntry {
|
struct ConfigEntry {
|
||||||
std::string value;
|
std::string value;
|
||||||
std::string get_string();
|
const std::string& get_string() const;
|
||||||
int get_int();
|
int get_int();
|
||||||
bool get_bool();
|
bool get_bool();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue