6#if !defined(__XTD_BASIC_STRING_INTERNAL__)
7#error "Do not include this file: Internal use only. Include <xtd/basic_string> or <xtd/basic_string.hpp> instead."
14template<
class char_t,
class traits_t,
class allocator_t>
17template<
class char_t,
class traits_t,
class allocator_t>
19 return index_of_any(values, 0,
size());
22template<
class char_t,
class traits_t,
class allocator_t>
24 return index_of_any(values, start_index,
size() - start_index);
27template<
class char_t,
class traits_t,
class allocator_t>
31 for (
const auto& item : *
this) {
32 if (index++ < start_index)
continue;
33 if (index - 1 > start_index + count)
break;
34 if (std::find(values.
begin(), values.
end(), item) != values.
end())
return index - 1;
39template<
class char_t,
class traits_t,
class allocator_t>
44template<
class char_t,
class traits_t,
class allocator_t>
49template<
class char_t,
class traits_t,
class allocator_t>
54template<
class char_t,
class traits_t,
class allocator_t>
56 return last_index_of_any(values, 0,
size());
59template<
class char_t,
class traits_t,
class allocator_t>
61 return last_index_of_any(values, start_index,
size() - start_index);
64template<
class char_t,
class traits_t,
class allocator_t>
67 auto index =
size() - 1;
68 for (
auto iterator =
crbegin(); iterator !=
crend(); ++iterator) {
69 if (index-- > start_index + count)
continue;
70 if (index + 1 < start_index)
break;
71 if (std::find(values.
begin(), values.
end(), *iterator) != values.
end())
return index + 1;
76template<
class char_t,
class traits_t,
class allocator_t>
81template<
class char_t,
class traits_t,
class allocator_t>
86template<
class char_t,
class traits_t,
class allocator_t>
91template<
class char_t,
class traits_t,
class allocator_t>
96template<
class char_t,
class traits_t,
class allocator_t>
101template<
class char_t,
class traits_t,
class allocator_t>
106template<
class char_t,
class traits_t,
class allocator_t>
111template<
class char_t,
class traits_t,
class allocator_t>
116template<
class char_t,
class traits_t,
class allocator_t>
121template<
class char_t,
class traits_t,
class allocator_t>
123 return split(separators, std::numeric_limits<xtd::size>::max(), options);
126template<
class char_t,
class traits_t,
class allocator_t>
131template<
class char_t,
class traits_t,
class allocator_t>
133 if (count == 0)
return {};
134 if (count == 1)
return {*
this};
136 auto result = std::vector<basic_string> {};
137 auto sub_string = basic_string {};
138 auto split_char_separators = separators.size() == 0 ? default_split_separators : separators;
139 for (
auto it =
begin(); it !=
end(); ++it) {
140 auto is_separator = std::find(split_char_separators.begin(), split_char_separators.end(), *it) != split_char_separators.end();
141 if (!is_separator) sub_string.chars_.append(basic_string(1, *it));
142 auto is_last = (it + 1 ==
end());
143 auto should_add = is_last || is_separator;
146 if (should_add && keep_empty) {
147 if (result.size() == count - 1) {
148 result.push_back(sub_string + basic_string(c_str(), it -
begin() + (is_separator ? 0 : 1),
length() - (it -
begin()) + (is_separator ? 0 : 1)));
151 result.push_back(sub_string);
152 sub_string.chars_.clear();
161template<
class char_t,
class traits_t,
class allocator_t>
166template<
class char_t,
class traits_t,
class allocator_t>
171template<
class char_t,
class traits_t,
class allocator_t>
173 if (start_index >=
size())
return {};
174 if (start_index + length >=
size())
return {
begin() + start_index,
end()};
178template<
class char_t,
class traits_t,
class allocator_t>
183template<
class char_t,
class traits_t,
class allocator_t>
185 return to_array(start_index, length);
188template<
class char_t,
class traits_t,
class allocator_t>
190 auto words = split({
' '});
191 for (
auto& word : words)
192 if (
word.size() && word !=
word.to_upper())
word =
static_cast<value_type
>(toupper(word[0])) +
word.substring(1).to_lower();
193 return basic_string::join(
" ", words);
196template<
class char_t,
class traits_t,
class allocator_t>
200template<
class char_t,
class traits_t,
class allocator_t>
202 return trim_start(trim_chars).trim_end(trim_chars);
205template<
class char_t,
class traits_t,
class allocator_t>
210template<
class char_t,
class traits_t,
class allocator_t>
212 if (!
size())
return *
this;
213 auto result = chars_;
214 while (std::find(trim_chars.begin(), trim_chars.end(), result[result.size() - 1]) != trim_chars.end())
215 result.erase(result.size() - 1, 1);
219template<
class char_t,
class traits_t,
class allocator_t>
222template<
class char_t,
class traits_t,
class allocator_t>
224 if (!
size())
return *
this;
225 auto result = chars_;
226 while (std::find(trim_chars.begin(), trim_chars.end(), result[0]) != trim_chars.end())
231template<
class char_t,
class traits_t,
class allocator_t>
233 auto result = basic_string::empty_string;
234 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
238template<
class char_t,
class traits_t,
class allocator_t>
240 auto result = basic_string::empty_string;
241 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
245template<
class char_t,
class traits_t,
class allocator_t>
246template<
class other_
char_t>
248 auto result = basic_string::empty_string;
249 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
254template<
class char_t,
class traits_t,
class allocator_t>
255template<
class object_t>
258 for (
const auto& arg : args)
259 result +=
format(
"{}", arg);
263template<
class char_t,
class traits_t,
class allocator_t>
264template<
class ...args_t>
266 auto result = basic_string<char> {};
268 auto formats = std::vector<__format_information<char>> {};
269 auto begin_format_iterator = fmt.end();
270 auto end_format_iterator = fmt.end();
271 for (
auto iterator = fmt.begin(); iterator != fmt.end(); ++iterator) {
272 if (*iterator ==
'{') {
273 if (++iterator == fmt.end())
275 if (*iterator ==
'{')
278 begin_format_iterator = iterator;
279 while (iterator != fmt.end() && *iterator !=
'}') ++iterator;
280 if (iterator == fmt.end())
282 end_format_iterator = iterator;
283 __format_information<char> fi;
284 fi.location = result.size();
285 auto format_str = std::basic_string<char> {begin_format_iterator, end_format_iterator};
286 if (format_str.size() == 0)
289 xtd::size index_alignment_separator = basic_string(format_str).index_of(
',');
290 xtd::size index_format_separator = basic_string(format_str).index_of(u
':');
292 if (index_alignment_separator != std::basic_string<char>::npos && index_format_separator != std::basic_string<char>::npos && index_alignment_separator > index_format_separator)
293 index_alignment_separator = std::basic_string<char>::npos;
295 if (index_alignment_separator != basic_string<char_t>::npos)
296 fi.alignment = format_str.substr(index_alignment_separator + 1, index_format_separator != std::basic_string<char>::npos ? index_format_separator - index_alignment_separator - 1 : std::basic_string<char>::npos);
298 if (index_format_separator != basic_string<char>::npos)
299 fi.format = format_str.substr(index_format_separator + 1);
301 if (index_alignment_separator == 0 || index_format_separator == 0)
304 auto index_str = std::basic_string<char> {};
305 if (index_alignment_separator != basic_string<char>::npos)
306 index_str = format_str.substr(0, index_alignment_separator);
307 else if (index_format_separator != basic_string<char>::npos)
308 index_str = format_str.substr(0, index_format_separator);
310 index_str = std::move(format_str);
312 for (
auto c : index_str)
314 fi.index = std::stoi(index_str);
320 formats.push_back(fi);
322 }
else if (*iterator ==
'}') {
323 if (++iterator == fmt.end())
325 if (*iterator !=
'}')
332 __basic_string_extract_format_arg(result, formats, std::forward<args_t>(args)...);
333 return result.c_str();
336template<
class char_t,
class traits_t,
class allocator_t>
337template<
class value_t>
342template<
class char_t,
class traits_t,
class allocator_t>
343template<
class value_t>
348template<
class char_t,
class traits_t,
class allocator_t>
349template<
class value_t>
354template<
class char_t,
class traits_t,
class allocator_t>
357template<
class char_t,
class traits_t,
class allocator_t>
360template<
class char_t,
class traits_t,
class allocator_t>
364void __basic_string_extract_format_arg(std::basic_string<char>& fmt,
xtd::size& index, std::vector<__format_information<char>>& formats, arg_t&& arg) {
367 for (
auto& format : formats) {
368 format.location += offset;
369 if (
format.index == index) {
373 if (!
format.alignment.empty()) {
376 alignment = std::stoi(
format.alignment);
380 if (alignment > 0) arg_str = arg_str.
pad_left(alignment);
381 else if (alignment < 0) arg_str = arg_str.
pad_right(-alignment);
383 fmt.insert(
format.location, arg_str);
384 offset += arg_str.size();
390template<
class ...args_t>
391void __basic_string_extract_format_arg(
xtd::basic_string<char>& fmt, std::vector<__format_information<char>>& formats, args_t&&... args) {
393 (__basic_string_extract_format_arg(
const_cast<std::basic_string<char>&
>(fmt.chars()), index, formats, args), ...);
398template<
class target_t,
class source_t>
399inline std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str)
noexcept {
400 auto out = std::basic_string<target_t> {};
402 for (
const auto& character : str) {
403 if (character >= 0xd800 && character <= 0xdbff)
404 codepoint = ((
character - 0xd800) << 10) + 0x10000;
406 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
409 if (codepoint <= 0x7f)
410 out.append(1,
static_cast<target_t
>(codepoint));
411 else if (codepoint <= 0x7ff) {
412 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
413 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
414 }
else if (codepoint <= 0xffff) {
415 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
416 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
417 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
419 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
420 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
421 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
422 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
431inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(std::basic_string<char>&& str)
noexcept {
432 auto out = std::basic_string<xtd::char16> {};
434 auto str_ptr = str.data();
435 while (*str_ptr != 0) {
436 auto ch =
static_cast<unsigned char>(*str_ptr);
437 if (ch <= 0x7f) codepoint = ch;
438 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
439 else if (ch <= 0xdf) codepoint = ch & 0x1f;
440 else if (ch <= 0xef) codepoint = ch & 0x0f;
441 else codepoint = ch & 0x07;
443 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
444 if (codepoint > 0xffff) {
447 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
448 out.append(1,
static_cast<xtd::char16>(codepoint));
455inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
456 auto out = std::basic_string<xtd::char16> {};
458 auto str_ptr = str.data();
459 while (*str_ptr != 0) {
460 auto ch =
static_cast<unsigned char>(*str_ptr);
461 if (ch <= 0x7f) codepoint = ch;
462 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
463 else if (ch <= 0xdf) codepoint = ch & 0x1f;
464 else if (ch <= 0xef) codepoint = ch & 0x0f;
465 else codepoint = ch & 0x07;
467 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
468 if (codepoint > 0xffff) {
471 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
472 out.append(1,
static_cast<xtd::char16>(codepoint));
479inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(std::basic_string<char>&& str)
noexcept {
480 auto out = std::basic_string<xtd::wchar> {};
482 auto str_ptr = str.data();
483 while (*str_ptr != 0) {
484 auto ch =
static_cast<unsigned char>(*str_ptr);
485 if (ch <= 0x7f) codepoint = ch;
486 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
487 else if (ch <= 0xdf) codepoint = ch & 0x1f;
488 else if (ch <= 0xef) codepoint = ch & 0x0f;
489 else codepoint = ch & 0x07;
491 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
493 out.append(1,
static_cast<xtd::wchar>(codepoint));
494 else if (codepoint > 0xffff) {
497 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
498 out.append(1,
static_cast<xtd::wchar>(codepoint));
505inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
506 auto out = std::basic_string<xtd::wchar> {};
508 auto str_ptr = str.data();
509 while (*str_ptr != 0) {
510 auto ch =
static_cast<unsigned char>(*str_ptr);
511 if (ch <= 0x7f) codepoint = ch;
512 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
513 else if (ch <= 0xdf) codepoint = ch & 0x1f;
514 else if (ch <= 0xef) codepoint = ch & 0x0f;
515 else codepoint = ch & 0x07;
517 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
519 out.append(1,
static_cast<xtd::wchar>(codepoint));
520 else if (codepoint > 0xffff) {
523 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
524 out.append(1,
static_cast<xtd::wchar>(codepoint));
531inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(std::basic_string<char>&& str)
noexcept {
532 auto out = std::basic_string<xtd::char32> {};
534 auto str_ptr = str.data();
535 while (*str_ptr != 0) {
536 auto ch =
static_cast<unsigned char>(*str_ptr);
537 if (ch <= 0x7f) codepoint = ch;
538 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
539 else if (ch <= 0xdf) codepoint = ch & 0x1f;
540 else if (ch <= 0xef) codepoint = ch & 0x0f;
541 else codepoint = ch & 0x07;
543 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
544 out.append(1,
static_cast<xtd::char32>(codepoint));
550inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
551 auto out = std::basic_string<xtd::char32> {};
553 auto str_ptr = str.data();
554 while (*str_ptr != 0) {
555 auto ch =
static_cast<unsigned char>(*str_ptr);
556 if (ch <= 0x7f) codepoint = ch;
557 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
558 else if (ch <= 0xdf) codepoint = ch & 0x1f;
559 else if (ch <= 0xef) codepoint = ch & 0x0f;
560 else codepoint = ch & 0x07;
562 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
563 out.append(1,
static_cast<xtd::char32>(codepoint));
569inline std::basic_string<char> __xtd_convert_to_string<char, char>(std::basic_string<char>&& str)
noexcept {
570 return std::move(str);
574inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
575 return std::move(str);
579inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
580 return std::move(str);
584inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
585 return std::move(str);
589inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
590 return std::move(str);
594inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(std::basic_string<char>&& str)
noexcept {
595 return std::basic_string<xtd::char8> {
reinterpret_cast<const xtd::char8*
>(str.c_str())};
599inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
600 return std::basic_string<char> {
reinterpret_cast<const char*
>(str.c_str())};
604inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
605 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
609inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
610 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
614inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
615 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
619inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
620 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
624inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
625 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));}
628inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
629 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));
632template<
class target_t,
class source_t>
633inline std::basic_string<target_t> __xtd_convert_to_string(
const std::basic_string<source_t>& str)
noexcept {
634 auto out = std::basic_string<target_t> {};
636 for (
const auto& character : str) {
637 if (character >= 0xd800 && character <= 0xdbff)
638 codepoint = ((
character - 0xd800) << 10) + 0x10000;
640 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
643 if (codepoint <= 0x7f)
644 out.append(1,
static_cast<target_t
>(codepoint));
645 else if (codepoint <= 0x7ff) {
646 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
647 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
648 }
else if (codepoint <= 0xffff) {
649 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
650 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
651 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
653 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
654 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
655 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
656 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
665inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(
const std::basic_string<char>& str)
noexcept {
666 auto out = std::basic_string<xtd::char16> {};
668 auto str_ptr = str.data();
669 while (*str_ptr != 0) {
670 auto ch =
static_cast<unsigned char>(*str_ptr);
671 if (ch <= 0x7f) codepoint = ch;
672 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
673 else if (ch <= 0xdf) codepoint = ch & 0x1f;
674 else if (ch <= 0xef) codepoint = ch & 0x0f;
675 else codepoint = ch & 0x07;
677 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
678 if (codepoint > 0xffff) {
681 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
682 out.append(1,
static_cast<xtd::char16>(codepoint));
689inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
690 auto out = std::basic_string<xtd::char16> {};
692 auto str_ptr = str.data();
693 while (*str_ptr != 0) {
694 auto ch =
static_cast<unsigned char>(*str_ptr);
695 if (ch <= 0x7f) codepoint = ch;
696 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
697 else if (ch <= 0xdf) codepoint = ch & 0x1f;
698 else if (ch <= 0xef) codepoint = ch & 0x0f;
699 else codepoint = ch & 0x07;
701 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
702 if (codepoint > 0xffff) {
705 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
706 out.append(1,
static_cast<xtd::char16>(codepoint));
713inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(
const std::basic_string<char>& str)
noexcept {
714 auto out = std::basic_string<xtd::wchar> {};
716 auto str_ptr = str.data();
717 while (*str_ptr != 0) {
718 auto ch =
static_cast<unsigned char>(*str_ptr);
719 if (ch <= 0x7f) codepoint = ch;
720 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
721 else if (ch <= 0xdf) codepoint = ch & 0x1f;
722 else if (ch <= 0xef) codepoint = ch & 0x0f;
723 else codepoint = ch & 0x07;
725 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
727 out.append(1,
static_cast<xtd::wchar>(codepoint));
728 else if (codepoint > 0xffff) {
731 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
732 out.append(1,
static_cast<xtd::wchar>(codepoint));
739inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
740 auto out = std::basic_string<xtd::wchar> {};
742 auto str_ptr = str.data();
743 while (*str_ptr != 0) {
744 auto ch =
static_cast<unsigned char>(*str_ptr);
745 if (ch <= 0x7f) codepoint = ch;
746 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
747 else if (ch <= 0xdf) codepoint = ch & 0x1f;
748 else if (ch <= 0xef) codepoint = ch & 0x0f;
749 else codepoint = ch & 0x07;
751 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
753 out.append(1,
static_cast<xtd::wchar>(codepoint));
754 else if (codepoint > 0xffff) {
757 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
758 out.append(1,
static_cast<xtd::wchar>(codepoint));
765inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(
const std::basic_string<char>& str)
noexcept {
766 auto out = std::basic_string<xtd::char32> {};
768 auto str_ptr = str.data();
769 while (*str_ptr != 0) {
770 auto ch =
static_cast<unsigned char>(*str_ptr);
771 if (ch <= 0x7f) codepoint = ch;
772 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
773 else if (ch <= 0xdf) codepoint = ch & 0x1f;
774 else if (ch <= 0xef) codepoint = ch & 0x0f;
775 else codepoint = ch & 0x07;
777 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
778 out.append(1,
static_cast<xtd::char32>(codepoint));
784inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
785 auto out = std::basic_string<xtd::char32> {};
787 auto str_ptr = str.data();
788 while (*str_ptr != 0) {
789 auto ch =
static_cast<unsigned char>(*str_ptr);
790 if (ch <= 0x7f) codepoint = ch;
791 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
792 else if (ch <= 0xdf) codepoint = ch & 0x1f;
793 else if (ch <= 0xef) codepoint = ch & 0x0f;
794 else codepoint = ch & 0x07;
796 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
797 out.append(1,
static_cast<xtd::char32>(codepoint));
803inline std::basic_string<char> __xtd_convert_to_string<char, char>(
const std::basic_string<char>& str)
noexcept {
808inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
813inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
818inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
823inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
828inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(
const std::basic_string<char>& str)
noexcept {
829 return reinterpret_cast<const xtd::char8*
>(str.c_str());
833inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
834 return reinterpret_cast<const char*
>(str.c_str());
838inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
839 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
843inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
844 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
848inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
849 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
853inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
854 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
858inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
859 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(str));
863inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
864 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(str));
Contains xtd::array class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:61
const_iterator end() const noexcept override
Returns an iterator to the element following the last element of the enumerable.
Definition basic_array.hpp:178
const_iterator begin() const noexcept override
Returns an iterator to the first element of the enumerable.
Definition basic_array.hpp:134
Represents text as a sequence of character units.
Definition basic_string.hpp:71
basic_string pad_left(xtd::size total_width) const noexcept
Right-aligns the characters in this basic_string, padding with spaces on the left for a specified tot...
Definition basic_string.hpp:1543
xtd::size index_of_any(const xtd::array< value_type > &values) const noexcept
Reports the index of the first occurrence in this instance of any character in a specified array of c...
xtd::size last_index_of_any(const xtd::array< value_type > &values) const noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
basic_string pad_right(xtd::size total_width) const noexcept
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.hpp:1557
auto concat(const ienumerable< char_t > &second) const noexcept
Definition enumerable.hpp:185
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
@ format
The format is not valid.
Definition exception_case.hpp:49
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:59
@ format_opened_bracket_without_end_bracket
The format contains open backet_without_end_bracket.
Definition exception_case.hpp:53
@ format_closing_bracket_without_open_bracket
The format contains close backet_without_open_bracket.
Definition exception_case.hpp:51
#define unused_
It may be used to suppress the "unused variable" or "unused local typedefs" compiler warnings when th...
Definition unused.hpp:30
@ character
Specifies that the text is trimmed to the nearest character.
Definition string_trimming.hpp:21
@ word
Specifies that text is trimmed to the nearest word.
Definition string_trimming.hpp:23
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:26
wchar_t wchar
Represents a wide character.
Definition wchar.hpp:24
int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:23
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
string_split_options
Specifies whether applicable xtd::string::split method overloads include or omit empty substrings fro...
Definition string_split_options.hpp:14
@ none
The return value includes array elements that contain an empty string.
Definition string_split_options.hpp:16
@ remove_empty_entries
The return value does not include array elements that contain an empty string.
Definition string_split_options.hpp:18
@ u
The U key.
Definition console_key.hpp:128
@ separator
The Separator key.
Definition console_key.hpp:172
const_iterator begin() const
Returns an iterator to the beginning.
Definition read_only_span.hpp:183
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
const_iterator end() const
Returns an iterator to the end.
Definition read_only_span.hpp:213
const_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning.
Definition read_only_span.hpp:194
const_reference at(size_type pos) const
Gets the specified element with bounds checking.
Definition read_only_span.hpp:255
constexpr size_type length() const noexcept
Returns the length of the current read_only_span.
Definition read_only_span.hpp:229
const_reverse_iterator crend() const
Returns a reverse iterator to the end.
Definition read_only_span.hpp:197
xtd::array< std::remove_cv_t< type_t > > to_array() const noexcept
Copies the contents of this read_only_span into a new array.
Definition read_only_span.hpp:368