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."
15template<
class char_t,
class traits_t,
class allocator_t>
17 return index_of_any(values, 0,
length());
20template<
class char_t,
class traits_t,
class allocator_t>
22 return index_of_any(values, start_index,
length() - start_index);
25template<
class char_t,
class traits_t,
class allocator_t>
29 for (
const auto& item :
self_) {
30 if (index++ < start_index)
continue;
31 if (index - 1 > start_index + count)
break;
32 if (std::find(values.
items().begin(), values.
items().end(), item) != values.
items().end())
return index - 1;
37template<
class char_t,
class traits_t,
class allocator_t>
42template<
class char_t,
class traits_t,
class allocator_t>
47template<
class char_t,
class traits_t,
class allocator_t>
52template<
class char_t,
class traits_t,
class allocator_t>
54 return last_index_of_any(values, 0,
length());
57template<
class char_t,
class traits_t,
class allocator_t>
59 return last_index_of_any(values, start_index,
length() - start_index);
62template<
class char_t,
class traits_t,
class allocator_t>
67 if (index-- > start_index + count)
continue;
68 if (index + 1 < start_index)
break;
69 if (std::find(values.
items().begin(), values.
items().end(), *iterator) != values.
items().end())
return index + 1;
74template<
class char_t,
class traits_t,
class allocator_t>
79template<
class char_t,
class traits_t,
class allocator_t>
84template<
class char_t,
class traits_t,
class allocator_t>
89template<
class char_t,
class traits_t,
class allocator_t>
94template<
class char_t,
class traits_t,
class allocator_t>
99template<
class char_t,
class traits_t,
class allocator_t>
104template<
class char_t,
class traits_t,
class allocator_t>
109template<
class char_t,
class traits_t,
class allocator_t>
114template<
class char_t,
class traits_t,
class allocator_t>
119template<
class char_t,
class traits_t,
class allocator_t>
121 return split(separators, std::numeric_limits<xtd::size>::max(), options);
124template<
class char_t,
class traits_t,
class allocator_t>
131# pragma GCC diagnostic push
132# pragma GCC diagnostic ignored "-Warray-bounds"
135template<
class char_t,
class traits_t,
class allocator_t>
137 if (count == 0)
return {};
138 if (count == 1)
return {
self_};
140 auto result = std::vector<basic_string> {};
141 auto sub_string = basic_string {};
142 auto split_char_separators = separators.length() == 0 ? default_split_separators : separators;
143 for (
auto it = chars().
begin(); it != chars().end(); ++it) {
144 auto is_separator = std::find(split_char_separators.items().begin(), split_char_separators.items().end(), *it) != split_char_separators.items().end();
145 if (!is_separator) sub_string.chars_.append(basic_string(*it, 1));
146 auto is_last = (it + 1 == chars().end());
147 auto should_add = is_last || is_separator;
150 if (should_add && keep_empty) {
151 if (result.size() == count - 1) {
152 result.push_back(sub_string + basic_string(chars().c_str() + (it - chars().
begin() + (is_separator ? 0 : 1)),
length() - (it - chars().
begin()) + (is_separator ? 0 : 1)));
155 result.push_back(sub_string);
156 sub_string.chars_.clear();
167# pragma GCC diagnostic pop
170template<
class char_t,
class traits_t,
class allocator_t>
175template<
class char_t,
class traits_t,
class allocator_t>
180template<
class char_t,
class traits_t,
class allocator_t>
182 if (start_index >=
self_.length())
return {};
183 if (start_index + length >=
self_.length())
return {chars().begin() + start_index, chars().end()};
184 return {chars().begin() + start_index, chars().begin() + start_index +
length};
187template<
class char_t,
class traits_t,
class allocator_t>
192template<
class char_t,
class traits_t,
class allocator_t>
194 return to_array(start_index, length);
197template<
class char_t,
class traits_t,
class allocator_t>
199 auto words = split({
' '});
200 for (
auto& word : words)
201 if (
word.length() && word !=
word.to_upper())
word =
static_cast<value_type
>(toupper(word[0])) +
word.substring(1).to_lower();
202 return basic_string::join(
" ", words);
205template<
class char_t,
class traits_t,
class allocator_t>
210template<
class char_t,
class traits_t,
class allocator_t>
212 return trim_start(trim_chars).trim_end(trim_chars);
215template<
class char_t,
class traits_t,
class allocator_t>
220template<
class char_t,
class traits_t,
class allocator_t>
223 auto result = chars_;
224 while (std::find(trim_chars.items().begin(), trim_chars.items().end(), result[result.size() - 1]) != trim_chars.items().end())
225 result.erase(result.size() - 1, 1);
229template<
class char_t,
class traits_t,
class allocator_t>
232template<
class char_t,
class traits_t,
class allocator_t>
235 auto result = chars_;
236 while (std::find(trim_chars.items().begin(), trim_chars.items().end(), result[0]) != trim_chars.items().end())
241template<
class char_t,
class traits_t,
class allocator_t>
243 auto result = basic_string::empty_string;
244 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
248template<
class char_t,
class traits_t,
class allocator_t>
250 auto result = basic_string::empty_string;
251 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
255template<
class char_t,
class traits_t,
class allocator_t>
256template<
class other_
char_t>
258 auto result = basic_string::empty_string;
259 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
264template<
class char_t,
class traits_t,
class allocator_t>
265template<
class object_t>
268 for (
const auto& arg : args)
269 result +=
format(
"{}", arg);
273template<
class char_t,
class traits_t,
class allocator_t>
274template<
class ...args_t>
276 return format(std::locale {}, fmt, std::forward<args_t>(args)...);
279template<
class char_t,
class traits_t,
class allocator_t>
280template<
class ...args_t>
282 auto result = basic_string<char> {};
284 auto formats = std::vector<__format_information<char>> {};
285 auto begin_format_iterator = fmt.end();
286 auto end_format_iterator = fmt.end();
287 for (
auto iterator = fmt.begin(); iterator != fmt.end(); ++iterator) {
288 if (*iterator ==
'{') {
289 if (++iterator == fmt.end())
291 if (*iterator ==
'{')
295 while (iterator != fmt.end() && *iterator !=
'}') ++
iterator;
296 if (iterator == fmt.end())
299 __format_information<char> fi;
300 fi.location = result.length();
301 auto format_str = std::basic_string<char> {begin_format_iterator, end_format_iterator};
302 if (format_str.length() == 0)
305 xtd::size index_alignment_separator = basic_string(format_str).index_of(
',');
306 xtd::size index_format_separator = basic_string(format_str).index_of(u
':');
308 if (index_alignment_separator != std::basic_string<char>::npos && index_format_separator != std::basic_string<char>::npos && index_alignment_separator > index_format_separator)
309 index_alignment_separator = std::basic_string<char>::npos;
311 if (index_alignment_separator != basic_string<char_t>::npos)
312 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);
314 if (index_format_separator != basic_string<char>::npos)
315 fi.format = format_str.substr(index_format_separator + 1);
317 if (index_alignment_separator == 0 || index_format_separator == 0)
320 auto index_str = std::basic_string<char> {};
321 if (index_alignment_separator != basic_string<char>::npos)
322 index_str = format_str.substr(0, index_alignment_separator);
323 else if (index_format_separator != basic_string<char>::npos)
324 index_str = format_str.substr(0, index_format_separator);
326 index_str = std::move(format_str);
328 for (
auto c : index_str)
330 fi.index = std::stoi(index_str);
336 formats.push_back(fi);
338 }
else if (*iterator ==
'}') {
339 if (++iterator == fmt.end())
341 if (*iterator !=
'}')
348 __basic_string_extract_format_arg(loc, result, formats, std::forward<args_t>(args)...);
349 return result.chars().c_str();
352template<
class char_t,
class traits_t,
class allocator_t>
353template<
class value_t>
358template<
class char_t,
class traits_t,
class allocator_t>
359template<
class value_t>
364template<
class char_t,
class traits_t,
class allocator_t>
365template<
class value_t>
370template<
class char_t,
class traits_t,
class allocator_t>
373template<
class char_t,
class traits_t,
class allocator_t>
376template<
class char_t,
class traits_t,
class allocator_t>
380void __basic_string_extract_format_arg(
const std::locale& loc, std::basic_string<char>& fmt,
xtd::size& index, std::vector<__format_information<char >>& formats, arg_t&& arg) {
383 for (
auto& format : formats) {
384 format.location += offset;
385 if (
format.index == index) {
392 alignment = std::stoi(
format.alignment);
399 fmt.insert(
format.location, arg_str);
400 offset += arg_str.
length();
406template<
class ...args_t>
407void __basic_string_extract_format_arg(
const std::locale& loc,
xtd::basic_string<char>& fmt, std::vector<__format_information<char >>& formats, args_t&&... args) {
408 [[maybe_unused]]
auto index =
xtd::size {0};
409 (__basic_string_extract_format_arg(loc,
const_cast<std::basic_string<char>&
> (fmt.
chars()), index, formats, args), ...);
413template<
class target_t,
class source_t>
414inline std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str)
noexcept {
415 auto out = std::basic_string<target_t> {};
417 for (
const auto& character : str) {
418 if (character >= 0xd800 && character <= 0xdbff)
419 codepoint = ((
character - 0xd800) << 10) + 0x10000;
421 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
424 if (codepoint <= 0x7f)
425 out.append(1,
static_cast<target_t
>(codepoint));
426 else if (codepoint <= 0x7ff) {
427 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
428 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
429 }
else if (codepoint <= 0xffff) {
430 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
431 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
432 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
434 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
435 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
436 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
437 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
449inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(std::basic_string<char>&& str)
noexcept {
450 auto out = std::basic_string<xtd::char16> {};
452 auto expected_bytes = 0;
453 auto str_ptr = str.data();
455 while (*str_ptr != 0) {
456 auto ch =
static_cast<unsigned char>(*str_ptr++);
458 if (expected_bytes == 0) {
463 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
464 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
465 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
468 out.push_back(0xfffd);
473 if ((ch & 0xc0) != 0x80) {
475 out.push_back(0xfffd);
480 codepoint = (codepoint << 6) | (ch & 0x3f);
485 if (expected_bytes == 0) {
486 if (codepoint > 0x10ffff) codepoint = 0xfffd;
488 if (codepoint > 0xffff) {
490 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
491 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
494 }
else if (codepoint < 0xd800 || codepoint >= 0xe000) out.push_back(
static_cast<xtd::char16>(codepoint));
495 else out.push_back(0xfffd);
500 if (expected_bytes != 0) out.push_back(0xfffd);
508inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
509 auto out = std::basic_string<xtd::char16> {};
511 auto expected_bytes = 0;
512 auto str_ptr = str.data();
514 while (*str_ptr != 0) {
515 auto ch =
static_cast<unsigned char>(*str_ptr++);
517 if (expected_bytes == 0) {
522 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
523 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
524 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
527 out.push_back(0xfffd);
532 if ((ch & 0xc0) != 0x80) {
534 out.push_back(0xfffd);
539 codepoint = (codepoint << 6) | (ch & 0x3f);
544 if (expected_bytes == 0) {
545 if (codepoint > 0x10ffff) codepoint = 0xfffd;
547 if (codepoint > 0xffff) {
549 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
550 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
553 }
else if (codepoint < 0xd800 || codepoint >= 0xe000) out.push_back(
static_cast<xtd::char16>(codepoint));
554 else out.push_back(0xfffd);
559 if (expected_bytes != 0) out.push_back(0xfffd);
567inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(std::basic_string<char>&& str)
noexcept {
568 auto out = std::basic_string<xtd::wchar> {};
570 auto expected_bytes = 0;
571 auto str_ptr = str.data();
573 while (*str_ptr != 0) {
574 auto ch =
static_cast<unsigned char>(*str_ptr++);
576 if (expected_bytes == 0) {
581 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
582 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
583 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
585 out.push_back(0xfffd);
590 if ((ch & 0xc0) != 0x80) {
592 out.push_back(0xfffd);
597 codepoint = (codepoint << 6) | (ch & 0x3f);
602 if (expected_bytes == 0) {
603 if (codepoint > 0x10ffff) codepoint = 0xfffd;
607 out.push_back(
static_cast<xtd::wchar>(codepoint));
610 if (codepoint > 0xffff) {
611 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
612 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
615 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
616 out.push_back(
static_cast<xtd::wchar>(codepoint));
619 out.push_back(0xfffd);
626 if (expected_bytes != 0) out.push_back(0xfffd);
634inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
635 auto out = std::basic_string<xtd::wchar> {};
637 auto expected_bytes = 0;
638 auto str_ptr = str.data();
640 while (*str_ptr != 0) {
641 auto ch =
static_cast<unsigned char>(*str_ptr++);
643 if (expected_bytes == 0) {
648 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
649 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
650 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
652 out.push_back(0xfffd);
657 if ((ch & 0xc0) != 0x80) {
659 out.push_back(0xfffd);
664 codepoint = (codepoint << 6) | (ch & 0x3f);
669 if (expected_bytes == 0) {
670 if (codepoint > 0x10ffff) codepoint = 0xfffd;
674 out.push_back(
static_cast<xtd::wchar>(codepoint));
677 if (codepoint > 0xffff) {
678 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
679 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
682 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
683 out.push_back(
static_cast<xtd::wchar>(codepoint));
686 out.push_back(0xfffd);
693 if (expected_bytes != 0) out.push_back(0xfffd);
701inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(std::basic_string<char>&& str)
noexcept {
702 auto out = std::basic_string<xtd::char32> {};
704 auto expected_bytes = 0;
705 auto str_ptr = str.data();
707 while (*str_ptr != 0) {
708 auto ch =
static_cast<unsigned char>(*str_ptr++);
710 if (expected_bytes == 0) {
714 out.push_back(
static_cast<xtd::char32>(codepoint));
715 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
716 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
717 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
718 else out.push_back(0xfffd);
721 if ((ch & 0xc0) != 0x80) {
723 out.push_back(0xfffd);
728 codepoint = (codepoint << 6) | (ch & 0x3f);
731 if (expected_bytes == 0) {
733 if (codepoint > 0x10ffff) codepoint = 0xfffd;
734 out.push_back(
static_cast<xtd::char32>(codepoint));
740 if (expected_bytes != 0) out.push_back(0xfffd);
748inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
749 auto out = std::basic_string<xtd::char32> {};
751 auto expected_bytes = 0;
752 auto str_ptr = str.data();
754 while (*str_ptr != 0) {
755 auto ch =
static_cast<unsigned char>(*str_ptr++);
757 if (expected_bytes == 0) {
761 out.push_back(
static_cast<xtd::char32>(codepoint));
762 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
763 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
764 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
765 else out.push_back(0xfffd);
768 if ((ch & 0xc0) != 0x80) {
770 out.push_back(0xfffd);
775 codepoint = (codepoint << 6) | (ch & 0x3f);
778 if (expected_bytes == 0) {
780 if (codepoint > 0x10ffff) codepoint = 0xfffd;
781 out.push_back(
static_cast<xtd::char32>(codepoint));
787 if (expected_bytes != 0) out.push_back(0xfffd);
792inline std::basic_string<char> __xtd_convert_to_string<char, char>(std::basic_string<char>&& str)
noexcept {
793 return std::move(str);
797inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
798 return std::move(str);
802inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
803 return std::move(str);
807inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
808 return std::move(str);
812inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
813 return std::move(str);
817inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(std::basic_string<char>&& str)
noexcept {
818 return std::basic_string<xtd::char8> {
reinterpret_cast<const xtd::char8*
>(str.c_str())};
822inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
823 return std::basic_string<char> {
reinterpret_cast<const char*
>(str.c_str())};
827inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
828 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
832inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
833 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
837inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
838 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
842inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
843 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
847inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
848 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));
852inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
853 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));
856template<
class target_t,
class source_t>
857inline std::basic_string<target_t> __xtd_convert_to_string(
const std::basic_string<source_t>& str)
noexcept {
858 auto out = std::basic_string<target_t> {};
860 for (
const auto& character : str) {
861 if (character >= 0xd800 && character <= 0xdbff)
862 codepoint = ((
character - 0xd800) << 10) + 0x10000;
864 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
867 if (codepoint <= 0x7f)
868 out.append(1,
static_cast<target_t
>(codepoint));
869 else if (codepoint <= 0x7ff) {
870 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
871 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
872 }
else if (codepoint <= 0xffff) {
873 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
874 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
875 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
877 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
878 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
879 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
880 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
892inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(
const std::basic_string<char>& str)
noexcept {
893 auto out = std::basic_string<xtd::char16> {};
895 auto expected_bytes = 0;
896 auto str_ptr = str.data();
898 while (*str_ptr != 0) {
899 auto ch =
static_cast<unsigned char>(*str_ptr++);
901 if (expected_bytes == 0) {
906 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
907 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
908 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
911 out.push_back(0xfffd);
916 if ((ch & 0xc0) != 0x80) {
918 out.push_back(0xfffd);
923 codepoint = (codepoint << 6) | (ch & 0x3f);
928 if (expected_bytes == 0) {
929 if (codepoint > 0x10ffff) codepoint = 0xfffd;
931 if (codepoint > 0xffff) {
933 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
934 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
937 }
else if (codepoint < 0xd800 || codepoint >= 0xe000) out.push_back(
static_cast<xtd::char16>(codepoint));
938 else out.push_back(0xfffd);
943 if (expected_bytes != 0) out.push_back(0xfffd);
951inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
952 auto out = std::basic_string<xtd::char16> {};
954 auto expected_bytes = 0;
955 auto str_ptr = str.data();
957 while (*str_ptr != 0) {
958 auto ch =
static_cast<unsigned char>(*str_ptr++);
960 if (expected_bytes == 0) {
965 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
966 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
967 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
970 out.push_back(0xfffd);
975 if ((ch & 0xc0) != 0x80) {
977 out.push_back(0xfffd);
982 codepoint = (codepoint << 6) | (ch & 0x3f);
987 if (expected_bytes == 0) {
988 if (codepoint > 0x10ffff) codepoint = 0xfffd;
990 if (codepoint > 0xffff) {
992 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
993 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
996 }
else if (codepoint < 0xd800 || codepoint >= 0xe000) out.push_back(
static_cast<xtd::char16>(codepoint));
997 else out.push_back(0xfffd);
1002 if (expected_bytes != 0) out.push_back(0xfffd);
1010inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(
const std::basic_string<char>& str)
noexcept {
1011 auto out = std::basic_string<xtd::wchar> {};
1012 auto codepoint = 0
u;
1013 auto expected_bytes = 0;
1014 auto str_ptr = str.data();
1016 while (*str_ptr != 0) {
1017 auto ch =
static_cast<unsigned char>(*str_ptr++);
1019 if (expected_bytes == 0) {
1024 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
1025 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
1026 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
1028 out.push_back(0xfffd);
1033 if ((ch & 0xc0) != 0x80) {
1035 out.push_back(0xfffd);
1040 codepoint = (codepoint << 6) | (ch & 0x3f);
1045 if (expected_bytes == 0) {
1046 if (codepoint > 0x10ffff) codepoint = 0xfffd;
1050 out.push_back(
static_cast<xtd::wchar>(codepoint));
1053 if (codepoint > 0xffff) {
1054 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
1055 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
1056 out.push_back(
static_cast<xtd::wchar>(high));
1058 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
1059 out.push_back(
static_cast<xtd::wchar>(codepoint));
1062 out.push_back(0xfffd);
1069 if (expected_bytes != 0) out.push_back(0xfffd);
1077inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
1078 auto out = std::basic_string<xtd::wchar> {};
1079 auto codepoint = 0
u;
1080 auto expected_bytes = 0;
1081 auto str_ptr = str.data();
1083 while (*str_ptr != 0) {
1084 auto ch =
static_cast<unsigned char>(*str_ptr++);
1086 if (expected_bytes == 0) {
1091 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
1092 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
1093 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
1095 out.push_back(0xfffd);
1100 if ((ch & 0xc0) != 0x80) {
1102 out.push_back(0xfffd);
1107 codepoint = (codepoint << 6) | (ch & 0x3f);
1112 if (expected_bytes == 0) {
1113 if (codepoint > 0x10ffff) codepoint = 0xfffd;
1117 out.push_back(
static_cast<xtd::wchar>(codepoint));
1120 if (codepoint > 0xffff) {
1121 unsigned int high = 0xd800 + ((codepoint - 0x10000) >> 10);
1122 unsigned int low = 0xdc00 + ((codepoint - 0x10000) & 0x3ff);
1123 out.push_back(
static_cast<xtd::wchar>(high));
1125 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
1126 out.push_back(
static_cast<xtd::wchar>(codepoint));
1129 out.push_back(0xfffd);
1136 if (expected_bytes != 0) out.push_back(0xfffd);
1144inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(
const std::basic_string<char>& str)
noexcept {
1145 auto out = std::basic_string<xtd::char32> {};
1146 auto codepoint = 0
u;
1147 auto expected_bytes = 0;
1148 auto str_ptr = str.data();
1150 while (*str_ptr != 0) {
1151 auto ch =
static_cast<unsigned char>(*str_ptr++);
1153 if (expected_bytes == 0) {
1157 out.push_back(
static_cast<xtd::char32>(codepoint));
1158 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
1159 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
1160 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
1161 else out.push_back(0xfffd);
1164 if ((ch & 0xc0) != 0x80) {
1166 out.push_back(0xfffd);
1171 codepoint = (codepoint << 6) | (ch & 0x3f);
1174 if (expected_bytes == 0) {
1176 if (codepoint > 0x10ffff) codepoint = 0xfffd;
1177 out.push_back(
static_cast<xtd::char32>(codepoint));
1183 if (expected_bytes != 0) out.push_back(0xfffd);
1191inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
1192 auto out = std::basic_string<xtd::char32> {};
1193 auto codepoint = 0
u;
1194 auto expected_bytes = 0;
1195 auto str_ptr = str.data();
1197 while (*str_ptr != 0) {
1198 auto ch =
static_cast<unsigned char>(*str_ptr++);
1200 if (expected_bytes == 0) {
1204 out.push_back(
static_cast<xtd::char32>(codepoint));
1205 }
else if (ch <= 0xdf) { codepoint = ch & 0x1f; expected_bytes = 1; }
1206 else if (ch <= 0xef) { codepoint = ch & 0x0f; expected_bytes = 2; }
1207 else if (ch <= 0xf7) { codepoint = ch & 0x07; expected_bytes = 3; }
1208 else out.push_back(0xfffd);
1211 if ((ch & 0xc0) != 0x80) {
1213 out.push_back(0xfffd);
1218 codepoint = (codepoint << 6) | (ch & 0x3f);
1221 if (expected_bytes == 0) {
1223 if (codepoint > 0x10ffff) codepoint = 0xfffd;
1224 out.push_back(
static_cast<xtd::char32>(codepoint));
1230 if (expected_bytes != 0) out.push_back(0xfffd);
1235inline std::basic_string<char> __xtd_convert_to_string<char, char>(
const std::basic_string<char>& str)
noexcept {
1240inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
1245inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
1250inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
1255inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
1260inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(
const std::basic_string<char>& str)
noexcept {
1261 return reinterpret_cast<const xtd::char8*
>(str.c_str());
1265inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
1266 return reinterpret_cast<const char*
>(str.c_str());
1270inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
1271 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
1275inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
1276 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
1280inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
1281 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
1285inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
1286 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
1290inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
1291 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(str));
1295inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
1296 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:64
virtual const base_type & items() const noexcept
Returns the underlying base type items.
Definition basic_array.hpp:113
Represents text as a sequence of character units.
Definition basic_string.hpp:66
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:1022
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.hpp:111
basic_string trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified xtd::basic_...
Definition basic_string.hpp:1407
xtd::array< basic_string > split() const noexcept
Splits this basic_string into substrings that are based on the default white-space characters....
static basic_string join(const basic_string &separator, const collection_t &values) noexcept
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:1701
const base_type & chars() const noexcept
Returns a reference to the underlying base type.
Definition basic_string.hpp:354
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::array< value_type > to_char_array() const noexcept
Copies the characters in this instance to a Unicode character array.
static basic_string concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c, const basic_string &str_d) noexcept
Concatenates four specified instances of basic_string.
Definition basic_string.hpp:1535
basic_string trim_end() const noexcept
Removes all trailing occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:1423
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 to_title_case() const noexcept
Converts the current basic_string to title case (except for words that are entirely in uppercase,...
virtual size_type length() const noexcept
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:380
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:1036
basic_string trim_start() const noexcept
Removes all leading occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:1439
virtual bool empty() const noexcept
Checks whether the container is empty.
Definition basic_string.hpp:375
xtd::array< value_type > to_array() const noexcept
Copies the characters in this instance to a Unicode character array.
basic_string< xtd::char32 > to_u32string() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::char32>.
Definition basic_string.hpp:1376
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
@ format
The format is not valid.
Definition exception_case.hpp:51
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:61
@ format_opened_bracket_without_end_bracket
The format contains open backet_without_end_bracket.
Definition exception_case.hpp:55
@ format_closing_bracket_without_open_bracket
The format contains close backet_without_open_bracket.
Definition exception_case.hpp:53
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
constexpr xtd::size npos
Represents a value that is not a valid position in a collection.
Definition npos.hpp:26
@ 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
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:23
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
@ high
Specifies that the process performs time-critical tasks that must be executed immediately,...
Definition process_priority_class.hpp:32
@ u
The U key.
Definition console_key.hpp:128
@ separator
The Separator key.
Definition console_key.hpp:172
@ low
Specifies low quality interpolation.
Definition interpolation_mode.hpp:26
virtual auto count() const noexcept -> xtd::size=0
Gets the number of elements contained in the xtd::collections::generic::icollection <type_t>.
const xtd::collections::generic::helpers::wrap_pointer_iterator< pointer > iterator
Represents the iterator of read_only_span value type.
Definition read_only_span.hpp:74
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_reverse_iterator crbegin() const
Returns a reverse iterator to the beginning.
Definition read_only_span.hpp:194
constexpr size_type length() const noexcept
Returns the length of the current read_only_span.
Definition read_only_span.hpp:229
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
Contains xtd::to_string methods.