|
OpenTTD Source 20251116-master-g21329071df
|
Ini file that only supports loading. More...
#include <ini_type.h>
Public Types | |
| using | IniGroupNameList = std::initializer_list< const std::string_view > |
Public Member Functions | |
| IniLoadFile (const IniGroupNameList &list_group_names={}, const IniGroupNameList &seq_group_names={}) | |
| Construct a new in-memory Ini file representation. | |
| const IniGroup * | GetGroup (std::string_view name) const |
| Get the group with the given name. | |
| IniGroup * | GetGroup (std::string_view name) |
| Get the group with the given name. | |
| IniGroup & | GetOrCreateGroup (std::string_view name) |
| Get the group with the given name, and if it doesn't exist create a new group. | |
| IniGroup & | CreateGroup (std::string_view name) |
| Create an group with the given name. | |
| void | RemoveGroup (std::string_view name) |
| Remove the group with the given name. | |
| void | LoadFromDisk (std::string_view filename, Subdirectory subdir) |
| Load the Ini file's data from the disk. | |
| virtual std::optional< FileHandle > | OpenFile (std::string_view filename, Subdirectory subdir, size_t *size)=0 |
| Open the INI file. | |
| virtual void | ReportFileError (std::string_view message)=0 |
| Report an error about the file contents. | |
Data Fields | |
| std::list< IniGroup > | groups |
| all groups in the ini | |
| std::string | comment |
| last comment in file | |
| const IniGroupNameList | list_group_names |
| list of group names that are lists | |
| const IniGroupNameList | seq_group_names |
| list of group names that are sequences. | |
Ini file that only supports loading.
Definition at line 50 of file ini_type.h.
| using IniLoadFile::IniGroupNameList = std::initializer_list<const std::string_view> |
Definition at line 51 of file ini_type.h.
| IniLoadFile::IniLoadFile | ( | const IniGroupNameList & | list_group_names = {}, |
| const IniGroupNameList & | seq_group_names = {} |
||
| ) |
Construct a new in-memory Ini file representation.
| list_group_names | A list with group names that should be loaded as lists instead of variables. |
| seq_group_names | A list with group names that should be loaded as lists of names. |
Definition at line 107 of file ini_load.cpp.
| IniGroup & IniLoadFile::CreateGroup | ( | std::string_view | name | ) |
Create an group with the given name.
This does not reuse an existing group of the same name.
| name | name of the group to create. |
Definition at line 161 of file ini_load.cpp.
References groups, IGT_LIST, IGT_SEQUENCE, IGT_VARIABLES, list_group_names, and seq_group_names.
Referenced by GetOrCreateGroup(), and LoadFromDisk().
| IniGroup * IniLoadFile::GetGroup | ( | std::string_view | name | ) |
Get the group with the given name.
| name | name of the group to find. |
nullptr if not found. Definition at line 132 of file ini_load.cpp.
References groups.
| const IniGroup * IniLoadFile::GetGroup | ( | std::string_view | name | ) | const |
Get the group with the given name.
| name | name of the group to find. |
nullptr if not found. Definition at line 118 of file ini_load.cpp.
References groups.
Referenced by BadgeClassLoadConfigFeature(), DumpGroup(), DumpSections(), BaseSet< T >::FillSetDetails(), GraphicsSetLoadConfig(), GRFLoadConfig(), IniLoadSettingList(), IniLoadSettings(), IsConversionNeeded(), HotkeyList::Load(), LoadFromConfig(), PickerLoadConfig(), RemoveEntriesFromIni(), and SaveToConfig().
| IniGroup & IniLoadFile::GetOrCreateGroup | ( | std::string_view | name | ) |
Get the group with the given name, and if it doesn't exist create a new group.
| name | name of the group to find. |
Definition at line 146 of file ini_load.cpp.
References CreateGroup(), and groups.
Referenced by BadgeClassSaveConfigFeature(), GraphicsSetSaveConfig(), IniSaveSettingList(), IniSaveSettings(), PickerSaveConfig(), HotkeyList::Save(), and SaveVersionInConfig().
| void IniLoadFile::LoadFromDisk | ( | std::string_view | filename, |
| Subdirectory | subdir | ||
| ) |
Load the Ini file's data from the disk.
| filename | the file to load. |
| subdir | the sub directory to load the file from. |
Definition at line 185 of file ini_load.cpp.
References IniItem::comment, IniGroup::comment, comment, CreateGroup(), IniGroup::CreateItem(), groups, IGT_SEQUENCE, StringConsumer::KEEP_SEPARATOR, OpenFile(), ReportFileError(), StringConsumer::SKIP_ONE_SEPARATOR, StrMakeValid(), IniGroup::type, IniItem::value, and StringConsumer::WHITESPACE_OR_NEWLINE.
Referenced by BaseMedia< Tbase_set >::AddFile(), WindowDesc::LoadFromConfig(), ProcessIniFile(), and WindowDesc::SaveToConfig().
|
pure virtual |
Open the INI file.
| filename | Name of the INI file. | |
| subdir | The subdir to load the file from. | |
| [out] | size | Size of the opened file. |
std::nullopt. Implemented in IniFile, and SettingsIniFile.
Referenced by LoadFromDisk().
| void IniLoadFile::RemoveGroup | ( | std::string_view | name | ) |
Remove the group with the given name.
| name | name of the group to remove. |
Definition at line 174 of file ini_load.cpp.
References groups, and IniGroup::name.
Referenced by DeleteGRFPresetFromConfig(), and SaveToConfig().
|
pure virtual |
Report an error about the file contents.
| message | The message to show. |
Implemented in IniFile, and SettingsIniFile.
Referenced by LoadFromDisk().
| std::string IniLoadFile::comment |
last comment in file
Definition at line 54 of file ini_type.h.
Referenced by LoadFromDisk(), and IniFile::SaveToDisk().
| std::list<IniGroup> IniLoadFile::groups |
all groups in the ini
Definition at line 53 of file ini_type.h.
Referenced by CreateGroup(), DumpSections(), GetGRFPresetList(), GetGroup(), GetGroup(), GetOrCreateGroup(), LoadFromDisk(), RemoveGroup(), and IniFile::SaveToDisk().
| const IniGroupNameList IniLoadFile::list_group_names |
list of group names that are lists
Definition at line 55 of file ini_type.h.
Referenced by CreateGroup().
| const IniGroupNameList IniLoadFile::seq_group_names |
list of group names that are sequences.
Definition at line 56 of file ini_type.h.
Referenced by CreateGroup().