xtd 0.2.0
Loading...
Searching...
No Matches
__as_string.hpp
Go to the documentation of this file.
1
3#pragma once
4
6#if !defined(__XTD_CORE_INTERNAL__)
7#error "Do not include this file: Internal use only"
8#endif
10
11#define __XTD_STD_INTERNAL__
12#include "__xtd_std_version.hpp"
13#undef __XTD_STD_INTERNAL__
14
16namespace xtd {
35 template<>
36 [[nodiscard]] inline auto as<xtd::string>(xtd::any value) -> xtd::string {
37 return xtd::convert::to_string(value);
38 }
39
57 template<>
58 [[nodiscard]] inline auto as<xtd::string>(bool value) -> xtd::string {
59 return xtd::convert::to_string(value);
60 }
61
79 template<>
80 [[nodiscard]] inline auto as<xtd::string>(xtd::byte value) -> xtd::string {
81 return xtd::convert::to_string(value);
82 }
83
103 template<>
104 [[nodiscard]] inline auto as<xtd::string>(xtd::byte value, xtd::byte from_base) -> xtd::string {
105 return xtd::convert::to_string(value, from_base);
106 }
107
126 template<>
127 [[nodiscard]] inline auto as<xtd::string>(char value) -> xtd::string {
128 return xtd::convert::to_string(value);
129 }
130
149 template<>
150 [[nodiscard]] inline auto as<xtd::string>(xtd::char8 value) -> xtd::string {
151 return xtd::convert::to_string(value);
152 }
153
172 template<>
173 [[nodiscard]] inline auto as<xtd::string>(xtd::char16 value) -> xtd::string {
174 return xtd::convert::to_string(value);
175 }
176
195 template<>
196 [[nodiscard]] inline auto as<xtd::string>(xtd::char32 value) -> xtd::string {
197 return xtd::convert::to_string(value);
198 }
199
218 template<>
219 [[nodiscard]] inline auto as<xtd::string>(xtd::wchar value) -> xtd::string {
220 return xtd::convert::to_string(value);
221 }
222
240 template<>
241 [[nodiscard]] inline auto as<xtd::string>(xtd::decimal value) -> xtd::string {
242 return xtd::convert::to_string(value);
243 }
244
262 template<>
263 [[nodiscard]] inline auto as<xtd::string>(double value) -> xtd::string {
264 return xtd::convert::to_string(value);
265 }
266
284 template<>
285 [[nodiscard]] inline auto as<xtd::string>(float value) -> xtd::string {
286 return xtd::convert::to_string(value);
287 }
288
306 template<>
307 [[nodiscard]] inline auto as<xtd::string>(xtd::int16 value) -> xtd::string {
308 return xtd::convert::to_string(value);
309 }
310
330 template<>
331 [[nodiscard]] inline auto as<xtd::string>(xtd::int16 value, xtd::byte from_base) -> xtd::string {
332 return xtd::convert::to_string(value, from_base);
333 }
334
352 template<>
353 [[nodiscard]] inline auto as<xtd::string>(xtd::int32 value) -> xtd::string {
354 return xtd::convert::to_string(value);
355 }
356
376 template<>
377 [[nodiscard]] inline auto as<xtd::string>(xtd::int32 value, xtd::byte from_base) -> xtd::string {
378 return xtd::convert::to_string(value, from_base);
379 }
380
398 template<>
399 [[nodiscard]] inline auto as<xtd::string>(xtd::int64 value) -> xtd::string {
400 return xtd::convert::to_string(value);
401 }
402
422 template<>
423 [[nodiscard]] inline auto as<xtd::string>(xtd::int64 value, xtd::byte from_base) -> xtd::string {
424 return xtd::convert::to_string(value, from_base);
425 }
426
444 template<>
445 [[nodiscard]] inline auto as<xtd::string>(xtd::slong value) -> xtd::string {
446 return xtd::convert::to_string(value);
447 }
448
468 template<>
469 [[nodiscard]] inline auto as<xtd::string>(xtd::slong value, xtd::byte from_base) -> xtd::string {
470 return xtd::convert::to_string(value, from_base);
471 }
472
490 template<>
491 [[nodiscard]] inline auto as<xtd::string>(xtd::sbyte value) -> xtd::string {
492 return xtd::convert::to_string(value);
493 }
494
514 template<>
515 [[nodiscard]] inline auto as<xtd::string>(xtd::sbyte value, xtd::byte from_base) -> xtd::string {
516 return xtd::convert::to_string(value, from_base);
517 }
518
536 template<>
537 [[nodiscard]] inline auto as<xtd::string>(xtd::uint16 value) -> xtd::string {
538 return xtd::convert::to_string(value);
539 }
540
560 template<>
561 [[nodiscard]] inline auto as<xtd::string>(xtd::uint16 value, xtd::byte from_base) -> xtd::string {
562 return xtd::convert::to_string(value, from_base);
563 }
564
582 template<>
583 [[nodiscard]] inline auto as<xtd::string>(xtd::uint32 value) -> xtd::string {
584 return xtd::convert::to_string(value);
585 }
586
606 template<>
607 [[nodiscard]] inline auto as<xtd::string>(xtd::uint32 value, xtd::byte from_base) -> xtd::string {
608 return xtd::convert::to_string(value, from_base);
609 }
610
628 template<>
629 [[nodiscard]] inline auto as<xtd::string>(xtd::uint64 value) -> xtd::string {
630 return xtd::convert::to_string(value);
631 }
632
652 template<>
653 [[nodiscard]] inline auto as<xtd::string>(xtd::uint64 value, xtd::byte from_base) -> xtd::string {
654 return xtd::convert::to_string(value, from_base);
655 }
656
674 template<>
675 [[nodiscard]] inline auto as<xtd::string>(xtd::ulong value) -> xtd::string {
676 return xtd::convert::to_string(value);
677 }
678
698 template<>
699 [[nodiscard]] inline auto as<xtd::string>(xtd::ulong value, xtd::byte from_base) -> xtd::string {
700 return xtd::convert::to_string(value, from_base);
701 }
702
720 template<>
721 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::string& value) -> xtd::u16string {
722 return value;
723 }
724
742 template<>
743 [[nodiscard]] inline auto as<xtd::u16string>(xtd::string& value) -> xtd::u16string {
744 return value;
745 }
746
765 template<>
766 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::string& value) -> xtd::u32string {
767 return value;
768 }
769
787 template<>
788 [[nodiscard]] inline auto as<xtd::u32string>(xtd::string& value) -> xtd::u32string {
789 return value;
790 }
791
810 template<>
811 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::string& value) -> xtd::u8string {
812 return value;
813 }
814
832 template<>
833 [[nodiscard]] inline auto as<xtd::u8string>(xtd::string& value) -> xtd::u8string {
834 return value;
835 }
836
855 template<>
856 [[nodiscard]] inline auto as<xtd::wstring>(const xtd::string& value) -> xtd::wstring {
857 return value;
858 }
859
877 template<>
878 [[nodiscard]] inline auto as<xtd::wstring>(xtd::string& value) -> xtd::wstring {
879 return value;
880 }
881
883 template<>
884 [[nodiscard]] inline auto as<xtd::u16string>(const char* value) -> xtd::u16string {
885 return xtd::string {value};
886 }
887 template<>
888 [[nodiscard]] inline auto as<xtd::u16string>(char* value) -> xtd::u16string {
889 return xtd::string {value};
890 }
891 template<>
892 [[nodiscard]] inline auto as<xtd::u32string>(const char* value) -> xtd::u32string {
893 return xtd::string {value};
894 }
895 template<>
896 [[nodiscard]] inline auto as<xtd::u32string>(char* value) -> xtd::u32string {
897 return xtd::string {value};
898 }
899 template<>
900 [[nodiscard]] inline auto as<xtd::u8string>(const char* value) -> xtd::u8string {
901 return xtd::string {value};
902 }
903 template<>
904 [[nodiscard]] inline auto as<xtd::u8string>(char* value) -> xtd::u8string {
905 return xtd::string {value};
906 }
907 template<>
908 [[nodiscard]] inline auto as<xtd::wstring>(const char* value) -> xtd::wstring {
909 return xtd::string {value};
910 }
911 template<>
912 [[nodiscard]] inline auto as<xtd::wstring>(char* value) -> xtd::wstring {
913 return xtd::string {value};
914 }
916
917
919 template<typename type_t>
920 [[nodiscard]] inline auto as(const xtd::u16string& value) -> type_t {
921 return value;
922 }
923 template<typename type_t>
924 [[nodiscard]] inline auto as(xtd::u16string& value) -> type_t {
925 return value;
926 }
928
947 template<>
948 [[nodiscard]] inline auto as<xtd::string>(const xtd::u16string& value) -> xtd::string {
949 return value;
950 }
951
969 template<>
970 [[nodiscard]] inline auto as<xtd::string>(xtd::u16string& value) -> xtd::string {
971 return value;
972 }
973
992 template<>
993 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::u16string& value) -> xtd::u16string {
994 return value;
995 }
996
1014 template<>
1015 [[nodiscard]] inline auto as<xtd::u16string>(xtd::u16string& value) -> xtd::u16string {
1016 return value;
1017 }
1018
1037 template<>
1038 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::u16string& value) -> xtd::u32string {
1039 return value;
1040 }
1041
1059 template<>
1060 [[nodiscard]] inline auto as<xtd::u32string>(xtd::u16string& value) -> xtd::u32string {
1061 return value;
1062 }
1063
1082 template<>
1083 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::u16string& value) -> xtd::u8string {
1084 return value;
1085 }
1086
1104 template<>
1105 [[nodiscard]] inline auto as<xtd::u8string>(xtd::u16string& value) -> xtd::u8string {
1106 return value;
1107 }
1108
1110 template<>
1111 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::char16* value) -> xtd::u16string {
1112 return xtd::u16string {value};
1113 }
1114 template<>
1115 [[nodiscard]] inline auto as<xtd::u16string>(xtd::char16* value) -> xtd::u16string {
1116 return xtd::u16string {value};
1117 }
1118 template<>
1119 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::char16* value) -> xtd::u32string {
1120 return xtd::u16string {value};
1121 }
1122 template<>
1123 [[nodiscard]] inline auto as<xtd::u32string>(xtd::char16* value) -> xtd::u32string {
1124 return xtd::u16string {value};
1125 }
1126 template<>
1127 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::char16* value) -> xtd::u8string {
1128 return xtd::u16string {value};
1129 }
1130 template<>
1131 [[nodiscard]] inline auto as<xtd::u8string>(xtd::char16* value) -> xtd::u8string {
1132 return xtd::u16string {value};
1133 }
1134 template<>
1135 [[nodiscard]] inline auto as<xtd::wstring>(const xtd::char16* value) -> xtd::wstring {
1136 return xtd::u16string {value};
1137 }
1138 template<>
1139 [[nodiscard]] inline auto as<xtd::wstring>(xtd::char16* value) -> xtd::wstring {
1140 return xtd::u16string {value};
1141 }
1143
1145 template<typename type_t>
1146 [[nodiscard]] inline auto as(const xtd::u32string& value) -> type_t {
1147 return value;
1148 }
1149 template<typename type_t>
1150 [[nodiscard]] inline auto as(xtd::u32string& value) -> type_t {
1151 return value;
1152 }
1154
1173 template<>
1174 [[nodiscard]] inline auto as<xtd::string>(const xtd::u32string& value) -> xtd::string {
1175 return value;
1176 }
1177
1195 template<>
1196 [[nodiscard]] inline auto as<xtd::string>(xtd::u32string& value) -> xtd::string {
1197 return value;
1198 }
1199
1218 template<>
1219 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::u32string& value) -> xtd::u16string {
1220 return value;
1221 }
1222
1240 template<>
1241 [[nodiscard]] inline auto as<xtd::u16string>(xtd::u32string& value) -> xtd::u16string {
1242 return value;
1243 }
1244
1263 template<>
1264 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::u32string& value) -> xtd::u32string {
1265 return value;
1266 }
1267
1285 template<>
1286 [[nodiscard]] inline auto as<xtd::u32string>(xtd::u32string& value) -> xtd::u32string {
1287 return value;
1288 }
1289
1308 template<>
1309 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::u32string& value) -> xtd::u8string {
1310 return value;
1311 }
1312
1330 template<>
1331 [[nodiscard]] inline auto as<xtd::u8string>(xtd::u32string& value) -> xtd::u8string {
1332 return value;
1333 }
1334
1336 template<>
1337 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::char32* value) -> xtd::u16string {
1338 return xtd::u32string {value};
1339 }
1340 template<>
1341 [[nodiscard]] inline auto as<xtd::u16string>(xtd::char32* value) -> xtd::u16string {
1342 return xtd::u32string {value};
1343 }
1344 template<>
1345 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::char32* value) -> xtd::u32string {
1346 return xtd::u32string {value};
1347 }
1348 template<>
1349 [[nodiscard]] inline auto as<xtd::u32string>(xtd::char32* value) -> xtd::u32string {
1350 return xtd::u32string {value};
1351 }
1352 template<>
1353 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::char32* value) -> xtd::u8string {
1354 return xtd::u32string {value};
1355 }
1356 template<>
1357 [[nodiscard]] inline auto as<xtd::u8string>(xtd::char32* value) -> xtd::u8string {
1358 return xtd::u32string {value};
1359 }
1360 template<>
1361 [[nodiscard]] inline auto as<xtd::wstring>(const xtd::char32* value) -> xtd::wstring {
1362 return xtd::u32string {value};
1363 }
1364 template<>
1365 [[nodiscard]] inline auto as<xtd::wstring>(xtd::char32* value) -> xtd::wstring {
1366 return xtd::u32string {value};
1367 }
1369
1371 template<typename type_t>
1372 [[nodiscard]] inline auto as(const xtd::u8string& value) -> type_t {
1373 return value;
1374 }
1375 template<typename type_t>
1376 [[nodiscard]] inline auto as(xtd::u8string& value) -> type_t {
1377 return value;
1378 }
1380
1399 template<>
1400 [[nodiscard]] inline auto as<xtd::string>(const xtd::u8string& value) -> xtd::string {
1401 return value;
1402 }
1403
1421 template<>
1422 [[nodiscard]] inline auto as<xtd::string>(xtd::u8string& value) -> xtd::string {
1423 return value;
1424 }
1425
1444 template<>
1445 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::u8string& value) -> xtd::u16string {
1446 return value;
1447 }
1448
1466 template<>
1467 [[nodiscard]] inline auto as<xtd::u16string>(xtd::u8string& value) -> xtd::u16string {
1468 return value;
1469 }
1470
1489 template<>
1490 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::u8string& value) -> xtd::u32string {
1491 return value;
1492 }
1493
1511 template<>
1512 [[nodiscard]] inline auto as<xtd::u32string>(xtd::u8string& value) -> xtd::u32string {
1513 return value;
1514 }
1515
1534 template<>
1535 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::u8string& value) -> xtd::u8string {
1536 return value;
1537 }
1538
1556 template<>
1557 [[nodiscard]] inline auto as<xtd::u8string>(xtd::u8string& value) -> xtd::u8string {
1558 return value;
1559 }
1560
1562 template<>
1563 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::char8* value) -> xtd::u16string {
1564 return xtd::u8string {value};
1565 }
1566 template<>
1567 [[nodiscard]] inline auto as<xtd::u16string>(xtd::char8* value) -> xtd::u16string {
1568 return xtd::u8string {value};
1569 }
1570 template<>
1571 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::char8* value) -> xtd::u32string {
1572 return xtd::u8string {value};
1573 }
1574 template<>
1575 [[nodiscard]] inline auto as<xtd::u32string>(xtd::char8* value) -> xtd::u32string {
1576 return xtd::u8string {value};
1577 }
1578 template<>
1579 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::char8* value) -> xtd::u8string {
1580 return xtd::u8string {value};
1581 }
1582 template<>
1583 [[nodiscard]] inline auto as<xtd::u8string>(xtd::char8* value) -> xtd::u8string {
1584 return xtd::u8string {value};
1585 }
1586 template<>
1587 [[nodiscard]] inline auto as<xtd::wstring>(const xtd::char8* value) -> xtd::wstring {
1588 return xtd::u8string {value};
1589 }
1590 template<>
1591 [[nodiscard]] inline auto as<xtd::wstring>(xtd::char8* value) -> xtd::wstring {
1592 return xtd::u8string {value};
1593 }
1595
1597 template<typename type_t>
1598 [[nodiscard]] inline auto as(const xtd::wstring& value) -> type_t {
1599 return value;
1600 }
1601 template<typename type_t>
1602 [[nodiscard]] inline auto as(xtd::wstring& value) -> type_t {
1603 return value;
1604 }
1606
1625 template<>
1626 [[nodiscard]] inline auto as<xtd::string>(const xtd::wstring& value) -> xtd::string {
1627 return value;
1628 }
1629
1647 template<>
1648 [[nodiscard]] inline auto as<xtd::string>(xtd::wstring& value) -> xtd::string {
1649 return value;
1650 }
1651
1670 template<>
1671 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::wstring& value) -> xtd::u16string {
1672 return value;
1673 }
1674
1692 template<>
1693 [[nodiscard]] inline auto as<xtd::u16string>(xtd::wstring& value) -> xtd::u16string {
1694 return value;
1695 }
1696
1715 template<>
1716 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::wstring& value) -> xtd::u32string {
1717 return value;
1718 }
1719
1737 template<>
1738 [[nodiscard]] inline auto as<xtd::u32string>(xtd::wstring& value) -> xtd::u32string {
1739 return value;
1740 }
1741
1760 template<>
1761 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::wstring& value) -> xtd::u8string {
1762 return value;
1763 }
1764
1782 template<>
1783 [[nodiscard]] inline auto as<xtd::u8string>(xtd::wstring& value) -> xtd::u8string {
1784 return value;
1785 }
1786
1788 template<>
1789 [[nodiscard]] inline auto as<xtd::u16string>(const xtd::wchar* value) -> xtd::u16string {
1790 return xtd::wstring {value};
1791 }
1792 template<>
1793 [[nodiscard]] inline auto as<xtd::u16string>(xtd::wchar* value) -> xtd::u16string {
1794 return xtd::wstring {value};
1795 }
1796 template<>
1797 [[nodiscard]] inline auto as<xtd::u32string>(const xtd::wchar* value) -> xtd::u32string {
1798 return xtd::wstring {value};
1799 }
1800 template<>
1801 [[nodiscard]] inline auto as<xtd::u32string>(xtd::wchar* value) -> xtd::u32string {
1802 return xtd::wstring {value};
1803 }
1804 template<>
1805 [[nodiscard]] inline auto as<xtd::u8string>(const xtd::wchar* value) -> xtd::u8string {
1806 return xtd::wstring {value};
1807 }
1808 template<>
1809 [[nodiscard]] inline auto as<xtd::u8string>(xtd::wchar* value) -> xtd::u8string {
1810 return xtd::wstring {value};
1811 }
1812 template<>
1813 [[nodiscard]] inline auto as<xtd::wstring>(const xtd::wchar* value) -> xtd::wstring {
1814 return xtd::wstring {value};
1815 }
1816 template<>
1817 [[nodiscard]] inline auto as<xtd::wstring>(xtd::wchar* value) -> xtd::wstring {
1818 return xtd::wstring {value};
1819 }
1821}
static auto to_string(xtd::any value) -> xtd::string
Convert xtd::any to string.
@ value
Represnets the constant operator precedence (42).
Definition operator_precedence.hpp:30
xtd::basic_string< xtd::char8 > u8string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:76
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
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::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:87
std::int64_t int64
Represents a 64-bit signed integer.
Definition int64.hpp:23
std::uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.hpp:23
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:26
__slong__ slong
Represents a 32-bit or 64-bit signed integer.
Definition slong.hpp:27
std::int8_t sbyte
Represents a 8-bit signed integer.
Definition sbyte.hpp:23
wchar_t wchar
Represents a wide character.
Definition wchar.hpp:24
__ulong__ ulong
Represents a 32-bit or 64-bit unsigned integer.
Definition ulong.hpp:27
long double decimal
Represents a decimal-precision floating-point number.
Definition decimal.hpp:23
std::uint16_t uint16
Represents a 16-bit unsigned integer.
Definition uint16.hpp:23
char16_t char16
Represents a 16-bit unicode character.
Definition char16.hpp:26
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
std::int16_t int16
Represents a 16-bit signed integer.
Definition int16.hpp:23
std::uint64_t uint64
Represents a 64-bit unsigned integer.
Definition uint64.hpp:23
std::uint8_t byte
Represents a 8-bit unsigned integer.
Definition byte.hpp:23
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:23
std::any any
Represents the any alias on std::any.
Definition any.hpp:24
auto as< xtd::string >(const std::string &value) -> xtd::string
Casts a type into another type.
Definition __as_std_string.hpp:61
auto as(any_object &o) -> type_t
Casts a type into another type.
Definition __as_any_object.hpp:60
auto as< xtd::wstring >(const xtd::string &value) -> xtd::wstring
Casts a type into another type.
Definition __as_string.hpp:856
auto as< xtd::u32string >(const xtd::string &value) -> xtd::u32string
Casts a type into another type.
Definition __as_string.hpp:766
auto as< xtd::u16string >(const xtd::string &value) -> xtd::u16string
Casts a type into another type.
Definition __as_string.hpp:721
auto as< xtd::u8string >(const xtd::string &value) -> xtd::u8string
Casts a type into another type.
Definition __as_string.hpp:811
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8