xtd 0.2.0
Loading...
Searching...
No Matches
__format_stringer.hpp
Go to the documentation of this file.
1
3#pragma once
4
5#define __XTD_STD_INTERNAL__
7#undef __XTD_STD_INTERNAL__
10#include "../any.hpp"
11#include "../chrono.hpp"
12#include "../optional.hpp"
13#include "../types.hpp"
14#include <algorithm>
15#include <array>
16#include <cctype>
17#include <cstddef>
18#include <cstdint>
19#include <deque>
20#include <forward_list>
21#include <functional>
22#include <iomanip>
23#include <iostream>
24#include <locale>
25#include <list>
26#include <map>
27#include <set>
28#include <sstream>
29#include <stdexcept>
30#include <string>
31#include <system_error>
32#include <tuple>
33#include <type_traits>
34#include <typeindex>
35#include <unordered_map>
36#include <unordered_set>
37#include <utility>
38#include <valarray>
39#include <vector>
40
41
43namespace xtd {
44 class iformatable;
45 class object;
46
47 template<class value_t>
48 inline std::string to_string(const value_t& value, const std::string& fmt, const std::locale& loc);
49 template<>
50 inline std::string to_string(const bool& value, const std::string& fmt, const std::locale& loc);
51 template<>
52 inline std::string to_string(const xtd::sbyte& value, const std::string& fmt, const std::locale& loc);
53 template<>
54 inline std::string to_string(const char& value, const std::string& fmt, const std::locale& loc);
55 template<>
56 inline std::string to_string(const unsigned char& value, const std::string& fmt, const std::locale& loc);
57 template<>
58 inline std::string to_string(const short& value, const std::string& fmt, const std::locale& loc);
59 template<>
60 inline std::string to_string(const unsigned short& value, const std::string& fmt, const std::locale& loc);
61 template<>
62 inline std::string to_string(const int& value, const std::string& fmt, const std::locale& loc);
63 template<>
64 inline std::string to_string(const unsigned int& value, const std::string& fmt, const std::locale& loc);
65 template<>
66 inline std::string to_string(const long& value, const std::string& fmt, const std::locale& loc);
67 template<>
68 inline std::string to_string(const unsigned long& value, const std::string& fmt, const std::locale& loc);
69 template<>
70 inline std::string to_string(const long long& value, const std::string& fmt, const std::locale& loc);
71 template<>
72 inline std::string to_string(const unsigned long long& value, const std::string& fmt, const std::locale& loc);
73 template<>
74 inline std::string to_string(const float& value, const std::string& fmt, const std::locale& loc);
75 template<>
76 inline std::string to_string(const double& value, const std::string& fmt, const std::locale& loc);
77 template<>
78 inline std::string to_string(const long double& value, const std::string& fmt, const std::locale& loc);
79 template<>
80 inline std::string to_string(const std::chrono::system_clock::time_point& value, const std::string& fmt, const std::locale& loc);
81 template<>
82 inline std::string to_string(const std::tm& value, const std::string& fmt, const std::locale& loc);
83 template<class type_t, class period_t = std::ratio<1>>
84 inline std::string to_string(const std::chrono::duration<type_t, period_t>& value, const std::string& fmt, const std::locale& loc);
85 template<>
86 inline std::string to_string(const xtd::char8& value, const std::string& fmt, const std::locale& loc);
87 template<>
88 inline std::string to_string(const xtd::char16& value, const std::string& fmt, const std::locale& loc);
89 template<>
90 inline std::string to_string(const xtd::char32& value, const std::string& fmt, const std::locale& loc);
91 template<>
92 inline std::string to_string(const xtd::wchar& value, const std::string& fmt, const std::locale& loc);
93 template<>
94 inline std::string to_string(const std::partial_ordering& value, const std::string& fmt, const std::locale& loc);
95 template<>
96 inline std::string to_string(const std::strong_ordering& value, const std::string& fmt, const std::locale& loc);
97 template<>
98 inline std::string to_string(const std::weak_ordering& value, const std::string& fmt, const std::locale& loc);
99 template<class value_t>
100 inline std::string to_string(const value_t* value, const std::string& fmt, const std::locale& loc);
101 template<class value_t>
102 inline std::string to_string(value_t* const value, const std::string& fmt, const std::locale& loc);
103 template<class type_t>
104 inline std::string to_string(const std::shared_ptr<type_t>& value, const std::string& fmt, const std::locale& loc);
105 template<class type_t>
106 inline std::string to_string(const std::unique_ptr<type_t>& value, const std::string& fmt, const std::locale& loc);
107 template<>
108 inline std::string to_string(const xtd::any& value, const std::string& fmt, const std::locale& loc);
109 template<class type_t>
110 inline std::string to_string(const std::optional<type_t>& value, const std::string& fmt, const std::locale& loc);
111 template<>
112 inline std::string to_string(const std::nullopt_t& value, const std::string& fmt, const std::locale& loc);
113 template<class type1_t, class type2_t>
114 inline std::string to_string(const std::pair<type1_t, type2_t>& value, const std::string& fmt, const std::locale& loc);
115 template<class ...types_t>
116 inline std::string to_string(const std::tuple<types_t ...>& value, const std::string& fmt, const std::locale& loc);
117 template<class type_t, size_t size>
118 inline std::string to_string(const std::array<type_t, size>& values, const std::string& fmt, const std::locale& loc);
119 template<class type_t, class allocator_t = std::allocator<type_t>>
120 inline std::string to_string(const std::deque<type_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
121 template<class type_t, class allocator_t = std::allocator<type_t>>
122 inline std::string to_string(const std::forward_list<type_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
123 template<class type_t>
124 inline std::string to_string(const std::initializer_list<type_t>& values, const std::string& fmt, const std::locale& loc);
125 template<class type_t, class allocator_t = std::allocator<type_t>>
126 inline std::string to_string(const std::list<type_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
127 template<class type_t>
128 inline std::string to_string(const std::valarray<type_t>& values, const std::string& fmt, const std::locale& loc);
129 template<class type_t, class allocator_t = std::allocator<type_t>>
130 inline std::string to_string(const std::vector<type_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
131 template<class key_t, class value_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<std::pair<const key_t, value_t >>>
132 inline std::string to_string(const std::map<key_t, value_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
133 template<class key_t, class value_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<std::pair<const key_t, value_t >>>
134 inline std::string to_string(const std::multimap<key_t, value_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
135 template<class key_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<key_t >>
136 inline std::string to_string(const std::multiset<key_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
137 template<class key_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<key_t >>
138 inline std::string to_string(const std::set<key_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
139 template<class key_t, class value_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<std::pair<const key_t, value_t >>>
140 inline std::string to_string(const std::unordered_map<key_t, value_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
141 template<class key_t, class value_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<std::pair<const key_t, value_t >>>
142 inline std::string to_string(const std::unordered_multimap<key_t, value_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
143 template<class key_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<key_t >>
144 inline std::string to_string(const std::unordered_multiset<key_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
145 template<class key_t, class compare_t = std::less<key_t>, class allocator_t = std::allocator<key_t >>
146 inline std::string to_string(const std::unordered_set<key_t, compare_t, allocator_t>& values, const std::string& fmt, const std::locale& loc);
147 #if defined(__xtd__cpp_lib_ranges)
148 //template <std::ranges::range range_t>
149 //inline std::string to_string(const range_t& values, const std::string& fmt, const std::locale& loc);
150 #endif
151 template<class type_t>
152 inline std::string to_string(const xtd::collections::generic::ienumerable<type_t>& values, const std::string& fmt, const std::locale& loc);
153 template<class type_t>
154 inline std::string to_string(const __xtd_raw_array_data__<type_t>& values, const std::string& fmt, const std::locale& loc);
155
156 template<class value_t>
157 inline std::wstring to_string(const value_t& value, const std::wstring& fmt, const std::locale& loc);
158 template<>
159 inline std::wstring to_string(const bool& value, const std::wstring& fmt, const std::locale& loc);
160 template<>
161 inline std::wstring to_string(const xtd::sbyte& value, const std::wstring& fmt, const std::locale& loc);
162 template<>
163 inline std::wstring to_string(const char& value, const std::wstring& fmt, const std::locale& loc);
164 template<>
165 inline std::wstring to_string(const unsigned char& value, const std::wstring& fmt, const std::locale& loc);
166 template<>
167 inline std::wstring to_string(const short& value, const std::wstring& fmt, const std::locale& loc);
168 template<>
169 inline std::wstring to_string(const unsigned short& value, const std::wstring& fmt, const std::locale& loc);
170 template<>
171 inline std::wstring to_string(const int& value, const std::wstring& fmt, const std::locale& loc);
172 template<>
173 inline std::wstring to_string(const unsigned int& value, const std::wstring& fmt, const std::locale& loc);
174 template<>
175 inline std::wstring to_string(const long& value, const std::wstring& fmt, const std::locale& loc);
176 template<>
177 inline std::wstring to_string(const unsigned long& value, const std::wstring& fmt, const std::locale& loc);
178 template<>
179 inline std::wstring to_string(const long long& value, const std::wstring& fmt, const std::locale& loc);
180 template<>
181 inline std::wstring to_string(const unsigned long long& value, const std::wstring& fmt, const std::locale& loc);
182 template<>
183 inline std::wstring to_string(const float& value, const std::wstring& fmt, const std::locale& loc);
184 template<>
185 inline std::wstring to_string(const double& value, const std::wstring& fmt, const std::locale& loc);
186 template<>
187 inline std::wstring to_string(const long double& value, const std::wstring& fmt, const std::locale& loc);
188 template<>
189 inline std::wstring to_string(const std::chrono::system_clock::time_point& value, const std::wstring& fmt, const std::locale& loc);
190 template<>
191 inline std::wstring to_string(const std::tm& value, const std::wstring& fmt, const std::locale& loc);
192
193 template<class type_t, class period_t = std::ratio<1>>
194 inline std::wstring to_string(const std::chrono::duration<type_t, period_t>& value, const std::wstring& fmt, const std::locale& loc);
195 template<>
196 inline std::wstring to_string(const xtd::char8& value, const std::wstring& fmt, const std::locale& loc);
197 template<>
198 inline std::wstring to_string(const xtd::char16& value, const std::wstring& fmt, const std::locale& loc);
199 template<>
200 inline std::wstring to_string(const xtd::char32& value, const std::wstring& fmt, const std::locale& loc);
201 template<>
202 inline std::wstring to_string(const xtd::wchar& value, const std::wstring& fmt, const std::locale& loc);
203
204 template<class type_t, class string_t>
205 inline string_t to_string(type_t value, const std::map<type_t, string_t, std::greater<type_t>>& values) {
206 auto it = values.find(value);
207 if (it != values.end()) return it->second;
208 string_t result;
209 long long rest = static_cast<long long>(value);
210 for (auto item : values) {
211 if (static_cast<long long>(item.first) != 0 && (rest & static_cast<long long>(item.first)) == static_cast<long long>(item.first)) {
212 if (!result.empty()) result = string_t {',', ' '} + result;
213 result = item.second + result;
214 rest -= static_cast<long long>(item.first);
215 }
216 }
217 if (!result.empty()) return result;
218 return to_string(static_cast<long long>(value), string_t {'G'}, std::locale());
219 }
220
221 template<class type_t, class string_t>
222 inline string_t to_string(type_t value, const std::map<type_t, string_t>& values) {
223 std::map<type_t, string_t, std::greater<type_t>> descending_values;
224 for (auto item : values) descending_values[item.first] = item.second;
225 return to_string(value, descending_values);
226 }
227
228 template<class type_t>
229 inline std::string to_string(type_t value, const std::initializer_list<std::pair<type_t, std::string>>& il) {
230 std::map<type_t, std::string, std::greater<type_t>> values;
231 for (auto item : il) values[item.first] = item.second;
232 return to_string(value, values);
233 }
234
235 template<class type_t>
236 inline std::wstring to_string(type_t value, const std::initializer_list<std::pair<type_t, std::wstring>>& il) {
237 std::map<type_t, std::wstring, std::greater<type_t>> values;
238 for (auto item : il) values[item.first] = item.second;
239 return to_string(value, values);
240 }
241}
242
243template<class char_t>
244inline std::basic_string<char_t> __codepoint_to_string(xtd::char32 codepoint) {
245 std::basic_string<char_t> result;
246 if (codepoint < 0x80)
247 result.push_back(static_cast<char_t>(codepoint));
248 else if (codepoint < 0x800) {
249 result.push_back(static_cast<char_t>((codepoint >> 6) | 0xc0));
250 result.push_back(static_cast<char_t>((codepoint & 0x3f) | 0x80));
251 } else if (codepoint < 0x10000) {
252 result.push_back(static_cast<char_t>((codepoint >> 12) | 0xe0));
253 result.push_back(static_cast<char_t>(((codepoint >> 6) & 0x3f) | 0x80));
254 result.push_back(static_cast<char_t>((codepoint & 0x3f) | 0x80));
255 } else {
256 result.push_back(static_cast<char_t>((codepoint >> 18) | 0xf0));
257 result.push_back(static_cast<char_t>(((codepoint >> 12) & 0x3f) | 0x80));
258 result.push_back(static_cast<char_t>(((codepoint >> 6) & 0x3f) | 0x80));
259 result.push_back(static_cast<char_t>((codepoint & 0x3f) | 0x80));
260 }
261 return result;
262}
263
264template<class char_t>
265inline std::basic_string<char_t> __to_string(char codepoint) {
266 return __codepoint_to_string<char_t>(codepoint);
267}
268
269template<class char_t>
270inline std::basic_string<char_t> __to_string(xtd::char32 codepoint) {
271 return __codepoint_to_string<char_t>(codepoint);
272}
273
274template<class char_t>
275inline std::basic_string<char_t> __to_string(xtd::char16 codepoint) {
276 return __codepoint_to_string<char_t>(codepoint);
277}
278
279template<class char_t>
280inline std::basic_string<char_t> __to_string(xtd::char8 codepoint) {
281 return __codepoint_to_string<char_t>(codepoint);
282}
283
284template<class char_t>
285inline std::basic_string<char_t> __to_string(xtd::wchar codepoint) {
286 return __codepoint_to_string<char_t>(codepoint);
287}
288
289template<class char_t>
290inline std::basic_string<char_t> __to_string(const std::basic_string<char_t>& str) {
291 std::basic_string<char_t> result;
292 std::for_each(str.begin(), str.end(), [&](auto codepoint) {result += __to_string<char_t>(codepoint);});
293 return result;
294}
295
296template<class char_t, class arg_t>
297inline std::basic_string<char_t> __to_string(const std::basic_string<arg_t>& str) {
298 std::basic_string<char_t> result;
299 for (auto codepoint : str)
300 result += __to_string<char_t>(codepoint);
301 return result;
302}
303
304template<class char_t, class arg_t>
305inline std::basic_string<char_t> __to_string(const arg_t* str) {
306 std::basic_string<char_t> result;
307 for (auto codepoint : std::basic_string<arg_t>(str))
308 result += __to_string<char_t>(codepoint);
309 return result;
310}
311
312template<class char_t, class type_t, class period_t = std::ratio<1>>
313std::basic_ostream<char_t>& operator <<(std::basic_ostream<char_t>& os, const std::chrono::duration<type_t, period_t>& value) {
314 return os << xtd::to_string(value, std::basic_string<char_t> {'G'}, std::locale());
315}
316
317std::ostream & operator <<(std::ostream& os, const xtd::char8* str);
318std::ostream & operator <<(std::ostream& os, const xtd::char16* str);
319std::ostream & operator <<(std::ostream& os, const xtd::char32* str);
320std::ostream & operator <<(std::ostream& os, const xtd::wchar* str);
321
322template<class enum_t>
323std::string __enum_to_string__(enum_t value) noexcept;
324std::string __iformatable_to_string(const xtd::iformatable& value) noexcept;
325std::string __object_to_string__(const xtd::object& value) noexcept;
326
327template<class char_t, class type_t, class bool_t>
328struct __enum_ostream__ {};
329
330template < class char_t, class type_t >
331struct __enum_ostream__ < char_t, type_t, std::true_type > {
332 std::basic_ostream < char_t > & to_stream(std::basic_ostream < char_t > & os, const type_t& value) noexcept {
333 return os << __enum_to_string__(value);
334 }
335};
336
337template < class char_t, class type_t >
338struct __enum_ostream__ < char_t, type_t, std::false_type > {
339 std::basic_ostream < char_t > & to_stream(std::basic_ostream < char_t > & os, const type_t& value) noexcept {
340 //return os << value;
341 return os << xtd::to_string(value, std::basic_string < char_t > {}, std::locale {});
342 }
343};
344
345template < class char_t, class type_t, class bool_t >
346struct __enum_or_polymorphic_ostream__ {};
347
348template < class char_t, class type_t >
349struct __enum_or_polymorphic_ostream__ < char_t, type_t, std::true_type > {
350 std::basic_ostream < char_t > & to_stream(std::basic_ostream < char_t > & os, const type_t& value) noexcept {
351 if (dynamic_cast < const xtd::iformatable* > (&value)) return os << __iformatable_to_string(dynamic_cast < const xtd::iformatable& > (value));
352 if (dynamic_cast < const xtd::object* > (&value)) return os << __object_to_string__(dynamic_cast < const xtd::object& > (value));
353 return os << value;
354 }
355};
356
357template < class char_t, class type_t >
358struct __enum_or_polymorphic_ostream__ < char_t, type_t, std::false_type > {
359 std::basic_ostream < char_t > & to_stream(std::basic_ostream < char_t > & os, const type_t& value) noexcept {
360 __enum_ostream__ < char, type_t, typename std::is_enum < type_t>::type > ().to_stream(os, value);
361 return os;
362 }
363};
364
365template < class value_t >
366std::string __format_stringer_to_std_string(const value_t& value) {
367 std::basic_stringstream < char > ss;
368 //ss << value;
369 __enum_or_polymorphic_ostream__ < char, value_t, typename std::is_polymorphic < value_t>::type > ().to_stream(ss, value);
370 return ss.str();
371}
372
373std::string __format_stringer_to_std_string(const char& c);
374std::string __format_stringer_to_std_string(const xtd::char8& c);
375std::string __format_stringer_to_std_string(const xtd::char16& c);
376std::string __format_stringer_to_std_string(const xtd::char32& c);
377std::string __format_stringer_to_std_string(const xtd::wchar& c);
378std::string __format_stringer_to_std_string(const char* str);
379std::string __format_stringer_to_std_string(const xtd::char8* str);
380std::string __format_stringer_to_std_string(const xtd::char16* str);
381std::string __format_stringer_to_std_string(const xtd::char32* str);
382std::string __format_stringer_to_std_string(const xtd::wchar* str);
383std::string __format_stringer_to_std_string(const std::string& str);
384std::string __format_stringer_to_std_string(const xtd::string& str);
385std::string __format_stringer_to_std_string(const std::u8string& str);
386std::string __format_stringer_to_std_string(const std::u16string& str);
387std::string __format_stringer_to_std_string(const std::u32string& str);
388std::string __format_stringer_to_std_string(const std::wstring& str);
389
390template < class char_t, class value_t >
391inline std::basic_string < char_t > __format_stringer(value_t value) {
392 std::basic_stringstream < char_t > ss;
393 ss << __format_stringer_to_std_string(value).c_str(); // Using "c_str()" is not the best method, but it is the only possibility if "char_t" is of another type than "char".
394 return ss.str();
395}
396
397template < class char_t, class value_t >
398inline std::basic_string < char_t > __format_stringer(const bool& value) {
399 std::basic_stringstream < char_t > ss;
400 ss << std::boolalpha << value;
401 return ss.str();
402}
403
404template < class char_t, class value_t, xtd::int32 len >
405inline std::basic_string < char_t > __format_stringer(const char*& value) {
406 std::basic_stringstream < char_t > ss;
407 ss << __to_string < char_t > (value);
408 return ss.str();
409}
410
411template < class char_t, class value_t, xtd::int32 len >
412inline std::basic_string < char_t > __format_stringer(const char* const& value) {
413 std::basic_stringstream < char_t > ss;
414 ss << __to_string < char_t > (value);
415 return ss.str();
416}
417
418template < class char_t, class value_t >
419inline std::basic_string < char_t > __format_stringer(const xtd::char8*& value) {
420 auto s = std::u8string(value);
421 std::basic_stringstream < char_t > ss;
422 ss << std::basic_string < char_t > (s.begin(), s.end());
423 return ss.str();
424}
425
426template < class char_t, class value_t >
427inline std::basic_string < char_t > __format_stringer(const xtd::char8* const& value) {
428 auto s = std::u8string(value);
429 std::basic_stringstream < char_t > ss;
430 ss << std::basic_string < char_t > (s.begin(), s.end());
431 return ss.str();
432}
433
434template < class char_t, class value_t >
435inline std::basic_string < char_t > __format_stringer(const xtd::char16*& value) {
436 std::basic_stringstream < char_t > ss;
437 ss << __to_string < char_t > (value);
438 return ss.str();
439}
440
441template < class char_t, class value_t >
442inline std::basic_string < char_t > __format_stringer(const xtd::char16* const& value) {
443 std::basic_stringstream < char_t > ss;
444 ss << __to_string < char_t > (value);
445 return ss.str();
446}
447
448template < class char_t, class value_t >
449inline std::basic_string < char_t > __format_stringer(const xtd::char32*& value) {
450 std::basic_stringstream < char_t > ss;
451 ss << __to_string < char_t > (value);
452 return ss.str();
453}
454
455template < class char_t, class value_t >
456inline std::basic_string < char_t > __format_stringer(const xtd::char32* const& value) {
457 std::basic_stringstream < char_t > ss;
458 ss << __to_string < char_t > (value);
459 return ss.str();
460}
461
462template < class char_t, class value_t >
463inline std::basic_string < char_t > __format_stringer(const xtd::wchar*& value) {
464 std::basic_stringstream < char_t > ss;
465 ss << __to_string < char_t > (value);
466 return ss.str();
467}
468
469template < class char_t, class value_t >
470inline std::basic_string < char_t > __format_stringer(const xtd::wchar* const& value) {
471 std::basic_stringstream < char_t > ss;
472 ss << __to_string < char_t > (value);
473 return ss.str();
474}
475
476template < >
477inline std::string __format_stringer < char, std::u8string& > (std::u8string& value) {
478 std::basic_stringstream < char > ss;
479 ss << std::string(value.begin(), value.end());
480 return ss.str();
481}
482
483template < >
484inline std::string __format_stringer < char, const std::u16string& > (const std::u16string& value) {
485 std::basic_stringstream < char > ss;
486 ss << __to_string < char > (value);
487 return ss.str();
488}
489
490template < >
491inline std::string __format_stringer < char, const std::u32string& > (const std::u32string& value) {
492 std::basic_stringstream < char > ss;
493 ss << __to_string < char > (value);
494 return ss.str();
495}
496
497template < >
498inline std::string __format_stringer < char, const std::wstring& > (const std::wstring& value) {
499 std::basic_stringstream < char > ss;
500 ss << __to_string < char > (value);
501 return ss.str();
502}
503
504template < >
505inline std::string __format_stringer < char, bool& > (bool& value) {
506 return xtd::to_string(value, "G", std::locale());
507}
508
509template < >
510inline std::string __format_stringer < char, xtd::sbyte& > (xtd::sbyte& value) {
511 return xtd::to_string(value, "G", std::locale());
512}
513
514template < >
515inline std::string __format_stringer < char, const unsigned char& > (const unsigned char& value) {
516 return xtd::to_string(value, "G", std::locale());
517}
518
519template < >
520inline std::string __format_stringer < char, unsigned char& > (unsigned char& value) {
521 return xtd::to_string(value, "G", std::locale());
522}
523
524template < >
525inline std::string __format_stringer < char, short& > (short& value) {
526 return xtd::to_string(value, "G", std::locale());
527}
528
529template < >
530inline std::string __format_stringer < char, unsigned short& > (unsigned short& value) {
531 return xtd::to_string(value, "G", std::locale());
532}
533
534template < >
535inline std::string __format_stringer < char, int& > (int& value) {
536 return xtd::to_string(value, "G", std::locale());
537}
538
539template < >
540inline std::string __format_stringer < char, unsigned int& > (unsigned int& value) {
541 return xtd::to_string(value, "G", std::locale());
542}
543
544template < >
545inline std::string __format_stringer < char, long& > (long& value) {
546 return xtd::to_string(value, "G", std::locale());
547}
548
549template < >
550inline std::string __format_stringer < char, unsigned long& > (unsigned long& value) {
551 return xtd::to_string(value, "G", std::locale());
552}
553
554template < >
555inline std::string __format_stringer < char, long long& > (long long& value) {
556 return xtd::to_string(value, "G", std::locale());
557}
558
559template < >
560inline std::string __format_stringer < char, unsigned long long& > (unsigned long long& value) {
561 return xtd::to_string(value, "G", std::locale());
562}
563
564template < >
565inline std::string __format_stringer < char, float& > (float& value) {
566 return xtd::to_string(value, "G", std::locale());
567}
568
569template < >
570inline std::string __format_stringer < char, double& > (double& value) {
571 return xtd::to_string(value, "G", std::locale());
572}
573
574template < >
575inline std::string __format_stringer < char, long double& > (long double& value) {
576 return xtd::to_string(value, "G", std::locale());
577}
578
579template < >
580inline std::string __format_stringer < char, std::chrono::system_clock::time_point& > (std::chrono::system_clock::time_point& value) {
581 return xtd::to_string(value, "G", std::locale());
582}
583
584template < >
585inline std::string __format_stringer < char, std::tm& > (tm& value) {
586 return xtd::to_string(value, "G", std::locale());
587}
588
589template < >
590inline std::string __format_stringer < char, xtd::wchar& > (xtd::wchar& value) {
591 return xtd::to_string(value, "G", std::locale());
592}
593
594template < >
595inline std::string __format_stringer < char, xtd::char8& > (xtd::char8& value) {
596 return xtd::to_string(value, "G", std::locale());
597}
598
599template < >
600inline std::string __format_stringer < char, xtd::char16& > (xtd::char16& value) {
601 return xtd::to_string(value, "G", std::locale());
602}
603
604template < >
605inline std::string __format_stringer < char, xtd::char32& > (xtd::char32& value) {
606 return xtd::to_string(value, "G", std::locale());
607}
608
609template < >
610inline std::wstring __format_stringer < xtd::wchar, std::u8string& > (std::u8string& value) {
611 std::basic_stringstream < xtd::wchar > ss;
612 ss << std::wstring(value.begin(), value.end());
613 return ss.str();
614}
615
616template < >
617inline std::wstring __format_stringer < xtd::wchar, const std::u16string& > (const std::u16string& value) {
618 std::basic_stringstream < xtd::wchar > ss;
619 ss << __to_string < xtd::wchar > (value);
620 return ss.str();
621}
622
623template < >
624inline std::wstring __format_stringer < xtd::wchar, const std::u32string& > (const std::u32string& value) {
625 std::basic_stringstream < xtd::wchar > ss;
626 ss << __to_string < xtd::wchar > (value);
627 return ss.str();
628}
629
630template < >
631inline std::wstring __format_stringer < xtd::wchar, const std::string& > (const std::string& value) {
632 std::basic_stringstream < xtd::wchar > ss;
633 ss << __to_string < xtd::wchar > (value);
634 return ss.str();
635}
636
637template < >
638inline std::wstring __format_stringer < xtd::wchar, bool& > (bool& value) {
639 return xtd::to_string(value, L"G", std::locale());
640}
641
642template < >
643inline std::wstring __format_stringer < xtd::wchar, xtd::sbyte& > (xtd::sbyte& value) {
644 return xtd::to_string(value, L"G", std::locale());
645}
646
647template < >
648inline std::wstring __format_stringer < xtd::wchar, char& > (char& value) {
649 return xtd::to_string(value, L"G", std::locale());
650}
651
652template < >
653inline std::wstring __format_stringer < xtd::wchar, unsigned char& > (unsigned char& value) {
654 return xtd::to_string(value, L"G", std::locale());
655}
656
657template < >
658inline std::wstring __format_stringer < xtd::wchar, short& > (short& value) {
659 return xtd::to_string(value, L"G", std::locale());
660}
661
662template < >
663inline std::wstring __format_stringer < xtd::wchar, unsigned short& > (unsigned short& value) {
664 return xtd::to_string(value, L"G", std::locale());
665}
666
667template < >
668inline std::wstring __format_stringer < xtd::wchar, int& > (int& value) {
669 return xtd::to_string(value, L"G", std::locale());
670}
671
672template < >
673inline std::wstring __format_stringer < xtd::wchar, unsigned int& > (unsigned int& value) {
674 return xtd::to_string(value, L"G", std::locale());
675}
676
677template < >
678inline std::wstring __format_stringer < xtd::wchar, long& > (long& value) {
679 return xtd::to_string(value, L"G", std::locale());
680}
681
682template < >
683inline std::wstring __format_stringer < xtd::wchar, unsigned long& > (unsigned long& value) {
684 return xtd::to_string(value, L"G", std::locale());
685}
686
687template < >
688inline std::wstring __format_stringer < xtd::wchar, long long& > (long long& value) {
689 return xtd::to_string(value, L"G", std::locale());
690}
691
692template < >
693inline std::wstring __format_stringer < xtd::wchar, unsigned long long& > (unsigned long long& value) {
694 return xtd::to_string(value, L"G", std::locale());
695}
696
697template < >
698inline std::wstring __format_stringer < xtd::wchar, float& > (float& value) {
699 return xtd::to_string(value, L"G", std::locale());
700}
701
702template < >
703inline std::wstring __format_stringer < xtd::wchar, double& > (double& value) {
704 return xtd::to_string(value, L"G", std::locale());
705}
706
707template < >
708inline std::wstring __format_stringer < xtd::wchar, long double& > (long double& value) {
709 return xtd::to_string(value, L"G", std::locale());
710}
711
712template < >
713inline std::wstring __format_stringer < xtd::wchar, std::chrono::system_clock::time_point& > (std::chrono::system_clock::time_point& value) {
714 return xtd::to_string(value, L"G", std::locale());
715}
716
717template < >
718inline std::wstring __format_stringer < xtd::wchar, std::tm& > (tm& value) {
719 return xtd::to_string(value, L"G", std::locale());
720}
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...
size_type find(const basic_string &str) const
Finds the first substring equal to the given character sequence. Search begins at 0,...
Definition basic_string.hpp:1148
Provides functionality to format the value of an object into a string representation.
Definition iformatable.hpp:35
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
std::any any
Represents the any alias on std::any.
Definition any.hpp:24
@ s
The S key.
Definition console_key.hpp:124
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
string to_string() const noexcept override
Returns the string representation of this xtd::read_only_span <type_t> object.
Definition read_only_span.hpp:375
Contains xtd::optional type.
Contains xtd fundamental types.