Codechange: Add const versions of GetItem/GetGroup, and sprinkle liberally.

Non-const version of GetItem is not needed.
This commit is contained in:
Peter Nelson
2023-10-11 00:38:57 +01:00
committed by Peter Nelson
parent 17ba9d8c96
commit 69e20e79ab
10 changed files with 73 additions and 58 deletions

View File

@@ -49,9 +49,9 @@ IniGroup::IniGroup(const std::string &name, IniGroupType type) : type(type)
* @param name name of the item to find.
* @return the requested item or nullptr if not found.
*/
IniItem *IniGroup::GetItem(const std::string &name)
const IniItem *IniGroup::GetItem(const std::string &name) const
{
for (IniItem &item : this->items) {
for (const IniItem &item : this->items) {
if (item.name == name) return &item;
}
@@ -111,6 +111,20 @@ IniLoadFile::IniLoadFile(const IniGroupNameList &list_group_names, const IniGrou
{
}
/**
* Get the group with the given name.
* @param name name of the group to find.
* @return The requested group or \c nullptr if not found.
*/
const IniGroup *IniLoadFile::GetGroup(const std::string &name) const
{
for (const IniGroup &group : this->groups) {
if (group.name == name) return &group;
}
return nullptr;
}
/**
* Get the group with the given name.
* @param name name of the group to find.