OpenTTD Source
20240917-master-g9ab0a47812
|
Go to the documentation of this file.
25 std::optional<std::string>
value;
51 using IniGroupNameList = std::initializer_list<std::string_view>;
76 virtual std::optional<FileHandle>
OpenFile(
const std::string &filename,
Subdirectory subdir,
size_t *size) = 0;
84 virtual void ReportFileError(
const char *
const pre,
const char *
const buffer,
const char *
const post) = 0;
93 std::optional<FileHandle>
OpenFile(
const std::string &filename,
Subdirectory subdir,
size_t *size)
override;
94 void ReportFileError(
const char *
const pre,
const char *
const buffer,
const char *
const post)
override;
IniItem & GetOrCreateItem(std::string_view name)
Get the item with the given name, and if it doesn't exist create a new item.
void SetValue(std::string_view value)
Replace the current value with another value.
IniGroup(std::string_view name, IniGroupType type)
Construct a new in-memory group of an Ini file.
std::string comment
last comment in file
@ IGT_LIST
A list of values, separated by and terminated by the next group block.
A single "line" in an ini file.
A group within an ini file.
std::list< IniItem > items
all items in the group
IniItem(std::string_view name)
Construct a new in-memory item of an Ini file.
const IniGroupNameList seq_group_names
list of group names that are sequences.
void Clear()
Clear all items in the group.
const IniGroupNameList list_group_names
list of group names that are lists
Ini file that only supports loading.
const IniItem * GetItem(std::string_view name) const
Get the item with the given name.
std::optional< std::string > value
The value of this item.
bool SaveToDisk(const std::string &filename)
Save the Ini file's data to the disk.
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.
IniGroup & GetOrCreateGroup(std::string_view name)
Get the group with the given name, and if it doesn't exist create a new group.
IniGroupType
Types of groups.
IniGroupType type
type of group
@ IGT_VARIABLES
Values of the form "landscape = hilly".
virtual std::optional< FileHandle > OpenFile(const std::string &filename, Subdirectory subdir, size_t *size)=0
Open the INI file.
void RemoveItem(std::string_view name)
Remove the item with the given name.
std::string comment
comment for group
std::string name
name of group
Ini file that supports both loading and saving.
virtual void ReportFileError(const char *const pre, const char *const buffer, const char *const post)=0
Report an error about the file contents.
IniLoadFile(const IniGroupNameList &list_group_names={}, const IniGroupNameList &seq_group_names={})
Construct a new in-memory Ini file representation.
@ IGT_SEQUENCE
A list of uninterpreted lines, terminated by the next group block.
const IniGroup * GetGroup(std::string_view name) const
Get the group with the given name.
IniFile(const IniGroupNameList &list_group_names={})
Create a new ini file with given group names.
Subdirectory
The different kinds of subdirectories OpenTTD uses.
std::list< IniGroup > groups
all groups in the ini
std::string name
The name of this item.
std::string comment
The comment associated with this item.
IniItem & CreateItem(std::string_view name)
Create an item with the given name.
void LoadFromDisk(const std::string &filename, Subdirectory subdir)
Load the Ini file's data from the disk.
void ReportFileError(const char *const pre, const char *const buffer, const char *const post) override
Report an error about the file contents.
std::optional< FileHandle > OpenFile(const std::string &filename, Subdirectory subdir, size_t *size) override
Open the INI file.