# IniFile Struct Reference

The complete ini file. More...

`#include <ini_type.h>`

## Public Member Functions

| IniFile (const char *const *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 *const * | list_group_names
| NULL terminated list with group names that are lists.

## Detailed Description

The complete ini file.

Definition at line 82 of file ini_type.h.

## Constructor & Destructor Documentation

IniFile::IniFile | ( | const char *const * | 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 100 of file ini.cpp.

References group, and last_group.

IniFile::~IniFile | ( |  | ) |

Free everything we loaded.

Definition at line 105 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 111 of file ini.cpp.

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

Referenced by BaseSet< T, Tnum_files, Tsubdir >::FillSetDetails(), ini_load_setting_list(), ini_load_settings(), ini_save_setting_list(), ini_save_settings(), and SaveVersionInConfig().

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 155 of file ini.cpp.

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

Referenced by BaseMedia< Tbase_set >::AddFile().

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

Remove the group with the given name.

Parameters:

  | name | name of the group to remove.

Definition at line 128 of file ini.cpp.

References group, last_group, and IniGroup::next.

Referenced by SaveToConfig().

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 271 of file ini.cpp.

References comment, IniGroup::comment, group, IniGroup::item, lastof, MemSetT(), IniGroup::name, IniItem::next, IniGroup::next, strecat(), and strecpy().

Referenced by SaveToConfig().

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

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