OpenTTD Source 20241224-master-gee860a5c8e
SettingsIniFile Struct Reference

Derived class for loading INI files without going through Fio stuff. More...

Inheritance diagram for SettingsIniFile:
IniLoadFile

Public Member Functions

 SettingsIniFile (const IniGroupNameList &list_group_names={}, const IniGroupNameList &seq_group_names={})
 Construct a new ini loader.
 
std::optional< FileHandleOpenFile (const std::string &filename, Subdirectory, size_t *size) override
 Open the INI file.
 
void ReportFileError (const char *const pre, const char *const buffer, const char *const post) override
 Report an error about the file contents.
 
- Public Member Functions inherited from IniLoadFile
 IniLoadFile (const IniGroupNameList &list_group_names={}, const IniGroupNameList &seq_group_names={})
 Construct a new in-memory Ini file representation.
 
const IniGroupGetGroup (std::string_view name) const
 Get the group with the given name.
 
IniGroupGetGroup (std::string_view name)
 Get the group with the given name.
 
IniGroupGetOrCreateGroup (std::string_view name)
 Get the group with the given name, and if it doesn't exist create a new group.
 
IniGroupCreateGroup (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 (const std::string &filename, Subdirectory subdir)
 Load the Ini file's data from the disk.
 

Additional Inherited Members

- Public Types inherited from IniLoadFile
using IniGroupNameList = std::initializer_list< std::string_view >
 
- Data Fields inherited from IniLoadFile
std::list< IniGroupgroups
 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.
 

Detailed Description

Derived class for loading INI files without going through Fio stuff.

Definition at line 148 of file settingsgen.cpp.

Constructor & Destructor Documentation

◆ SettingsIniFile()

SettingsIniFile::SettingsIniFile ( const IniGroupNameList &  list_group_names = {},
const IniGroupNameList &  seq_group_names = {} 
)
inline

Construct a new ini loader.

Parameters
list_group_namesA list with group names that should be loaded as lists instead of variables.
See also
IGT_LIST
Parameters
seq_group_namesA list with group names that should be loaded as lists of names.
See also
IGT_SEQUENCE

Definition at line 154 of file settingsgen.cpp.

Member Function Documentation

◆ OpenFile()

std::optional< FileHandle > SettingsIniFile::OpenFile ( const std::string &  filename,
Subdirectory  subdir,
size_t *  size 
)
inlineoverridevirtual

Open the INI file.

Parameters
filenameName of the INI file.
subdirThe subdir to load the file from.
[out]sizeSize of the opened file.
Returns
File handle of the opened file, or std::nullopt.

Implements IniLoadFile.

Definition at line 159 of file settingsgen.cpp.

References FileHandle::Open().

◆ ReportFileError()

void SettingsIniFile::ReportFileError ( const char *const  pre,
const char *const  buffer,
const char *const  post 
)
inlineoverridevirtual

Report an error about the file contents.

Parameters
prePrefix text of the buffer part.
bufferPart of the file with the error.
postSuffix text of the buffer part.

Implements IniLoadFile.

Definition at line 173 of file settingsgen.cpp.


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