5#define __XTD_STD_INTERNAL__
7#undef __XTD_STD_INTERNAL__
18#include <forward_list>
29#include <system_error>
33#include <unordered_map>
34#include <unordered_set>
49template<
typename char_t>
50[[nodiscard]]
inline auto __codepoint_to_string(
xtd::char32 codepoint) -> std::basic_string<char_t> {
51 std::basic_string<char_t> result;
53 result.push_back(
static_cast<char_t
>(codepoint));
54 else if (codepoint < 0x800) {
55 result.push_back(
static_cast<char_t
>((codepoint >> 6) | 0xc0));
56 result.push_back(
static_cast<char_t
>((codepoint & 0x3f) | 0x80));
57 }
else if (codepoint < 0x10000) {
58 result.push_back(
static_cast<char_t
>((codepoint >> 12) | 0xe0));
59 result.push_back(
static_cast<char_t
>(((codepoint >> 6) & 0x3f) | 0x80));
60 result.push_back(
static_cast<char_t
>((codepoint & 0x3f) | 0x80));
62 result.push_back(
static_cast<char_t
>((codepoint >> 18) | 0xf0));
63 result.push_back(
static_cast<char_t
>(((codepoint >> 12) & 0x3f) | 0x80));
64 result.push_back(
static_cast<char_t
>(((codepoint >> 6) & 0x3f) | 0x80));
65 result.push_back(
static_cast<char_t
>((codepoint & 0x3f) | 0x80));
70template<
typename char_t>
71[[nodiscard]]
inline auto __to_string(
char codepoint) -> std::basic_string<char_t> {
72 return __codepoint_to_string<char_t>(codepoint);
75template<
typename char_t>
76[[nodiscard]]
inline auto __to_string(
xtd::char32 codepoint) -> std::basic_string<char_t> {
77 return __codepoint_to_string<char_t>(codepoint);
80template<
typename char_t>
81[[nodiscard]]
inline auto __to_string(
xtd::char16 codepoint) -> std::basic_string<char_t> {
82 return __codepoint_to_string<char_t>(codepoint);
85template<
typename char_t>
86[[nodiscard]]
inline auto __to_string(
xtd::char8 codepoint) -> std::basic_string<char_t> {
87 return __codepoint_to_string<char_t>(codepoint);
90template<
typename char_t>
91[[nodiscard]]
inline auto __to_string(
xtd::wchar codepoint) -> std::basic_string<char_t> {
92 return __codepoint_to_string<char_t>(codepoint);
95template<
typename char_t>
96[[nodiscard]]
inline auto __to_string(
const std::basic_string<char_t>& str) -> std::basic_string<char_t> {
97 std::basic_string<char_t> result;
98 std::for_each(str.begin(), str.end(), [&](
auto codepoint) {result += __to_string<char_t>(codepoint);});
102template<
typename char_t,
typename arg_t>
103[[nodiscard]]
inline auto __to_string(
const std::basic_string<arg_t>& str) -> std::basic_string<char_t> {
104 std::basic_string<char_t> result;
105 for (
auto codepoint : str)
106 result += __to_string<char_t>(codepoint);
110template<
typename char_t,
typename arg_t>
111[[nodiscard]]
inline auto __to_string(
const arg_t* str) -> std::basic_string<char_t> {
112 std::basic_string<char_t> result;
113 for (
auto codepoint : std::basic_string<arg_t>(str))
114 result += __to_string<char_t>(codepoint);
118auto operator <<(std::ostream& os,
const xtd::char8* str) -> std::ostream&;
119auto operator <<(std::ostream& os,
const xtd::char16* str) -> std::ostream&;
120auto operator <<(std::ostream& os,
const xtd::char32* str) -> std::ostream&;
121auto operator <<(std::ostream& os,
const xtd::wchar* str) -> std::ostream&;
123template<
typename enum_t>
124[[nodiscard]]
auto __enum_to_string__(enum_t value)
noexcept -> std::string;
125[[nodiscard]]
auto __iformatable_to_string(
const xtd::iformatable& value)
noexcept -> std::string;
126[[nodiscard]]
auto __object_to_string__(
const xtd::object& value)
noexcept -> std::string;
128template<
typename char_t,
typename type_t,
typename bool_t>
129struct __enum_ostream__ {};
131template <
class char_t,
typename type_t >
132struct __enum_ostream__ < char_t, type_t, std::true_type > {
133 auto to_stream(std::basic_ostream<char_t>& os,
const type_t& value)
noexcept -> std::basic_ostream<char_t>& {
134 return os << __enum_to_string__(value);
138template <
class char_t,
typename type_t,
typename bool_t >
139struct __enum_or_polymorphic_ostream__ {};
141template <
class char_t,
typename type_t >
142struct __enum_or_polymorphic_ostream__ < char_t, type_t, std::true_type > {
143 auto to_stream(std::basic_ostream<char_t>& os,
const type_t& value)
noexcept -> std::basic_ostream <char_t>& {
144 if (
dynamic_cast < const xtd::iformatable*
> (&value))
return os << __iformatable_to_string(dynamic_cast<const xtd::iformatable&>(value));
145 if (
dynamic_cast < const xtd::object*
> (&value))
return os << __object_to_string__(
dynamic_cast<const xtd::object&
>(value));
150template <
class char_t,
typename type_t >
151struct __enum_or_polymorphic_ostream__ < char_t, type_t, std::false_type > {
152 auto to_stream(std::basic_ostream<char_t>& os,
const type_t& value)
noexcept -> std::basic_ostream<char_t>& {
153 __enum_ostream__ < char, type_t, typename std::is_enum < type_t>::type > ().to_stream(os, value);
158template <
class value_t >
159[[nodiscard]]
auto __format_stringer_to_std_string(
const value_t& value) -> std::string {
160 std::basic_stringstream<char> ss;
162 __enum_or_polymorphic_ostream__ < char, value_t, typename std::is_polymorphic < value_t>::type > ().to_stream(ss, value);
166[[nodiscard]]
auto __format_stringer_to_std_string(
const char& c) -> std::string;
167[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::char8& c) -> std::string;
168[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::char16& c) -> std::string;
169[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::char32& c) -> std::string;
170[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::wchar& c) -> std::string;
171[[nodiscard]]
auto __format_stringer_to_std_string(
const char* str) -> std::string;
172[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::char8* str) -> std::string;
173[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::char16* str) -> std::string;
174[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::char32* str) -> std::string;
175[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::wchar* str) -> std::string;
176[[nodiscard]]
auto __format_stringer_to_std_string(
const std::string& str) -> std::string;
177[[nodiscard]]
auto __format_stringer_to_std_string(
const xtd::string& str) -> std::string;
178[[nodiscard]]
auto __format_stringer_to_std_string(
const std::u8string& str) -> std::string;
179[[nodiscard]]
auto __format_stringer_to_std_string(
const std::u16string& str) -> std::string;
180[[nodiscard]]
auto __format_stringer_to_std_string(
const std::u32string& str) -> std::string;
181[[nodiscard]]
auto __format_stringer_to_std_string(
const std::wstring& str) -> std::string;
183template <
class char_t,
typename value_t >
184[[nodiscard]]
inline auto __format_stringer(value_t value) -> std::basic_string<char_t> {
185 std::basic_stringstream<char_t> ss;
186 ss << __format_stringer_to_std_string(value).c_str();
190template <
class char_t,
typename value_t >
191[[nodiscard]]
inline auto __format_stringer(
const bool& value) -> std::basic_string<char_t> {
192 std::basic_stringstream<char_t> ss;
193 ss << std::boolalpha <<
value;
197template <
class char_t,
typename value_t, xtd::
int32 len >
198[[nodiscard]]
inline auto __format_stringer(
const char*& value) -> std::basic_string<char_t> {
199 std::basic_stringstream<char_t> ss;
200 ss << __to_string < char_t > (value);
204template <
class char_t,
typename value_t, xtd::
int32 len >
205[[nodiscard]]
inline auto __format_stringer(
const char*
const& value) -> std::basic_string<char_t> {
206 std::basic_stringstream<char_t> ss;
207 ss << __to_string < char_t > (value);
211template <
class char_t,
typename value_t >
212[[nodiscard]]
inline auto __format_stringer(
const xtd::char8*& value) -> std::basic_string<char_t> {
213 auto s = std::u8string(value);
214 std::basic_stringstream<char_t> ss;
215 ss << std::basic_string<char_t> (
s.begin(),
s.end());
219template <
class char_t,
typename value_t >
220[[nodiscard]]
inline auto __format_stringer(
const xtd::char8*
const& value) -> std::basic_string<char_t> {
221 auto s = std::u8string(value);
222 std::basic_stringstream<char_t> ss;
223 ss << std::basic_string<char_t> (
s.begin(),
s.end());
227template <
class char_t,
typename value_t >
228[[nodiscard]]
inline auto __format_stringer(
const xtd::char16*& value) -> std::basic_string<char_t> {
229 std::basic_stringstream<char_t> ss;
230 ss << __to_string < char_t > (value);
234template <
class char_t,
typename value_t >
235[[nodiscard]]
inline auto __format_stringer(
const xtd::char16*
const& value) -> std::basic_string<char_t> {
236 std::basic_stringstream<char_t> ss;
237 ss << __to_string < char_t > (value);
241template <
class char_t,
typename value_t >
242[[nodiscard]]
inline auto __format_stringer(
const xtd::char32*& value) -> std::basic_string<char_t> {
243 std::basic_stringstream<char_t> ss;
244 ss << __to_string < char_t > (value);
248template <
class char_t,
typename value_t >
249[[nodiscard]]
inline auto __format_stringer(
const xtd::char32*
const& value) -> std::basic_string<char_t> {
250 std::basic_stringstream<char_t> ss;
251 ss << __to_string < char_t > (value);
255template <
class char_t,
typename value_t >
256[[nodiscard]]
inline auto __format_stringer(
const xtd::wchar*& value) -> std::basic_string<char_t> {
257 std::basic_stringstream<char_t> ss;
258 ss << __to_string < char_t > (value);
262template <
class char_t,
typename value_t >
263[[nodiscard]]
inline auto __format_stringer(
const xtd::wchar*
const& value) -> std::basic_string<char_t> {
264 std::basic_stringstream<char_t> ss;
265 ss << __to_string < char_t > (value);
270[[nodiscard]]
inline auto __format_stringer<char, std::u8string&>(std::u8string& value) -> std::string {
271 std::basic_stringstream < char > ss;
272 ss << std::string(
value.begin(),
value.end());
277[[nodiscard]]
inline auto __format_stringer<char, const std::u16string&>(
const std::u16string& value) -> std::string {
278 std::basic_stringstream < char > ss;
279 ss << __to_string < char > (value);
284[[nodiscard]]
inline auto __format_stringer<char, const std::u32string&>(
const std::u32string& value) -> std::string {
285 std::basic_stringstream < char > ss;
286 ss << __to_string < char > (value);
291[[nodiscard]]
inline auto __format_stringer<char, const std::wstring&>(
const std::wstring& value) -> std::string {
292 std::basic_stringstream < char > ss;
293 ss << __to_string < char > (value);
298[[nodiscard]]
inline auto __format_stringer<char, bool&>(
bool& value) -> std::string;
301[[nodiscard]]
inline auto __format_stringer<char, xtd::sbyte&>(
xtd::sbyte& value) -> std::string;
304[[nodiscard]]
inline auto __format_stringer<char, const unsigned char&>(
const unsigned char& value) -> std::string;
307[[nodiscard]]
inline auto __format_stringer<char, unsigned char&>(
unsigned char& value) -> std::string;
310[[nodiscard]]
inline auto __format_stringer<char, short&>(
short& value) -> std::string;
313[[nodiscard]]
inline auto __format_stringer<char, unsigned short&>(
unsigned short& value) -> std::string;
316[[nodiscard]]
inline auto __format_stringer<char, int&>(
int& value) -> std::string;
319[[nodiscard]]
inline auto __format_stringer<char, unsigned int&>(
unsigned int& value) -> std::string;
322[[nodiscard]]
inline auto __format_stringer<char, long&>(
long& value) -> std::string;
325[[nodiscard]]
inline auto __format_stringer<char, unsigned long&>(
unsigned long& value) -> std::string;
328[[nodiscard]]
inline auto __format_stringer<char, long long&>(
long long& value) -> std::string;
331[[nodiscard]]
inline auto __format_stringer<char, unsigned long long&>(
unsigned long long& value) -> std::string;
334[[nodiscard]]
inline auto __format_stringer<char, float&>(
float& value) -> std::string;
337[[nodiscard]]
inline auto __format_stringer<char, double&>(
double& value) -> std::string;
340[[nodiscard]]
inline auto __format_stringer<char, long double&>(
long double& value) -> std::string;
343[[nodiscard]]
inline auto __format_stringer<char, std::chrono::system_clock::time_point&>(std::chrono::system_clock::time_point& value) -> std::string;
346[[nodiscard]]
inline auto __format_stringer<char, std::tm&>(tm& value) -> std::string;
349[[nodiscard]]
inline auto __format_stringer<char, xtd::wchar&>(
xtd::wchar& value) -> std::string;
352[[nodiscard]]
inline auto __format_stringer<char, xtd::char8&>(
xtd::char8& value) -> std::string;
355[[nodiscard]]
inline auto __format_stringer<char, xtd::char16&>(
xtd::char16& value) -> std::string;
358[[nodiscard]]
inline auto __format_stringer<char, xtd::char32&>(
xtd::char32& value) -> std::string;
Contains xtd::any type and std::bad_any_cast exception.
Contains std::chrono::days, std::chrono::weeks, std::chrono::months and std::chrono::years duration t...
Represents text as a sequence of character units.
Definition basic_string.hpp:66
Provides information about a specific culture (called a locale for unmanaged code development)....
Definition culture_info.hpp:43
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.hpp:45
Contains xtd::collections::generic::ienumerable <type_t> interface.
@ value
Represnets the constant operator precedence (42).
Definition operator_precedence.hpp:30
xtd::basic_string< char > string
Represents text as a sequence of UTF-8 code units.
Definition __string_definitions.hpp:43
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:26
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
char16_t char16
Represents a 16-bit unicode character.
Definition char16.hpp:26
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:23
@ s
The S key.
Definition console_key.hpp:124
Contains classes that define culture-related information, including language, country/region,...
Definition culture_info.hpp:20
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
Contains xtd::optional type.
Contains xtd fundamental types.