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:

committed by
Peter Nelson

parent
c47a0e1578
commit
1fecbeff76
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user