Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: src/shared/Registry.h

Issue 5171515343503360: Issue #41 - Bring method of determining IE version up to date (Closed)
Patch Set: simplify Registry_Key Created July 26, 2014, 5 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/shared/Registry.h
===================================================================
new file mode 100644
--- /dev/null
+++ b/src/shared/Registry.h
@@ -0,0 +1,58 @@
+#include <string>
sergei 2014/07/28 11:46:27 Where is the guard?
+#include <Windows.h>
+
+namespace AdblockPlus
+{
+ /**
+ * An open key in the system registry.
+ *
+ * This class is not completely general.
+ * In particular, it cannot encapsulate the predefined registry keys
+ * such as HKEY_CLASSES_ROOT.
+ * These classes are considered "always open",
+ * and the destructor should not close them.
+ * Rather than trying to detect these predefined keys,
+ * we simply don't allow them to be constructed.
+ * In practice, this is a limitation without much consequence.
+ * If this were a library designed for standalone use,
+ * this limitation might not be appropriate, but it's fine here.
+ */
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
+ class Registry_Key
sergei 2014/07/28 11:46:27 remove underscore
+ {
+ /**
+ * 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
+ */
+ HKEY key;
+
+ public:
+ /**
+ * Constructor to open a key as a subkey key of an existing parent.
+ * Opens the key with read-only access.
+ *
+ * The constructor throws if 'key_name' is not found,
+ * to preserve the invariant that the registry key is open.
+ * The constructor also throws if 'key_name' is empty,
+ * to preserve the invariant the the registry key is not predefinded.
+ *
+ * \param parent
+ * An open registry key. This may be one of the predefined keys.
+ * \param key_name
+ * Name of the subkey to be opened under the parent.
+ */
+ Registry_Key(HKEY parent, std::wstring key_name);
sergei 2014/07/28 11:46:27 - const references - keyName
+
+ /**
+ * Destructor always closes the key.
+ */
+ ~Registry_Key();
+
+ /**
+ * Retrieve a value from a name-value pair within the present key.
+ *
+ * Throws if the name is not found within the dictionary.
+ * Throws if the name is found but is not a string.
+ */
+ std::wstring value_wstring(std::wstring name) const;
sergei 2014/07/28 11:46:27 To be consistent with the rest code, it's better t
+ };
+}
+

Powered by Google App Engine
This is Rietveld