@@ -16,118 +16,115 @@ import errors;
16
16
[[nodiscard]] HMODULE get_current_module () noexcept
17
17
{
18
18
HMODULE module;
19
- GetModuleHandleEx (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
20
- reinterpret_cast <PCTSTR >(get_current_module), &module);
19
+ GetModuleHandleExW (GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
20
+ reinterpret_cast <PCWSTR >(get_current_module), &module);
21
21
22
22
return module;
23
23
}
24
24
25
- export
25
+ export constexpr std::byte operator " " _byte( const unsigned long long int n)
26
26
{
27
- constexpr std::byte operator " " _byte (const unsigned long long int n)
28
- {
29
- return static_cast <std::byte>(n);
30
- }
31
-
32
-
33
- [[nodiscard]] inline const char * pixel_format_to_string (const GUID& guid) noexcept
34
- {
35
- if (guid == GUID_WICPixelFormat2bppGray)
36
- return " GUID_WICPixelFormat2bppGray" ;
27
+ return static_cast <std::byte>(n);
28
+ }
37
29
38
- if (guid == GUID_WICPixelFormat4bppGray)
39
- return " GUID_WICPixelFormat4bppGray" ;
40
30
41
- if (guid == GUID_WICPixelFormat8bppGray)
42
- return " GUID_WICPixelFormat8bppGray" ;
31
+ export [[nodiscard]] inline const char * pixel_format_to_string (const GUID& guid) noexcept
32
+ {
33
+ if (guid == GUID_WICPixelFormat2bppGray)
34
+ return " GUID_WICPixelFormat2bppGray" ;
43
35
44
- if (guid == GUID_WICPixelFormat16bppGray )
45
- return " GUID_WICPixelFormat16bppGray " ;
36
+ if (guid == GUID_WICPixelFormat4bppGray )
37
+ return " GUID_WICPixelFormat4bppGray " ;
46
38
47
- if (guid == GUID_WICPixelFormat24bppRGB )
48
- return " GUID_WICPixelFormat24bppRGB " ;
39
+ if (guid == GUID_WICPixelFormat8bppGray )
40
+ return " GUID_WICPixelFormat8bppGray " ;
49
41
50
- if (guid == GUID_WICPixelFormat48bppRGB )
51
- return " GUID_WICPixelFormat48bppRGB " ;
42
+ if (guid == GUID_WICPixelFormat16bppGray )
43
+ return " GUID_WICPixelFormat16bppGray " ;
52
44
53
- return " Unknown" ;
54
- }
55
-
56
- [[nodiscard]] inline std::wstring guid_to_string (const GUID& guid)
57
- {
58
- std::wstring guid_text;
45
+ if (guid == GUID_WICPixelFormat24bppRGB)
46
+ return " GUID_WICPixelFormat24bppRGB" ;
59
47
60
- guid_text. resize ( 39 );
61
- VERIFY ( StringFromGUID2 (guid, guid_text. data (), static_cast < int >(guid_text. size ())) != 0 ) ;
48
+ if (guid == GUID_WICPixelFormat48bppRGB)
49
+ return " GUID_WICPixelFormat48bppRGB " ;
62
50
63
- // Remove the double null terminator.
64
- guid_text. resize (guid_text. size () - 1 );
51
+ return " Unknown " ;
52
+ }
65
53
66
- return guid_text;
67
- }
54
+ export [[nodiscard]] inline std::wstring guid_to_string (const GUID& guid)
55
+ {
56
+ std::wstring guid_text;
68
57
69
- [[nodiscard]] inline std::wstring get_module_path ()
70
- {
71
- std::wstring path (100 , L' ?' );
72
- size_t path_size;
73
- size_t actual_size;
58
+ guid_text.resize (39 );
59
+ VERIFY (StringFromGUID2 (guid, guid_text.data (), static_cast <int >(guid_text.size ())) != 0 );
74
60
75
- do
76
- {
77
- path_size = path.size ();
78
- actual_size = ::GetModuleFileName (get_current_module (), path.data (), static_cast <DWORD>(path_size));
61
+ // Remove the double null terminator.
62
+ guid_text.resize (guid_text.size () - 1 );
79
63
80
- if (actual_size + 1 > path_size)
81
- {
82
- path.resize (path_size * 2 , L' ?' );
83
- }
84
- } while (actual_size + 1 > path_size);
64
+ return guid_text;
65
+ }
85
66
86
- path.resize (actual_size);
87
- return path;
88
- }
67
+ export [[nodiscard]] inline std::wstring get_module_path ()
68
+ {
69
+ std::wstring path (100 , L' ?' );
70
+ size_t path_size;
71
+ size_t actual_size;
89
72
90
- template <>
91
- struct std ::formatter<winrt::hresult> : std::formatter<int32_t >
73
+ do
92
74
{
93
- auto format (const winrt::hresult& result, std::format_context& ctx) const
75
+ path_size = path.size ();
76
+ actual_size = ::GetModuleFileName (get_current_module (), path.data (), static_cast <DWORD>(path_size));
77
+
78
+ if (actual_size + 1 > path_size)
94
79
{
95
- return std::formatter< int32_t >:: format (result. value , ctx );
80
+ path. resize (path_size * 2 , L ' ? ' );
96
81
}
97
- };
82
+ } while (actual_size + 1 > path_size) ;
98
83
99
- inline void check_hresult (const winrt::hresult result, const winrt::hresult result_to_throw)
100
- {
101
- if (result < 0 )
102
- throw_hresult (result_to_throw);
103
- }
84
+ path.resize (actual_size);
85
+ return path;
86
+ }
104
87
105
- [[nodiscard]] constexpr bool failed (const winrt::hresult result) noexcept
88
+ export template <>
89
+ struct std ::formatter<winrt::hresult> : std::formatter<int32_t >
90
+ {
91
+ auto format (const winrt::hresult& result, std::format_context& ctx) const
106
92
{
107
- return result < 0 ;
93
+ return std::formatter< int32_t >:: format ( result. value , ctx) ;
108
94
}
95
+ };
109
96
110
- template < typename T>
111
- T* check_in_pointer (_In_ T * pointer)
112
- {
113
- if (!pointer)
114
- winrt::throw_hresult (error_invalid_argument);
97
+ export inline void check_hresult ( const winrt::hresult result, const winrt::hresult result_to_throw)
98
+ {
99
+ if (result < 0 )
100
+ throw_hresult (result_to_throw);
101
+ }
115
102
116
- return pointer;
117
- }
103
+ export [[nodiscard]] constexpr bool failed (const winrt::hresult result) noexcept
104
+ {
105
+ return result < 0 ;
106
+ }
118
107
119
- template <typename T>
120
- T* check_out_pointer (T * pointer)
121
- {
122
- if (!pointer)
123
- winrt::throw_hresult (error_pointer );
108
+ export template <typename T>
109
+ T* check_in_pointer (_In_ T * pointer)
110
+ {
111
+ if (!pointer)
112
+ winrt::throw_hresult (error_invalid_argument );
124
113
125
- return pointer;
126
- }
114
+ return pointer;
115
+ }
127
116
128
- inline void check_condition (const bool condition, const winrt::hresult result_to_throw)
129
- {
130
- if (!condition)
131
- throw_hresult (result_to_throw);
132
- }
117
+ export template <typename T>
118
+ T* check_out_pointer (T* pointer)
119
+ {
120
+ if (!pointer)
121
+ winrt::throw_hresult (error_pointer);
122
+
123
+ return pointer;
124
+ }
125
+
126
+ export inline void check_condition (const bool condition, const winrt::hresult result_to_throw)
127
+ {
128
+ if (!condition)
129
+ throw_hresult (result_to_throw);
133
130
}
0 commit comments