Windows C++ Library
Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes
WCL::AppConfig Class Reference

The facade used for reading and writing application settings. More...

#include <AppConfig.hpp>

List of all members.

Public Types

enum  Storage { AUTOMATIC = -1, REGISTRY = 1, INIFILE = 2 }
 The storage types. More...
typedef std::vector< tstring > StringArray
 An array based list of strings.

Public Member Functions

 AppConfig (const tstring &publisher, const tstring &application)
 Constructor.
 ~AppConfig ()
 Destructor.
Storage getStorageType () const
 Get the current storage mechanism.
void setStorageType (Storage storage)
 Set the storage mechanism.
tstring readString (const tstring &sectionName, const tstring &keyName, const tstring &defaultValue) const
 Read a string value.
template<typename T >
readValue (const tstring &sectionName, const tstring &keyName, const T &defaultValue) const
 Read a value.
void readList (const tstring &sectionName, const tstring &keyName, const tstring &defaultValue, StringArray &list) const
 Read a list of values.
void writeString (const tstring &sectionName, const tstring &keyName, const tstring &value)
 Write a string value.
template<typename T >
void writeValue (const tstring &sectionName, const tstring &keyName, const T &value)
 Write a value.
void writeList (const tstring &sectionName, const tstring &keyName, const StringArray &list)
 Write a list of values.
void deleteSection (const tstring &sectionName)
 Delete the entire section.

Static Public Attributes

static const tstring DEFAULT_SECTION = TXT("")
 The name for the default section.

Private Member Functions

Storage determineProvider () const
 Determine which provider to use.
IConfigProviderPtr getProvider () const
 Get the provider.

Private Attributes

Storage m_storage
 The current storage mechanism.
IConfigProviderPtr m_provider
 The data provider.
tstring m_publisher
 The name of the publisher.
tstring m_application
 The name of the application.

Detailed Description

The facade used for reading and writing application settings.

The class encapsulates the details of where the settings are being stored, e.g. the Registry, an .ini file etc. However, it is possible to explicitly set the storage type as some users may want to do this.


Member Typedef Documentation

typedef std::vector<tstring> WCL::AppConfig::StringArray

An array based list of strings.


Member Enumeration Documentation

The storage types.

Enumerator:
AUTOMATIC 

Automatically determine the storage.

REGISTRY 

Use the Registry.

INIFILE 

Use an .ini file.


Constructor & Destructor Documentation

WCL::AppConfig::AppConfig ( const tstring &  publisher,
const tstring &  application 
)

Constructor.

Destructor.


Member Function Documentation

Get the current storage mechanism.

Set the storage mechanism.

This makes the storage mechanism explicit.

tstring WCL::AppConfig::readString ( const tstring &  sectionName,
const tstring &  keyName,
const tstring &  defaultValue 
) const

Read a string value.

template<typename T >
T WCL::AppConfig::readValue ( const tstring &  sectionName,
const tstring &  keyName,
const T &  defaultValue 
) const [inline]

Read a value.

void WCL::AppConfig::readList ( const tstring &  sectionName,
const tstring &  keyName,
const tstring &  defaultValue,
StringArray list 
) const

Read a list of values.

void WCL::AppConfig::writeString ( const tstring &  sectionName,
const tstring &  keyName,
const tstring &  value 
)

Write a string value.

template<typename T >
void WCL::AppConfig::writeValue ( const tstring &  sectionName,
const tstring &  keyName,
const T &  value 
) [inline]

Write a value.

void WCL::AppConfig::writeList ( const tstring &  sectionName,
const tstring &  keyName,
const StringArray list 
)

Write a list of values.

void WCL::AppConfig::deleteSection ( const tstring &  sectionName)

Delete the entire section.

Determine which provider to use.

Get the provider.

The provider is created on-demand and then cached for subsequent queries.


Member Data Documentation

const tstring WCL::AppConfig::DEFAULT_SECTION = TXT("") [static]

The name for the default section.

Storage WCL::AppConfig::m_storage [mutable, private]

The current storage mechanism.

The data provider.

tstring WCL::AppConfig::m_publisher [private]

The name of the publisher.

tstring WCL::AppConfig::m_application [private]

The name of the application.


The documentation for this class was generated from the following files: