Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

AnyConfig::AcFileConfig Class Reference

Uses an .INI style file for the configuration. More...

#include <AnyConfig.h>

Inheritance diagram for AnyConfig::AcFileConfig::

AnyConfig::AcWriteableConfig AnyConfig::AcConfiguration List of all members.

Public Methods

 AcFileConfig ()
 Constructor method. More...

virtual ~AcFileConfig ()
 Destructor method. More...

virtual bool copyTo (AcWriteableConfig *pWriteableConfig)
 Copy this configuration to another configuration. More...

virtual bool copyTo (FILE *pF, AcWriteableConfig *pWriteableConfig)
 Hack to use for instance stdin. More...

virtual void display ()
 Mostly for debugging purposes, write out the configuration to stdout. More...

virtual bool getStr (const char *pKey, CString &rValue)
 Retrieve a string from the configuration for the specified key. More...

virtual bool initialize (AcConfiguration &parentConfig)
 Initialize the configuration using another, probably more primitive, parent configuration. More...

virtual bool initRequired ()
 Returns true if the derived AcConfiguration requires to be initialized. More...

virtual bool keyExists (const char *pKey)
 Check if a given key exists. More...

virtual void setStr (const char *pKey, const char *pValue)
 Set the configuration item to the passed string value. More...

const CString& GetCfgFileName () const
 Returns the value of member '_cfgFileName'. More...

void SetCfgFileName (const CString &rCfgFileName)
 Set the value of member '_cfgFileName' to 'rCfgFileName'. More...


Protected Methods

virtual bool getNextItem (FILE *pf, CString &rSection, CString &rKey, CString &rValue)
 Retrieves the next key item from an opened text file. More...


Private Methods

void ConstructorInclude ()
 Method which must be called first in a constructor. More...

void DestructorInclude ()
 Method which must be called first in a destructor. More...


Private Attributes

CString _cfgFileName

Detailed Description

Uses an .INI style file for the configuration.

This is a rather inefficient implementation as it re-reads and re-writes the file whenever one of its methods are invoked. Use AcBufFileConfig instead if you have large configuration files.


Constructor & Destructor Documentation

AnyConfig::AcFileConfig::AcFileConfig ( )
 

Constructor method.

AnyConfig::AcFileConfig::~AcFileConfig ( ) [virtual]
 

Destructor method.


Member Function Documentation

void AnyConfig::AcFileConfig::ConstructorInclude ( ) [private]
 

Method which must be called first in a constructor.

Reimplemented from AnyConfig::AcWriteableConfig.

void AnyConfig::AcFileConfig::DestructorInclude ( ) [private]
 

Method which must be called first in a destructor.

Reimplemented from AnyConfig::AcWriteableConfig.

const CString & AnyConfig::AcFileConfig::GetCfgFileName ( ) const [inline]
 

Returns the value of member '_cfgFileName'.

void AnyConfig::AcFileConfig::SetCfgFileName ( const CString & rCfgFileName ) [inline]
 

Set the value of member '_cfgFileName' to 'rCfgFileName'.

bool AnyConfig::AcFileConfig::copyTo ( FILE * pF,
AcWriteableConfig * pWriteableConfig ) [virtual]
 

Hack to use for instance stdin.

Parameters:
pF   Opened and positioned FILE pointer.
pWriteableConfig   Destination configuration.

bool AnyConfig::AcFileConfig::copyTo ( AcWriteableConfig * pWriteableConfig ) [virtual]
 

Copy this configuration to another configuration.

This method is specifically handy when the source configuration comes from a text file and the destination configuration is AcMemConfig, which offers much more functionality. Along the same lines, this method can be used to save an AcMemConfig in a file. If the target configuration already has filled-in items, the result of this operation is undefined. Some derived classes may end up containing a merged result of the old and the new values (AcMemConfig, AcEnvConfig), other may only contain the copied values (like AcFileConfig).

Parameters:
pWriteableConfig   A pointer to an initialized AcWriteableConfig.
return   True if the derived configuration supports copying, false otherwise.

Reimplemented from AnyConfig::AcConfiguration.

void AnyConfig::AcFileConfig::display ( ) [virtual]
 

Mostly for debugging purposes, write out the configuration to stdout.

Reimplemented from AnyConfig::AcConfiguration.

bool AnyConfig::AcFileConfig::getNextItem ( FILE * pf,
CString & rSection,
CString & rKey,
CString & rValue ) [protected, virtual]
 

Retrieves the next key item from an opened text file.

Parameters:
pf   The opened configuration text file.
rSection   The section of the next key found.
rKey   The key name found.
rValue   The value found.
Returns:
False if there were no more key items in the file.

bool AnyConfig::AcFileConfig::getStr ( const char * pKey,
CString & rValue ) [virtual]
 

Retrieve a string from the configuration for the specified key.

Parameters:
pKey   The key to look for (in the current section).
rValue   Will be filled in with the value found.
Returns:
False if the key could not be located in the current section (if any).

Reimplemented from AnyConfig::AcConfiguration.

bool AnyConfig::AcFileConfig::initRequired ( ) [virtual]
 

Returns true if the derived AcConfiguration requires to be initialized.

See the initialize() function for the various derived classes for more details. Note that this function must return false once the initialization has been done once.

Reimplemented from AnyConfig::AcConfiguration.

bool AnyConfig::AcFileConfig::initialize ( AcConfiguration & parentConfig ) [virtual]
 

Initialize the configuration using another, probably more primitive, parent configuration.

To use the AcFileConfig class it must be initialized. Alternatively, the logFilePathName member can be set programmatically.

Parameters:
parentConfig   The parent configuration to use. For an AcFileConfig this configuration must supply the following key in the currently selected section: "CFGFILENAME=os_specific_path_name"
Returns:
False if the initialization failed.

Reimplemented from AnyConfig::AcConfiguration.

bool AnyConfig::AcFileConfig::keyExists ( const char * pKey ) [virtual]
 

Check if a given key exists.

Parameters:
key   The key to look for in [the current section in] the configuration.
Returns:
True if the key exists.

Reimplemented from AnyConfig::AcConfiguration.

void AnyConfig::AcFileConfig::setStr ( const char * pKey,
const char * pValue ) [virtual]
 

Set the configuration item to the passed string value.

Parameters:
pKey   The item to set.
pValue   The value to set it to. This must be a valid pointer to a valid C string.

Reimplemented from AnyConfig::AcWriteableConfig.


The documentation for this class was generated from the following files:
Generated at Wed Nov 21 11:34:18 2001 for AnyConfig by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001