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

AnyConfig::AcMemConfig Class Reference

Holds an in-memory configuration. More...

#include <AnyConfig.h>

Inheritance diagram for AnyConfig::AcMemConfig::

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

Public Methods

void AddMemCfgSection (AcMemCfgSection *item)
void RemoveMemCfgSection (AcMemCfgSection *item)
void DeleteAllMemCfgSection ()
void ReplaceMemCfgSection (AcMemCfgSection *item, AcMemCfgSection *newItem)
AcMemCfgSectionGetFirstMemCfgSection () const
AcMemCfgSectionGetLastMemCfgSection () const
AcMemCfgSectionGetNextMemCfgSection (AcMemCfgSection *pos) const
AcMemCfgSectionGetPrevMemCfgSection (AcMemCfgSection *pos) const
int GetMemCfgSectionCount () const
 AcMemConfig ()
 Constructor method. More...

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

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

virtual void copyTo (CString &rCString)
 Copy this configuration to a stringified representation. More...

virtual AcConfigurationcreateFromSection (const char *section)
 Extract a sub-configuration containing only the indicated section. More...

virtual void display ()
 Mostly for debugging purposes, display the configuration. More...

virtual bool getSectionStr (const char *pSection, const char *pKey, CString &rValue)
 Like getStr() but can fetch keys from another section than the current one. More...

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

virtual bool initialize (const char *fromString)
 Build a configuration from a stringified representation. 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 setSectionStr (const char *pSection, const char *pKey, const char *pValue)
 Like setStr() but can set keys in another section than the current one. More...

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

AcMemCfgSectionFindEqualOrBiggerMemCfgSection (const CString &section)
AcMemCfgSectionFindEqualOrSmallerMemCfgSection (const CString &section)
AcMemCfgSectionFindMemCfgSection (const CString &section)
AcMemCfgSectionFindReverseMemCfgSection (const CString &section)

Protected Methods

virtual AcMemCfgItemfindItem (const char *pSection, const char *pKey)
 Return a pointer to the specified key in the current section, if both exist. 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

AcMemCfgSection_topMemCfgSection
int _countMemCfgSection

Detailed Description

Holds an in-memory configuration.

This configuration class is mostly used for activities like copying configurations or buffering ones that are expensive to use directly. It also allows to "bootstrap" the configuration system by programmatically creating an initial parent configuration.


Constructor & Destructor Documentation

AnyConfig::AcMemConfig::AcMemConfig ( )
 

Constructor method.

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

Destructor method.


Member Function Documentation

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

Method which must be called first in a constructor.

Reimplemented from AnyConfig::AcWriteableConfig.

Reimplemented in AnyConfig::AcBufFileConfig.

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

Method which must be called first in a destructor.

Reimplemented from AnyConfig::AcWriteableConfig.

Reimplemented in AnyConfig::AcBufFileConfig.

void AnyConfig::AcMemConfig::copyTo ( CString & rCString ) [virtual]
 

Copy this configuration to a stringified representation.

Parameters:
string   The stringified representation on return.

bool AnyConfig::AcMemConfig::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.

AcConfiguration * AnyConfig::AcMemConfig::createFromSection ( const char * section ) [virtual]
 

Extract a sub-configuration containing only the indicated section.

Parameters:
section   The section to extract.
Returns:
An AcConfiguration pointer if the section existed or NULL if it didn't or the derived class does not support this operation. The returned configuration will already have its one and only section selected.

Note to implementors:
If your implementation returns a specialized sub-class for this, make sure it is either not an AcWriteableConfig implementation or if it is that writing to it does not alter the original section's information.
Probably your best solution is to return an AcMemConfig with a copy of the section, like the original classes do.

Reimplemented from AnyConfig::AcConfiguration.

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

Mostly for debugging purposes, display the configuration.

Reimplemented from AnyConfig::AcConfiguration.

Reimplemented in AnyConfig::AcBufFileConfig.

AcMemCfgItem * AnyConfig::AcMemConfig::findItem ( const char * pSection,
const char * pKey ) [protected, virtual]
 

Return a pointer to the specified key in the current section, if both exist.

Parameters:
pKey   The key to find.
Returns:
Either the pointer to the item found or NULL if the section or key did not exist.

bool AnyConfig::AcMemConfig::getSectionStr ( const char * pSection,
const char * pKey,
CString & rValue ) [virtual]
 

Like getStr() but can fetch keys from another section than the current one.

The default implementation just pushes _currentSection on stack, replaces it with the supplied section and calls the regular getStr() function.

Parameters:
pKey   The key to fetch.
pSection   The section to fetch it from.
rValue   The value found, if any.
Returns:
False if the key could not be found in the specified section.

Reimplemented from AnyConfig::AcConfiguration.

bool AnyConfig::AcMemConfig::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::AcMemConfig::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.

Reimplemented in AnyConfig::AcBufFileConfig.

bool AnyConfig::AcMemConfig::initialize ( const char * fromString ) [virtual]
 

Build a configuration from a stringified representation.

Parameters:
fromString   The string representation of a configuration.
Returns:
False if the conversion failed.

bool AnyConfig::AcMemConfig::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::AcMemConfig::setSectionStr ( const char * pSection,
const char * pKey,
const char * pValue ) [virtual]
 

Like setStr() but can set keys in another section than the current one.

The default implementation just pushes _currentSection on stack, replaces it with the supplied section and calls the regular setStr() function.

Parameters:
pKey   The key to set.
pSection   The section to set it in.
pValue   The value to set it to.

Reimplemented from AnyConfig::AcWriteableConfig.

void AnyConfig::AcMemConfig::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:19 2001 for AnyConfig by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001