OpenTTD Source: IniGroup Struct Reference

OpenTTD Source 13.1

Public Member Functions | Data Fields
IniGroup Struct Reference

A group within an ini file. More...

`#include <ini_type.h>`

## Public Member Functions
| IniGroup (struct IniLoadFile *parent, const std::string &name)
| Construct a new in-memory group of an Ini file. More...
| ~IniGroup ()
| Free everything we loaded.
IniItem * | GetItem (const std::string &name, bool create)
| Get the item with the given name, and if it doesn't exist and create is true it creates a new item. More...
void | RemoveItem (const std::string &name)
| Remove the item with the given name. More...
void | Clear ()
| Clear all items in the group.

## Data Fields
IniGroup * | next
| the next group within this file
IniGroupType | type
| type of group
IniItem * | item
| the first item in the group
IniItem ** | last_item
| the last item in the group
std::string | name
| name of group
std::string | comment
| comment for group

## Detailed Description

A group within an ini file.

Definition at line 38 of file ini_type.h.

## Constructor & Destructor Documentation

## ◆ IniGroup()

IniGroup::IniGroup | ( | struct IniLoadFile * | parent,
|  | const std::string & | name
| ) |  |

Construct a new in-memory group of an Ini file.

Parameters

  parent | the file we belong to
  name | the name of the group

Definition at line 51 of file ini_load.cpp.

References IGT_LIST, IGT_SEQUENCE, item, IniLoadFile::last_group, last_item, IniLoadFile::list_group_names, name, next, IniLoadFile::seq_group_names, StrMakeValid(), and type.

## Member Function Documentation

## ◆ GetItem()

IniItem * IniGroup::GetItem | ( | const std::string & | name,
|  | bool | create
| ) |  |

Get the item with the given name, and if it doesn't exist and create is true it creates a new item.

Parameters

  name | name of the item to find.
  create | whether to create an item when not found or not.

Returns
  the requested item or nullptr if not found.

Definition at line 91 of file ini_load.cpp.

References item, IniItem::name, name, and IniItem::next.

Referenced by DumpSections(), FindItemValue(), IniLoadSettings(), IniSaveSettingList(), HotkeyList::Load(), HotkeyList::Save(), and SaveVersionInConfig().

## ◆ RemoveItem()

void IniGroup::RemoveItem | ( | const std::string & | name | ) |

Remove the item with the given name.

Parameters

  name | Name of the item to remove.

Definition at line 107 of file ini_load.cpp.

References item, last_item, IniItem::name, name, and IniItem::next.

Referenced by RemoveEntriesFromIni().

The documentation for this struct was generated from the following files:

- src/ini_type.h
- src/ini_load.cpp