Configuration Manager
Topics
:Overview
Conditional Directives
Functions
The configuration manager class is used to load program parameters from a text based (ASCII) configuration file. This allows specified program parameters to be changed without having to recompile the program. Users or the program itself can customize the application simply by modifying the text based configuration file named within the application.
Each configurable parameter is assigned a case-sensitive name in the file followed by an equal sign, then a value. The first character of a parameter name must be alphanumeric. If the first character is not alphanumeric the line will be ignored. The configuration manager can read strings, integer, or floating point values from the text file. A number sign or a semicolon precedes comments in the configuration file. The following is an example of a program configuration file:
# Define a signed long integer value Long=2147483647 # This comment will be ignored # Define a signed short integer value Int = 32768 # Define a double precision floating point value Float= 1.12345 # Define a character string value String=YES
There can only be one instance of a parameter name in the file. If a parameter is named two or more times, the configuration manager will use the first one it finds and ignore all others. Limits and default values for each parameter must be defined within the application itself. The application is responsible for creating the configurable parameters in the file. This version of the configuration manager allows you to update any changes to existing values. If the parameter you are changing does not exist, the parameter name and value will be written to the configuration file.
The following conditional directives are used to define non-portable file routines that need to be ported between UNIX and WIN32 platforms.
__UNIX__ - Directive used for all UNIX compilers
__WIN32__ - Directive used for all WIN32 compilers
__BCC32__ - Directive required for all BCC32 compilers
gxConfig::gxConfig()
gxConfig::~gxConfig()
gxConfig::ChangeConfigValue()
gxConfig::FilterComments()
gxConfig::GetCommentChar()
gxConfig::GetDFPValue()
gxConfig::GetFileName()
gxConfig::GetFloatValue()
gxConfig::GetIntValue()
gxConfig::GetLongValue()
gxConfig::GetParmID()
gxConfig::GetStrValue()
gxConfig::Load()
gxConfig::ReLoad()
gxConfig::ReadComments()
gxConfig::SetCommentChar()
gxConfig::SetFileName()
gxConfig::SetParmID()
gxConfig::UnLoad()
gxConfig::WriteCommentLine()
gxConfig::WriteConfigLine()
gxConfig::WriteLine()
gxConfig::gxConfig()
- Class constructor used to construct a configuration file object.gxConfig::gxConfig(const gxString &fname)
- Class constructor used to construct a configuration file object and set the name of the configuration file.gxConfig::gxConfig(char *fname)
- Class constructor used to construct a configuration file object and set the name of the configuration file.gxConfig::gxConfig(const char *fname)
- Class constructor used to construct a configuration file object and set the name of the configuration file.gxConfig::gxConfig(const gxString &fname, const gxString &p_id)
- Class constructor used to construct a configuration file object and set the name of the configuration file and the string value that will be used to identify parameter values within the file.gxConfig::gxConfig(const gxString &fname, char *p_id)
- Class constructor used to construct a configuration file object and set the name of the configuration file and the string value that will be used to identify parameter values within the file.gxConfig::gxConfig(const gxString &fname, const char *p_id)
- Class constructor used to construct a configuration file object and set the name of the configuration file and the string value that will be used to identify parameter values within the file. - Class destructor responsible for clearing the list and de-allocating all the nodes when a gxConfig object is destroyed.int gxConfig::ChangeConfigValue(const gxString &parm, const gxString &value)
- Public member function used to a modify a configuration file user-defined string value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const char *parm, const gxString &value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const gxString &parm, unsigned value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const char *parm, unsigned value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(char *parm, unsigned value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const gxString &parm, long value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const char *parm, long value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(char *parm, long value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const gxString &parm, float value)
Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const char *parm, float value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(char *parm, float value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const gxString &parm, double value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const gxString &parm, const char *value)
Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const char *parm, double value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(char *parm, double value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(char *parm, const gxString &value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const gxString &parm, char *value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const char *parm, const char *value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(char *parm, char *value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const gxString &parm, int value)
Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(const char *parm, int value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.int gxConfig::ChangeConfigValue(char *parm, int value)
- Public member function used to a modify a configuration file value. NOTE: All parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configuration file parameter. By default an equal sign will be used as a parameter ID.void gxConfig::FilterComments()
- Public member function used to force the configuration manager to ignore all lines starting with a comment ID when the configuration file is loaded from disk.char gxConfig::GetCommentChar()
- Public member function that returns the character value currently being used by the configuration manager to filter comments from a file.double gxConfig::GetDFPValue(char *Name, int fn=1)
- Public member function used to read a double precision floating point value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.double gxConfig::GetDFPValue(const char *Name, int fn=1)
- Public member function used to read a double precision floating point value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.double gxConfig::GetDFPValue(const gxString &Name, int fn=1)
- Public member function used to read a double precision floating point value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found. - Public member function used to get the name of the current configuration file.double gxConfig::GetFloatValue(char *Name, int fn=1)
- Public member function used to read a double precision floating point value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.double gxConfig::GetFloatValue(const char *Name, int fn=1)
- Public member function used to read a double precision floating point value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.double gxConfig::GetFloatValue(const gxString &Name, int fn=1)
- Public member function used to read a double precision floating point value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.int gxConfig::GetIntValue(char *Name, int fn=1)
- Public member function used to read an integer value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.int gxConfig::GetIntValue(const char *Name, int fn=1)
- Public member function used to read an integer value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.int gxConfig::GetIntValue(const gxString &Name, int fn=1)
- Public member function used to read an integer value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.long gxConfig::GetLongValue(char *Name, int fn=1)
- Public member function used to read a long integer value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.long gxConfig::GetLongValue(const char *Name, int fn=1)
- Public member function used to read a long integer value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found.long gxConfig::GetLongValue(const gxString &Name, int fn=1)
- Public member function used to read a long integer value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns zero if the parameter name is not found. - Public member function that returns the character string currently being used by the configuration manager to identify configurable parameters.char* gxConfig::GetStrValue(char *Name, int fn=1)
- Public member function used to read a string value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns a null value if the parameter name is not found.char* gxConfig::GetStrValue(const char *Name, int fn=1)
- Public member function used to read a string value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns a null value if the parameter name is not found.char* gxConfig::GetStrValue(const gxString &Name, int fn=1)
- Public member function used to read a string value from the configurable parameter list loaded in memory by the gxConfig::Load() function. This function searches for the configurable parameter list based on the "Name" variable and will search using the full name unless the "fn" variable is false. Returns a null value if the parameter name is not found. - Public member function used to load all the configurable names and values after the configuration file has been named by the gxConfig class constructor or a call to the gxConfig::SetFileName() function. Returns false if the file cannot be opened or a memory allocation error occurred.int gxConfig::Load(char *fname)
- Public member function used to load all the configurable names and values from the specified file. Returns false if the file cannot be opened or a memory allocation error occurred.int gxConfig::Load(const char *fname)
- Public member function used to load all the configurable names and values from the specified file. Returns false if the file cannot be opened or a memory allocation error occurred.int gxConfig::Load(const gxString &fname)
- Public member function used to load all the configurable names and values from the specified file. Returns false if the file cannot be opened or a memory allocation error occurred. - Public member function used to reload the configurable names and values after the configuration file has been named by the gxConfig class constructor or a call to the gxConfig::SetFileName() function. Returns false if the file cannot be opened or a memory allocation error occurred.int gxConfig::ReLoad(char *fname)
- Public member function used to reload configurable names and values from the specified file. Returns false if the file cannot be opened or a memory allocation error occurred.int gxConfig::ReLoad(const char *fname)
- Public member function used to reload configurable names and values from the specified file. Returns false if the file cannot be opened or a memory allocation error occurred.int gxConfig::ReLoad(const gxString &fname)
- Public member function used to reload configurable names and values from the specified file. Returns false if the file cannot be opened or a memory allocation error occurred. - Public member function used to force the configuration manager to read all lines starting with a comment ID when the configuration file is loaded from disk.void gxConfig::SetCommentChar(char c)
- Public member function used to set the character value used by the configuration manager to identify comment strings in the configuration file.void gxConfig::SetFileName(const gxString &s)
- Public member function used to set the name of the configuration file.void gxConfig::SetFileName(const char *s)
- Public member function used to set the name of the configuration file.void gxConfig::SetFileName(char *s)
- Public member function used to set the name of the configuration file.void gxConfig::SetParmID(const gxString &s)
- Public member function used to set the string value used by the configuration manager to identify configurable parameters in the configuration file. By default an equal sign will be used as a parameter ID.void gxConfig::SetParmID(char *s)
- Public member function used to set the string value used by the configuration manager to identify configurable parameters in the configuration file. By default an equal sign will be used as a parameter ID.void gxConfig::SetParmID(const char *s)
- Public member function used to set the string value used by the configuration manager to identify configurable parameters in the configuration file. By default an equal sign will be used as a parameter ID. - Public member function used to unload all the configurable names and values from memory.int gxConfig::WriteCommentLine(const gxString &s)
- Public member function used to write a comment line to the configuration file. NOTE: Do not include the comment ID character. The comment ID will by automatically inserted. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteCommentLine(const char *s)
- Public member function used to write a comment line to the configuration file. NOTE: Do not include the comment ID character. The comment ID will by automatically inserted. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteCommentLine(char *s)
- Public member function used to write a comment line to the configuration file. NOTE: Do not include the comment ID character. The comment ID will by automatically inserted. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteConfigLine(const gxString &parm, const gxString &value)
- Public member function used to write a line to the configuration file. NOTE: Parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configurable file parameter. By default an equal sign will be used as a parameter ID. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteConfigLine(const char *parm, const char *value)
- Public member function used to write a line to the configuration file. NOTE: Parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configurable file parameter. By default an equal sign will be used as a parameter ID. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteConfigLine(char *parm, char *value)
- Public member function used to write a line to the configuration file. NOTE: Parameter values should not contain a parameter ID label at the end of the string. The parameter ID label will be added to mark it as a configurable file parameter. By default an equal sign will be used as a parameter ID. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteLine(const gxString &s)
- Public member function used to write a line of text to the configuration file. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteLine(const char *s)
- Public member function used to write a line of text to the configuration file. Returns zero if an error occurs or one to indicate that the line was written successfully.int gxConfig::WriteLine(char *s)
- Public member function used to write a line of text to the configuration file. Returns zero if an error occurs or one to indicate that the line was written successfully.
End Of Document |