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