1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
5 #include "cmConfigure.h" // IWYU pragma: keep
7 #include <cstdint> // IWYU pragma: keep
11 #include <cm/optional>
12 #include <cm/string_view>
13 #include <cmext/enum_set>
14 #include <cmext/string_view>
18 class cmWindowsRegistry
32 // Registry supported types
33 enum class ValueType : std::uint8_t
41 using ValueTypeSet = cm::enum_set<ValueType>;
43 // All types as defined by enum ValueType
44 static const ValueTypeSet AllTypes;
45 // same as AllTYpes but without type REG_MULTI_SZ
46 static const ValueTypeSet SimpleTypes;
48 cmWindowsRegistry(cmMakefile&,
49 const ValueTypeSet& supportedTypes = AllTypes);
51 // Helper routine to convert string to enum value
52 static cm::optional<View> ToView(cm::string_view name);
53 // Helper routine to convert enum to string
54 static cm::string_view FromView(View view);
56 cm::optional<std::string> ReadValue(cm::string_view key,
57 View view = View::Both,
58 cm::string_view separator = "\0"_s)
60 return this->ReadValue(key, ""_s, view, separator);
62 cm::optional<std::string> ReadValue(cm::string_view key,
64 View view = View::Both,
65 cm::string_view separator = "\0"_s);
67 cm::optional<std::vector<std::string>> GetValueNames(cm::string_view key,
68 View view = View::Both);
69 cm::optional<std::vector<std::string>> GetSubKeys(cm::string_view key,
70 View view = View::Both);
72 // Expand an expression which may contains multiple references
74 // Depending of the view specified, one or two expansions can be done.
75 cm::optional<std::vector<std::string>> ExpandExpression(
76 cm::string_view expression, View view, cm::string_view separator = "\0"_s);
78 cm::string_view GetLastError() const;
81 #if defined(_WIN32) && !defined(__CYGWIN__)
82 std::vector<View> ComputeViews(View view);
85 ValueTypeSet SupportedTypes = AllTypes;
87 std::string LastError;