UNIVERS
15.3
UNIVERS base processing software API
|
Class for operating with ini-file which contains sections. More...
#include <IniFile.hpp>
Public Types | |
enum | LoadMode { Append, Overwrite, Truncate, Merge } |
Public Member Functions | |
IniFile () | |
IniFile (const char *path) | |
virtual | ~IniFile () |
virtual void | set_path (const char *path) |
virtual void | save () const |
virtual void | save (const char *path) const |
virtual void | load (const char *path, LoadMode mode=Overwrite, IniSection::MergeMode mmode=IniSection::AppendAll) |
virtual void | reload () |
virtual const IniSection & | get (const char *type, const char *name="") const |
const IniSection & | operator() (const char *type, const char *name="") const |
virtual IniSection & | fetch (const char *type, const char *name="") |
IniSection & | operator[] (const char *type) |
virtual IniSection * | add_section (const char *type, const char *name="") |
virtual void | remove_section (const char *type, const char *name="") |
virtual char ** | get_list_of_types (int &n) const |
virtual char ** | get_list_of_names (const char *type, int &n) const |
Protected Member Functions | |
int | tn2i (const char *type, const char *name) const |
Protected Attributes | |
char * | ini_path |
struct stat | stat_buf |
IniSectionsAr | isar |
Class for operating with ini-file which contains sections.
The ini-file has following format:
[SectionType1 SectionName1] section lines ... [SectionType2 SectionName2] section lines ...
The last line of the section is the last line of file or the line before start of next section.
SectionName is optional. In case of it is not empty it allows to distinguish several sections of the same type in the same ini-file.
enum IniFile::LoadMode |
IniFile::IniFile | ( | ) |
Open empty ini-file without.
IniFile::IniFile | ( | const char * | path | ) |
Open given ini-file and read all sections from it to local array.
|
virtual |
Destroy the object without flushing the contents of sections to disk file.
|
virtual |
Create new section or return pointer to existent one. The last case take place only if type and name are matched exactly.
|
virtual |
Get the section by type and name (the last one encountered). ERROR__NOT_FOUND may be excited in case of no section is found. If name is NULL then the last one mentioned in ini-file with matched type and arbitrary name will be returned.
|
virtual |
Get the section by type and name (the last one encountered). ERROR__NOT_FOUND may be excited in case of no section is found. If name is NULL then the last one mentioned in ini-file with matched type and arbitrary name will be returned.
|
virtual |
Get list of names for given type and its volume n. The list may be released by strlistfree().
|
virtual |
Get list of types and its volume n. The list may be released by strlistfree().
|
virtual |
Load given ini-file to the object. Depending the flag loading may be done with truncating previous contents, overwriting existing sections, adding only newly encountered section or merging existent sections. In the last case section merging may be tuned according to special mode which allows to truncate, overwrite or append (NAME,VALUE) pairs.
|
inline |
Synonymous to get(const char* type, const char* name).
|
inline |
Synonymous to fetch(const char* type, const char* name = "").
|
virtual |
Reload contents of original file taking care of changed on disk sections (IniFile::Overwrite).
|
virtual |
Remove section. If name is NULL then the last one mentioned in ini-file with matched type and arbitrary name will be returned.
|
virtual |
Save contents of all sections to original file. Does nothing in case of empty file path.
|
virtual |
Save contents of all sections to given file.
|
virtual |
Setup new file path.
|
protected |
Find the index of section with given type and name. If name is NULL then the last one mentioned in ini-file with matched type and arbitrary name will be returned. Return -1 if not found.
|
protected |
Path to the ini-file. May be NULL in case of
|
protected |
Array of section in file/creation order.
|
protected |
File info which allows to make smart reload in case of changed contents