-
Notifications
You must be signed in to change notification settings - Fork 247
/
base_string_operators.h
171 lines (138 loc) · 6.59 KB
/
base_string_operators.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
WINRT_EXPORT namespace winrt
{
inline bool operator==(hstring const& left, hstring const& right) noexcept
{
return std::wstring_view(left) == std::wstring_view(right);
}
inline bool operator==(hstring const& left, std::wstring const& right) noexcept
{
return std::wstring_view(left) == right;
}
inline bool operator==(std::wstring const& left, hstring const& right) noexcept
{
return left == std::wstring_view(right);
}
inline bool operator==(hstring const& left, wchar_t const* right) noexcept
{
return std::wstring_view(left) == right;
}
inline bool operator==(wchar_t const* left, hstring const& right) noexcept
{
return left == std::wstring_view(right);
}
bool operator==(hstring const& left, std::nullptr_t) = delete;
bool operator==(std::nullptr_t, hstring const& right) = delete;
inline bool operator<(hstring const& left, hstring const& right) noexcept
{
return std::wstring_view(left) < std::wstring_view(right);
}
inline bool operator<(std::wstring const& left, hstring const& right) noexcept
{
return left < std::wstring_view(right);
}
inline bool operator<(hstring const& left, std::wstring const& right) noexcept
{
return std::wstring_view(left) < right;
}
inline bool operator<(hstring const& left, wchar_t const* right) noexcept
{
return std::wstring_view(left) < right;
}
inline bool operator<(wchar_t const* left, hstring const& right) noexcept
{
return left < std::wstring_view(right);
}
bool operator<(hstring const& left, std::nullptr_t) = delete;
bool operator<(std::nullptr_t, hstring const& right) = delete;
inline bool operator!=(hstring const& left, hstring const& right) noexcept { return !(left == right); }
inline bool operator>(hstring const& left, hstring const& right) noexcept { return right < left; }
inline bool operator<=(hstring const& left, hstring const& right) noexcept { return !(right < left); }
inline bool operator>=(hstring const& left, hstring const& right) noexcept { return !(left < right); }
inline bool operator!=(hstring const& left, std::wstring const& right) noexcept { return !(left == right); }
inline bool operator>(hstring const& left, std::wstring const& right) noexcept { return right < left; }
inline bool operator<=(hstring const& left, std::wstring const& right) noexcept { return !(right < left); }
inline bool operator>=(hstring const& left, std::wstring const& right) noexcept { return !(left < right); }
inline bool operator!=(std::wstring const& left, hstring const& right) noexcept { return !(left == right); }
inline bool operator>(std::wstring const& left, hstring const& right) noexcept { return right < left; }
inline bool operator<=(std::wstring const& left, hstring const& right) noexcept { return !(right < left); }
inline bool operator>=(std::wstring const& left, hstring const& right) noexcept { return !(left < right); }
inline bool operator!=(hstring const& left, wchar_t const* right) noexcept { return !(left == right); }
inline bool operator>(hstring const& left, wchar_t const* right) noexcept { return right < left; }
inline bool operator<=(hstring const& left, wchar_t const* right) noexcept { return !(right < left); }
inline bool operator>=(hstring const& left, wchar_t const* right) noexcept { return !(left < right); }
inline bool operator!=(wchar_t const* left, hstring const& right) noexcept { return !(left == right); }
inline bool operator>(wchar_t const* left, hstring const& right) noexcept { return right < left; }
inline bool operator<=(wchar_t const* left, hstring const& right) noexcept { return !(right < left); }
inline bool operator>=(wchar_t const* left, hstring const& right) noexcept { return !(left < right); }
bool operator!=(hstring const& left, std::nullptr_t right) = delete;
bool operator>(hstring const& left, std::nullptr_t right) = delete;
bool operator<=(hstring const& left, std::nullptr_t right) = delete;
bool operator>=(hstring const& left, std::nullptr_t right) = delete;
bool operator!=(std::nullptr_t left, hstring const& right) = delete;
bool operator>(std::nullptr_t left, hstring const& right) = delete;
bool operator<=(std::nullptr_t left, hstring const& right) = delete;
bool operator>=(std::nullptr_t left, hstring const& right) = delete;
}
namespace winrt::impl
{
inline hstring concat_hstring(std::wstring_view const& left, std::wstring_view const& right)
{
auto size = static_cast<uint32_t>(left.size() + right.size());
if (size == 0)
{
return{};
}
hstring_builder text(size);
memcpy_s(text.data(), left.size() * sizeof(wchar_t), left.data(), left.size() * sizeof(wchar_t));
memcpy_s(text.data() + left.size(), right.size() * sizeof(wchar_t), right.data(), right.size() * sizeof(wchar_t));
return text.to_hstring();
}
}
WINRT_EXPORT namespace winrt
{
inline hstring operator+(hstring const& left, hstring const& right)
{
return impl::concat_hstring(left, right);
}
inline hstring operator+(hstring const& left, std::wstring const& right)
{
return impl::concat_hstring(left, right);
}
inline hstring operator+(std::wstring const& left, hstring const& right)
{
return impl::concat_hstring(left, right);
}
inline hstring operator+(hstring const& left, wchar_t const* right)
{
return impl::concat_hstring(left, right);
}
inline hstring operator+(wchar_t const* left, hstring const& right)
{
return impl::concat_hstring(left, right);
}
inline hstring operator+(hstring const& left, wchar_t right)
{
return impl::concat_hstring(left, std::wstring_view(&right, 1));
}
inline hstring operator+(wchar_t left, hstring const& right)
{
return impl::concat_hstring(std::wstring_view(&left, 1), right);
}
hstring operator+(hstring const& left, std::nullptr_t) = delete;
hstring operator+(std::nullptr_t, hstring const& right) = delete;
inline hstring operator+(hstring const& left, std::wstring_view const& right)
{
return impl::concat_hstring(left, right);
}
inline hstring operator+(std::wstring_view const& left, hstring const& right)
{
return impl::concat_hstring(left, right);
}
#ifndef WINRT_LEAN_AND_MEAN
inline std::wostream& operator<<(std::wostream& stream, hstring const& string)
{
stream << static_cast<std::wstring_view>(string);
return stream;
}
#endif
}