C++ Based OPC UA Client/Server/PubSub SDK
1.7.3.505
|
The UaSettings class provides persistent platform-independent application settings. More...
#include <uasettings.h>
Public Types | |
enum | Scope { UserScope = 0, SystemScope = 1 } |
Scope enumeration. More... | |
Public Member Functions | |
UaSettings (const UaUniString &sOrganization, const UaUniString &sApplication, Scope scope=UserScope) | |
construction Get the needed variables to create the path to the INI file. More... | |
UaSettings (const UaUniString &sPath) | |
construction Get the path to the already created INI file and call method to read it out. More... | |
~UaSettings () | |
destruction calls the private method writeIniFile() to write all values out of the map into the ini file. | |
void | sync () |
Writes any unsaved changes to permanent storage. | |
UaUniString | organizationName () const |
Get the name of the organization. More... | |
UaUniString | applicationName () const |
Get the name of the application. More... | |
Scope | scope () const |
Get the actual used scope. More... | |
void | beginGroup (const UaUniString &sGroup) |
Appends a prefix to the current group. More... | |
void | removeKey (const UaUniString &sKey) |
Removes the setting sKey. More... | |
void | setValue (const UaUniString &sKey, const UaVariant &value) |
Sets the value of setting sKey to value. More... | |
UaUniString | endGroup () |
Resets the group to what it was before the corresponding beginGroup() call. More... | |
UaUniString | group () |
Returns the current group. More... | |
UaUniStringList | childGroups () const |
Returns a list of all key top-level groups that contain keys that can be read using the UaSettings object. More... | |
UaUniStringList | childKeys () const |
Returns a list of all top-level keys that can be read using the UaSettings object. More... | |
UaVariant | value (const UaUniString &sKey, const UaVariant &defaultValue=UaVariant()) |
Returns the value for setting sKey. More... | |
bool | contains (const UaUniString &sKey) |
Checks if the given sKey exists in the current group. More... | |
The UaSettings class provides persistent platform-independent application settings.
Users normally expect an application to remember its settings (window sizes and positions, options, etc.) across sessions. This information is often stored in the system registry on Windows. On Unix systems, many applications (including the KDE applications) use INI text files. UaSettings is an abstraction around these technologies, enabling you to save and restore application settings in a portable manner. UaSettings's API is based on UaVariant, allowing you to save most value-based types, such as UaString with the minimum of effort.
UaSettings::UaSettings | ( | const UaUniString & | sOrganization, |
const UaUniString & | sApplication, | ||
Scope | scope = UserScope |
||
) |
construction Get the needed variables to create the path to the INI file.
sOrganization | the name of the organization. |
sApplication | the name of the application. |
scope | the scope of the user or of the system. |
UaSettings::UaSettings | ( | const UaUniString & | sPath | ) |
construction Get the path to the already created INI file and call method to read it out.
sPath | the path to the existing INI file. |
|
inline |
Get the name of the application.
void UaSettings::beginGroup | ( | const UaUniString & | sGroup | ) |
Appends a prefix to the current group.
The current group is automatically added in front of all keys specified to UaSettings. Groups are useful to avoid typing in the same setting paths over and over. For example:
sGroup | the group you want to have. |
UaUniStringList UaSettings::childGroups | ( | ) | const |
Returns a list of all key top-level groups that contain keys that can be read using the UaSettings object.
UaUniStringList UaSettings::childKeys | ( | ) | const |
Returns a list of all top-level keys that can be read using the UaSettings object.
bool UaSettings::contains | ( | const UaUniString & | sKey | ) |
Checks if the given sKey exists in the current group.
sKey | the key to search for. |
UaUniString UaSettings::endGroup | ( | ) |
Resets the group to what it was before the corresponding beginGroup() call.
For example:
UaUniString UaSettings::group | ( | ) |
|
inline |
Get the name of the organization.
void UaSettings::removeKey | ( | const UaUniString & | sKey | ) |
Removes the setting sKey.
sKey | the key to remove from the INI file.. |
|
inline |
Get the actual used scope.
void UaSettings::setValue | ( | const UaUniString & | sKey, |
const UaVariant & | value | ||
) |
Sets the value of setting sKey to value.
If the key already exists, the previous value is overwritten. For example:
sKey | the key you want to write into the ini file. |
value | the value for the key to write into the ini file. |
UaVariant UaSettings::value | ( | const UaUniString & | sKey, |
const UaVariant & | defaultValue = UaVariant() |
||
) |
Returns the value for setting sKey.
If the setting doesn't exist, returns defaultValue. If no default value is specified, a default UaVariant is returned. For example:
sKey | the key you want to read out of the INI file. |
defaultValue | the value for the key to read out the INI file. |