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 list = std::vector<basic_string> {};
137 auto sub_string = basic_string::empty_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));
143 if (list.size() == count - 1) {
144 list.push_back(sub_string + basic_string(c_str(), it -
begin() + (is_separator ? 0 : 1), length() - (it -
begin()) + (is_separator ? 0 : 1)));
147 list.push_back(sub_string);
148 sub_string.chars_.clear();
154template<
class char_t,
class traits_t,
class allocator_t>
156 return to_array(0,
size());
159template<
class char_t,
class traits_t,
class allocator_t>
161 return to_array(start_index,
size() - start_index);
164template<
class char_t,
class traits_t,
class allocator_t>
166 if (start_index >=
size())
return {};
167 if (start_index + length >=
size())
return {
begin() + start_index,
end()};
168 return {
begin() + start_index,
begin() + start_index + length};
171template<
class char_t,
class traits_t,
class allocator_t>
173 return to_array(0,
size());
176template<
class char_t,
class traits_t,
class allocator_t>
178 return to_array(start_index, length);
181template<
class char_t,
class traits_t,
class allocator_t>
183 auto words = split({
' '});
184 for (
auto& word : words)
186 return basic_string::join(
" ", words);
189template<
class char_t,
class traits_t,
class allocator_t>
193template<
class char_t,
class traits_t,
class allocator_t>
195 return trim_start(trim_chars).
trim_end(trim_chars);
198template<
class char_t,
class traits_t,
class allocator_t>
203template<
class char_t,
class traits_t,
class allocator_t>
205 if (!
size())
return *
this;
206 auto result = chars_;
207 while (std::find(trim_chars.begin(), trim_chars.end(), result[result.size() - 1]) != trim_chars.end())
208 result.erase(result.size() - 1, 1);
212template<
class char_t,
class traits_t,
class allocator_t>
215template<
class char_t,
class traits_t,
class allocator_t>
217 if (!
size())
return *
this;
218 auto result = chars_;
219 while (std::find(trim_chars.begin(), trim_chars.end(), result[0]) != trim_chars.end())
224template<
class char_t,
class traits_t,
class allocator_t>
226 auto result = basic_string::empty_string;
227 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
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>
239template<
class other_
char_t>
241 auto result = basic_string::empty_string;
242 std::for_each(values.begin(), values.end(), [&](
const auto & item) {result += item;});
247template<
class char_t,
class traits_t,
class allocator_t>
248template<
class object_t>
251 for (
const auto& arg : args)
252 result +=
format(
"{}", arg);
256template<
class char_t,
class traits_t,
class allocator_t>
257template<
class ...args_t>
259 auto result = basic_string<char> {};
261 auto formats = std::vector<__format_information<char>> {};
262 auto begin_format_iterator = fmt.
end();
263 auto end_format_iterator = fmt.end();
264 for (
auto iterator = fmt.begin(); iterator != fmt.end(); ++iterator) {
265 if (*iterator ==
'{') {
266 if (++iterator == fmt.end())
268 if (*iterator ==
'{')
271 begin_format_iterator = iterator;
272 while (iterator != fmt.end() && *iterator !=
'}') ++iterator;
273 if (iterator == fmt.end())
275 end_format_iterator = iterator;
276 __format_information<char> fi;
277 fi.location = result.size();
278 auto format_str = std::basic_string<char> {begin_format_iterator, end_format_iterator};
279 if (format_str.size() == 0)
282 xtd::size index_alignment_separator = basic_string(format_str).index_of(
',');
283 xtd::size index_format_separator = basic_string(format_str).index_of(u
':');
285 if (index_alignment_separator != std::basic_string<char>::npos && index_format_separator != std::basic_string<char>::npos && index_alignment_separator > index_format_separator)
286 index_alignment_separator = std::basic_string<char>::npos;
288 if (index_alignment_separator != basic_string<char_t>::npos)
289 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);
291 if (index_format_separator != basic_string<char>::npos)
292 fi.format = format_str.substr(index_format_separator + 1);
294 if (index_alignment_separator == 0 || index_format_separator == 0)
297 auto index_str = std::basic_string<char> {};
298 if (index_alignment_separator != basic_string<char>::npos)
299 index_str = format_str.substr(0, index_alignment_separator);
300 else if (index_format_separator != basic_string<char>::npos)
301 index_str = format_str.substr(0, index_format_separator);
303 index_str = std::move(format_str);
305 for (
auto c : index_str)
307 fi.index = std::stoi(index_str);
313 formats.push_back(fi);
315 }
else if (*iterator ==
'}') {
316 if (++iterator == fmt.end())
318 if (*iterator !=
'}')
325 __basic_string_extract_format_arg(result, formats, std::forward<args_t>(args)...);
326 return result.c_str();
329template<
class char_t,
class traits_t,
class allocator_t>
330template<
class value_t>
335template<
class char_t,
class traits_t,
class allocator_t>
336template<
class value_t>
341template<
class char_t,
class traits_t,
class allocator_t>
342template<
class value_t>
347template<
class char_t,
class traits_t,
class allocator_t>
350template<
class char_t,
class traits_t,
class allocator_t>
353template<
class char_t,
class traits_t,
class allocator_t>
357void __basic_string_extract_format_arg(std::basic_string<char>& fmt,
xtd::size& index, std::vector<__format_information<char>>& formats, arg_t&& arg) {
360 for (
auto& format : formats) {
361 format.location += offset;
362 if (
format.index == index) {
369 alignment = std::stoi(
format.alignment);
373 if (alignment > 0) arg_str = arg_str.
pad_left(alignment);
374 else if (alignment < 0) arg_str = arg_str.
pad_right(-alignment);
377 offset += arg_str.
size();
383template<
class ...args_t>
384void __basic_string_extract_format_arg(
xtd::basic_string<char>& fmt, std::vector<__format_information<char>>& formats, args_t&&... args) {
386 (__basic_string_extract_format_arg(
const_cast<std::basic_string<char>&
>(fmt.
chars()), index, formats, args), ...);
391template<
class target_t,
class source_t>
392inline std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str)
noexcept {
393 auto out = std::basic_string<target_t> {};
395 for (
const auto& character : str) {
396 if (character >= 0xd800 && character <= 0xdbff)
397 codepoint = ((
character - 0xd800) << 10) + 0x10000;
399 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
402 if (codepoint <= 0x7f)
403 out.append(1,
static_cast<target_t
>(codepoint));
404 else if (codepoint <= 0x7ff) {
405 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
406 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
407 }
else if (codepoint <= 0xffff) {
408 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
409 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
410 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
412 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
413 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
414 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
415 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
424inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(std::basic_string<char>&& str)
noexcept {
425 auto out = std::basic_string<xtd::char16> {};
427 auto str_ptr = str.data();
428 while (*str_ptr != 0) {
429 auto ch =
static_cast<unsigned char>(*str_ptr);
430 if (ch <= 0x7f) codepoint = ch;
431 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
432 else if (ch <= 0xdf) codepoint = ch & 0x1f;
433 else if (ch <= 0xef) codepoint = ch & 0x0f;
434 else codepoint = ch & 0x07;
436 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
437 if (codepoint > 0xffff) {
440 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
441 out.append(1,
static_cast<xtd::char16>(codepoint));
447#if defined(__xtd__cpp_lib_char8_t)
449inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
450 auto out = std::basic_string<xtd::char16> {};
452 auto str_ptr = str.data();
453 while (*str_ptr != 0) {
454 auto ch =
static_cast<unsigned char>(*str_ptr);
455 if (ch <= 0x7f) codepoint = ch;
456 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
457 else if (ch <= 0xdf) codepoint = ch & 0x1f;
458 else if (ch <= 0xef) codepoint = ch & 0x0f;
459 else codepoint = ch & 0x07;
461 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
462 if (codepoint > 0xffff) {
465 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
466 out.append(1,
static_cast<xtd::char16>(codepoint));
474inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(std::basic_string<char>&& str)
noexcept {
475 auto out = std::basic_string<xtd::wchar> {};
477 auto str_ptr = str.data();
478 while (*str_ptr != 0) {
479 auto ch =
static_cast<unsigned char>(*str_ptr);
480 if (ch <= 0x7f) codepoint = ch;
481 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
482 else if (ch <= 0xdf) codepoint = ch & 0x1f;
483 else if (ch <= 0xef) codepoint = ch & 0x0f;
484 else codepoint = ch & 0x07;
486 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
488 out.append(1,
static_cast<xtd::wchar>(codepoint));
489 else if (codepoint > 0xffff) {
492 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
493 out.append(1,
static_cast<xtd::wchar>(codepoint));
499#if defined(__xtd__cpp_lib_char8_t)
501inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
502 auto out = std::basic_string<xtd::wchar> {};
504 auto str_ptr = str.data();
505 while (*str_ptr != 0) {
506 auto ch =
static_cast<unsigned char>(*str_ptr);
507 if (ch <= 0x7f) codepoint = ch;
508 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
509 else if (ch <= 0xdf) codepoint = ch & 0x1f;
510 else if (ch <= 0xef) codepoint = ch & 0x0f;
511 else codepoint = ch & 0x07;
513 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
515 out.append(1,
static_cast<xtd::wchar>(codepoint));
516 else if (codepoint > 0xffff) {
519 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
520 out.append(1,
static_cast<xtd::wchar>(codepoint));
528inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(std::basic_string<char>&& str)
noexcept {
529 auto out = std::basic_string<xtd::char32> {};
531 auto str_ptr = str.data();
532 while (*str_ptr != 0) {
533 auto ch =
static_cast<unsigned char>(*str_ptr);
534 if (ch <= 0x7f) codepoint = ch;
535 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
536 else if (ch <= 0xdf) codepoint = ch & 0x1f;
537 else if (ch <= 0xef) codepoint = ch & 0x0f;
538 else codepoint = ch & 0x07;
540 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
541 out.append(1,
static_cast<xtd::char32>(codepoint));
546#if defined(__xtd__cpp_lib_char8_t)
548inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
549 auto out = std::basic_string<xtd::char32> {};
551 auto str_ptr = str.data();
552 while (*str_ptr != 0) {
553 auto ch =
static_cast<unsigned char>(*str_ptr);
554 if (ch <= 0x7f) codepoint = ch;
555 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
556 else if (ch <= 0xdf) codepoint = ch & 0x1f;
557 else if (ch <= 0xef) codepoint = ch & 0x0f;
558 else codepoint = ch & 0x07;
560 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
561 out.append(1,
static_cast<xtd::char32>(codepoint));
568inline std::basic_string<char> __xtd_convert_to_string<char, char>(std::basic_string<char>&& str)
noexcept {
569 return std::move(str);
573inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
574 return std::move(str);
578inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
579 return std::move(str);
582#if defined(__xtd__cpp_lib_char8_t)
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);
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);
594#if defined(__xtd__cpp_lib_char8_t)
596inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(std::basic_string<char>&& str)
noexcept {
597 return std::basic_string<xtd::char8> {
reinterpret_cast<const xtd::char8*
>(str.c_str())};
601inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(std::basic_string<xtd::char8>&& str)
noexcept {
602 return std::basic_string<char> {
reinterpret_cast<const char*
>(str.c_str())};
607inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
608 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
612inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
613 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(std::move(str)));
617inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
618 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
622inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(std::basic_string<xtd::wchar>&& str)
noexcept {
623 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(std::move(str)));
627inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(std::basic_string<xtd::char16>&& str)
noexcept {
628 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));}
631inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(std::basic_string<xtd::char32>&& str)
noexcept {
632 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(std::move(str)));
635template<
class target_t,
class source_t>
636inline std::basic_string<target_t> __xtd_convert_to_string(
const std::basic_string<source_t>& str)
noexcept {
637 auto out = std::basic_string<target_t> {};
639 for (
const auto& character : str) {
640 if (character >= 0xd800 && character <= 0xdbff)
641 codepoint = ((
character - 0xd800) << 10) + 0x10000;
643 if (character >= 0xdc00 && character <= 0xdfff) codepoint |=
character - 0xdc00;
646 if (codepoint <= 0x7f)
647 out.append(1,
static_cast<target_t
>(codepoint));
648 else if (codepoint <= 0x7ff) {
649 out.append(1,
static_cast<target_t
>(0xc0 | ((codepoint >> 6) & 0x1f)));
650 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
651 }
else if (codepoint <= 0xffff) {
652 out.append(1,
static_cast<target_t
>(0xe0 | ((codepoint >> 12) & 0x0f)));
653 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
654 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
656 out.append(1,
static_cast<target_t
>(0xf0 | ((codepoint >> 18) & 0x07)));
657 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 12) & 0x3f)));
658 out.append(1,
static_cast<target_t
>(0x80 | ((codepoint >> 6) & 0x3f)));
659 out.append(1,
static_cast<target_t
>(0x80 | (codepoint & 0x3f)));
668inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, char>(
const std::basic_string<char>& str)
noexcept {
669 auto out = std::basic_string<xtd::char16> {};
671 auto str_ptr = str.data();
672 while (*str_ptr != 0) {
673 auto ch =
static_cast<unsigned char>(*str_ptr);
674 if (ch <= 0x7f) codepoint = ch;
675 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
676 else if (ch <= 0xdf) codepoint = ch & 0x1f;
677 else if (ch <= 0xef) codepoint = ch & 0x0f;
678 else codepoint = ch & 0x07;
680 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
681 if (codepoint > 0xffff) {
684 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
685 out.append(1,
static_cast<xtd::char16>(codepoint));
691#if defined(__xtd__cpp_lib_char8_t)
693inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
694 auto out = std::basic_string<xtd::char16> {};
696 auto str_ptr = str.data();
697 while (*str_ptr != 0) {
698 auto ch =
static_cast<unsigned char>(*str_ptr);
699 if (ch <= 0x7f) codepoint = ch;
700 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
701 else if (ch <= 0xdf) codepoint = ch & 0x1f;
702 else if (ch <= 0xef) codepoint = ch & 0x0f;
703 else codepoint = ch & 0x07;
705 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
706 if (codepoint > 0xffff) {
709 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
710 out.append(1,
static_cast<xtd::char16>(codepoint));
718inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, char>(
const std::basic_string<char>& str)
noexcept {
719 auto out = std::basic_string<xtd::wchar> {};
721 auto str_ptr = str.data();
722 while (*str_ptr != 0) {
723 auto ch =
static_cast<unsigned char>(*str_ptr);
724 if (ch <= 0x7f) codepoint = ch;
725 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
726 else if (ch <= 0xdf) codepoint = ch & 0x1f;
727 else if (ch <= 0xef) codepoint = ch & 0x0f;
728 else codepoint = ch & 0x07;
730 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
732 out.append(1,
static_cast<xtd::wchar>(codepoint));
733 else if (codepoint > 0xffff) {
736 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
737 out.append(1,
static_cast<xtd::wchar>(codepoint));
743#if defined(__xtd__cpp_lib_char8_t)
745inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
746 auto out = std::basic_string<xtd::wchar> {};
748 auto str_ptr = str.data();
749 while (*str_ptr != 0) {
750 auto ch =
static_cast<unsigned char>(*str_ptr);
751 if (ch <= 0x7f) codepoint = ch;
752 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
753 else if (ch <= 0xdf) codepoint = ch & 0x1f;
754 else if (ch <= 0xef) codepoint = ch & 0x0f;
755 else codepoint = ch & 0x07;
757 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff)) {
759 out.append(1,
static_cast<xtd::wchar>(codepoint));
760 else if (codepoint > 0xffff) {
763 }
else if (codepoint < 0xd800 || codepoint >= 0xe000)
764 out.append(1,
static_cast<xtd::wchar>(codepoint));
772inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, char>(
const std::basic_string<char>& str)
noexcept {
773 auto out = std::basic_string<xtd::char32> {};
775 auto str_ptr = str.data();
776 while (*str_ptr != 0) {
777 auto ch =
static_cast<unsigned char>(*str_ptr);
778 if (ch <= 0x7f) codepoint = ch;
779 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
780 else if (ch <= 0xdf) codepoint = ch & 0x1f;
781 else if (ch <= 0xef) codepoint = ch & 0x0f;
782 else codepoint = ch & 0x07;
784 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
785 out.append(1,
static_cast<xtd::char32>(codepoint));
790#if defined(__xtd__cpp_lib_char8_t)
792inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
793 auto out = std::basic_string<xtd::char32> {};
795 auto str_ptr = str.data();
796 while (*str_ptr != 0) {
797 auto ch =
static_cast<unsigned char>(*str_ptr);
798 if (ch <= 0x7f) codepoint = ch;
799 else if (ch <= 0xbf) codepoint = (codepoint << 6) | (ch & 0x3f);
800 else if (ch <= 0xdf) codepoint = ch & 0x1f;
801 else if (ch <= 0xef) codepoint = ch & 0x0f;
802 else codepoint = ch & 0x07;
804 if (((*str_ptr & 0xc0) != 0x80) && (codepoint <= 0x10ffff))
805 out.append(1,
static_cast<xtd::char32>(codepoint));
812inline std::basic_string<char> __xtd_convert_to_string<char, char>(
const std::basic_string<char>& str)
noexcept {
817inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
822inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
826#if defined(__xtd__cpp_lib_char8_t)
828inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
834inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
838#if defined(__xtd__cpp_lib_char8_t)
840inline std::basic_string<xtd::char8> __xtd_convert_to_string<xtd::char8, char>(
const std::basic_string<char>& str)
noexcept {
841 return reinterpret_cast<const xtd::char8*
>(str.c_str());
845inline std::basic_string<char> __xtd_convert_to_string<char, xtd::char8>(
const std::basic_string<xtd::char8>& str)
noexcept {
846 return reinterpret_cast<const char*
>(str.c_str());
851inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
852 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
856inline std::basic_string<xtd::char16> __xtd_convert_to_string<xtd::char16, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
857 return __xtd_convert_to_string<xtd::char16>(__xtd_convert_to_string<char>(str));
861inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
862 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
866inline std::basic_string<xtd::char32> __xtd_convert_to_string<xtd::char32, xtd::wchar>(
const std::basic_string<xtd::wchar>& str)
noexcept {
867 return __xtd_convert_to_string<xtd::char32>(__xtd_convert_to_string<char>(str));
871inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char16>(
const std::basic_string<xtd::char16>& str)
noexcept {
872 return __xtd_convert_to_string<xtd::wchar>(__xtd_convert_to_string<char>(str));
876inline std::basic_string<xtd::wchar> __xtd_convert_to_string<xtd::wchar, xtd::char32>(
const std::basic_string<xtd::char32>& str)
noexcept {
877 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:59
const_iterator end() const noexcept override
Returns an iterator to the element following the last element of the enumarable.
Definition basic_array.hpp:161
const_iterator begin() const noexcept override
Returns an iterator to the first element of the enumarable.
Definition basic_array.hpp:117
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:1575
basic_string trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified xtd::basic_...
Definition basic_string.hpp:1962
xtd::array< basic_string > split() const noexcept
Splits this basic_string into substrings that are based on the default white-space characters....
basic_string insert(xtd::size start_index, const basic_string &value) const
Inserts a specified instance of basic_string at a specified index position in this instance.
Definition basic_string.hpp:1492
const base_type & chars() const noexcept
Returns a reference to the underlying base type.
Definition basic_string.hpp:875
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.
const_iterator end() const override
Returns an iterator to the character following the last character of the string. This character acts ...
Definition basic_string.hpp:900
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:2111
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:2288
basic_string trim_end() const noexcept
Removes all trailing occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:1978
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...
size_type size() const noexcept
Returns the number of char_t elements in the string, i.e. std::distance(begin(), end()).
Definition basic_string.hpp:926
basic_string to_title_case() const noexcept
Converts the current basic_string to title case (except for words that are entirely in uppercase,...
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:1589
basic_string trim_start() const noexcept
Removes all leading occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:1994
basic_string()=default
Initializes a new instance of xtd::basic_string.
bool empty() const noexcept
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string.hpp:896
xtd::array< value_type > to_array() const noexcept
Copies the characters in this instance to a Unicode character array.
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
exception_case
Represents the exception case used by the xtd::helpers::exception helper class.
Definition exception_case.hpp:25
@ format
The format is not valid.
@ index_out_of_range
The index is out of range.
@ format_opened_bracket_without_end_bracket
The format contains open backet_without_end_bracket.
@ format_closing_bracket_without_open_bracket
The format contains close backet_without_open_bracket.
#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.
@ word
Specifies that text is trimmed to the nearest word.
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:27
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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:26
string_split_options
Specifies whether applicable xtd::string::split method overloads include or omit empty substrings fro...
Definition string_split_options.hpp:14
std::string to_string(const value_t &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition to_string.hpp:41
@ none
The return value includes array elements that contain an empty string.
@ remove_empty_entries
The return value does not include array elements that contain an empty string.
@ begin
Specifies the beginning of a stream.
@ separator
The Separator key.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition xtd_about_box.hpp:10