| LEFT | RIGHT |
| 1 #ifndef REGISTRY_H | 1 #ifndef REGISTRY_H |
| 2 #define REGISTRY_H | 2 #define REGISTRY_H |
| 3 | 3 |
| 4 #include <string> | 4 #include <string> |
| 5 #include <Windows.h> | 5 #include <Windows.h> |
| 6 | 6 |
| 7 namespace AdblockPlus | 7 namespace AdblockPlus |
| 8 { | 8 { |
| 9 /** | 9 /** |
| 10 * An open key in the system registry. | 10 * An open key in the system registry. |
| 11 * | 11 * |
| 12 * This class is not completely general. | 12 * This class is not completely general. |
| 13 * In particular, it cannot encapsulate the predefined registry keys | 13 * In particular, it cannot encapsulate the predefined registry keys |
| 14 * such as HKEY_CLASSES_ROOT. | 14 * such as HKEY_CLASSES_ROOT. |
| 15 * These classes are considered "always open", | 15 * These classes are considered "always open", |
| 16 * and the destructor should not close them. | 16 * and the destructor should not close them. |
| 17 * Rather than trying to detect these predefined keys, | 17 * Rather than trying to detect these predefined keys, |
| 18 * we simply don't allow them to be constructed. | 18 * we simply don't allow them to be constructed. |
| 19 * In practice, this is a limitation without much consequence. | 19 * In practice, this is a limitation without much consequence. |
| 20 * If this were a library designed for standalone use, | 20 * If this were a library designed for standalone use, |
| 21 * this limitation might not be appropriate, but it's fine here. | 21 * this limitation might not be appropriate, but it's fine here. |
| 22 */ | 22 */ |
| 23 class Registry_Key | 23 class RegistryKey |
| 24 { | 24 { |
| 25 /** | 25 /** |
| 26 * Handle to registry key that is open and not predefined. | 26 * Handle to registry key that is open and not predefined. |
| 27 */ | 27 */ |
| 28 HKEY key; | 28 HKEY key; |
| 29 | 29 |
| 30 public: | 30 public: |
| 31 /** | 31 /** |
| 32 * Constructor to open a key as a subkey key of an existing parent. | 32 * Constructor to open a key as a subkey key of an existing parent. |
| 33 * Opens the key with read-only access. | 33 * Opens the key with read-only access. |
| 34 * | 34 * |
| 35 * The constructor throws if 'key_name' is not found, | 35 * The constructor throws if 'key_name' is not found, |
| 36 * to preserve the invariant that the registry key is open. | 36 * to preserve the invariant that the registry key is open. |
| 37 * The constructor also throws if 'key_name' is empty, | 37 * The constructor also throws if 'key_name' is empty, |
| 38 * to preserve the invariant the the registry key is not predefinded. | 38 * to preserve the invariant the the registry key is not predefinded. |
| 39 * | 39 * |
| 40 * \param parent | 40 * \param parent |
| 41 * An open registry key. This may be one of the predefined keys. | 41 * An open registry key. This may be one of the predefined keys. |
| 42 * \param key_name | 42 * \param key_name |
| 43 * Name of the subkey to be opened under the parent. | 43 * Name of the subkey to be opened under the parent. |
| 44 */ | 44 */ |
| 45 Registry_Key(HKEY parent, const std::wstring& key_name); | 45 RegistryKey(HKEY parent, const std::wstring& key_name); |
| 46 | 46 |
| 47 /** | 47 /** |
| 48 * Destructor always closes the key. | 48 * Destructor always closes the key. |
| 49 */ | 49 */ |
| 50 ~Registry_Key(); | 50 ~RegistryKey(); |
| 51 | 51 |
| 52 /** | 52 /** |
| 53 * Retrieve a value from a name-value pair within the present key. | 53 * Retrieve a value from a name-value pair within the present key. |
| 54 * | 54 * |
| 55 * Throws if the name is not found within the dictionary. | 55 * Throws if the name is not found within the dictionary. |
| 56 * Throws if the name is found but is not a string. | 56 * Throws if the name is found but is not a string. |
| 57 */ | 57 */ |
| 58 std::wstring value_wstring(const std::wstring& name) const; | 58 std::wstring value_wstring(const std::wstring& name) const; |
| 59 }; | 59 }; |
| 60 } | 60 } |
| 61 | 61 |
| 62 #endif | 62 #endif |
| LEFT | RIGHT |