Codechange: Remove create parameter from IniLoadFile::GetGroup.

GetGroup now only returns nullptr if the group does not exist.
Use GetOrCreateGroup to create a group.

This avoids creating groups while reading ini files.
This commit is contained in:
Peter Nelson
2023-10-10 19:25:59 +01:00
committed by Peter Nelson
parent c47a0e1578
commit 1fecbeff76
8 changed files with 37 additions and 30 deletions

View File

@@ -174,23 +174,17 @@ IniLoadFile::~IniLoadFile()
}
/**
* Get the group with the given name. If it doesn't exist
* and \a create_new is \c true create a new group.
* Get the group with the given name.
* @param name name of the group to find.
* @param create_new Allow creation of group if it does not exist.
* @return The requested group if it exists or was created, else \c nullptr.
* @return The requested group or \c nullptr if not found.
*/
IniGroup *IniLoadFile::GetGroup(const std::string &name, bool create_new)
IniGroup *IniLoadFile::GetGroup(const std::string &name) const
{
/* does it exist already? */
for (IniGroup *group = this->group; group != nullptr; group = group->next) {
if (group->name == name) return group;
}
if (!create_new) return nullptr;
/* otherwise make a new one */
return &this->CreateGroup(name);
return nullptr;
}
/**