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>
201template<
class char_t,
class traits_t,
class allocator_t>
203 return trim_start(trim_chars).trim_end(trim_chars);
206template<
class char_t,
class traits_t,
class allocator_t>
211template<
class char_t,
class traits_t,
class allocator_t>
213 if (!
size())
return *
this;
214 auto result = chars_;
215 while (std::find(trim_chars.begin(), trim_chars.end(), result[result.size() - 1]) != trim_chars.end())
216 result.erase(result.size() - 1, 1);
220template<
class char_t,
class traits_t,
class allocator_t>
223template<
class char_t,
class traits_t,
class allocator_t>
225 if (!
size())
return *
this;
226 auto result = chars_;
227 while (std::find(trim_chars.begin(), trim_chars.end(), result[0]) != trim_chars.end())
232template<
class char_t,
class traits_t,
class allocator_t>
234 auto result = basic_string::empty_string;
235 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
239template<
class char_t,
class traits_t,
class allocator_t>
241 auto result = basic_string::empty_string;
242 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
246template<
class char_t,
class traits_t,
class allocator_t>
247template<
class other_
char_t>
249 auto result = basic_string::empty_string;
250 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
255template<
class char_t,
class traits_t,
class allocator_t>
256template<
class object_t>
259 for (
const auto& arg : args)
260 result +=
format(
"{}", arg);
264template<
class char_t,
class traits_t,
class allocator_t>
265template<
class ...args_t>
267 auto result = basic_string<char> {};
269 auto formats = std::vector<__format_information<char>> {};
270 auto begin_format_iterator = fmt.end();
271 auto end_format_iterator = fmt.end();
272 for (
auto iterator = fmt.begin(); iterator != fmt.end(); ++iterator) {
273 if (*iterator ==
'{') {
274 if (++iterator == fmt.end())
276 if (*iterator ==
'{')
279 begin_format_iterator = iterator;
280 while (iterator != fmt.end() && *iterator !=
'}') ++iterator;
281 if (iterator == fmt.end())
283 end_format_iterator = iterator;
284 __format_information<char> fi;
285 fi.location = result.size();
286 auto format_str = std::basic_string<char> {begin_format_iterator, end_format_iterator};
287 if (format_str.size() == 0)
290 xtd::size index_alignment_separator = basic_string(format_str).index_of(
',');
291 xtd::size index_format_separator = basic_string(format_str).index_of(u
':');
293 if (index_alignment_separator != std::basic_string<char>::npos && index_format_separator != std::basic_string<char>::npos && index_alignment_separator > index_format_separator)
294 index_alignment_separator = std::basic_string<char>::npos;
296 if (index_alignment_separator != basic_string<char_t>::npos)
297 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);
299 if (index_format_separator != basic_string<char>::npos)
300 fi.format = format_str.substr(index_format_separator + 1);
302 if (index_alignment_separator == 0 || index_format_separator == 0)
305 auto index_str = std::basic_string<char> {};
306 if (index_alignment_separator != basic_string<char>::npos)
307 index_str = format_str.substr(0, index_alignment_separator);
308 else if (index_format_separator != basic_string<char>::npos)
309 index_str = format_str.substr(0, index_format_separator);
311 index_str = std::move(format_str);
313 for (
auto c : index_str)
315 fi.index = std::stoi(index_str);
321 formats.push_back(fi);
323 }
else if (*iterator ==
'}') {
324 if (++iterator == fmt.end())
326 if (*iterator !=
'}')
333 __basic_string_extract_format_arg(result, formats, std::forward<args_t>(args)...);
334 return result.c_str();
337template<
class char_t,
class traits_t,
class allocator_t>
338template<
class value_t>
343template<
class char_t,
class traits_t,
class allocator_t>
344template<
class value_t>
349template<
class char_t,
class traits_t,
class allocator_t>
350template<
class value_t>
355template<
class char_t,
class traits_t,
class allocator_t>
358template<
class char_t,
class traits_t,
class allocator_t>
361template<
class char_t,
class traits_t,
class allocator_t>
365void __basic_string_extract_format_arg(std::basic_string<char>& fmt,
xtd::size& index, std::vector<__format_information<char >> & formats, arg_t&& arg) {
368 for (
auto& format : formats) {
369 format.location += offset;
370 if (
format.index == index) {
374 if (!
format.alignment.empty()) {
377 alignment = std::stoi(
format.alignment);
381 if (alignment > 0) arg_str = arg_str.
pad_left(alignment);
382 else if (alignment < 0) arg_str = arg_str.
pad_right(-alignment);
384 fmt.insert(
format.location, arg_str);
385 offset += arg_str.size();
391template<
class ...args_t>
392void __basic_string_extract_format_arg(
xtd::basic_string<char>& fmt, std::vector<__format_information<char >> & formats, args_t&&... args) {
394 (__basic_string_extract_format_arg(
const_cast<std::basic_string<char>&
> (fmt.chars()), index, formats, args), ...);
399template<
class target_t,
class source_t>
400inline std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str)
noexcept {
401 auto out = std::basic_string<target_t> {};
403 for (
const auto& character : str) {
404 if (character >= 0xd800 && character <= 0xdbff)
405 codepoint = ((
character - 0xd800) << 10) + 0x10000;
407 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
410 if (codepoint <= 0x7f)
411 out.append(1,
static_cast<target_t
>(codepoint));
412 else if (codepoint <= 0x7ff) {
413 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
414 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
415 }
else if (codepoint <= 0xffff) {
416 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
417 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
418 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
420 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
421 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
422 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
423 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
432inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(std::basic_string<char>&& str)
noexcept {
433 auto out = std::basic_string<xtd::char16> {};
435 auto str_ptr = str.data();
436 while (*str_ptr != 0) {
437 auto ch =
static_cast<unsigned char>(*str_ptr);
438 if (ch <= 0x7f) codepoint = ch;
439 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
440 else if (ch <= 0xdf) codepoint = ch & 0x1f;
441 else if (ch <= 0xef) codepoint = ch & 0x0f;
442 else codepoint = ch & 0x07;
444 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
445 if (codepoint > 0xffff) {
448 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
449 out.append(1,
static_cast<xtd::char16>(codepoint));
456inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
457 auto out = std::basic_string<xtd::char16> {};
459 auto str_ptr = str.data();
460 while (*str_ptr != 0) {
461 auto ch =
static_cast<unsigned char>(*str_ptr);
462 if (ch <= 0x7f) codepoint = ch;
463 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
464 else if (ch <= 0xdf) codepoint = ch & 0x1f;
465 else if (ch <= 0xef) codepoint = ch & 0x0f;
466 else codepoint = ch & 0x07;
468 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
469 if (codepoint > 0xffff) {
472 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
473 out.append(1,
static_cast<xtd::char16>(codepoint));
480inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(std::basic_string<char>&& str)
noexcept {
481 auto out = std::basic_string<xtd::wchar> {};
483 auto str_ptr = str.data();
484 while (*str_ptr != 0) {
485 auto ch =
static_cast<unsigned char>(*str_ptr);
486 if (ch <= 0x7f) codepoint = ch;
487 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
488 else if (ch <= 0xdf) codepoint = ch & 0x1f;
489 else if (ch <= 0xef) codepoint = ch & 0x0f;
490 else codepoint = ch & 0x07;
492 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
494 out.append(1,
static_cast<xtd::wchar>(codepoint));
495 else if (codepoint > 0xffff) {
498 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
499 out.append(1,
static_cast<xtd::wchar>(codepoint));
506inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
507 auto out = std::basic_string<xtd::wchar> {};
509 auto str_ptr = str.data();
510 while (*str_ptr != 0) {
511 auto ch =
static_cast<unsigned char>(*str_ptr);
512 if (ch <= 0x7f) codepoint = ch;
513 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
514 else if (ch <= 0xdf) codepoint = ch & 0x1f;
515 else if (ch <= 0xef) codepoint = ch & 0x0f;
516 else codepoint = ch & 0x07;
518 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
520 out.append(1,
static_cast<xtd::wchar>(codepoint));
521 else if (codepoint > 0xffff) {
524 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
525 out.append(1,
static_cast<xtd::wchar>(codepoint));
532inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(std::basic_string<char>&& str)
noexcept {
533 auto out = std::basic_string<xtd::char32> {};
535 auto str_ptr = str.data();
536 while (*str_ptr != 0) {
537 auto ch =
static_cast<unsigned char>(*str_ptr);
538 if (ch <= 0x7f) codepoint = ch;
539 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
540 else if (ch <= 0xdf) codepoint = ch & 0x1f;
541 else if (ch <= 0xef) codepoint = ch & 0x0f;
542 else codepoint = ch & 0x07;
544 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
545 out.append(1,
static_cast<xtd::char32>(codepoint));
551inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
552 auto out = std::basic_string<xtd::char32> {};
554 auto str_ptr = str.data();
555 while (*str_ptr != 0) {
556 auto ch =
static_cast<unsigned char>(*str_ptr);
557 if (ch <= 0x7f) codepoint = ch;
558 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
559 else if (ch <= 0xdf) codepoint = ch & 0x1f;
560 else if (ch <= 0xef) codepoint = ch & 0x0f;
561 else codepoint = ch & 0x07;
563 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
564 out.append(1,
static_cast<xtd::char32>(codepoint));
570inline std::basic_string<char> __xtd_convert_to_string<char, char>(std::basic_string<char>&& str)
noexcept {
571 return std::move(str);
575inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
576 return std::move(str);
580inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
581 return std::move(str);
585inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
586 return std::move(str);
590inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
591 return std::move(str);
595inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(std::basic_string<char>&& str)
noexcept {
596 return std::basic_string<xtd::char8> {
reinterpret_cast<const xtd::char8*
>(str.c_str())};
600inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
601 return std::basic_string<char> {
reinterpret_cast<const char*
>(str.c_str())};
605inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
606 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
610inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
611 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
615inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
616 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
620inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
621 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
625inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
626 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));
630inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
631 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));
634template<
class target_t,
class source_t>
635inline std::basic_string<target_t> __xtd_convert_to_string(
const std::basic_string<source_t>& str)
noexcept {
636 auto out = std::basic_string<target_t> {};
638 for (
const auto& character : str) {
639 if (character >= 0xd800 && character <= 0xdbff)
640 codepoint = ((
character - 0xd800) << 10) + 0x10000;
642 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
645 if (codepoint <= 0x7f)
646 out.append(1,
static_cast<target_t
>(codepoint));
647 else if (codepoint <= 0x7ff) {
648 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
649 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
650 }
else if (codepoint <= 0xffff) {
651 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
652 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
653 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
655 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
656 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
657 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
658 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
667inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(
const std::basic_string<char>& str)
noexcept {
668 auto out = std::basic_string<xtd::char16> {};
670 auto str_ptr = str.data();
671 while (*str_ptr != 0) {
672 auto ch =
static_cast<unsigned char>(*str_ptr);
673 if (ch <= 0x7f) codepoint = ch;
674 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
675 else if (ch <= 0xdf) codepoint = ch & 0x1f;
676 else if (ch <= 0xef) codepoint = ch & 0x0f;
677 else codepoint = ch & 0x07;
679 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
680 if (codepoint > 0xffff) {
683 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
684 out.append(1,
static_cast<xtd::char16>(codepoint));
691inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
692 auto out = std::basic_string<xtd::char16> {};
694 auto str_ptr = str.data();
695 while (*str_ptr != 0) {
696 auto ch =
static_cast<unsigned char>(*str_ptr);
697 if (ch <= 0x7f) codepoint = ch;
698 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
699 else if (ch <= 0xdf) codepoint = ch & 0x1f;
700 else if (ch <= 0xef) codepoint = ch & 0x0f;
701 else codepoint = ch & 0x07;
703 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
704 if (codepoint > 0xffff) {
707 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
708 out.append(1,
static_cast<xtd::char16>(codepoint));
715inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(
const std::basic_string<char>& str)
noexcept {
716 auto out = std::basic_string<xtd::wchar> {};
718 auto str_ptr = str.data();
719 while (*str_ptr != 0) {
720 auto ch =
static_cast<unsigned char>(*str_ptr);
721 if (ch <= 0x7f) codepoint = ch;
722 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
723 else if (ch <= 0xdf) codepoint = ch & 0x1f;
724 else if (ch <= 0xef) codepoint = ch & 0x0f;
725 else codepoint = ch & 0x07;
727 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
729 out.append(1,
static_cast<xtd::wchar>(codepoint));
730 else if (codepoint > 0xffff) {
733 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
734 out.append(1,
static_cast<xtd::wchar>(codepoint));
741inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
742 auto out = std::basic_string<xtd::wchar> {};
744 auto str_ptr = str.data();
745 while (*str_ptr != 0) {
746 auto ch =
static_cast<unsigned char>(*str_ptr);
747 if (ch <= 0x7f) codepoint = ch;
748 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
749 else if (ch <= 0xdf) codepoint = ch & 0x1f;
750 else if (ch <= 0xef) codepoint = ch & 0x0f;
751 else codepoint = ch & 0x07;
753 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
755 out.append(1,
static_cast<xtd::wchar>(codepoint));
756 else if (codepoint > 0xffff) {
759 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
760 out.append(1,
static_cast<xtd::wchar>(codepoint));
767inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(
const std::basic_string<char>& str)
noexcept {
768 auto out = std::basic_string<xtd::char32> {};
770 auto str_ptr = str.data();
771 while (*str_ptr != 0) {
772 auto ch =
static_cast<unsigned char>(*str_ptr);
773 if (ch <= 0x7f) codepoint = ch;
774 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
775 else if (ch <= 0xdf) codepoint = ch & 0x1f;
776 else if (ch <= 0xef) codepoint = ch & 0x0f;
777 else codepoint = ch & 0x07;
779 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
780 out.append(1,
static_cast<xtd::char32>(codepoint));
786inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
787 auto out = std::basic_string<xtd::char32> {};
789 auto str_ptr = str.data();
790 while (*str_ptr != 0) {
791 auto ch =
static_cast<unsigned char>(*str_ptr);
792 if (ch <= 0x7f) codepoint = ch;
793 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
794 else if (ch <= 0xdf) codepoint = ch & 0x1f;
795 else if (ch <= 0xef) codepoint = ch & 0x0f;
796 else codepoint = ch & 0x07;
798 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
799 out.append(1,
static_cast<xtd::char32>(codepoint));
805inline std::basic_string<char> __xtd_convert_to_string<char, char>(
const std::basic_string<char>& str)
noexcept {
810inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
815inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
820inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
825inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
830inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(
const std::basic_string<char>& str)
noexcept {
831 return reinterpret_cast<const xtd::char8*
>(str.c_str());
835inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
836 return reinterpret_cast<const char*
>(str.c_str());
840inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
841 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
845inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
846 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
850inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
851 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
855inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
856 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
860inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
861 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(str));
865inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
866 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