# IniFile Struct Reference

The complete ini file. More...

`#include <ini_type.h>`

## Public Member Functions
| IniFile (const char **list_group_names=NULL)
| Construct a new in-memory Ini file representation.
| ~IniFile ()
| Free everything we loaded.
IniGroup * | GetGroup (const char *name, size_t len=0)
| Get the group with the given name, and if it doesn't exist create a new group.
void | RemoveGroup (const char *name)
| Remove the group with the given name.
void | LoadFromDisk (const char *filename)
| Load the Ini file's data from the disk.
bool | SaveToDisk (const char *filename)
| Save the Ini file's data to the disk.
## Data Fields
IniGroup * | group
| the first group in the ini
IniGroup ** | last_group
| the last group in the ini
char * | comment
| last comment in file
const char ** | list_group_names
| NULL terminated list with group names that are lists.

## Detailed Description

The complete ini file.

Definition at line 75 of file ini_type.h.

## Constructor & Destructor Documentation

IniFile::IniFile | ( | const char ** | list_group_names = `NULL` | ) |

Construct a new in-memory Ini file representation.

Parameters:

  | list_group_names | A NULL terminated list with groups that should be loaded as lists instead of variables.

Definition at line 87 of file ini.cpp.

References group, and last_group.

IniFile::~IniFile | ( |  | ) |

Free everything we loaded.

Definition at line 92 of file ini.cpp.

References comment, and group.

## Member Function Documentation

IniGroup * IniFile::GetGroup | ( | const char * | name,
|  | size_t | len = `0` |
| ) |  |  |

Get the group with the given name, and if it doesn't exist create a new group.

Parameters:

  | name | name of the group to find.
  | len | the maximum length of said name.

Returns:
  the requested group.

Definition at line 98 of file ini.cpp.

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

Referenced by FillGraphicsSetDetails(), ini_load_setting_list(), ini_load_settings(), ini_save_setting_list(), ini_save_settings(), and SaveVersionInConfig().

void IniFile::RemoveGroup | ( | const char * | name | ) |

Remove the group with the given name.

Parameters:

  | name | name of the group to remove.

Definition at line 117 of file ini.cpp.

References group, last_group, and IniGroup::next.

Referenced by SaveToConfig().

void IniFile::LoadFromDisk | ( | const char * | filename | ) |

Load the Ini file's data from the disk.

Parameters:

  | filename | the file to load.

Precondition:
  nothing has been loaded yet.

Definition at line 144 of file ini.cpp.

References IniItem::comment, IniGroup::comment, comment, DATA_DIR, FioFOpenFile(), group, last_group, max(), ReallocT(), ShowInfoF(), and IniItem::value.

Referenced by OBGFileScanner::AddFile().

bool IniFile::SaveToDisk | ( | const char * | filename | ) |

Save the Ini file's data to the disk.

Parameters:

  | filename | the file to save to.

Returns:
  true if saving succeeded.

Definition at line 259 of file ini.cpp.

References comment, IniItem::comment, IniGroup::comment, group, IniGroup::item, IniItem::name, IniGroup::name, IniItem::next, IniGroup::next, and IniItem::value.

Referenced by SaveToConfig().

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

- src/ini_type.h
- src/ini.cpp