C12Adapter Opensource C++ Interface
|
Provides the access to Windows registry, system dependent class. More...
Public Types | |
enum | PredefinedKeyEnum { KeyClassesRoot = 0, KeyCurrentUser = 1, KeyLocalMachine = 2, KeyUsers = 3 } |
Key type within the registry, determines the location of the registry hive. More... | |
Public Member Functions | |
MRegistry () | |
Creates an empty uninitialized registry access object. More... | |
MRegistry (const MRegistry &parent, const MStdString &subLocation) | |
Creates a sub-entry of the given opened registry object. More... | |
virtual | ~MRegistry () |
Object destructor, closes the registry access object and frees the resources. | |
MStdStringVector | GetAllSubkeys () const |
Get the list of subkeys in the registry. More... | |
MStdStringVector | GetAllValues () const |
Get the list of value names in the registry access object. More... | |
bool | IsOpen () const |
Tells whether the registry is open. More... | |
bool | IsReadOnly () const |
Tells whether the registry access object is read-only. More... | |
void | Open (PredefinedKeyEnum parentKey, const MStdString &location, bool readonly) |
Open the registry folder for the desired access. More... | |
void | OpenSubkey (const MRegistry &parent, const MStdString &subLocation) |
Open a sub-entry of the given opened registry object. More... | |
void | Close () |
Make sure the changes are flushed into persistent storage and close the registry. More... | |
bool | IsPresent (const MStdString &keyOrValue) const |
Whether the key or value with such name is present in the open registry access object. More... | |
bool | IsSubkeyPresent (const MStdString &key) const |
Whether the key with such name is present in the open registry access object. More... | |
bool | IsValuePresent (const MStdString &valueName) const |
Whether the value with such name is present in the open registry access object. More... | |
MStdString | GetString (const MStdString &valueName, const MStdString &defaultValue) const |
Get the string representation of the value name, or default if value with such name does not exist. More... | |
MStdString | GetExistingString (const MStdString &valueName) const |
Get the string representation of the value associated with the value name given. More... | |
int | GetInteger (const MStdString &valueName, int defaultValue) const |
Get the integer representation of the value name, or default if value with such name does not exist. More... | |
int | GetExistingInteger (const MStdString &valueName) const |
Get the integer representation of the value associated with the value name given. More... | |
MByteString | GetBinary (const MStdString &valueName, const MByteString &defaultValue) const |
Get the binary representation of the value name, or default if value with such name does not exist. More... | |
MByteString | GetExistingBinary (const MStdString &valueName) const |
Get the binary representation of the value associated with the value name given. More... | |
void | SetString (const MStdString &valueName, const MStdString &value) |
Associate the given string value with the name. More... | |
void | SetInteger (const MStdString &valueName, int value) |
Associate the given integer value with the name. More... | |
void | SetBinary (const MStdString &valueName, const MByteString &value) |
Associate the given binary value with the name. More... | |
void | Remove (const MStdString &keyOrValue) |
Remove either the key or the value with such name from the registry access object. More... | |
void | RemoveValue (const MStdString &valueName) |
Remove value with such name from the registry access object. More... | |
void | RemoveSubkey (const MStdString &key) |
Remove key with such name from the registry. More... | |
void | CheckIfOpen () const |
Check if the registry access object is open, throw an exception otherwise. More... | |
MRegistry (PredefinedKeyEnum parentKey, const MStdString &location, bool readonly) | |
MRegistry (PredefinedKeyEnum parentKey, const char *location, bool readonly) | |
![]() | |
virtual | ~MObject () |
Object destructor. | |
virtual const MClass * | GetClass () const =0 |
Get the final class of the object. More... | |
virtual unsigned | GetEmbeddedSizeof () const |
For embedded object types, return the size of the class. More... | |
bool | IsEmbeddedObject () const |
Tell if the object is of embedded kind. More... | |
SHOW_INTERNAL MVariant | Call (const MStdString &name, const MVariant ¶ms) |
Call the object service with parameters, given as variant. More... | |
MVariant | Call0 (const MStdString &name) |
Call the object service with no parameters. More... | |
MVariant | Call1 (const MStdString &name, const MVariant &p1) |
Call the object service with one parameter. More... | |
MVariant | Call2 (const MStdString &name, const MVariant &p1, const MVariant &p2) |
Call the object service with two parameter. More... | |
MVariant | Call3 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3) |
Call the object service with three parameter. More... | |
MVariant | Call4 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4) |
Call the object service with four parameter. More... | |
MVariant | Call5 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5) |
Call the object service with five parameter. More... | |
MVariant | Call6 (const MStdString &name, const MVariant &p1, const MVariant &p2, const MVariant &p3, const MVariant &p4, const MVariant &p5, const MVariant &p6) |
Call the object service with six parameter. More... | |
virtual MVariant | CallV (const MStdString &name, const MVariant::VariantVector ¶ms) |
Call the object service with parameters, given as variant vector. More... | |
virtual bool | IsPropertyPresent (const MStdString &name) const |
Tell if the property with the given name exists. | |
virtual bool | IsServicePresent (const MStdString &name) const |
Tell if the service with the given name exists. | |
virtual MVariant | GetProperty (const MStdString &name) const |
Get the property value using name of the property. More... | |
virtual void | SetProperty (const MStdString &name, const MVariant &value) |
Set the property using name of the property, and value. More... | |
virtual MStdStringVector | GetAllPropertyNames () const |
Return the list of publicly available properties, persistent or not. More... | |
virtual MStdStringVector | GetAllPersistentPropertyNames () const |
Return the list of persistent properties. More... | |
virtual void | SetPersistentPropertiesToDefault () |
Set the persistent properties of the object to their default values. More... | |
virtual MVariant | GetPersistentPropertyDefaultValue (const MStdString &name) const |
Get the default value of persistent property with the name given. More... | |
virtual void | SetPersistentPropertyToDefault (const MStdString &name) |
Set the persistent property with the name given to default value. More... | |
virtual const char * | GetType () const |
Get the name of the type for the object (could be the same as class name). | |
virtual void | SetType (const MStdString &) |
Intentionally, it will set the name of the type for the object, but the service will not allow setting the name to anything other than the current name. More... | |
virtual void | Validate () |
Validate internal structures of the object. More... | |
Additional Inherited Members | |
![]() | |
static const MClass * | GetStaticClass () |
Get the declared class of this particular object. More... | |
static bool | IsClassPresent (const MStdString &name) |
Tells if the given class name is available. More... | |
![]() | |
static const MClass | s_class |
Class of MObject. | |
![]() | |
MObject () | |
Object constructor, protected as the class is abstract. | |
void | DoSetPersistentPropertiesToDefault (const MClass *staticClass) |
Set the persistent properties to their default values for one object provided the class for that object. More... | |
Provides the access to Windows registry, system dependent class.
Only string data types are supported for values, however MRegistry provides services that allow handling them as integers. There is no check provided, and for example, one can store 1.2 as string, and read it as a rounded integer, or vice versa.
It is possible to request read-only access to a registry.
Key type within the registry, determines the location of the registry hive.
MRegistry::MRegistry | ( | ) |
Creates an empty uninitialized registry access object.
|
explicit |
Initializes the registry from location.
It allows opening global versus user registry access object, as read-only or read-write.
parentKey | Predefined key to use as parent, any of these enumeration values: |
location | A string that defines the location within the registry, as described in class header. |
readonly | When true, the registry is opened in read-only mode. Otherwise, and this is the default, the registry is open for both reading and writing. |
|
explicit |
Initializes the registry from location.
It allows opening global versus user registry access object, as read-only or read-write.
parentKey | Predefined key to use as parent, any of these enumeration values: |
location | A string that defines the location within the registry, as described in class header. |
readonly | When true, the registry is opened in read-only mode. Otherwise, and this is the default, the registry is open for both reading and writing. |
MRegistry::MRegistry | ( | const MRegistry & | parent, |
const MStdString & | subLocation | ||
) |
Creates a sub-entry of the given opened registry object.
When there is already an open registry, and there is a need to access its "subdirectory", this method is both a convenience and performance improvement. The read-only flag is copied from the parent.
parent | An open registry to use for creation of its child. |
subLocation | Location relative to parent where to open the result registry access object |
void MRegistry::CheckIfOpen | ( | ) | const |
void MRegistry::Close | ( | ) |
Make sure the changes are flushed into persistent storage and close the registry.
If the registry access object was not open prior to this method, it will succeed by doing nothing.
MStdStringVector MRegistry::GetAllSubkeys | ( | ) | const |
Get the list of subkeys in the registry.
MStdStringVector MRegistry::GetAllValues | ( | ) | const |
Get the list of value names in the registry access object.
MByteString MRegistry::GetBinary | ( | const MStdString & | valueName, |
const MByteString & | defaultValue | ||
) | const |
Get the binary representation of the value name, or default if value with such name does not exist.
valueName | Name of the value in the open registry access object |
defaultValue | What to return if there is no such value in registry access object. |
MByteString MRegistry::GetExistingBinary | ( | const MStdString & | valueName | ) | const |
Get the binary representation of the value associated with the value name given.
valueName | Name of the value in the open registry access object. |
int MRegistry::GetExistingInteger | ( | const MStdString & | valueName | ) | const |
Get the integer representation of the value associated with the value name given.
valueName | Name of the value in the open registry access object. |
MStdString MRegistry::GetExistingString | ( | const MStdString & | valueName | ) | const |
Get the string representation of the value associated with the value name given.
valueName | Name of the value in the open registry access object. |
int MRegistry::GetInteger | ( | const MStdString & | valueName, |
int | defaultValue | ||
) | const |
Get the integer representation of the value name, or default if value with such name does not exist.
valueName | Name of the value in the open registry access object. |
defaultValue | What to return if there is no such value in registry access object. |
MStdString MRegistry::GetString | ( | const MStdString & | valueName, |
const MStdString & | defaultValue | ||
) | const |
Get the string representation of the value name, or default if value with such name does not exist.
valueName | Name of the value in the open registry access object. |
defaultValue | What to return if there is no such value in registry. |
|
inline |
Tells whether the registry is open.
bool MRegistry::IsPresent | ( | const MStdString & | keyOrValue | ) | const |
Whether the key or value with such name is present in the open registry access object.
keyOrValue | A subkey or value to find in the registry. |
bool MRegistry::IsReadOnly | ( | ) | const |
Tells whether the registry access object is read-only.
This property is not about the rights of the particular registry entry, but rather in which way the registry access object was opened. The same registry access object can be opened in either read-write or read-only mode, should the user have the appropriate rights.
bool MRegistry::IsSubkeyPresent | ( | const MStdString & | key | ) | const |
Whether the key with such name is present in the open registry access object.
key | A subkey to find in the registry. |
bool MRegistry::IsValuePresent | ( | const MStdString & | valueName | ) | const |
Whether the value with such name is present in the open registry access object.
The value shall not be prefixed by key, or it will not be found.
valueName | A value to find in the registry. |
void MRegistry::Open | ( | PredefinedKeyEnum | parentKey, |
const MStdString & | location, | ||
bool | readonly | ||
) |
Open the registry folder for the desired access.
parentKey | Predefined key to use as parent, any of these enumeration values: |
location | A string that defines the location within the registry, as described in class header. |
readonly | When true, the registry access object is opened in read-only mode. Otherwise, and this is the default, the registry access object is open for both reading and writing. |
void MRegistry::OpenSubkey | ( | const MRegistry & | parent, |
const MStdString & | subLocation | ||
) |
Open a sub-entry of the given opened registry object.
When there is already an open registry, and there is a need to access its "subdirectory", this method is both a convenience and performance improvement. The read-only flag is copied from the parent.
parent | An open registry to use for creation of its child. |
subLocation | Location relative to parent where to open the result registry access object |
void MRegistry::Remove | ( | const MStdString & | keyOrValue | ) |
Remove either the key or the value with such name from the registry access object.
keyOrValue | Name of the value or subkey to remove. |
void MRegistry::RemoveSubkey | ( | const MStdString & | key | ) |
Remove key with such name from the registry.
key | Name of the key to remove. |
void MRegistry::RemoveValue | ( | const MStdString & | valueName | ) |
Remove value with such name from the registry access object.
valueName | Name of the value to remove. |
void MRegistry::SetBinary | ( | const MStdString & | valueName, |
const MByteString & | value | ||
) |
Associate the given binary value with the name.
In case the registry access object item with such name does not exist, it is created, and the value is initialized to one given.
valueName | Name of the value in the registry. |
value | New value for the given name. |
void MRegistry::SetInteger | ( | const MStdString & | valueName, |
int | value | ||
) |
Associate the given integer value with the name.
In case the registry access object item with such name does not exist, it is created, and the value is initialized to one given.
valueName | Name of the value in the registry. |
value | New value for the given name. |
void MRegistry::SetString | ( | const MStdString & | valueName, |
const MStdString & | value | ||
) |
Associate the given string value with the name.
In case the registry access object item with such name does not exist, it is created, and the value is initialized to one given.
valueName | Name of the value in the registry. |
value | New value for the given name. |