@@ -32,8 +32,7 @@ namespace cppwinrt
3232
3333 explicit registry_key (HKEY handle) :
3434 handle(handle)
35- {
36- }
35+ {}
3736
3837 ~registry_key () noexcept
3938 {
@@ -44,8 +43,7 @@ namespace cppwinrt
4443 }
4544 };
4645
47- template <typename T>
48- struct com_ptr
46+ template <typename T> struct com_ptr
4947 {
5048 T* ptr{};
5149
@@ -91,23 +89,17 @@ namespace cppwinrt
9189 {
9290 com_ptr<IStream> stream;
9391
94- auto streamResult = SHCreateStreamOnFileW (
95- xml_path.c_str (),
96- STGM_READ, &stream.ptr );
97- if (xml_path_requirement == xml_requirement::optional &&
98- (streamResult == HRESULT_FROM_WIN32 (ERROR_FILE_NOT_FOUND) ||
99- streamResult == HRESULT_FROM_WIN32 (ERROR_PATH_NOT_FOUND)))
92+ auto streamResult = SHCreateStreamOnFileW (xml_path.c_str (), STGM_READ, &stream.ptr );
93+ if (xml_path_requirement == xml_requirement::optional && (streamResult == HRESULT_FROM_WIN32 (ERROR_FILE_NOT_FOUND) ||
94+ streamResult == HRESULT_FROM_WIN32 (ERROR_PATH_NOT_FOUND)))
10095 {
10196 return ;
10297 }
10398 check_xml (streamResult);
10499
105100 com_ptr<IXmlReader> reader;
106101
107- check_xml (CreateXmlReader (
108- __uuidof (IXmlReader),
109- reinterpret_cast <void **>(&reader.ptr ),
110- nullptr ));
102+ check_xml (CreateXmlReader (__uuidof (IXmlReader), reinterpret_cast <void **>(&reader.ptr ), nullptr ));
111103
112104 check_xml (reader->SetInput (stream.ptr ));
113105 XmlNodeType node_type = XmlNodeType_None;
@@ -153,13 +145,13 @@ namespace cppwinrt
153145 HKEY key;
154146
155147 if (0 != RegOpenKeyExW (
156- HKEY_LOCAL_MACHINE,
157- L" SOFTWARE\\ Microsoft\\ Windows Kits\\ Installed Roots" ,
158- 0 ,
159- // https://task.ms/29349404 - The SDK sometimes stores the 64 bit location into KitsRoot10 which is wrong,
160- // this breaks 64-bit cppwinrt.exe, so work around this by forcing to use the WoW64 hive.
161- KEY_READ | KEY_WOW64_32KEY,
162- &key))
148+ HKEY_LOCAL_MACHINE,
149+ L" SOFTWARE\\ Microsoft\\ Windows Kits\\ Installed Roots" ,
150+ 0 ,
151+ // https://task.ms/29349404 - The SDK sometimes stores the 64 bit location into KitsRoot10 which is
152+ // wrong, this breaks 64-bit cppwinrt.exe, so work around this by forcing to use the WoW64 hive.
153+ KEY_READ | KEY_WOW64_32KEY,
154+ &key))
163155 {
164156 throw std::invalid_argument (" Could not find the Windows SDK in the registry" );
165157 }
@@ -173,26 +165,14 @@ namespace cppwinrt
173165
174166 DWORD path_size = 0 ;
175167
176- if (0 != RegQueryValueExW (
177- key.handle ,
178- L" KitsRoot10" ,
179- nullptr ,
180- nullptr ,
181- nullptr ,
182- &path_size))
168+ if (0 != RegQueryValueExW (key.handle , L" KitsRoot10" , nullptr , nullptr , nullptr , &path_size))
183169 {
184170 throw std::invalid_argument (" Could not find the Windows SDK path in the registry" );
185171 }
186172
187173 std::wstring root ((path_size / sizeof (wchar_t )) - 1 , L' ?' );
188174
189- RegQueryValueExW (
190- key.handle ,
191- L" KitsRoot10" ,
192- nullptr ,
193- nullptr ,
194- reinterpret_cast <BYTE*>(root.data ()),
195- &path_size);
175+ RegQueryValueExW (key.handle , L" KitsRoot10" , nullptr , nullptr , reinterpret_cast <BYTE*>(root.data ()), &path_size);
196176
197177 return root;
198178 }
@@ -258,7 +238,7 @@ namespace cppwinrt
258238 char * next_part = subkey.data ();
259239 bool force_newer = false ;
260240
261- for (size_t i = 0 ; ; ++i)
241+ for (size_t i = 0 ;; ++i)
262242 {
263243 auto version_part = strtoul (next_part, &next_part, 10 );
264244
@@ -303,8 +283,7 @@ namespace cppwinrt
303283 throw std::invalid_argument (message);
304284 }
305285
306- template <typename ...T>
307- [[noreturn]] inline void throw_invalid (std::string message, T const &... args)
286+ template <typename ... T> [[noreturn]] inline void throw_invalid (std::string message, T const &... args)
308287 {
309288 (message.append (args), ...);
310289 throw std::invalid_argument (message);
@@ -314,7 +293,7 @@ namespace cppwinrt
314293 {
315294 static constexpr uint32_t no_min = 0 ;
316295 static constexpr uint32_t no_max = UINT_MAX;
317-
296+
318297 std::string_view name;
319298 uint32_t min{ no_min };
320299 uint32_t max{ no_max };
@@ -325,7 +304,7 @@ namespace cppwinrt
325304 struct reader
326305 {
327306 template <typename C, typename V, size_t numOptions>
328- reader (C const argc, V const argv, const option (& options)[numOptions])
307+ reader (C const argc, V const argv, const option (& options)[numOptions])
329308 {
330309#ifdef _DEBUG
331310 {
@@ -410,8 +389,7 @@ namespace cppwinrt
410389 return result->second .front ();
411390 }
412391
413- template <typename F>
414- auto files (std::string_view const & name, F directory_filter) const
392+ template <typename F> auto files (std::string_view const & name, F directory_filter) const
415393 {
416394 std::set<std::string> files;
417395
@@ -449,12 +427,14 @@ namespace cppwinrt
449427#if defined(_WIN32) || defined(_WIN64)
450428 std::array<char , 260 > local{};
451429#ifdef _WIN64
452- ExpandEnvironmentStringsA (" %windir%\\ System32\\ WinMetadata" , local.data (), static_cast <uint32_t >(local.size ()));
430+ ExpandEnvironmentStringsA (
431+ " %windir%\\ System32\\ WinMetadata" , local.data (), static_cast <uint32_t >(local.size ()));
453432#else
454- ExpandEnvironmentStringsA (" %windir%\\ SysNative\\ WinMetadata" , local.data (), static_cast <uint32_t >(local.size ()));
433+ ExpandEnvironmentStringsA (
434+ " %windir%\\ SysNative\\ WinMetadata" , local.data (), static_cast <uint32_t >(local.size ()));
455435#endif
456436 add_directory (local.data ());
457- #else /* defined(_WIN32) || defined(_WIN64) */
437+ #else /* defined(_WIN32) || defined(_WIN64) */
458438 throw_invalid (" Spec '" , path, " ' not supported outside of Windows" );
459439#endif /* defined(_WIN32) || defined(_WIN64) */
460440 continue ;
@@ -466,7 +446,7 @@ namespace cppwinrt
466446 {
467447#if defined(_WIN32) || defined(_WIN64)
468448 sdk_version = get_sdk_version ();
469- #else /* defined(_WIN32) || defined(_WIN64) */
449+ #else /* defined(_WIN32) || defined(_WIN64) */
470450 throw_invalid (" Spec '" , path, " ' not supported outside of Windows" );
471451#endif /* defined(_WIN32) || defined(_WIN64) */
472452 }
@@ -505,7 +485,7 @@ namespace cppwinrt
505485 // Not all Extension SDKs include an SDKManifest.xml file; ignore those which do not (e.g. WindowsIoT).
506486 add_files_from_xml (files, sdk_version, xml_path, sdk_path, xml_requirement::optional);
507487 }
508- #else /* defined(_WIN32) || defined(_WIN64) */
488+ #else /* defined(_WIN32) || defined(_WIN64) */
509489 throw_invalid (" Spec '" , path, " ' not supported outside of Windows" );
510490#endif /* defined(_WIN32) || defined(_WIN64) */
511491
@@ -520,18 +500,16 @@ namespace cppwinrt
520500
521501 auto files (std::string_view const & name) const
522502 {
523- return files (name, [](auto &&) {return true ; });
503+ return files (name, [](auto &&) { return true ; });
524504 }
525505
526506 private:
527-
528507 inline bool starts_with (std::string_view const & value, std::string_view const & match) noexcept
529508 {
530509 return 0 == value.compare (0 , match.size (), match);
531510 }
532511
533- template <typename O>
534- auto find (O const & options, std::string_view const & arg)
512+ template <typename O> auto find (O const & options, std::string_view const & arg)
535513 {
536514 for (auto current = std::begin (options); current != std::end (options); ++current)
537515 {
@@ -546,8 +524,7 @@ namespace cppwinrt
546524
547525 std::map<std::string_view, std::vector<std::string>> m_options;
548526
549- template <typename O, typename L>
550- void extract_option (std::string_view arg, O const & options, L& last)
527+ template <typename O, typename L> void extract_option (std::string_view arg, O const & options, L& last)
551528 {
552529 if (arg[0 ] == ' -'
553530#if defined(_WIN32) || defined(_WIN64)
@@ -580,12 +557,15 @@ namespace cppwinrt
580557 }
581558 }
582559
583- template <typename O, typename L>
560+ template <typename O, typename L>
584561 void extract_response_file (std::string_view const & arg, O const & options, L& last)
585562 {
586563 std::filesystem::path response_path{ std::string{ arg } };
587564 std::string extension = response_path.extension ().generic_string ();
588- std::transform (extension.begin (), extension.end (), extension.begin (),
565+ std::transform (
566+ extension.begin (),
567+ extension.end (),
568+ extension.begin (),
589569 [](auto c) { return static_cast <unsigned char >(::tolower (c)); });
590570
591571 // Check if misuse of @ prefix, so if directory or metadata file instead of response file.
@@ -699,4 +679,4 @@ namespace cppwinrt
699679 }
700680 }
701681 };
702- }
682+ } // namespace cppwinrt
0 commit comments