Windows C++ Library
|
The facade used for reading and writing application settings. More...
#include <AppConfig.hpp>
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 §ionName, const tstring &keyName, const tstring &defaultValue) const |
Read a string value. | |
template<typename T > | |
T | readValue (const tstring §ionName, const tstring &keyName, const T &defaultValue) const |
Read a value. | |
void | readList (const tstring §ionName, const tstring &keyName, const tstring &defaultValue, StringArray &list) const |
Read a list of values. | |
void | writeString (const tstring §ionName, const tstring &keyName, const tstring &value) |
Write a string value. | |
template<typename T > | |
void | writeValue (const tstring §ionName, const tstring &keyName, const T &value) |
Write a value. | |
void | writeList (const tstring §ionName, const tstring &keyName, const StringArray &list) |
Write a list of values. | |
void | deleteSection (const tstring §ionName) |
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. |
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.
typedef std::vector<tstring> WCL::AppConfig::StringArray |
An array based list of strings.
WCL::AppConfig::AppConfig | ( | const tstring & | publisher, |
const tstring & | application | ||
) |
Constructor.
Destructor.
Get the current storage mechanism.
void WCL::AppConfig::setStorageType | ( | Storage | storage | ) |
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.
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.
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.
AppConfig::Storage WCL::AppConfig::determineProvider | ( | ) | const [private] |
Determine which provider to use.
IConfigProviderPtr WCL::AppConfig::getProvider | ( | ) | const [private] |
Get the provider.
The provider is created on-demand and then cached for subsequent queries.
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.
IConfigProviderPtr WCL::AppConfig::m_provider [mutable, private] |
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.