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
8 #include <initializer_list>
12 #include <cm/optional>
13 #include <cm/string_view>
14 #include <cmext/enum_set>
15 #include <cmext/string_view>
19 class cmWindowsRegistry
33 // Registry supported types
34 enum class ValueType
: std::uint8_t
42 using ValueTypeSet
= cm::enum_set
<ValueType
>;
44 // All types as defined by enum ValueType
45 static const ValueTypeSet AllTypes
;
46 // same as AllTYpes but without type REG_MULTI_SZ
47 static const ValueTypeSet SimpleTypes
;
49 cmWindowsRegistry(cmMakefile
&,
50 const ValueTypeSet
& supportedTypes
= AllTypes
);
52 // Helper routine to convert string to enum value
53 static cm::optional
<View
> ToView(cm::string_view name
);
54 // Helper routine to convert enum to string
55 static cm::string_view
FromView(View view
);
57 cm::optional
<std::string
> ReadValue(cm::string_view key
,
58 View view
= View::Both
,
59 cm::string_view separator
= "\0"_s
)
61 return this->ReadValue(key
, ""_s
, view
, separator
);
63 cm::optional
<std::string
> ReadValue(cm::string_view key
,
65 View view
= View::Both
,
66 cm::string_view separator
= "\0"_s
);
68 cm::optional
<std::vector
<std::string
>> GetValueNames(cm::string_view key
,
69 View view
= View::Both
);
70 cm::optional
<std::vector
<std::string
>> GetSubKeys(cm::string_view key
,
71 View view
= View::Both
);
73 // Expand an expression which may contains multiple references
75 // Depending of the view specified, one or two expansions can be done.
76 cm::optional
<std::vector
<std::string
>> ExpandExpression(
77 cm::string_view expression
, View view
, cm::string_view separator
= "\0"_s
);
79 cm::string_view
GetLastError() const;
82 #if defined(_WIN32) && !defined(__CYGWIN__)
83 std::vector
<View
> ComputeViews(View view
);
86 ValueTypeSet SupportedTypes
= AllTypes
;
88 std::string LastError
;