5#define __XTD_STD_INTERNAL__
7#undef __XTD_STD_INTERNAL__
20#include <forward_list>
31#include <system_error>
35#include <unordered_map>
36#include <unordered_set>
52inline std::basic_string<char_t> __codepoint_to_string(
xtd::char32 codepoint) {
53 std::basic_string<char_t> result;
55 result.push_back(
static_cast<char_t
>(codepoint));
56 else if (codepoint < 0x800) {
57 result.push_back(
static_cast<char_t
>((codepoint >> 6) | 0xc0));
58 result.push_back(
static_cast<char_t
>((codepoint & 0x3f) | 0x80));
59 }
else if (codepoint < 0x10000) {
60 result.push_back(
static_cast<char_t
>((codepoint >> 12) | 0xe0));
61 result.push_back(
static_cast<char_t
>(((codepoint >> 6) & 0x3f) | 0x80));
62 result.push_back(
static_cast<char_t
>((codepoint & 0x3f) | 0x80));
64 result.push_back(
static_cast<char_t
>((codepoint >> 18) | 0xf0));
65 result.push_back(
static_cast<char_t
>(((codepoint >> 12) & 0x3f) | 0x80));
66 result.push_back(
static_cast<char_t
>(((codepoint >> 6) & 0x3f) | 0x80));
67 result.push_back(
static_cast<char_t
>((codepoint & 0x3f) | 0x80));
73inline std::basic_string<char_t> __to_string(
char codepoint) {
74 return __codepoint_to_string<char_t>(codepoint);
78inline std::basic_string<char_t> __to_string(
xtd::char32 codepoint) {
79 return __codepoint_to_string<char_t>(codepoint);
83inline std::basic_string<char_t> __to_string(
xtd::char16 codepoint) {
84 return __codepoint_to_string<char_t>(codepoint);
88inline std::basic_string<char_t> __to_string(
xtd::char8 codepoint) {
89 return __codepoint_to_string<char_t>(codepoint);
93inline std::basic_string<char_t> __to_string(
xtd::wchar codepoint) {
94 return __codepoint_to_string<char_t>(codepoint);
98inline std::basic_string<char_t> __to_string(
const std::basic_string<char_t>& str) {
99 std::basic_string<char_t> result;
100 std::for_each(str.begin(), str.end(), [&](
auto codepoint) {result += __to_string<char_t>(codepoint);});
104template<
class char_t,
class arg_t>
105inline std::basic_string<char_t> __to_string(
const std::basic_string<arg_t>& str) {
106 std::basic_string<char_t> result;
107 for (
auto codepoint : str)
108 result += __to_string<char_t>(codepoint);
112template<
class char_t,
class arg_t>
113inline std::basic_string<char_t> __to_string(
const arg_t* str) {
114 std::basic_string<char_t> result;
115 for (
auto codepoint : std::basic_string<arg_t>(str))
116 result += __to_string<char_t>(codepoint);
120std::ostream& operator <<(std::ostream& os,
const xtd::char8* str);
121std::ostream& operator <<(std::ostream& os,
const xtd::char16* str);
122std::ostream& operator <<(std::ostream& os,
const xtd::char32* str);
123std::ostream& operator <<(std::ostream& os,
const xtd::wchar* str);
125template<
class enum_t>
126std::string __enum_to_string__(enum_t value)
noexcept;
128std::string __object_to_string__(
const xtd::object& value)
noexcept;
130template<
class char_t,
class type_t,
class bool_t>
131struct __enum_ostream__ {};
133template <
class char_t,
class type_t >
134struct __enum_ostream__ < char_t, type_t, std::true_type > {
135 std::basic_ostream < char_t >& to_stream(std::basic_ostream < char_t >& os,
const type_t& value)
noexcept {
136 return os << __enum_to_string__(value);
140template <
class char_t,
class type_t,
class bool_t >
141struct __enum_or_polymorphic_ostream__ {};
143template <
class char_t,
class type_t >
144struct __enum_or_polymorphic_ostream__ < char_t, type_t, std::true_type > {
145 std::basic_ostream < char_t >& to_stream(std::basic_ostream < char_t >& os,
const type_t& value)
noexcept {
146 if (
dynamic_cast < const xtd::iformatable*
> (&value))
return os << __iformatable_to_string(dynamic_cast < const xtd::iformatable& > (value));
147 if (
dynamic_cast < const xtd::object*
> (&value))
return os << __object_to_string__(
dynamic_cast < const xtd::object&
> (value));
152template <
class char_t,
class type_t >
153struct __enum_or_polymorphic_ostream__ < char_t, type_t, std::false_type > {
154 std::basic_ostream < char_t >& to_stream(std::basic_ostream < char_t >& os,
const type_t& value)
noexcept {
155 __enum_ostream__ < char, type_t, typename std::is_enum < type_t>::type > ().to_stream(os, value);
160template <
class value_t >
161std::string __format_stringer_to_std_string(
const value_t& value) {
162 std::basic_stringstream < char > ss;
164 __enum_or_polymorphic_ostream__ < char, value_t, typename std::is_polymorphic < value_t>::type > ().to_stream(ss, value);
168std::string __format_stringer_to_std_string(
const char& c);
169std::string __format_stringer_to_std_string(
const xtd::char8& c);
170std::string __format_stringer_to_std_string(
const xtd::char16& c);
171std::string __format_stringer_to_std_string(
const xtd::char32& c);
172std::string __format_stringer_to_std_string(
const xtd::wchar& c);
173std::string __format_stringer_to_std_string(
const char* str);
174std::string __format_stringer_to_std_string(
const xtd::char8* str);
175std::string __format_stringer_to_std_string(
const xtd::char16* str);
176std::string __format_stringer_to_std_string(
const xtd::char32* str);
177std::string __format_stringer_to_std_string(
const xtd::wchar* str);
178std::string __format_stringer_to_std_string(
const std::string& str);
179std::string __format_stringer_to_std_string(
const xtd::string& str);
180std::string __format_stringer_to_std_string(
const std::u8string& str);
181std::string __format_stringer_to_std_string(
const std::u16string& str);
182std::string __format_stringer_to_std_string(
const std::u32string& str);
183std::string __format_stringer_to_std_string(
const std::wstring& str);
185template <
class char_t,
class value_t >
186inline std::basic_string < char_t > __format_stringer(value_t value) {
187 std::basic_stringstream < char_t > ss;
188 ss << __format_stringer_to_std_string(value).c_str();
192template <
class char_t,
class value_t >
193inline std::basic_string < char_t > __format_stringer(
const bool& value) {
194 std::basic_stringstream < char_t > ss;
195 ss << std::boolalpha << value;
199template <
class char_t,
class value_t, xtd::
int32 len >
200inline std::basic_string < char_t > __format_stringer(
const char*& value) {
201 std::basic_stringstream < char_t > ss;
202 ss << __to_string < char_t > (value);
206template <
class char_t,
class value_t, xtd::
int32 len >
207inline std::basic_string < char_t > __format_stringer(
const char*
const& value) {
208 std::basic_stringstream < char_t > ss;
209 ss << __to_string < char_t > (value);
213template <
class char_t,
class value_t >
214inline std::basic_string < char_t > __format_stringer(
const xtd::char8*& value) {
215 auto s = std::u8string(value);
216 std::basic_stringstream < char_t > ss;
217 ss << std::basic_string < char_t > (
s.begin(),
s.end());
221template <
class char_t,
class value_t >
222inline std::basic_string < char_t > __format_stringer(
const xtd::char8*
const& value) {
223 auto s = std::u8string(value);
224 std::basic_stringstream < char_t > ss;
225 ss << std::basic_string < char_t > (
s.begin(),
s.end());
229template <
class char_t,
class value_t >
230inline std::basic_string < char_t > __format_stringer(
const xtd::char16*& value) {
231 std::basic_stringstream < char_t > ss;
232 ss << __to_string < char_t > (value);
236template <
class char_t,
class value_t >
237inline std::basic_string < char_t > __format_stringer(
const xtd::char16*
const& value) {
238 std::basic_stringstream < char_t > ss;
239 ss << __to_string < char_t > (value);
243template <
class char_t,
class value_t >
244inline std::basic_string < char_t > __format_stringer(
const xtd::char32*& value) {
245 std::basic_stringstream < char_t > ss;
246 ss << __to_string < char_t > (value);
250template <
class char_t,
class value_t >
251inline std::basic_string < char_t > __format_stringer(
const xtd::char32*
const& value) {
252 std::basic_stringstream < char_t > ss;
253 ss << __to_string < char_t > (value);
257template <
class char_t,
class value_t >
258inline std::basic_string < char_t > __format_stringer(
const xtd::wchar*& value) {
259 std::basic_stringstream < char_t > ss;
260 ss << __to_string < char_t > (value);
264template <
class char_t,
class value_t >
265inline std::basic_string < char_t > __format_stringer(
const xtd::wchar*
const& value) {
266 std::basic_stringstream < char_t > ss;
267 ss << __to_string < char_t > (value);
272inline std::string __format_stringer < char, std::u8string& > (std::u8string& value) {
273 std::basic_stringstream < char > ss;
274 ss << std::string(value.begin(), value.end());
279inline std::string __format_stringer < char, const std::u16string& > (
const std::u16string& value) {
280 std::basic_stringstream < char > ss;
281 ss << __to_string < char > (value);
286inline std::string __format_stringer < char, const std::u32string& > (
const std::u32string& value) {
287 std::basic_stringstream < char > ss;
288 ss << __to_string < char > (value);
293inline std::string __format_stringer < char, const std::wstring& > (
const std::wstring& value) {
294 std::basic_stringstream < char > ss;
295 ss << __to_string < char > (value);
300inline std::string __format_stringer < char, bool& > (
bool& value);
303inline std::string __format_stringer < char, xtd::sbyte& > (
xtd::sbyte& value);
306inline std::string __format_stringer < char, const unsigned char& > (
const unsigned char& value);
309inline std::string __format_stringer < char, unsigned char& > (
unsigned char& value);
312inline std::string __format_stringer < char, short& > (
short& value);
315inline std::string __format_stringer < char, unsigned short& > (
unsigned short& value);
318inline std::string __format_stringer < char, int& > (
int& value);
321inline std::string __format_stringer < char, unsigned int& > (
unsigned int& value);
324inline std::string __format_stringer < char, long& > (
long& value);
327inline std::string __format_stringer < char, unsigned long& > (
unsigned long& value);
330inline std::string __format_stringer < char, long long& > (
long long& value);
333inline std::string __format_stringer < char, unsigned long long& > (
unsigned long long& value);
336inline std::string __format_stringer < char, float& > (
float& value);
339inline std::string __format_stringer < char, double& > (
double& value);
342inline std::string __format_stringer < char, long double& > (
long double& value);
345inline std::string __format_stringer < char, std::chrono::system_clock::time_point& > (std::chrono::system_clock::time_point& value);
348inline std::string __format_stringer < char, std::tm& > (tm& value);
351inline std::string __format_stringer < char, xtd::wchar& > (
xtd::wchar& value);
354inline std::string __format_stringer < char, xtd::char8& > (
xtd::char8& value);
357inline std::string __format_stringer < char, xtd::char16& > (
xtd::char16& value);
360inline std::string __format_stringer < char, xtd::char32& > (
xtd::char32& value);
Contains string definitions.
Contains __xtd_std_version definitions.
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:67
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:44
Contains xtd::collections::generic::ienumerable <type_t> interface.
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.