OpenTTD Source  1.11.0-beta2
IniLoadFile Struct Referenceabstract

Ini file that only supports loading. More...

#include <ini_type.h>

Inheritance diagram for IniLoadFile:
IniFile SettingsIniFile

Public Member Functions

 IniLoadFile (const char *const *list_group_names=nullptr, const char *const *seq_group_names=nullptr)
 Construct a new in-memory Ini file representation. More...
 
virtual ~IniLoadFile ()
 Free everything we loaded.
 
IniGroupGetGroup (const std::string &name, bool create_new=true)
 Get the group with the given name. More...
 
void RemoveGroup (const char *name)
 Remove the group with the given name. More...
 
void LoadFromDisk (const std::string &filename, Subdirectory subdir)
 Load the Ini file's data from the disk. More...
 
virtual FILE * OpenFile (const std::string &filename, Subdirectory subdir, size_t *size)=0
 Open the INI file. More...
 
virtual void ReportFileError (const char *const pre, const char *const buffer, const char *const post)=0
 Report an error about the file contents. More...
 

Data Fields

IniGroupgroup
 the first group in the ini
 
IniGroup ** last_group
 the last group in the ini
 
std::string comment
 last comment in file
 
const char *const * list_group_names
 nullptr terminated list with group names that are lists
 
const char *const * seq_group_names
 nullptr terminated list with group names that are sequences.
 

Detailed Description

Ini file that only supports loading.

Definition at line 54 of file ini_type.h.

Constructor & Destructor Documentation

◆ IniLoadFile()

IniLoadFile::IniLoadFile ( const char *const *  list_group_names = nullptr,
const char *const *  seq_group_names = nullptr 
)

Construct a new in-memory Ini file representation.

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

Definition at line 122 of file ini_load.cpp.

References group, and last_group.

Member Function Documentation

◆ GetGroup()

IniGroup * IniLoadFile::GetGroup ( const std::string &  name,
bool  create_new = true 
)

Get the group with the given name.

If it doesn't exist and create_new is true create a new group.

Parameters
namename of the group to find.
create_newAllow creation of group if it does not exist.
Returns
The requested group if it exists or was created, else nullptr.

Definition at line 143 of file ini_load.cpp.

References IniGroup::comment, group, IniGroup::name, and IniGroup::next.

Referenced by DumpGroup(), DumpSections(), BaseSet< GraphicsSet, MAX_GFT, true >::FillSetDetails(), GRFLoadConfig(), IniLoadSettingList(), IniLoadSettings(), IniSaveSettingList(), HotkeyList::Load(), HotkeyList::Save(), and SaveVersionInConfig().

◆ LoadFromDisk()

void IniLoadFile::LoadFromDisk ( const std::string &  filename,
Subdirectory  subdir 
)

Load the Ini file's data from the disk.

Parameters
filenamethe file to load.
subdirthe sub directory to load the file from.
Precondition
nothing has been loaded yet.

Definition at line 195 of file ini_load.cpp.

References IniItem::comment, IniGroup::comment, comment, group, IGT_SEQUENCE, last_group, OpenFile(), ReallocT(), ReportFileError(), IniGroup::type, and IniItem::value.

Referenced by BaseMedia< GraphicsSet >::AddFile(), WindowDesc::LoadFromConfig(), LoadIniFile(), and WindowDesc::SaveToConfig().

◆ OpenFile()

virtual FILE* IniLoadFile::OpenFile ( const std::string &  filename,
Subdirectory  subdir,
size_t *  size 
)
pure virtual

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 nullptr.

Implemented in SettingsIniFile, and IniFile.

Referenced by LoadFromDisk().

◆ RemoveGroup()

void IniLoadFile::RemoveGroup ( const char *  name)

Remove the group with the given name.

Parameters
namename of the group to remove.

Definition at line 162 of file ini_load.cpp.

References group, last_group, IniGroup::name, and IniGroup::next.

◆ ReportFileError()

virtual void IniLoadFile::ReportFileError ( const char *const  pre,
const char *const  buffer,
const char *const  post 
)
pure virtual

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.

Implemented in SettingsIniFile, and IniFile.

Referenced by LoadFromDisk().


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