A class representing a configuration for the application.
![]() | Construction |
![]() | Section functions |
![]() | Get/Set variables |
![]() | defaultSection The current section for variable values. |
Run Time Type functions
Comparison functions
I/O functions
Miscellaneous functions
A class representing a configuration for the application. There are four sources of configuration information. The system environment, a system wide configuration file, an application specific configuration file or an explicit configuration file.Configuration information follows a three level hierarchy:
file ,section andvariable . Thus, a configuration file consists of a number of sections each with a number of variables selected by akey . Each variable has an associated value.Note that the evironment source for configuration information does not have sections. The section is ignored and the same set of keys are available.
The configuration file is a standard text file for the platform with its internals appearing in the form:
[Section String] Key Name=Value String
System
Application
PConfig( Source src, const PString & appname )
appname - Name of application PConfig( Source src, const PString & appname, const PString & manuf )
appname - Name of application
manuf - Manufacturer PConfig( const PString & section, Source src = Application )
src - Standard source for the configuration. PConfig( const PString & section, Source src, const PString & appname )
src - Standard source for the configuration.
appname - Name of application PConfig( const PString & section, Source src, const PString & appname, const PString & manuf )
src - Standard source for the configuration.
appname - Name of application
manuf - Manufacturer PConfig( const PFilePath & filename, const PString & section )
section - Default section to search for variables.
Note when the Environment source is being used the default section may be set but it is ignored.
Note when the Environment source is being used the default
section may be retrieved but it is ignored.
Note when the Environment source is being used this will
return an empty list as there are no section present.
Note that the section header is also removed so the section will not
appear in the GetSections() function.
Note that the variable and key are removed from the file. The key will
no longer appear in the GetKeys() function. If you wish to delete the
value without deleting the key, use SetString() to set it to the empty
string.
This function allows a caller to distinguish between getting a saved
value or using the default value. For example if you called
GetString("MyKey", "DefVal") there is no way to distinguish between
the default "DefVal" being used, or the user had explicitly saved the
value "DefVal" into the PConfig.
PString GetDefaultSection() const
PStringList GetSections() const
PStringList GetKeys() const
PStringList GetKeys( const PString & section ) const
PStringToString GetAllKeyValues() const
PStringToString GetAllKeyValues( const PString & section ) const
void DeleteSection()
void DeleteSection( const PString & section )
void DeleteKey( const PString & key )
void DeleteKey( const PString & section, const PString & key )
key - Key of the variable to delete.BOOL HasKey( const PString & key ) const
BOOL HasKey( const PString & section, const PString & key ) const
key - Key of the variable.
If the key is not present the value returned is the that provided by the dlft parameter. Note that this is different from the key being present but having no value, in which case an empty string is returned.
The boolean value can be specified in a number of ways. The TRUE value
is returned if the string value for the variable begins with either the
'T' character or the 'Y' character. Alternatively if the string can
be converted to a numeric value, a non-zero value will also return TRUE.
Thus the values can be Key=True, Key=Yes or Key=1 for TRUE and
Key=False, Key=No, or Key=0 for FALSE. If the key is not present the value returned is the that provided by
the dlft parameter. Note that this is different from the
key being present but having no value, in which case FALSE is returned.
If value is TRUE then the string "True" is written to the variable
otherwise the string "False" is set.
The value is always formatted as a signed number with no leading or
trailing blanks.
If the key is not present the value returned is the that provided by
the dlft parameter. Note that this is different from the
key being present but having no value, in which case zero is returned.
The value is always formatted as a signed number with no leading or
trailing blanks.
If the key is not present the value returned is the that provided by
the dlft parameter. Note that this is different from the
key being present but having no value, in which case zero is returned.
The value is always formatted as a signed decimal or exponential form
number with no leading or trailing blanks, ie it uses the %g formatter
from the printf() function.
If the key is not present the value returned is the that provided by
the dlft parameter. Note that this is different from the
key being present but having no value, in which case zero is returned.
PString GetString( const PString & key, const PString & dflt ) const
dflt - Default value for the variable.PString GetString( const PString & section, const PString & key, const PString & dflt ) const
key - The key name for the variable.
dflt - Default value for the variable.void SetString( const PString & key, const PString & value )
value - New value to set for the variable.void SetString( const PString & section, const PString & key, const PString & value )
key - The key name for the variable.
value - New value to set for the variable.BOOL GetBoolean( const PString & key, BOOL dflt = FALSE ) const
dflt - Default value for the variable.BOOL GetBoolean( const PString & section, const PString & key, BOOL dflt = FALSE ) const
key - The key name for the variable.
dflt - Default value for the variable.void SetBoolean( const PString & key, BOOL value )
value - New value to set for the variable.void SetBoolean( const PString & section, const PString & key, BOOL value )
key - The key name for the variable.
value - New value to set for the variable.void SetInteger( const PString & key, long value )
value - New value to set for the variable.void SetInteger( const PString & section, const PString & key, long value )
key - The key name for the variable.
value - New value to set for the variable.PInt64 GetInt64( const PString & key, PInt64 dflt = 0 ) const
dflt - Default value for the variable.PInt64 GetInt64( const PString & section, const PString & key, PInt64 dflt = 0 ) const
key - The key name for the variable.
dflt - Default value for the variable.void SetInt64( const PString & key, PInt64 value )
value - New value to set for the variable.void SetInt64( const PString & section, const PString & key, PInt64 value )
key - The key name for the variable.
value - New value to set for the variable.double GetReal( const PString & key, double dflt = 0 ) const
dflt - Default value for the variable.double GetReal( const PString & section, const PString & key, double dflt = 0 ) const
key - The key name for the variable.
dflt - Default value for the variable.void SetReal( const PString & key, double value )
value - New value to set for the variable.void SetReal( const PString & section, const PString & key, double value )
key - The key name for the variable.
value - New value to set for the variable.PTime GetTime( const PString & key ) const
PTime GetTime( const PString & key, const PTime & dflt ) const
dflt - Default value for the variable.PTime GetTime( const PString & section, const PString & key ) const
key - The key name for the variable.PTime GetTime( const PString & section, const PString & key, const PTime & dflt ) const
key - The key name for the variable.
dflt - Default value for the variable.void SetTime( const PString & key, const PTime & value )
value - New value to set for the variable.void SetTime( const PString & section, const PString & key, const PTime & value )
key - The key name for the variable.
value - New value to set for the variable.
Alphabetic index HTML hierarchy of classes or Java