iConfigFile Struct Reference (Crystal Space 2.0 Public API Reference)

| ## Public API Reference

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions
iConfigFile Struct Reference
Utilities

Configuration file interface. More...

`#include <iutil/cfgfile.h>`

Inheritance diagram for iConfigFile:

List of all members.

## Public Member Functions
virtual void | Clear ()=0
| Delete all options and rewind all iterators.
virtual void | DeleteKey (const char *Key)=0
| Delete a key and its value and comment.
virtual csPtr< iConfigIterator > | Enumerate (const char *Subsection=0)=0
| Enumerate selected keys.
virtual bool | GetBool (const char *Key, bool Def=false) const =0
| Get a boolean value from the configuration.
virtual const char * | GetComment (const char *Key) const =0
| Get the comment of the given key, or 0 if no comment exists.
virtual const char * | GetEOFComment () const =0
| return the final comment at the end of the configuration file
virtual const char * | GetFileName () const =0
| Get configuration file name.
virtual float | GetFloat (const char *Key, float Def=0.0) const =0
| Get a float value from the configuration.
virtual int | GetInt (const char *Key, int Def=0) const =0
| Get an integer value from the configuration.
virtual const char * | GetStr (const char *Key, const char *Def="") const =0
| Get a string value from the configuration.
virtual csPtr< iStringArray > | GetTuple (const char *Key) const =0
| Get a tuple set from the configuration.
virtual iVFS * | GetVFS () const =0
| Get the VFS object on which this file is stored (if any).
virtual bool | KeyExists (const char *Key) const =0
| Test if a key exists.
virtual bool | Load (const char *iFileName, iVFS *=0, bool Merge=false, bool NewWins=true)=0
| Load a configuration file.
virtual bool | Save ()=0
| Save configuration to the same place from which it was loaded.
virtual bool | Save (const char *iFileName, iVFS *=0)=0
| Save configuration into the given file (on VFS or on the physical filesystem).
virtual void | SetBool (const char *Key, bool Value)=0
| Set a boolean value.
virtual bool | SetComment (const char *Key, const char *Text)=0
| Set the comment for given key.
virtual void | SetEOFComment (const char *Text)=0
| set the final comment at the end of the configuration file
virtual void | SetFileName (const char *, iVFS *)=0
| Set config file name.
virtual void | SetFloat (const char *Key, float Value)=0
| Set a floating-point value.
virtual void | SetInt (const char *Key, int Value)=0
| Set an integer value.
virtual void | SetStr (const char *Key, const char *Val)=0
| Set an null-terminated string value.
virtual void | SetTuple (const char *Key, iStringArray *Value)=0
| Set a tuple value.
virtual bool | SubsectionExists (const char *Subsection) const =0
| Test if at least one key exists with the given Subsection prefix.

## Detailed Description

Configuration file interface.

Definition at line 36 of file cfgfile.h.

## Member Function Documentation

virtual void iConfigFile::Clear | ( |  | ) | `[pure virtual]`

Delete all options and rewind all iterators.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual void iConfigFile::DeleteKey | ( | const char * | Key | ) | `[pure virtual]`

Delete a key and its value and comment.

Implemented in csConfigManager, csConfigFile, csWin32RegistryConfig, and csConfigDocument.

virtual csPtr<iConfigIterator> iConfigFile::Enumerate | ( | const char * | Subsection = `0` | ) | `[pure virtual]`

Enumerate selected keys.

If a subsection is given, only those keys which are prefixed by the subsection string will be enumerated. The returned iterator does not yet point to a valid key. You must call Next() to set it to the first key.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual bool iConfigFile::GetBool | ( | const char * | Key,
|  | bool | Def = `false`
| ) |  | const`[pure virtual]`

Get a boolean value from the configuration.

The optional default value (Def parameter) will be used if the key was not found.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual const char* iConfigFile::GetComment | ( | const char * | Key | ) | const`[pure virtual]`

Get the comment of the given key, or 0 if no comment exists.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual const char* iConfigFile::GetEOFComment | ( |  | ) | const`[pure virtual]`

return the final comment at the end of the configuration file

Implemented in csConfigManager, csConfigFile, csWin32RegistryConfig, and csConfigDocument.

virtual const char* iConfigFile::GetFileName | ( |  | ) | const`[pure virtual]`

Get configuration file name.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigDocument, and csConfigFile.

virtual float iConfigFile::GetFloat | ( | const char * | Key,
|  | float | Def = `0.0`
| ) |  | const`[pure virtual]`

Get a float value from the configuration.

The optional default value (Def parameter) will be used if the key was not found.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual int iConfigFile::GetInt | ( | const char * | Key,
|  | int | Def = `0`
| ) |  | const`[pure virtual]`

Get an integer value from the configuration.

The optional default value (Def parameter) will be used if the key was not found.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual const char* iConfigFile::GetStr | ( | const char * | Key,
|  | const char * | Def = `""`
| ) |  | const`[pure virtual]`

Get a string value from the configuration.

The optional default value (Def parameter) will be used if the key was not found.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual csPtr<iStringArray> iConfigFile::GetTuple | ( | const char * | Key | ) | const`[pure virtual]`

Get a tuple set from the configuration.

Implemented in csConfigManager, csConfigFile, and csConfigDocument.

virtual iVFS* iConfigFile::GetVFS | ( |  | ) | const`[pure virtual]`

Get the VFS object on which this file is stored (if any).

Returns 0 if this file resides within the real (non-VFS) filesystem.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigDocument, and csConfigFile.

virtual bool iConfigFile::KeyExists | ( | const char * | Key | ) | const`[pure virtual]`

Test if a key exists.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual bool iConfigFile::Load | ( | const char * | iFileName,
|  | iVFS * | = `0`,
|  | bool | Merge = `false`,
|  | bool | NewWins = `true`
| ) |  | `[pure virtual]`

Load a configuration file.

If the file resides in a real filesystem, rather than a VFS filesystem, then pass 0 for the VFS argument.

You can set the Merge flag to merge the newly loaded configuration information into the existing information. If you do so, nothing will happen if the named file doesn't exist. The NewWins flag determines the behavior in case of configuration key conflicts. If true, then the new configuration value replaces the old for that key. If false, then the old value is kept, and the new value is ignored. The recorded file name will be set to the name of the newly loaded file if the Merge flag is false; otherwise it will retain the old name.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigDocument, and csConfigFile.

virtual bool iConfigFile::Save | ( |  | ) | `[pure virtual]`

Save configuration to the same place from which it was loaded.

Returns true if the save operation succeeded.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual bool iConfigFile::Save | ( | const char * | iFileName,
|  | iVFS * | = `0`
| ) |  | `[pure virtual]`

Save configuration into the given file (on VFS or on the physical filesystem).

If the second parameter is skipped, the file will be written to the physical filesystem, otherwise it is stored on given VFS filesystem. This method does not change the internally stored file name.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual void iConfigFile::SetBool | ( | const char * | Key,
|  | bool | Value
| ) |  | `[pure virtual]`

Set a boolean value.

Implemented in csConfigManager, csConfigFile, csWin32RegistryConfig, and csConfigDocument.

virtual bool iConfigFile::SetComment | ( | const char * | Key,
|  | const char * | Text
| ) |  | `[pure virtual]`

Set the comment for given key.

In addition to an actual comment, you can use "" for Text to place an empty comment line before this key, or 0 to remove the comment entirely. The comment may contain newline characters. Returns false if the key does not exist.

Implemented in csConfigManager, csConfigFile, csWin32RegistryConfig, and csConfigDocument.

virtual void iConfigFile::SetEOFComment | ( | const char * | Text | ) | `[pure virtual]`

set the final comment at the end of the configuration file

Implemented in csConfigManager, csConfigFile, csWin32RegistryConfig, and csConfigDocument.

virtual void iConfigFile::SetFileName | ( | const char * | ,
|  | iVFS * |
| ) |  | `[pure virtual]`

Set config file name.

You can use this if you want Save() to write to another file. This will set the dirty flag.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigDocument, and csConfigFile.

virtual void iConfigFile::SetFloat | ( | const char * | Key,
|  | float | Value
| ) |  | `[pure virtual]`

Set a floating-point value.

Implemented in csConfigManager, csConfigFile, csWin32RegistryConfig, and csConfigDocument.

virtual void iConfigFile::SetInt | ( | const char * | Key,
|  | int | Value
| ) |  | `[pure virtual]`

Set an integer value.

Implemented in csConfigManager, csConfigFile, csWin32RegistryConfig, and csConfigDocument.

virtual void iConfigFile::SetStr | ( | const char * | Key,
|  | const char * | Val
| ) |  | `[pure virtual]`

Set an null-terminated string value.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

virtual void iConfigFile::SetTuple | ( | const char * | Key,
|  | iStringArray * | Value
| ) |  | `[pure virtual]`

Set a tuple value.

Implemented in csConfigManager, csConfigFile, and csConfigDocument.

virtual bool iConfigFile::SubsectionExists | ( | const char * | Subsection | ) | const`[pure virtual]`

Test if at least one key exists with the given Subsection prefix.

Implemented in csConfigManager, csWin32RegistryConfig, csConfigFile, and csConfigDocument.

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

- iutil/cfgfile.h