csConfigFile Class Reference
Configuration file which implements the iConfigFile SCF interface. More...
#include <csutil/cfgfile.h>
Inheritance diagram for csConfigFile:
Public Member Functions | |
virtual void | Clear () |
Delete all options and rewind all iterators. | |
csConfigFile (iBase *) | |
Create a new empty configuration object. | |
csConfigFile (const char *Filename=0, iVFS *=0) | |
Create a new configuration object from the given file. | |
virtual void | DeleteKey (const char *Key) |
Delete a key and its comment. | |
virtual csPtr< iConfigIterator > | Enumerate (const char *Subsection=0) |
Enumerate selected keys. | |
virtual bool | GetBool (const char *Key, bool Def=false) const |
Get a boolean value from the configuration. | |
virtual const char * | GetComment (const char *Key) const |
Get the comment of the given key, or 0 if no comment exists. | |
virtual const char * | GetEOFComment () const |
return the final comment at the end of the configuration file | |
virtual const char * | GetFileName () const |
Get configuration file name. | |
virtual float | GetFloat (const char *Key, float Def=0.0) const |
Get a float value from the configuration. | |
virtual int | GetInt (const char *Key, int Def) const |
Get an integer value from the configuration. | |
virtual const char * | GetStr (const char *Key, const char *Def="") const |
Get a string value from the configuration. | |
virtual iVFS * | GetVFS () const |
Get the VFS object on which this file is stored (if any). | |
virtual bool | IsEmpty () const |
Is the configuration object empty? | |
virtual bool | KeyExists (const char *Key) const |
Test if a key exists. | |
virtual bool | Load (const char *iFileName, iVFS *=0, bool Merge=false, bool NewWins=true) |
Load a configuration file. | |
virtual void | ParseCommandLine (iCommandLineParser *cmdline, iVFS *vfs, bool Merge=false, bool NewWins=true) |
Parse the command line for configuration options. | |
virtual bool | Save (const char *iFileName, iVFS *=0) |
Save configuration into the given file (on VFS or on the physical filesystem). | |
virtual bool | Save () |
Save configuration to the same place from which it was loaded. | |
virtual void | SetBool (const char *Key, bool Value) |
Set a boolean value. | |
virtual bool | SetComment (const char *Key, const char *Text) |
Set the comment for given key. | |
virtual void | SetEOFComment (const char *Text) |
set the final comment at the end of the configuration file | |
virtual void | SetFileName (const char *, iVFS *) |
Set config file name. | |
virtual void | SetFloat (const char *Key, float Value) |
Set a floating-point value. | |
virtual void | SetInt (const char *Key, int Value) |
Set an integer value. | |
virtual void | SetStr (const char *Key, const char *Val) |
Set an null-terminated string value. | |
virtual bool | SubsectionExists (const char *Subsection) const |
Test if at least one key exists with the given Subsection prefix. | |
virtual | ~csConfigFile () |
Delete this configuration. | |
Friends | |
class | csConfigIterator |
Detailed Description
Configuration file which implements the iConfigFile SCF interface.
Definition at line 39 of file cfgfile.h.
Constructor & Destructor Documentation
csConfigFile::csConfigFile | ( | const char * | Filename = 0 , |
|
iVFS * | = 0 | |||
) |
Create a new configuration object from the given file.
csConfigFile::csConfigFile | ( | iBase * | ) |
Create a new empty configuration object.
virtual csConfigFile::~csConfigFile | ( | ) | [virtual] |
Delete this configuration.
Member Function Documentation
virtual void csConfigFile::Clear | ( | ) | [virtual] |
virtual void csConfigFile::DeleteKey | ( | const char * | Key | ) | [virtual] |
virtual csPtr<iConfigIterator> csConfigFile::Enumerate | ( | const char * | Subsection = 0 |
) | [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.
Implements iConfigFile.
virtual bool csConfigFile::GetBool | ( | const char * | Key, | |
bool | Def = false | |||
) | const [virtual] |
virtual const char* csConfigFile::GetComment | ( | const char * | Key | ) | const [virtual] |
virtual const char* csConfigFile::GetEOFComment | ( | ) | const [virtual] |
virtual const char* csConfigFile::GetFileName | ( | ) | const [virtual] |
virtual float csConfigFile::GetFloat | ( | const char * | Key, | |
float | Def = 0.0 | |||
) | const [virtual] |
virtual int csConfigFile::GetInt | ( | const char * | Key, | |
int | Def | |||
) | const [virtual] |
virtual const char* csConfigFile::GetStr | ( | const char * | Key, | |
const char * | Def = "" | |||
) | const [virtual] |
virtual iVFS* csConfigFile::GetVFS | ( | ) | const [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.
Implements iConfigFile.
virtual bool csConfigFile::IsEmpty | ( | ) | const [virtual] |
Is the configuration object empty?
virtual bool csConfigFile::KeyExists | ( | const char * | Key | ) | const [virtual] |
virtual bool csConfigFile::Load | ( | const char * | iFileName, | |
iVFS * | = 0 , |
|||
bool | Merge = false , |
|||
bool | NewWins = true | |||
) | [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.
Implements iConfigFile.
virtual void csConfigFile::ParseCommandLine | ( | iCommandLineParser * | cmdline, | |
iVFS * | vfs, | |||
bool | Merge = false , |
|||
bool | NewWins = true | |||
) | [virtual] |
Parse the command line for configuration options.
Recognized are the -cfgset
parameters, which sets a single setting, and -cfgfile
, which reads settings from the specified file.
The meanings of the vfs
, Merge
and NewWins
arguments are the same as for Load().
virtual bool csConfigFile::Save | ( | const char * | iFileName, | |
iVFS * | = 0 | |||
) | [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.
Implements iConfigFile.
virtual bool csConfigFile::Save | ( | ) | [virtual] |
Save configuration to the same place from which it was loaded.
Returns true if the save operation succeeded.
Implements iConfigFile.
virtual void csConfigFile::SetBool | ( | const char * | Key, | |
bool | Value | |||
) | [virtual] |
virtual bool csConfigFile::SetComment | ( | const char * | Key, | |
const char * | Text | |||
) | [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.
Implements iConfigFile.
virtual void csConfigFile::SetEOFComment | ( | const char * | Text | ) | [virtual] |
virtual void csConfigFile::SetFileName | ( | const char * | , | |
iVFS * | ||||
) | [virtual] |
Set config file name.
You can use this if you want Save() to write to another file. This will set the dirty flag.
Implements iConfigFile.
virtual void csConfigFile::SetFloat | ( | const char * | Key, | |
float | Value | |||
) | [virtual] |
virtual void csConfigFile::SetInt | ( | const char * | Key, | |
int | Value | |||
) | [virtual] |
virtual void csConfigFile::SetStr | ( | const char * | Key, | |
const char * | Val | |||
) | [virtual] |
virtual bool csConfigFile::SubsectionExists | ( | const char * | Subsection | ) | const [virtual] |
The documentation for this class was generated from the following file:
- csutil/cfgfile.h
Generated for Crystal Space by doxygen 1.4.7