6#if !defined(__XTD_TUNIT_INTERNAL__)
7#error "Do not include this file: Internal use only"
15#include <forward_list>
16#include <initializer_list>
27#include <unordered_map>
28#include <unordered_set>
31#include <xtd/optional>
32#include <xtd/target_id>
36template<
class type_t>
struct __tunit_is_printable : std::false_type {};
37template<>
struct __tunit_is_printable<bool> : std::true_type {};
38template<>
struct __tunit_is_printable<char> : std::true_type {};
39template<>
struct __tunit_is_printable<signed char> : std::true_type {};
40template<>
struct __tunit_is_printable<unsigned char> : std::true_type {};
41template<>
struct __tunit_is_printable<wchar_t> : std::true_type {};
42#if defined(__xtd__cpp_lib_char8_t)
43template<>
struct __tunit_is_printable<
xtd::
char8> : std::true_type {};
45template<>
struct __tunit_is_printable<
xtd::
char16> : std::true_type {};
46template<>
struct __tunit_is_printable<
xtd::
char32> : std::true_type {};
47template<>
struct __tunit_is_printable<short> : std::true_type {};
48template<>
struct __tunit_is_printable<unsigned short> : std::true_type {};
49template<>
struct __tunit_is_printable<int> : std::true_type {};
50template<>
struct __tunit_is_printable<unsigned int> : std::true_type {};
51template<>
struct __tunit_is_printable<long> : std::true_type {};
52template<>
struct __tunit_is_printable<unsigned long> : std::true_type {};
53template<>
struct __tunit_is_printable<long long> : std::true_type {};
54template<>
struct __tunit_is_printable<unsigned long long> : std::true_type {};
55template<>
struct __tunit_is_printable<const char*> : std::true_type {};
56template<>
struct __tunit_is_printable<const wchar_t*> : std::true_type {};
57template<>
struct __tunit_is_printable<float> : std::true_type {};
58template<>
struct __tunit_is_printable<double> : std::true_type {};
59template<>
struct __tunit_is_printable<long double> : std::true_type {};
60template<>
struct __tunit_is_printable<std::
string> : std::true_type {};
61template<>
struct __tunit_is_printable<
xtd::
string> : std::true_type {};
62#if defined(__xtd__cpp_lib_char8_t)
63template<>
struct __tunit_is_printable<std::
u8string> : std::true_type {};
65template<>
struct __tunit_is_printable<std::
u16string> : std::true_type {};
66template<>
struct __tunit_is_printable<std::
u32string> : std::true_type {};
67template<>
struct __tunit_is_printable<std::
wstring> : std::true_type {};
69template<
typename char_t,
typename char_traits_t,
typename value_t>
70static void __tunit_print_value(std::basic_ostream<char_t, char_traits_t>& os,
const value_t& value, std::true_type) {
71 os.operator << (value);
74template<
typename char_t,
typename char_traits_t,
typename value_t>
75static void __tunit_print_value(std::basic_ostream<char_t, char_traits_t>& os, value_t* value, std::true_type) {
76 os.operator << (value);
79template<
typename char_t,
typename char_traits_t,
typename value_t>
80static void __tunit_print_value(std::basic_ostream<char_t, char_traits_t>& os,
const value_t* value, std::true_type) {
81 os.operator << (value);
84template<
typename char_t,
typename char_traits_t,
typename value_t>
85static void __tunit_print_value(std::basic_ostream<char_t, char_traits_t>& os,
const value_t& value, std::false_type) {
86 size_t size =
sizeof(value) > 32 ? 32 : sizeof(value);
87 os <<
size <<
"-byte object <";
88 for (
size_t index = 0; index !=
size; index++)
89 os << (index != 0 ? (index % 2 == 0 ?
" " :
"-") :
"") << std::hex << std::setiosflags(std::ios_base::
uppercase) << std::setw(2) << std::setfill(
'0') << static_cast<int>(reinterpret_cast<const unsigned char*>(&value)[index]) << std::resetiosflags(std::ios_base::dec) << std::dec;
90 os << (
size <
sizeof(value) ?
"-..." :
"") <<
">";
93template<
typename char_t,
typename char_traits_t,
typename value_t>
94static void __print(std::basic_ostream<char_t, char_traits_t>& os,
const value_t& value) {
95 __tunit_print_value(os, value, __tunit_is_printable<value_t>());
98template<
typename char_t,
typename char_traits_t,
typename value_t>
99static void __print(std::basic_ostream<char_t, char_traits_t>& os, value_t* value) {
100 __tunit_print_value(os, value, __tunit_is_printable<value_t>());
103template<
typename char_t,
typename char_traits_t,
typename value_t>
104static void __print(std::basic_ostream<char_t, char_traits_t>& os,
const value_t* value) {
105 __tunit_print_value(os, value, __tunit_is_printable<value_t>());
108template <
typename char_t,
typename char_traits_t,
typename value_t>
109struct __tunit_value_printer {
110 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const value_t*& value) {
113 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const value_t*
const& value) {
116 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const value_t& value) {
121template <
typename char_t,
typename char_traits_t>
122struct __tunit_value_printer<char_t, char_traits_t, std::exception> {
123 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::exception& value) {
124 os <<
"exception: " << value.what();
128template <
typename char_t,
typename char_traits_t,
typename value_t>
129struct __tunit_value_printer<char_t, char_traits_t, std::
optional<value_t>> {
130 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::optional<value_t>& value) {
131 if (!value.has_value())
135 __tunit_value_printer<char_t, char_traits_t, value_t>::print(os, value.value());
141template <
typename char_t,
typename char_traits_t>
142struct __tunit_value_printer<char_t, char_traits_t, std::
string> {
143 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::string& value) {
144 os << std::quoted(value);
148template <
typename char_t,
typename char_traits_t>
149struct __tunit_value_printer<char_t, char_traits_t,
xtd::
string> {
150 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::string& value) {
151 os << std::quoted(value);
155#if defined(__xtd__cpp_lib_char8_t)
156template <
typename char_t,
typename char_traits_t>
157struct __tunit_value_printer<char_t, char_traits_t, std::
u8string> {
158 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::u8string& value) {
159 __tunit_value_printer<char_t, char_traits_t, xtd::char8>::print(os, value.c_str());
164template <
typename char_t,
typename char_traits_t>
165struct __tunit_value_printer<char_t, char_traits_t, std::
u16string> {
166 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::u16string& value) {
167 __tunit_value_printer<char_t, char_traits_t, xtd::char16>::print(os, value.c_str());
171template <
typename char_t,
typename char_traits_t>
172struct __tunit_value_printer<char_t, char_traits_t, std::
u32string> {
173 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::u32string& value) {
174 __tunit_value_printer<char_t, char_traits_t, xtd::char32>::print(os, value.c_str());
178template <
typename char_t,
typename char_traits_t>
179struct __tunit_value_printer<char_t, char_traits_t, std::
wstring> {
180 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::wstring& value) {
181 __tunit_value_printer<char_t, char_traits_t, wchar_t>::print(os, value.c_str());
185template <
typename char_t,
typename char_traits_t>
186struct __tunit_value_printer<char_t, char_traits_t, const char*> {
187 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const char*
const& value) {
188 os << std::quoted(value);
191 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const char*& value) {
192 os << std::quoted(value);
195 static void print(std::basic_ostream<char_t, char_traits_t>& os,
char value) {
200template <
typename char_t,
typename char_traits_t>
201struct __tunit_value_printer<char_t, char_traits_t, char> {
202 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const char*
const& value) {
203 os << std::quoted(value);
206 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const char*& value) {
207 os << std::quoted(value);
210 static void print(std::basic_ostream<char_t, char_traits_t>& os,
char value) {
215#if defined(__xtd__cpp_lib_char8_t)
216template <
typename char_t,
typename char_traits_t>
217struct __tunit_value_printer<char_t, char_traits_t, const
xtd::
char8*> {
218 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char8*
const& value) {
220 for (
size_t index = 0; value[index] !=
'\0'; index++)
221 __tunit_value_printer<char_t, char_traits_t, xtd::char8>::print(os, value[index]);
225 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char8*& value) {
227 for (
size_t index = 0; value[index] !=
'\0'; index++)
228 __tunit_value_printer<char_t, char_traits_t, xtd::char8>::print(os, value[index]);
232 static void print(std::basic_ostream<char_t, char_traits_t>& os,
xtd::char8 value) {
233 if (value <=
char(0xFF))
234 os << static_cast<char>(value);
236 os <<
"\\x" << std::hex << static_cast<int>(value);
240template <
typename char_t,
typename char_traits_t>
241struct __tunit_value_printer<char_t, char_traits_t,
xtd::
char8> {
242 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char8*
const& value) {
244 for (
size_t index = 0; value[index] !=
'\0'; index++)
245 __tunit_value_printer<char_t, char_traits_t, xtd::char8>::print(os, value[index]);
249 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char8*& value) {
251 for (
size_t index = 0; value[index] !=
'\0'; index++)
252 __tunit_value_printer<char_t, char_traits_t, xtd::char8>::print(os, value[index]);
256 static void print(std::basic_ostream<char_t, char_traits_t>& os,
xtd::char8 value) {
257 os << static_cast<char>(value);
262template <
typename char_t,
typename char_traits_t>
263struct __tunit_value_printer<char_t, char_traits_t, const
xtd::
char16*> {
264 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char16*
const& value) {
266 for (
size_t index = 0; value[index] !=
'\0'; index++)
267 __tunit_value_printer<char_t, char_traits_t, xtd::char16>::print(os, value[index]);
271 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char16*& value) {
273 for (
size_t index = 0; value[index] != L
'\0'; index++)
274 __tunit_value_printer<char_t, char_traits_t, xtd::char16>::print(os, value[index]);
278 static void print(std::basic_ostream<char_t, char_traits_t>& os,
xtd::char16 value) {
280 os << static_cast<char>(value);
282 os <<
"\\x" << std::hex << static_cast<int>(value);
286template <
typename char_t,
typename char_traits_t>
287struct __tunit_value_printer<char_t, char_traits_t,
xtd::
char16> {
288 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char16*
const& value) {
290 for (
size_t index = 0; value[index] != L
'\0'; index++)
291 __tunit_value_printer<char_t, char_traits_t, xtd::char16>::print(os, value[index]);
295 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char16*& value) {
297 for (
size_t index = 0; value[index] != L
'\0'; index++)
298 __tunit_value_printer<char_t, char_traits_t, xtd::char16>::print(os, value[index]);
302 static void print(std::basic_ostream<char_t, char_traits_t>& os,
xtd::char16 value) {
304 os << static_cast<char>(value);
306 os <<
"\\x" << std::hex << static_cast<int>(value);
310template <
typename char_t,
typename char_traits_t>
311struct __tunit_value_printer<char_t, char_traits_t, const
xtd::
char32*> {
312 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char32*
const& value) {
314 for (
size_t index = 0; value[index] != L
'\0'; index++)
315 __tunit_value_printer<char_t, char_traits_t, xtd::char32>::print(os, value[index]);
319 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char32*& value) {
321 for (
size_t index = 0; value[index] != L
'\0'; index++)
322 __tunit_value_printer<char_t, char_traits_t, xtd::char32>::print(os, value[index]);
326 static void print(std::basic_ostream<char_t, char_traits_t>& os,
xtd::char32 value) {
328 os << static_cast<char>(value);
330 os <<
"\\x" << std::hex << static_cast<int>(value);
334template <
typename char_t,
typename char_traits_t>
335struct __tunit_value_printer<char_t, char_traits_t,
xtd::
char32> {
336 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char32*
const& value) {
338 for (
size_t index = 0; value[index] != L
'\0'; index++)
339 __tunit_value_printer<char_t, char_traits_t, xtd::char32>::print(os, value[index]);
343 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const xtd::char32*& value) {
345 for (
size_t index = 0; value[index] != L
'\0'; index++)
346 __tunit_value_printer<char_t, char_traits_t, xtd::char32>::print(os, value[index]);
350 static void print(std::basic_ostream<char_t, char_traits_t>& os,
xtd::char32 value) {
352 os << static_cast<char>(value);
354 os <<
"\\x" << std::hex << static_cast<int>(value);
358template <
typename char_t,
typename char_traits_t>
359struct __tunit_value_printer<char_t, char_traits_t, const wchar_t*> {
360 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const wchar_t*
const& value) {
362 for (
size_t index = 0; value[index] != L
'\0'; index++)
363 __tunit_value_printer<char_t, char_traits_t, wchar_t>::print(os, value[index]);
367 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const wchar_t*& value) {
369 for (
size_t index = 0; value[index] != L
'\0'; index++)
370 __tunit_value_printer<char_t, char_traits_t, wchar_t>::print(os, value[index]);
374 static void print(std::basic_ostream<char_t, char_traits_t>& os,
wchar_t value) {
376 os << static_cast<char>(value);
378 os <<
"\\x" << std::hex << static_cast<int>(value);
382template <
typename char_t,
typename char_traits_t>
383struct __tunit_value_printer<char_t, char_traits_t, wchar_t> {
384 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const wchar_t*
const& value) {
386 for (
size_t index = 0; value[index] != L
'\0'; index++)
387 __tunit_value_printer<char_t, char_traits_t, wchar_t>::print(os, value[index]);
391 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const wchar_t*& value) {
393 for (
size_t index = 0; value[index] != L
'\0'; index++)
394 __tunit_value_printer<char_t, char_traits_t, wchar_t>::print(os, value[index]);
398 static void print(std::basic_ostream<char_t, char_traits_t>& os,
wchar_t value) {
400 os << static_cast<char>(value);
402 os <<
"\\x" << std::hex << static_cast<int>(value);
406template <
typename char_t,
typename char_traits_t,
typename type1_t,
typename type2_t>
407struct __tunit_value_printer<char_t, char_traits_t, std::pair<type1_t, type2_t>> {
408 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::pair<type1_t, type2_t>& value) {
410 __tunit_value_printer<char_t, char_traits_t, type1_t>::print(os, value.first);
412 __tunit_value_printer<char_t, char_traits_t, type2_t>::print(os, value.second);
417template<
typename char_t,
typename char_traits_t,
typename type_t,
unsigned N,
unsigned Last>
418struct __tuple_printer {
419 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const type_t& value) {
420 __tunit_value_printer<char_t, char_traits_t, typename std::tuple_element<N, type_t>::type>::print(os, std::get<N>(value));
422 __tuple_printer < char_t, char_traits_t, type_t, N + 1, Last >::print(os, value);
426template<
typename char_t,
typename char_traits_t,
typename type_t,
unsigned N>
427struct __tuple_printer<char_t, char_traits_t, type_t, N, N> {
428 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const type_t& value) {
429 __tunit_value_printer<char_t, char_traits_t, typename std::tuple_element<N, type_t>::type>::print(os, std::get<N>(value));
433template <
typename char_t,
typename char_traits_t,
typename ... Types>
434struct __tunit_value_printer<char_t, char_traits_t, std::tuple<Types ...>> {
435 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::tuple<Types ...>& value) {
437 __tuple_printer < char_t, char_traits_t, std::tuple<Types ...>, 0,
sizeof...(Types) - 1 >::print(os, value);
442template <
typename char_t,
typename char_traits_t>
443struct __tunit_value_printer<char_t, char_traits_t, std::tuple<>> {
444 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::tuple<>&) {
449template <
typename char_t,
typename char_traits_t,
typename Iterator>
450std::basic_ostream<char_t, char_traits_t>& __print_sequence_container(std::basic_ostream<char_t, char_traits_t>& os,
const Iterator& begin,
const Iterator& end) {
453 for (Iterator it = begin; it !=
end; ++it) {
454 if (!first) os <<
", ";
455 __tunit_value_printer<char_t, char_traits_t, typename std::iterator_traits<Iterator>::value_type>::print(os, *it);
461template <
typename char_t,
typename char_traits_t,
typename value_t,
size_t Size>
462struct __tunit_value_printer<char_t, char_traits_t, std::array<value_t, Size>> {
463 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::array<value_t, Size>& values) {
464 __print_sequence_container(os, values.begin(), values.end());
468template <
typename char_t,
typename char_traits_t,
typename value_t>
469struct __tunit_value_printer<char_t, char_traits_t, std::deque<value_t>> {
470 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::deque<value_t>& values) {
471 __print_sequence_container(os, values.begin(), values.end());
475template <
typename char_t,
typename char_traits_t,
typename value_t>
476struct __tunit_value_printer<char_t, char_traits_t, std::forward_list<value_t>> {
477 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::forward_list<value_t>& values) {
478 __print_sequence_container(os, values.begin(), values.end());
482template <
typename char_t,
typename char_traits_t,
typename value_t>
483struct __tunit_value_printer<char_t, char_traits_t, std::list<value_t>> {
484 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::list<value_t>& values) {
485 __print_sequence_container(os, values.begin(), values.end());
489template <
typename char_t,
typename char_traits_t,
typename value_t>
490struct __tunit_value_printer<char_t, char_traits_t, std::initializer_list<value_t>> {
491 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::initializer_list<value_t>& values) {
492 __print_sequence_container(os, values.begin(), values.end());
496template <
typename char_t,
typename char_traits_t,
typename value_t>
497struct __tunit_value_printer<char_t, char_traits_t, std::vector<value_t>> {
498 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::vector<value_t>& values) {
499 __print_sequence_container(os, values.begin(), values.end());
503template <
typename char_t,
typename char_traits_t,
typename Iterator>
504std::basic_ostream<char_t, char_traits_t>& __print_associative_container(std::basic_ostream<char_t, char_traits_t>& os,
const Iterator& begin,
const Iterator& end) {
507 for (Iterator it = begin; it !=
end; ++it) {
508 if (!first) os <<
", ";
509 __tunit_value_printer<char_t, char_traits_t, typename std::iterator_traits<Iterator>::value_type>::print(os, *it);
515template <
typename char_t,
typename char_traits_t,
typename Key,
typename value_t>
516struct __tunit_value_printer<char_t, char_traits_t, std::map<Key, value_t>> {
517 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::map<Key, value_t>& values) {
518 __print_associative_container(os, values.begin(), values.end());
522template <
typename char_t,
typename char_traits_t,
typename Key,
typename value_t>
523struct __tunit_value_printer<char_t, char_traits_t, std::multimap<Key, value_t>> {
524 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::multimap<Key, value_t>& values) {
525 __print_associative_container(os, values.begin(), values.end());
529template <
typename char_t,
typename char_traits_t,
typename value_t>
530struct __tunit_value_printer<char_t, char_traits_t, std::multiset<value_t>> {
531 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::multiset<value_t>& values) {
532 __print_associative_container(os, values.begin(), values.end());
536template <
typename char_t,
typename char_traits_t,
typename value_t>
537struct __tunit_value_printer<char_t, char_traits_t, std::set<value_t>> {
538 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::set<value_t>& values) {
539 __print_associative_container(os, values.begin(), values.end());
543template <
typename char_t,
typename char_traits_t,
typename Key,
typename value_t>
544struct __tunit_value_printer<char_t, char_traits_t, std::unordered_map<Key, value_t>> {
545 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::unordered_map<Key, value_t>& values) {
546 __print_associative_container(os, values.begin(), values.end());
550template <
typename char_t,
typename char_traits_t,
typename Key,
typename value_t>
551struct __tunit_value_printer<char_t, char_traits_t, std::unordered_multimap<Key, value_t>> {
552 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::unordered_multimap<Key, value_t>& values) {
553 __print_associative_container(os, values.begin(), values.end());
557template <
typename char_t,
typename char_traits_t,
typename value_t>
558struct __tunit_value_printer<char_t, char_traits_t, std::unordered_multiset<value_t>> {
559 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::unordered_multiset<value_t>& values) {
560 __print_associative_container(os, values.begin(), values.end());
564template <
typename char_t,
typename char_traits_t,
typename value_t>
565struct __tunit_value_printer<char_t, char_traits_t, std::unordered_set<value_t>> {
566 static void print(std::basic_ostream<char_t, char_traits_t>& os,
const std::unordered_set<value_t>& values) {
567 __print_associative_container(os, values.begin(), values.end());
571#if __XTD_CURRENT_TARGET_ID__ == __XTD_TARGET_ID_TEST_APPLICATION__
572template <
typename char_t,
typename char_traits_t,
typename type_t>
573std::basic_ostream<char_t, char_traits_t>& operator <<(std::basic_ostream<char_t, char_traits_t>& os,
const type_t& value) {
574 __tunit_value_printer<char_t, char_traits_t, type_t>::print(os, value);
578template <
typename char_t,
typename char_traits_t,
typename type_t>
579std::basic_ostream<char_t, char_traits_t>& operator <<(std::basic_ostream<char_t, char_traits_t>& os,
const type_t* value) {
580 __tunit_value_printer<char_t, char_traits_t, type_t>::print(os, value);
584template <
typename char_t,
typename char_traits_t,
typename type_t>
585std::basic_ostream<char_t, char_traits_t>& operator <<(std::basic_ostream<char_t, char_traits_t>& os, type_t* value) {
586 __tunit_value_printer<char_t, char_traits_t, type_t>::print(os, value);
591inline std::string __tunit_codepoint_to_string(
xtd::char32 codepoint) {
593 if (codepoint < 0x80)
594 result.push_back(
static_cast<char>(codepoint));
595 else if (codepoint < 0x800) {
596 result.push_back(
static_cast<char>((codepoint >> 6) | 0xc0));
597 result.push_back(
static_cast<char>((codepoint & 0x3f) | 0x80));
598 }
else if (codepoint < 0x10000) {
599 result.push_back(
static_cast<char>((codepoint >> 12) | 0xe0));
600 result.push_back(
static_cast<char>(((codepoint >> 6) & 0x3f) | 0x80));
601 result.push_back(
static_cast<char>((codepoint & 0x3f) | 0x80));
603 result.push_back(
static_cast<char>((codepoint >> 18) | 0xf0));
604 result.push_back(
static_cast<char>(((codepoint >> 12) & 0x3f) | 0x80));
605 result.push_back(
static_cast<char>(((codepoint >> 6) & 0x3f) | 0x80));
606 result.push_back(
static_cast<char>((codepoint & 0x3f) | 0x80));
611#if defined(__xtd__cpp_lib_char8_t)
613 std::stringstream ss;
614 ss << std::quoted(__tunit_codepoint_to_string(value));
620 std::stringstream ss;
621 ss << std::quoted(__tunit_codepoint_to_string(value));
626 std::stringstream ss;
627 ss << std::quoted(__tunit_codepoint_to_string(value));
631inline xtd::string __tunit_to_string(
const wchar_t& value) {
632 std::stringstream ss;
633 ss << std::quoted(__tunit_codepoint_to_string(value));
637inline xtd::string __tunit_to_string(
const std::string& value) {
638 std::stringstream ss;
639 ss << std::quoted(value);
644 std::stringstream ss;
645 ss << std::quoted(value.
chars());
649#if defined(__xtd__cpp_lib_char8_t)
650inline xtd::string __tunit_to_string(
const std::u8string& value) {
651 std::stringstream ss;
652 ss << std::quoted(value);
657inline xtd::string __tunit_to_string(
const std::u16string& value) {
660 for (
auto codepoint : value)
661 result += __tunit_codepoint_to_string(codepoint);
666inline xtd::string __tunit_to_string(
const std::u32string& value) {
669 for (
auto codepoint : value)
670 result += __tunit_codepoint_to_string(codepoint);
675inline xtd::string __tunit_to_string(
const std::wstring& value) {
678 for (
auto codepoint : value)
679 result += __tunit_codepoint_to_string(codepoint);
684inline xtd::string __tunit_to_string(
const void* value) {
685 std::stringstream ss;
686 ss <<
"\"" <<
reinterpret_cast<xtd::intptr>(value) <<
"\"";
691 std::stringstream ss;
692 ss <<
"\"" <<
reinterpret_cast<xtd::intptr>(value) <<
"\"";
696inline xtd::string __tunit_to_string(
const char* value) {
697 std::stringstream ss;
698 ss << std::quoted(value);
702#if defined(__xtd__cpp_lib_char8_t)
704 return __tunit_to_string(std::u8string(value));
709 return __tunit_to_string(std::u16string(value));
713 return __tunit_to_string(std::u32string(value));
716inline xtd::string __tunit_to_string(
const wchar_t* value) {
717 return __tunit_to_string(std::wstring(value));
720template <
typename value_t>
721inline xtd::string __tunit_to_string(
const value_t& value) {
722 std::stringstream ss;
727template <
typename value_t>
728inline xtd::string __tunit_to_string(
const value_t* value) {
729 std::stringstream ss;
730 ss << reinterpret_cast<xtd::intptr>(value);
734template <
typename value_t>
735inline xtd::string __tunit_to_string(value_t* value) {
736 std::stringstream ss;
737 ss << reinterpret_cast<xtd::intptr>(value);
Represents text as a sequence of character units.
Definition basic_string.hpp:79
const base_type & chars() const noexcept
Returns a reference to the underlying base type.
Definition basic_string.hpp:883
xtd::basic_string< xtd::wchar > wstring
Represents text as a sequence of UTF-16 code unit on Windows or UTF-32 code unit on non-Windows syste...
Definition __string_definitions.hpp:89
xtd::basic_string< xtd::char8 > u8string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:77
xtd::basic_string< xtd::char16 > u16string
Represents text as a sequence of UTF-16 code units.
Definition __string_definitions.hpp:54
xtd::basic_string< xtd::char32 > u32string
Represents text as a sequence of UTF-32 code units.
Definition __string_definitions.hpp:65
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
@ uppercase
Defines a uppercase text transformation.
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:27
std::optional< type_t > optional
Represents the null_opt alias on std::nullopt_t.
Definition optional.hpp:175
char16_t char16
Represents a 16-bit unicode character.
Definition char16.hpp:26
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:26
intmax_t intptr
Represent a pointer or a handle.
Definition intptr.hpp:23
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10
void print(arg_t &&value)
Writes the text representation of the specified value to the standard output stream.
Definition print.hpp:13