/** * @file include/ActivMiddleware/ActivBase/Windows/RegistryHelper.h * * @brief Header file for the registry helper class. */ #if (!defined ACTIV_BASE_WINDOWS_REGISTRY_HELPER_H) #define ACTIV_BASE_WINDOWS_REGISTRY_HELPER_H #include "ActivMiddleware/ActivBase/External.h" //! Activ namespace. namespace Activ { /** * @brief Registry helper class. * * RegistryHelper wraps up methods for getting, setting and deleting registry values, * deleting registry keys and enumerating keys and values. */ class RegistryHelper { public: /** * @brief Enumeration of basic types supported by RegistryHelper. */ enum Type { TYPE_UNSUPPORTED, ///< Unsupported type. TYPE_UNSIGNED32, ///< Unsigned 32 bit type. TYPE_STRING, ///< 0 terminated string type. TYPE_BINARY ///< Variable length binary type. }; /** * @brief Destructor. */ ACTIV_BASE_API virtual ~RegistryHelper(); /** * @brief Get an UNSIGNED32 value. * * @param keyName the full name of the key holding the value to retrieve. * @param valueName the name of the value within key \a keyName to retrieve. * @param value on success, the retrieved value is stored in \a value. * * @throw OsException * @throw BaseException */ ACTIV_BASE_API static void GetValue(const char *keyName, const char *valueName, uint32_t &value); /** * @brief Get a STRING value. * * @param keyName the full name of the key holding the value to retrieve. * @param valueName the name of the value within key \a keyName to retrieve. * @param value to receive the string. * * @throw OsException * @throw BaseException */ ACTIV_BASE_API static void GetValue(const char *keyName, const char *valueName, String &value); /** * @brief Get a BINARY value. * * @param keyName the full name of the key holding the value to retrieve. * @param valueName the name of the value within key \a keyName to retrieve. * @param value on success, the retrieved buffer is stored in \a value. * @param maxValueLen the size of the buffer pointed to by \a value. * On success, maxValueLen will contain the length of the retrieved buffer. * * @throw OsException * @throw BaseException */ ACTIV_BASE_API static void GetValue(const char *keyName, const char *valueName, void *value, uint32_t &maxValueLen); /** * @brief Set an UNSIGNED32 value. * * @param keyName the full name of the key in which to set the value. * @param valueName the name of the value within key \a keyName to set. * @param value the UNSIGNED32 value to set. * * @throw OsException */ ACTIV_BASE_API static void SetValue(const char *keyName, const char *valueName, const uint32_t value); /** * @brief Set a STRING value. * * @param keyName the full name of the key in which to set the value. * @param valueName the name of the value within key \a keyName to set. * @param value the string to set the value to. * * @throw OsException */ ACTIV_BASE_API static void SetValue(const char *keyName, const char *valueName, const String &value); /** * @brief Set a BINARY value. * * @param keyName the full name of the key in which to set the value. * @param valueName the name of the value within key \a keyName to set. * @param value pointer to the buffer to store. * @param valueLen the length of the buffer pointer to by \a value. * * @throw OsException */ ACTIV_BASE_API static void SetValue(const char *keyName, const char *valueName, const void *value, const uint32_t valueLen); /** * @brief Delete a key and all sub keys. * * @param keyName the full name of the key to delete. * * @throw OsException */ ACTIV_BASE_API static void DeleteKey(const char *keyName); /** * @brief Delete a value from a key. * * @param keyName the full name of the key containing the value to delete. * @param valueName the name of the value to delete. * * @throw OsException */ ACTIV_BASE_API static void DeleteValue(const char *keyName, const char *valueName); /** * @brief Enumerate all sub keys of a given key. * * The OnKey() callback will be invoked for all sub keys of the given key. * * @param keyName the full name of the root key to enumerate from. * * @return the number of keys enumerated. */ ACTIV_BASE_API size_t EnumerateKeys(const char *keyName); /** * @brief Enumerate all values of a given key. * * The OnValue() callback will be invoked for all values within the given key. * * @param keyName the full name of the key to enumerate values from. * * @return the number of values enumerated. */ ACTIV_BASE_API size_t EnumerateValues(const char *keyName); protected: /** * @brief The callback invoked by EnumerateKeys(). * * @param fullKeyName the full key name, including all parent keys. * @param keyName the key name only. * @param index the index of the key within it's parent key, 0 based. * * @return false to stop enumerating more keys, true to continue. */ ACTIV_BASE_API virtual bool OnKey(const char *fullKeyName, const char *keyName, uint_fast32_t index); /** * @brief The callback invoked by EnumerateValues(). * * @param fullKeyName the full key name, including all parent keys. * @param valueName the name of the enumerated value within \a fullKeyName. * @param index the index of the value within it's key, 0 based. * @param type the type of the value. * * @return false to stop enumerating more values, true to continue. */ ACTIV_BASE_API virtual bool OnValue(const char *fullKeyName, const char *valueName, uint_fast32_t index, Type type); }; } // namespace Activ #endif // (!defined ACTIV_BASE_WINDOWS_REGISTRY_HELPER_H)