xtd 0.2.0
Loading...
Searching...
No Matches
basic_string.hpp
Go to the documentation of this file.
1
4#pragma once
6#define __XTD_CORE_INTERNAL__
11#undef __XTD_CORE_INTERNAL__
12#define __XTD_STD_INTERNAL__
14#undef __XTD_STD_INTERNAL__
17#include "hash_code.hpp"
18#include "icomparable.hpp"
19#include "iequatable.hpp"
20#include "null.hpp"
21#include "string_comparison.hpp"
23#include "types.hpp"
24#include "object.hpp"
25#include "parse.hpp"
26#include "to_string.hpp"
27#include "types.hpp"
28#include "unused.hpp"
29#include <cctype>
30#if defined(__xtd__cpp_lib_format)
31#include <format>
32#endif
33#include <iomanip>
34#include <ostream>
35#include <sstream>
36#include <string>
37
39template<class ...args_t>
40void __basic_string_extract_format_arg(const std::locale& loc, xtd::basic_string<char>& fmt, xtd::array<__format_information<char >> & formats, args_t&&... args);
41template<class target_t, class source_t>
42std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str) noexcept;
43template<class target_t, class source_t>
44std::basic_string<target_t> __xtd_convert_to_string(const std::basic_string<source_t>& str) noexcept;
45std::basic_string<char> __xtd_demangle(const std::basic_string<char>& value) noexcept;
46std::basic_string<char> __xtd_get_class_name(const std::type_info& value) noexcept;
47std::basic_string<char> __xtd_get_full_class_name(const std::type_info& value) noexcept;
49
51namespace xtd {
70 template<class char_t, class traits_t, class allocator_t>
71 class basic_string : public object, public xtd::icomparable<basic_string<char_t, traits_t, allocator_t>>, public xtd::iequatable<basic_string<char_t, traits_t, allocator_t >>, public xtd::collections::generic::ienumerable<char_t> {
72 public:
74
78 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
80 using traits_type = typename base_type::traits_type;
82 using value_type = typename base_type::value_type;
84 using allocator_type = typename base_type::allocator_type;
86 using size_type = typename base_type::size_type;
88 using difference_type = typename base_type::difference_type;
90 using reference = typename base_type::reference;
92 using const_reference = typename base_type::const_reference;
94 using pointer = typename base_type::pointer;
96 using const_pointer = typename base_type::const_pointer;
104 using reverse_iterator = typename base_type::reverse_iterator;
106 using const_reverse_iterator = typename base_type::const_reverse_iterator;
108 using enumerator_type = typename xtd::collections::generic::enumerator<value_type>;
110
112
116 static const basic_string empty_string;
117
126 inline static constexpr size_type npos = base_type::npos;
127
136 static inline constexpr xtd::size bpos = 0;
137
154 static inline constexpr xtd::size epos = npos - 1;
156
158
161 basic_string() = default;
164 explicit basic_string(const allocator_type & allocator) noexcept;
165
168 basic_string(const basic_string<char>& str) noexcept {
169 if constexpr(std::is_same_v<char, char_t>) chars_ = str.chars_;
170 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
171 }
172
175 basic_string(const basic_string<xtd::char16>& str) noexcept {
176 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str.chars_;
177 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
178 }
181 basic_string(const basic_string<xtd::char32>& str) noexcept {
182 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str.chars_;
183 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
184 }
187 basic_string(const basic_string<xtd::char8>& str) noexcept {
188 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str.chars_;
189 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
190 }
193 basic_string(const basic_string<xtd::wchar>& str) noexcept {
194 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str.chars_;
195 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
196 }
197
201 basic_string(const basic_string<char>& str, const allocator_type & allocator) noexcept {
202 if constexpr(std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, allocator);
203 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
204 }
208 basic_string(const basic_string<xtd::char16>& str, const allocator_type & allocator) noexcept {
209 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, allocator);
210 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
211 }
215 basic_string(const basic_string<xtd::char32>& str, const allocator_type & allocator) noexcept {
216 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, allocator);
217 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
218 }
222 basic_string(const basic_string<xtd::char8>& str, const allocator_type & allocator) noexcept {
223 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, allocator);
224 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
225 }
229 basic_string(const basic_string<xtd::wchar>& str, const allocator_type & allocator) noexcept {
230 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, allocator);
231 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
232 }
233
238 basic_string(const basic_string<char>& str, xtd::size index) {
240 if constexpr(std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index);
241 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index)));
242 }
249 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index);
250 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index)));
251 }
258 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index);
259 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index)));
260 }
267 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index);
268 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index)));
269 }
276 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index);
277 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index)));
278 }
279
285 basic_string(const basic_string<char>& str, xtd::size index, const allocator_type & allocator) {
287 if constexpr(std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index, allocator);
288 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index)), allocator);
289 }
295 basic_string(const basic_string<xtd::char16>& str, xtd::size index, const allocator_type & allocator) {
297 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index, allocator);
298 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index)), allocator);
299 }
305 basic_string(const basic_string<xtd::char32>& str, xtd::size index, const allocator_type & allocator) {
307 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index, allocator);
308 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index)), allocator);
309 }
315 basic_string(const basic_string<xtd::char8>& str, xtd::size index, const allocator_type & allocator) {
317 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index, allocator);
318 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index)), allocator);
319 }
325 basic_string(const basic_string<xtd::wchar>& str, xtd::size index, const allocator_type & allocator) {
327 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index, allocator);
328 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index)), allocator);
329 }
330
338 if constexpr(std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index, count);
339 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index, count)));
340 }
348 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index, count);
349 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index, count)));
350 }
358 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index, count);
359 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index, count)));
360 }
368 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index, count);
369 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index, count)));
370 }
378 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index, count);
379 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index, count)));
380 }
381
388 basic_string(const basic_string<char>& str, xtd::size index, xtd::size count, const allocator_type & allocator) {
390 if constexpr(std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
391 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index, count)), allocator);
392 }
399 basic_string(const basic_string<xtd::char16>& str, xtd::size index, xtd::size count, const allocator_type & allocator) {
401 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
402 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index, count)), allocator);
403 }
410 basic_string(const basic_string<xtd::char32>& str, xtd::size index, xtd::size count, const allocator_type & allocator) {
412 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
413 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index, count)), allocator);
414 }
421 basic_string(const basic_string<xtd::char8>& str, xtd::size index, xtd::size count, const allocator_type & allocator) {
423 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
424 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index, count)), allocator);
425 }
432 basic_string(const basic_string<xtd::wchar>& str, xtd::size index, xtd::size count, const allocator_type & allocator) {
434 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
435 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index, count)), allocator);
436 }
437
440 basic_string(basic_string&&) = default;
441
445 basic_string(basic_string&& str, const allocator_type & allocator) noexcept : chars_(std::move(str.chars_)) {}
446
451 basic_string(xtd::size count, char character) : basic_string(std::basic_string<char>(count, character)) {}
456 basic_string(xtd::size count, char character, const allocator_type & allocator) : basic_string(std::basic_string<char>(count, character), allocator) {}
460 basic_string(xtd::size count, xtd::char16 character) : basic_string(std::basic_string<xtd::char16>(count, character)) {}
465 basic_string(xtd::size count, xtd::char16 character, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char16>(count, character), allocator) {}
469 basic_string(xtd::size count, xtd::char32 character) : basic_string(std::basic_string<xtd::char32>(count, character)) {}
474 basic_string(xtd::size count, xtd::char32 character, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char32>(count, character), allocator) {}
478 basic_string(xtd::size count, xtd::char8 character) : basic_string(std::basic_string<xtd::char8>(count, character)) {}
483 basic_string(xtd::size count, xtd::char8 character, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char8>(count, character), allocator) {}
487 basic_string(xtd::size count, xtd::wchar character) : basic_string(std::basic_string<xtd::wchar>(count, character)) {}
493 basic_string(xtd::size count, xtd::wchar character, const allocator_type & allocator) : basic_string(std::basic_string<xtd::wchar>(count, character), allocator) {}
494
498 basic_string(char character, xtd::size count) : basic_string(std::basic_string<char>(count, character)) {}
503 basic_string(char character, xtd::size count, const allocator_type & allocator) : basic_string(std::basic_string<char>(count, character), allocator) {}
507 basic_string(xtd::char16 character, xtd::size count) : basic_string(std::basic_string<xtd::char16>(count, character)) {}
512 basic_string(xtd::char16 character, xtd::size count, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char16>(count, character), allocator) {}
516 basic_string(xtd::char32 character, xtd::size count) : basic_string(std::basic_string<xtd::char32>(count, character)) {}
521 basic_string(xtd::char32 character, xtd::size count, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char32>(count, character), allocator) {}
525 basic_string(xtd::char8 character, xtd::size count) : basic_string(std::basic_string<xtd::char8>(count, character)) {}
530 basic_string(xtd::char8 character, xtd::size count, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char8>(count, character), allocator) {}
534 basic_string(xtd::wchar character, xtd::size count) : basic_string(std::basic_string<xtd::wchar>(count, character)) {}
539 basic_string(xtd::wchar character, xtd::size count, const allocator_type & allocator) : basic_string(std::basic_string<xtd::wchar>(count, character), allocator) {}
540
543 basic_string(const char* str) { // Can't be explicit by design.
545 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
546 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
547 }
550 basic_string(const xtd::char16 * str) { // Can't be explicit by design.
552 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
553 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
554 }
557 basic_string(const xtd::char32 * str) { // Can't be explicit by design.
559 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
560 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
561 }
564 basic_string(const xtd::char8 * str) { // Can't be explicit by design.
566 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
567 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
568 }
571 basic_string(const xtd::wchar * str) { // Can't be explicit by design.
573 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
574 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
575 }
576
580 basic_string(const char* str, const allocator_type & allocator) {
582 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, allocator);
583 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str), allocator);
584 }
588 basic_string(const xtd::char16 * str, const allocator_type & allocator) {
590 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, allocator);
591 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str), allocator);
592 }
596 basic_string(const xtd::char32 * str, const allocator_type & allocator) {
598 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, allocator);
599 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str), allocator);
600 }
604 basic_string(const xtd::char8 * str, const allocator_type & allocator) {
606 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, allocator);
607 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str), allocator);
608 }
612 basic_string(const xtd::wchar * str, const allocator_type & allocator) : chars_(allocator) {
614 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
615 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
616 }
617
620 basic_string(const char* str, xtd::size count) {
622 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count);
623 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count));
624 }
629 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count);
630 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count));
631 }
636 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count);
637 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count));
638 }
641 basic_string(const xtd::char8 * str, xtd::size count) {
643 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count);
644 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count));
645 }
648 basic_string(const xtd::wchar * str, xtd::size count) {
650 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count);
651 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
652 }
653
658 basic_string(const char* str, xtd::size count, const allocator_type & allocator) {
660 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count, allocator);
661 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count), allocator);
662 }
667 basic_string(const xtd::char16 * str, xtd::size count, const allocator_type & allocator) : chars_(allocator) {
669 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count, allocator);
670 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count), allocator);
671 }
676 basic_string(const xtd::char32 * str, xtd::size count, const allocator_type & allocator) : chars_(allocator) {
678 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count, allocator);
679 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count), allocator);
680 }
685 basic_string(const xtd::char8 * str, xtd::size count, const allocator_type & allocator) : chars_(allocator) {
687 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count, allocator);
688 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count), allocator);
689 }
694 basic_string(const xtd::wchar * str, xtd::size count, const allocator_type & allocator) : chars_(allocator) {
696 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count, allocator);
697 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count), allocator);
698 }
699
702 basic_string(const std::basic_string<char>& str) noexcept { // Can't be explicit by design.
703 if constexpr(std::is_same_v<char, char_t>) chars_ = str;
704 else chars_ = __xtd_convert_to_string<value_type>(str);
705 }
708 basic_string(const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
709 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str;
710 else chars_ = __xtd_convert_to_string<value_type>(str);
711 }
714 basic_string(const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
715 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str;
716 else chars_ = __xtd_convert_to_string<value_type>(str);
717 }
720 basic_string(const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
721 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str;
722 else chars_ = __xtd_convert_to_string<value_type>(str);
723 }
726 basic_string(const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
727 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str;
728 else chars_ = __xtd_convert_to_string<value_type>(str);
729 }
730
734 basic_string(const std::basic_string<char>& str, const allocator_type & allocator) noexcept {
735 if constexpr(std::is_same_v<char, char_t>) chars_ = base_type(str, allocator);
736 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
737 }
741 basic_string(const std::basic_string<xtd::char16>& str, const allocator_type & allocator) noexcept {
742 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str, allocator);
743 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
744 }
748 basic_string(const std::basic_string<xtd::char32>& str, const allocator_type & allocator) noexcept {
749 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str, allocator);
750 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
751 }
755 basic_string(const std::basic_string<xtd::char8>& str, const allocator_type & allocator) noexcept {
756 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str, allocator);
757 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
758 }
762 basic_string(const std::basic_string<xtd::wchar>& str, const allocator_type & allocator) noexcept {
763 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str, allocator);
764 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
765 }
766
770 template<class input_iterator_t>
771 basic_string(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
776 template<class input_iterator_t>
777 basic_string(input_iterator_t first, input_iterator_t last, const allocator_type & allocator) : chars_(first, last, allocator) {}
778
782 template<class string_view_like_t>
783 explicit constexpr basic_string(const string_view_like_t& string_view) : chars_(string_view) {}
787 template<class string_view_like_t>
788 explicit constexpr basic_string(const string_view_like_t& string_view, const allocator_type & allocator) : chars_(string_view, allocator) {}
794 template<class string_view_like_t>
795 constexpr basic_string(const string_view_like_t& string_view, size_type index, size_type count) : chars_(string_view, index, count) {}
801 template<class string_view_like_t>
802 constexpr basic_string(const string_view_like_t& string_view, size_type index, size_type count, const allocator_type & allocator) : chars_(string_view, index, count, allocator) {}
803
806 basic_string(std::initializer_list<char> il) : basic_string(std::basic_string<char>(il)) {}
809 basic_string(std::initializer_list<xtd::char16> il) : basic_string(std::basic_string<xtd::char16>(il)) {}
812 basic_string(std::initializer_list<xtd::char32> il) : basic_string(std::basic_string<xtd::char32>(il)) {}
815 basic_string(std::initializer_list<xtd::char8> il) : basic_string(std::basic_string<xtd::char8>(il)) {}
818 basic_string(std::initializer_list<xtd::wchar> il) : basic_string(std::basic_string<xtd::wchar>(il)) {}
819
823 basic_string(std::initializer_list<char> il, const allocator_type & allocator) : basic_string(std::basic_string<char>(il), allocator) {}
827 basic_string(std::initializer_list<xtd::char16> il, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char16>(il), allocator) {}
831 basic_string(std::initializer_list<xtd::char32> il, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char32>(il), allocator) {}
835 basic_string(std::initializer_list<xtd::char8> il, const allocator_type & allocator) : basic_string(std::basic_string<xtd::char8>(il), allocator) {}
839 basic_string(std::initializer_list<xtd::wchar> il, const allocator_type & allocator) : basic_string(std::basic_string<xtd::wchar>(il), allocator) {}
841
843
853 const_pointer c_str() const noexcept {return chars_.c_str();}
856 const base_type & chars() const noexcept {return chars_;}
857
860 base_type & chars() noexcept {return chars_;}
861
865 virtual size_type count() const noexcept {return chars_.size();}
866
874 const_pointer data() const noexcept {return chars_.data();}
875
878 virtual bool empty() const noexcept {return length() == 0;}
879
883 virtual size_type length() const noexcept {return chars_.size();}
884
888 virtual size_type size() const noexcept {return chars_.size();}
890
892
912 int32 compare(const basic_string & str) const {return chars_.compare(str);}
934 int32 compare(size_type pos1, size_type count1, const basic_string & str) const {return chars_.compare(pos1, count1, str);}
958 int32 compare(size_type pos1, size_type count1, const basic_string & str, size_type pos2) const {return chars_.compare(pos1, count1, str, pos2);}
983 int32 compare(size_type pos1, size_type count1, const basic_string & str, size_type pos2, size_type count2) const {return chars_.compare(pos1, count1, str, pos2, count2);}
1002 int32 compare(const_pointer s) const {return chars_.compare(s);}
1024 int32 compare(size_type pos1, size_type count1, const_pointer s) const {return chars_.compare(pos1, count1, s);}
1047 int32 compare(size_type pos1, size_type count1, const_pointer s, size_type count2) const {return chars_.compare(pos1, count1, s, count2);}
1048
1058 int32 compare_to(const object & value) const {
1060 return compare_to(static_cast<const basic_string&>(value));
1061 }
1062
1070 int32 compare_to(const basic_string & value) const noexcept override {return chars_.compare(value.chars_);}
1071
1075 virtual bool contains(value_type value) const noexcept {return find(value) != npos;}
1079 virtual bool contains(const basic_string & value) const noexcept {return find(value) != npos;}
1080
1084 bool equals(const object & obj) const noexcept override {return dynamic_cast<const basic_string*>(&obj) && equals(static_cast<const basic_string&>(obj));}
1089 bool equals(const basic_string & value) const noexcept override {return equals(value, false);}
1095 bool equals(const basic_string & value, bool ignore_case) const noexcept {
1096 if (ignore_case) return to_upper().chars_ == value.to_upper().chars_;
1097 return chars_ == value.chars_;
1098 }
1099
1103 bool ends_with(value_type value) const noexcept {return ends_with(value, false);}
1108 bool ends_with(value_type value, bool ignore_case) const noexcept {
1109 if (ignore_case) return to_lower().rfind(static_cast<value_type>(tolower(value))) == length() - 1;
1110 return chars_.rfind(value) == length() - 1;
1111 }
1112
1115 bool ends_with(const basic_string & value) const noexcept {return ends_with(value, xtd::string_comparison::ordinal);}
1120 bool ends_with(const basic_string & value, bool ignore_case) const noexcept {return ends_with(value, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
1125 bool ends_with(const basic_string & value, xtd::string_comparison comparison_type) const noexcept {
1126 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.rfind(value.to_lower()) + value.to_lower().length() == length();
1127 return chars_.rfind(value) + value.length() == length();
1128 }
1129
1133 size_type find(const basic_string & str) const {return chars_.find(str);}
1139 size_type find(const basic_string & str, size_type pos) const {return chars_.find(str, pos);}
1147 size_type find(const_pointer s, size_type pos, size_type count) const {return chars_.find(s, pos, count);}
1153 size_type find(const_pointer s) const {return chars_.find(s);}
1160 size_type find(const_pointer s, size_type pos) const {return chars_.find(s, pos);}
1165 size_type find(value_type ch) const {return chars_.find(ch);}
1171 size_type find(value_type ch, size_type pos) const {return chars_.find(ch, pos);}
1172
1177 size_type find_first_of(const basic_string & str) const {return chars_.find_first_of(str);}
1183 size_type find_first_of(const basic_string & str, size_type pos) const {return chars_.find_first_of(str, pos);}
1191 size_type find_first_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_first_of(s, pos, count);}
1197 size_type find_first_of(const_pointer s) const {return chars_.find_first_of(s);}
1204 size_type find_first_of(const_pointer s, size_type pos) const {return chars_.find_first_of(s, pos);}
1209 size_type find_first_of(char_t ch) const {return chars_.find_first_of(ch);}
1215 size_type find_first_of(char_t ch, size_type pos) const {return chars_.find_first_of(ch, pos);}
1216
1221 size_type find_first_not_of(const basic_string & str) const {return chars_.find_first_not_of(str);}
1227 size_type find_first_not_of(const basic_string & str, size_type pos) const {return chars_.find_first_not_of(str, pos);}
1235 size_type find_first_not_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_first_not_of(s, pos, count);}
1241 size_type find_first_not_of(const_pointer s) const {return chars_.find_first_not_of(s);}
1248 size_type find_first_not_of(const_pointer s, size_type pos) const {return chars_.find_first_not_of(s, pos);}
1253 size_type find_first_not_of(char_t ch) const {return chars_.find_first_not_of(ch);}
1259 size_type find_first_not_of(char_t ch, size_type pos) const {return chars_.find_first_not_of(ch, pos);}
1260
1265 size_type find_last_of(const basic_string & str) const {return chars_.find_last_of(str);}
1271 size_type find_last_of(const basic_string & str, size_type pos) const {return chars_.find_last_of(str, pos);}
1279 size_type find_last_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_last_of(s, pos, count);}
1285 size_type find_last_of(const_pointer s) const {return chars_.find_last_of(s);}
1292 size_type find_last_of(const_pointer s, size_type pos) const {return chars_.find_last_of(s, pos);}
1297 size_type find_last_of(char_t ch) const {return chars_.find_last_of(ch);}
1303 size_type find_last_of(char_t ch, size_type pos) const {return chars_.find_last_of(ch, pos);}
1304
1309 size_type find_last_not_of(const basic_string & str) const {return chars_.find_last_not_of(str);}
1315 size_type find_last_not_of(const basic_string & str, size_type pos) const {return chars_.find_last_not_of(str, pos);}
1323 size_type find_last_not_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_last_not_of(s, pos, count);}
1329 size_type find_last_not_of(const_pointer s) const {return chars_.find_last_not_of(s);}
1336 size_type find_last_not_of(const_pointer s, size_type pos) const {return chars_.find_last_not_of(s, pos);}
1341 size_type find_last_not_of(char_t ch) const {return chars_.find_last_not_of(ch);}
1347 size_type find_last_not_of(char_t ch, size_type pos) const {return chars_.find_last_not_of(ch, pos);}
1348
1351 allocator_type get_allocator() const {return chars_.get_allocator();}
1352
1355 virtual const base_type & get_base_type() const noexcept {return chars_;}
1356
1359 xtd::size get_hash_code() const noexcept override {return xtd::hash_code::combine(chars_);}
1360
1361 enumerator_type get_enumerator() const noexcept override {
1362 class basic_string_enumerator : public xtd::collections::generic::ienumerator<value_type> {
1363 public:
1364 explicit basic_string_enumerator(const basic_string & chars) : chars_(chars) {}
1365
1366 const value_type & current() const override {return chars_[index_];}
1367
1368 bool move_next() override {return ++index_ < chars_.length();}
1369
1370 void reset() override {index_ = basic_string::npos;}
1371
1372 protected:
1373 const basic_string& chars_;
1374 xtd::size index_ = basic_string::npos;
1375 };
1377 }
1378
1382 xtd::size index_of(const basic_string & value) const noexcept {return index_of(value, 0, length());}
1387 xtd::size index_of(const basic_string & value, xtd::size start_index) const {return index_of(value, start_index, length() - start_index);}
1394 xtd::size index_of(const basic_string & value, xtd::size start_index, xtd::size count) const {
1396 auto result = find(value, start_index);
1397 return result > start_index + count ? npos : result;
1398 }
1399
1402 xtd::size index_of(value_type value) const noexcept {return index_of(value, 0, length());}
1407 xtd::size index_of(value_type value, xtd::size start_index) const {return index_of(value, start_index, length() - start_index);}
1416 auto result = find(value, start_index);
1417 return result > start_index + count ? npos : result;
1418 }
1419
1423 xtd::size index_of_any(const xtd::array<value_type>& values) const noexcept;
1429 xtd::size index_of_any(const xtd::array<value_type>& values, xtd::size start_index) const;
1438 xtd::size index_of_any(const std::initializer_list<value_type>& values) const noexcept;
1439 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
1440 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
1442
1449 basic_string insert(xtd::size start_index, const basic_string & value) const {
1451 auto result = self_;
1452 result.chars_.insert(start_index, value);
1453 return result;
1454 }
1455
1459 xtd::size last_index_of(const basic_string & value) const noexcept {return last_index_of(value, 0, length());}
1465 xtd::size last_index_of(const basic_string & value, xtd::size start_index) const {return last_index_of(value, start_index, length() - start_index);}
1472 xtd::size last_index_of(const basic_string & value, xtd::size start_index, xtd::size count) const {
1474 auto result = chars_.rfind(value, start_index + count - value.length());
1475 return result < start_index ? npos : result;
1476 }
1477
1480 xtd::size last_index_of(value_type value) const noexcept {return last_index_of(value, 0, length());}
1486 xtd::size last_index_of(value_type value, xtd::size start_index) const {return last_index_of(value, start_index, length() - start_index);}
1496 auto result = chars_.rfind(value, start_index + count - 1);
1497 return result < start_index ? npos : result;
1498 }
1499
1516 xtd::size last_index_of_any(const std::initializer_list<value_type>& values) const noexcept;
1517 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
1518 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
1520
1526 basic_string pad_left(xtd::size total_width) const noexcept {return pad_left(total_width, ' ');}
1533 basic_string pad_left(xtd::size total_width, char32 padding_char) const noexcept {return total_width < length() ? self_ : basic_string(total_width - length(), padding_char) + self_;}
1534
1540 basic_string pad_right(xtd::size total_width) const noexcept {return pad_right(total_width, ' ');}
1547 basic_string pad_right(xtd::size total_width, char32 padding_char) const noexcept {return total_width < length() ? self_ : self_ + basic_string(total_width - length(), padding_char);}
1548
1553 basic_string quoted() const {return quoted('"', '\\');}
1558 basic_string quoted(value_type delimiter) const {return quoted(delimiter, '\\');}
1565 std::wstringstream ss;
1566 if constexpr(std::is_same_v<xtd::wchar, value_type>) ss << std::quoted(chars_, delimiter, escape);
1567 else ss << std::quoted(__xtd_convert_to_string<xtd::wchar>(chars_), static_cast<xtd::wchar>(delimiter), static_cast<xtd::wchar>(escape));
1568 return ss.str();
1569 }
1570
1574 basic_string remove(xtd::size start_index) const {return remove(start_index, length() - start_index);}
1581 auto result = self_;
1582 result.chars_.erase(start_index, count);
1583 return result;
1584 }
1585
1590 basic_string replace(value_type old_char, value_type new_char) const noexcept {return replace(string(1, old_char), string(1, new_char));}
1596 basic_string replace(const basic_string & old_string, const basic_string & new_string) const noexcept {
1597 auto result = self_;
1598 auto old_size = old_string.length();
1599 auto new_size = new_string.length();
1600 auto index = xtd::size {0};
1601 while (true) {
1602 index = result.find(old_string, index);
1603 if (index == npos) break;
1604 if (old_size == new_size) result.chars_.replace(index, old_size, new_string);
1605 else {
1606 result.chars_.erase(index, old_string.length());
1607 result.chars_.insert(index, new_string);
1608 }
1609 index += new_string.length();
1610 }
1611 return result;
1612 }
1613
1617 size_type rfind(const basic_string & str) const {return chars_.rfind(str);}
1623 size_type rfind(const basic_string & str, size_type pos) const {return chars_.rfind(str, pos);}
1631 size_type rfind(const_pointer s, size_type pos, size_type count) const {return chars_.rfind(s, pos, count);}
1637 size_type rfind(const_pointer s) const {return chars_.rfind(s);}
1644 size_type rfind(const_pointer s, size_type pos) const {return chars_.rfind(s, pos);}
1649 size_type rfind(value_type ch) const {return chars_.rfind(ch);}
1655 size_type rfind(value_type ch, size_type pos) const {return chars_.rfind(ch, pos);}
1656
1661 xtd::array<basic_string> split() const noexcept;
1667 xtd::array<basic_string> split(value_type separator) const noexcept;
1684 xtd::array<basic_string> split(value_type separator, xtd::string_split_options options) const noexcept;
1693 xtd::array<basic_string> split(value_type separator, xtd::size count) const noexcept;
1705 xtd::array<basic_string> split(value_type separator, xtd::size count, xtd::string_split_options options) const noexcept;
1711 xtd::array<basic_string> split(const xtd::array<value_type>& separators) const noexcept;
1728 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::string_split_options options) const noexcept;
1737 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count) const noexcept;
1749 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count, xtd::string_split_options options) const noexcept;
1750
1755 bool starts_with(value_type value) const noexcept {return starts_with(value, false);}
1761 bool starts_with(value_type value, bool ignore_case) const noexcept {
1762 if (ignore_case) return to_lower().find(static_cast<value_type>(tolower(value))) == 0;
1763 return find(value) == 0;
1764 }
1769 bool starts_with(const basic_string & value) const noexcept {return starts_with(value, string_comparison::ordinal);}
1775 bool starts_with(const basic_string & value, bool ignore_case) const noexcept {return starts_with(value, ignore_case ? string_comparison::ordinal_ignore_case : string_comparison::ordinal);}
1780 bool starts_with(const basic_string & value, xtd::string_comparison comparison_type) const noexcept {
1781 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().find(value.to_lower()) == 0;
1782 return find(value) == 0;
1783 }
1784
1789 basic_string substr() const {return chars_.substr();}
1795 basic_string substr(size_type pos) const {
1797 return chars_.substr(pos);
1798 }
1805 basic_string substr(size_type pos, size_type count) const {
1807 return chars_.substr(pos, count);
1808 }
1809
1815 basic_string substring(xtd::size start_index) const {
1817 return substr(start_index);
1818 }
1824 basic_string substring(xtd::size start_index, xtd::size length) const {
1825 if (start_index > self_.length() || start_index + length > self_.length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1826 return substr(start_index, length);
1827 }
1828
1831 xtd::array<value_type> to_array() const noexcept;
1835 xtd::array<value_type> to_array(xtd::size start_index) const;
1840 xtd::array<value_type> to_array(xtd::size start_index, xtd::size length) const;
1841
1844 xtd::array<value_type> to_char_array() const noexcept;
1849 xtd::array<value_type> to_char_array(xtd::size start_index, xtd::size length) const;
1850
1853 basic_string to_lower() const noexcept {
1854 auto result = basic_string::empty_string;
1855 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::tolower(c));});
1856 return result;
1857 }
1858
1862 basic_string<char> to_string() const noexcept override {
1863 if constexpr(std::is_same_v<char, char_t>) return chars_;
1864 else return __xtd_convert_to_string<char>(chars_);
1865 }
1866
1869 basic_string to_title_case() const noexcept;
1870
1873 basic_string<xtd::char16> to_u16string() const noexcept {
1874 if constexpr(std::is_same_v<xtd::char16, char_t>) return chars_;
1875 else return __xtd_convert_to_string<xtd::char16>(chars_);
1876 }
1877
1880 basic_string<xtd::char32> to_u32string() const noexcept {
1881 if constexpr(std::is_same_v<xtd::char32, char_t>) return chars_;
1882 else return __xtd_convert_to_string<xtd::char32>(chars_);
1883 }
1884
1887 basic_string<xtd::char8> to_u8string() const noexcept {
1888 if constexpr(std::is_same_v<xtd::char8, char_t>) return chars_;
1889 else return __xtd_convert_to_string<xtd::char8>(chars_);
1890 }
1891
1894 basic_string to_upper() const noexcept {
1895 auto result = basic_string::empty_string;
1896 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::toupper(c));});
1897 return result;
1898 }
1899
1902 basic_string<xtd::wchar> to_wstring() const noexcept {
1903 if constexpr(std::is_same_v<xtd::wchar, char_t>) return chars_;
1904 else return __xtd_convert_to_string<xtd::wchar>(chars_);
1905 }
1906
1911 basic_string trim() const noexcept {return trim(default_trim_chars);}
1916 basic_string trim(value_type trim_char) const noexcept;
1921 basic_string trim(const xtd::array<value_type>& trim_chars) const noexcept;
1922
1927 basic_string trim_end() const noexcept {return trim_end(default_trim_chars);}
1932 basic_string trim_end(value_type trim_char) const noexcept;
1937 basic_string trim_end(const xtd::array<value_type>& trim_chars) const noexcept;
1938
1943 basic_string trim_start() const noexcept {return trim_start(default_trim_chars);}
1948 basic_string trim_start(value_type trim_char) const noexcept;
1953 basic_string trim_start(const xtd::array<value_type>& trim_chars) const noexcept;
1955
1957
1968 static int32 compare(const basic_string & str_a, const basic_string & str_b) noexcept {return compare(str_a, str_b, false);}
1979 static int32 compare(const basic_string & str_a, const basic_string & str_b, bool ignore_case) noexcept {return compare(str_a, str_b, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
1990 static int32 compare(const basic_string & str_a, const basic_string & str_b, xtd::string_comparison comparison_type) noexcept {return comparison_type == xtd::string_comparison::ordinal_ignore_case ? str_a.to_lower().compare(str_b.to_lower()) : str_a.compare(str_b);}
2003 static int32 compare(const basic_string & str_a, xtd::size index_a, const basic_string & str_b, xtd::size index_b, xtd::size length) {return compare(str_a, index_a, str_b, index_b, length, false);}
2017 static int32 compare(const basic_string & str_a, xtd::size index_a, const basic_string & str_b, xtd::size index_b, xtd::size length, bool ignore_case) {return compare(str_a, index_a, str_b, index_b, length, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
2031 static int32 compare(const basic_string & str_a, xtd::size index_a, const basic_string & str_b, xtd::size index_b, xtd::size length, xtd::string_comparison comparison_type) {return comparison_type == xtd::string_comparison::ordinal_ignore_case ? str_a.substr(index_a, length).to_lower().compare(str_b.substr(index_b, length).to_lower()) : str_a.substr(index_a, length).compare(str_b.substr(index_b, length));}
2032
2039 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 {return str_a + str_b + str_c + str_d;}
2046 template<class object_a_t, class object_b_t, class object_c_t, class object_d_t>
2047 static basic_string concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c, object_d_t obj_d) noexcept {return format("{}{}{}{}", obj_a, obj_b, obj_c, obj_d);}
2053 static basic_string concat(const basic_string & str_a, const basic_string & str_b, const basic_string & str_c) noexcept {return str_a + str_b + str_c;}
2059 template<class object_a_t, class object_b_t, class object_c_t>
2060 static basic_string concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept {return format("{}{}{}", obj_a, obj_b, obj_c);}
2065 static basic_string concat(const basic_string & str_a, const basic_string & str_b) noexcept {return str_a + str_b;}
2070 template<class object_a_t, class object_b_t>
2071 static basic_string concat(object_a_t obj_a, object_b_t obj_b) noexcept {return format("{}{}", obj_a, obj_b);}
2075 static basic_string concat(const xtd::array<basic_string>& values) noexcept;
2077 static basic_string concat(const xtd::array<const_pointer>& values) noexcept;
2078 template<class other_char_t>
2079 static basic_string concat(const xtd::array<const other_char_t*>& values) noexcept;
2080 static basic_string concat(const std::initializer_list<basic_string>& values) noexcept {
2081 auto result = basic_string::empty_string;
2082 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
2083 return result;
2084 }
2085 static basic_string concat(const std::initializer_list<const_pointer>& values) noexcept {
2086 auto result = basic_string::empty_string;
2087 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
2088 return result;
2089 }
2090 template<class other_char_t>
2091 static basic_string concat(const std::initializer_list<const other_char_t*>& values) noexcept {
2092 auto result = basic_string::empty_string;
2093 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
2094 return result;
2095 }
2100 template<class object_t>
2101 static basic_string concat(const xtd::array<object_t>& args) noexcept;
2103 template<class object_t>
2104 static basic_string concat(const std::initializer_list<object_t>& args) noexcept {
2105 basic_string result;
2106 for (const auto& arg : args)
2107 result += format("{}", arg);
2108 return result;
2109 }
2114 template<class value_t>
2115 static basic_string concat(value_t value) noexcept {
2116 return format("{}", value);
2117 }
2118
2139 static basic_string demangle(const basic_string & name) {
2140 if constexpr(std::is_same_v<char, char_t>) return __xtd_demangle(name.chars());
2141 else return __xtd_demangle(__xtd_convert_to_string<char>(name.chars()));
2142 }
2143
2149 static bool equals(const basic_string & a, const basic_string & b) noexcept{return a.equals(b);}
2155 template<class char_a_t, class char_b_t>
2156 static bool equals(const char_a_t* a, const char_b_t* b) noexcept{return basic_string {a}.equals(basic_string {b});}
2157
2164 static bool equals(const basic_string & a, const basic_string & b, bool ignore_case) noexcept {return a.equals(b, ignore_case);}
2171 template<class char_a_t, class char_b_t>
2172 static bool equals(const char_a_t* a, const char_b_t* b, bool ignore_case) noexcept{return basic_string {a}.equals(basic_string {b}, ignore_case);}
2173
2180 template<class ...args_t>
2181 static basic_string format(const basic_string<char>& fmt, args_t&& ... args);
2182
2190 template<class ...args_t>
2191 static basic_string format(const std::locale & loc, const basic_string<char>& fmt, args_t&& ... args);
2192
2196 static bool is_empty(const xtd::basic_string<value_type, traits_type, allocator_type>& string) noexcept {return !string.length();}
2197
2204 template<class collection_t>
2205 static basic_string join(const basic_string separator, const collection_t& values) noexcept {
2206 xtd::size i = 0;
2207 basic_string result;
2208 for (const auto& item : values)
2209 result += format("{}{}", (i++ != 0 ? separator : basic_string {}), item);
2210 return result;
2211 }
2219 template<class collection_t>
2220 static basic_string join(const basic_string & separator, const collection_t& values, xtd::size index) {return join(separator, values, index, values.size() - index);}
2229 template<class collection_t>
2230 static basic_string join(const basic_string & separator, const collection_t& values, xtd::size index, xtd::size count) {
2231 if (index > values.size() || index + count > values.size()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
2232 xtd::size i = 0;
2233 basic_string result;
2234 for (const auto& item : values) {
2235 if (i >= index) result += format("{}{}", (i != index ? separator : basic_string {}), item);
2236 if (++i >= index + count) break;
2237 }
2238 return result;
2239 }
2240
2242 template<class value_t>
2243 static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values) noexcept;
2244 template<class value_t>
2245 static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values, xtd::size index);
2246 template<class value_t>
2247 static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values, xtd::size index, xtd::size count);
2249
2253 template<class value_t>
2254 static value_t parse(const basic_string & str) {
2255 if constexpr(std::is_same_v<char, char_t>) return xtd::parse<value_t>(str.chars());
2256 else return xtd::parse<value_t>(__xtd_convert_to_string<char>(str.chars()));
2257 }
2258
2318 template<class ...args_t>
2319 static basic_string sprintf(const basic_string & fmt, args_t&& ... args) noexcept {return __sprintf(fmt.chars().c_str(), convert_param(std::forward<args_t>(args)) ...);}
2320
2325 template<class value_t>
2326 static bool try_parse(const basic_string & str, value_t& value) noexcept {
2327 try {
2328 value = parse<value_t>(str);
2329 return true;
2330 } catch (...) {
2331 return false;
2332 }
2333 }
2335
2337
2343 const_reference operator [](xtd::size index) const {
2345 return chars_[index == epos ? length() - 1 : index];
2346 }
2347
2350 operator const base_type & () const noexcept {return chars_;}
2351
2355 basic_string& operator =(const basic_string<char>& str) noexcept {
2356 if constexpr(std::is_same<char_t, char>::value) chars_ = str.chars_;
2357 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2358 return self_;
2359 }
2363 basic_string& operator =(const basic_string<xtd::char16>& str) noexcept {
2364 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str.chars_;
2365 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2366 return self_;
2367 }
2371 basic_string& operator =(const basic_string<xtd::char32>& str) noexcept {
2372 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str.chars_;
2373 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2374 return self_;
2375 }
2379 basic_string& operator =(const basic_string<xtd::char8>& str) noexcept {
2380 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str.chars_;
2381 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2382 return self_;
2383 }
2387 basic_string& operator =(const basic_string<xtd::wchar>& str) noexcept {
2388 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str.chars_;
2389 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2390 return self_;
2391 }
2392
2396 basic_string& operator =(basic_string<char>&& str) noexcept {
2397 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str.chars_);
2398 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2399 return self_;
2400 }
2404 basic_string& operator =(basic_string<xtd::char16>&& str) noexcept {
2405 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str.chars_);
2406 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2407 return self_;
2408 }
2412 basic_string& operator =(basic_string<xtd::char32>&& str) noexcept {
2413 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str.chars_);
2414 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2415 return self_;
2416 }
2420 basic_string& operator =(basic_string<xtd::char8>&& str) noexcept {
2421 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str.chars_);
2422 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2423 return self_;
2424 }
2428 basic_string& operator =(basic_string<xtd::wchar>&& str) noexcept {
2429 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str.chars_);
2430 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2431 return self_;
2432 }
2433
2437 basic_string& operator =(const std::basic_string<char>& str) noexcept {
2438 if constexpr(std::is_same<char_t, char>::value) chars_ = str;
2439 else chars_ = __xtd_convert_to_string<value_type>(str);
2440 return self_;
2441 }
2445 basic_string& operator =(const std::basic_string<xtd::char16>& str) noexcept {
2446 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str;
2447 else chars_ = __xtd_convert_to_string<value_type>(str);
2448 return self_;
2449 }
2453 basic_string& operator =(const std::basic_string<xtd::char32>& str) noexcept {
2454 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str;
2455 else chars_ = __xtd_convert_to_string<value_type>(str);
2456 return self_;
2457 }
2461 basic_string& operator =(const std::basic_string<xtd::char8>& str) noexcept {
2462 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str;
2463 else chars_ = __xtd_convert_to_string<value_type>(str);
2464 return self_;
2465 }
2469 basic_string& operator =(const std::basic_string<xtd::wchar>& str) noexcept {
2470 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str;
2471 else chars_ = __xtd_convert_to_string<value_type>(str);
2472 return self_;
2473 }
2474
2478 basic_string& operator =(std::basic_string<char>&& str) noexcept {
2479 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str);
2480 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2481 return self_;
2482 }
2486 basic_string& operator =(std::basic_string<xtd::char16>&& str) noexcept {
2487 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str);
2488 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2489 return self_;
2490 }
2494 basic_string& operator =(std::basic_string<xtd::char32>&& str) noexcept {
2495 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str);
2496 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2497 return self_;
2498 }
2502 basic_string& operator =(std::basic_string<xtd::char8>&& str) noexcept {
2503 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str);
2504 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2505 return self_;
2506 }
2510 basic_string& operator =(std::basic_string<xtd::wchar>&& str) noexcept {
2511 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str);
2512 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2513 return self_;
2514 }
2515
2520 basic_string& operator =(const char* str) {
2522 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
2523 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
2524 return self_;
2525 }
2530 basic_string& operator =(const xtd::char16 * str) {
2532 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
2533 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
2534 return self_;
2535 }
2540 basic_string& operator =(const xtd::char32 * str) {
2542 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
2543 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
2544 return self_;
2545 }
2550 basic_string& operator =(const xtd::char8 * str) {
2552 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
2553 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
2554 return self_;
2555 }
2560 basic_string& operator =(const xtd::wchar * str) {
2562 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
2563 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
2564 return self_;
2565 }
2566
2570 basic_string& operator =(char character) {
2571 self_ = basic_string(1, character);
2572 return self_;
2573 }
2577 basic_string& operator =(xtd::char16 character) {
2578 self_ = basic_string(1, character);
2579 return self_;
2580 }
2584 basic_string& operator =(xtd::char32 character) {
2585 self_ = basic_string(1, character);
2586 return self_;
2587 }
2591 basic_string& operator =(xtd::char8 character) {
2592 self_ = basic_string(1, character);
2593 return self_;
2594 }
2598 basic_string& operator =(xtd::wchar character) {
2599 self_ = basic_string(1, character);
2600 return self_;
2601 }
2602
2606 basic_string& operator =(const std::initializer_list<char>& il) {
2607 self_ = basic_string(il);
2608 return self_;
2609 }
2613 basic_string& operator =(const std::initializer_list<xtd::char16>& il) {
2614 self_ = basic_string(il);
2615 return self_;
2616 }
2620 basic_string& operator =(const std::initializer_list<xtd::char32>& il) {
2621 self_ = basic_string(il);
2622 return self_;
2623 }
2627 basic_string& operator =(const std::initializer_list<xtd::char8>& il) {
2628 self_ = basic_string(il);
2629 return self_;
2630 }
2634 basic_string& operator =(const std::initializer_list<xtd::wchar>& il) {
2635 self_ = basic_string(il);
2636 return self_;
2637 }
2638
2642 basic_string & operator +=(const basic_string<char>& str) {
2643 if constexpr(std::is_same_v<char, char_t>) chars_ += str.chars_;
2644 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2645 return self_;
2646 }
2650 basic_string & operator +=(const basic_string<xtd::char16>& str) {
2651 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str.chars_;
2652 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2653 return self_;
2654 }
2658 basic_string & operator +=(const basic_string<xtd::char32>& str) {
2659 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str.chars_;
2660 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2661 return self_;
2662 }
2666 basic_string & operator +=(const basic_string<xtd::char8>& str) {
2667 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str.chars_;
2668 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2669 return self_;
2670 }
2674 basic_string & operator +=(const basic_string<xtd::wchar>& str) {
2675 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str.chars_;
2676 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2677 return self_;
2678 }
2679
2683 basic_string & operator +=(basic_string<char>&& str) {
2684 if constexpr(std::is_same_v<char, char_t>) chars_ += std::move(str.chars_);
2685 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2686 return self_;
2687 }
2691 basic_string & operator +=(basic_string<xtd::char16>&& str) {
2692 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += std::move(str.chars_);
2693 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2694 return self_;
2695 }
2699 basic_string & operator +=(basic_string<xtd::char32>&& str) {
2700 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += std::move(str.chars_);
2701 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2702 return self_;
2703 }
2707 basic_string & operator +=(basic_string<xtd::char8>&& str) {
2708 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += std::move(str.chars_);
2709 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2710 return self_;
2711 }
2715 basic_string & operator +=(basic_string<xtd::wchar>&& str) {
2716 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += std::move(str.chars_);
2717 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2718 return self_;
2719 }
2720
2724 basic_string & operator +=(const std::basic_string<char>& str) {
2725 if constexpr(std::is_same_v<char, char_t>) chars_ += str;
2726 else chars_ += __xtd_convert_to_string<value_type>(str);
2727 return self_;
2728 }
2732 basic_string & operator +=(const std::basic_string<xtd::char16>& str) {
2733 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str;
2734 else chars_ += __xtd_convert_to_string<value_type>(str);
2735 return self_;
2736 }
2740 basic_string & operator +=(const std::basic_string<xtd::char32>& str) {
2741 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str;
2742 else chars_ += __xtd_convert_to_string<value_type>(str);
2743 return self_;
2744 }
2748 basic_string & operator +=(const std::basic_string<xtd::char8>& str) {
2749 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str;
2750 else chars_ += __xtd_convert_to_string<value_type>(str);
2751 return self_;
2752 }
2756 basic_string & operator +=(const std::basic_string<xtd::wchar>& str) {
2757 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str;
2758 else chars_ += __xtd_convert_to_string<value_type>(str);
2759 return self_;
2760 }
2761
2765 basic_string & operator +=(const char* str) {
2766 chars_ += basic_string(str).chars_;
2767 return self_;
2768 }
2772 basic_string & operator +=(const xtd::char16 * str) {
2773 chars_.append(basic_string(str).chars_); return self_;
2774 }
2778 basic_string & operator +=(const xtd::char32 * str) {
2779 chars_ += basic_string(str).chars_;
2780 return self_;
2781 }
2785 basic_string & operator +=(const xtd::char8 * str) {
2786 chars_ += basic_string(str).chars_;
2787 return self_;
2788 }
2792 basic_string & operator +=(const xtd::wchar * str) {
2793 chars_ += basic_string(str).chars_;
2794 return self_;
2795 }
2799 basic_string & operator +=(char ch) {
2800 chars_ += basic_string(1, ch).chars_;
2801 return self_;
2802 }
2806 basic_string & operator +=(xtd::char16 ch) {
2807 chars_ += basic_string(1, ch).chars_;
2808 return self_;
2809 }
2813 basic_string & operator +=(xtd::char32 ch) {
2814 chars_ += basic_string(1, ch).chars_;
2815 return self_;
2816 }
2820 basic_string & operator +=(xtd::char8 ch) {
2821 chars_ += basic_string(1, ch).chars_;
2822 return self_;
2823 }
2827 basic_string & operator +=(xtd::wchar ch) {
2828 chars_ += basic_string(1, ch).chars_;
2829 return self_;
2830 }
2831
2836 friend basic_string operator +(const basic_string & lhs, const basic_string<char>& rhs) {
2837 auto result = lhs;
2838 result += rhs;
2839 return result;
2840 }
2845 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::char16>& rhs) {
2846 auto result = lhs;
2847 result += rhs;
2848 return result;
2849 }
2854 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::char32>& rhs) {
2855 auto result = lhs;
2856 result += rhs;
2857 return result;
2858 }
2863 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::char8>& rhs) {
2864 auto result = lhs;
2865 result += rhs;
2866 return result;
2867 }
2872 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::wchar>& rhs) {
2873 auto result = lhs;
2874 result += rhs;
2875 return result;
2876 }
2877
2882 friend basic_string operator +(basic_string&& lhs, basic_string<char>&& rhs) {
2883 auto result = std::move(lhs);
2884 result += std::move(rhs);
2885 return result;
2886 }
2891 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::char16>&& rhs) {
2892 auto result = std::move(lhs);
2893 result += std::move(rhs);
2894 return result;
2895 }
2900 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::char32>&& rhs) {
2901 auto result = std::move(lhs);
2902 result += std::move(rhs);
2903 return result;
2904 }
2909 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::char8>&& rhs) {
2910 auto result = std::move(lhs);
2911 result += std::move(rhs);
2912 return result;
2913 }
2918 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::wchar>&& rhs) {
2919 auto result = std::move(lhs);
2920 result += std::move(rhs);
2921 return result;
2922 }
2923
2928 friend basic_string operator +(basic_string&& lhs, const basic_string<char>& rhs) {
2929 auto result = std::move(lhs);
2930 result += rhs;
2931 return result;
2932 }
2937 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::char16>& rhs) {
2938 auto result = std::move(lhs);
2939 result += rhs;
2940 return result;
2941 }
2946 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::char32>& rhs) {
2947 auto result = std::move(lhs);
2948 result += rhs;
2949 return result;
2950 }
2955 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::char8>& rhs) {
2956 auto result = std::move(lhs);
2957 result += rhs;
2958 return result;
2959 }
2964 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::wchar>& rhs) {
2965 auto result = std::move(lhs);
2966 result += rhs;
2967 return result;
2968 }
2969
2974 friend basic_string operator +(const basic_string & lhs, basic_string<char>&& rhs) {
2975 auto result = lhs;
2976 result += std::move(rhs);
2977 return result;
2978 }
2983 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::char16>&& rhs) {
2984 auto result = lhs;
2985 result += std::move(rhs);
2986 return result;
2987 }
2992 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::char32>&& rhs) {
2993 auto result = lhs;
2994 result += std::move(rhs);
2995 return result;
2996 }
3001 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::char8>&& rhs) {
3002 auto result = lhs;
3003 result += std::move(rhs);
3004 return result;
3005 }
3010 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::wchar>&& rhs) {
3011 auto result = lhs;
3012 result += std::move(rhs);
3013 return result;
3014 }
3015
3020 friend basic_string operator +(const basic_string & lhs, const std::basic_string<char>& rhs) {
3021 auto result = lhs;
3022 result += rhs;
3023 return result;
3024 }
3029 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char16>& rhs) {
3030 auto result = lhs;
3031 result += rhs;
3032 return result;
3033 }
3038 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char32>& rhs) {
3039 auto result = lhs;
3040 result += rhs;
3041 return result;
3042 }
3047 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char8>& rhs) {
3048 auto result = lhs;
3049 result += rhs;
3050 return result;
3051 }
3056 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::wchar>& rhs) {
3057 auto result = lhs;
3058 result += rhs;
3059 return result;
3060 }
3061
3066 friend basic_string operator +(const std::basic_string<char>& lhs, const basic_string & rhs) {
3067 auto result = lhs;
3068 if constexpr(std::is_same_v<char, char_t>) result += rhs.chars();
3069 else result += __xtd_convert_to_string<char>(rhs.chars());
3070 return result;
3071 }
3076 friend basic_string operator +(const std::basic_string<xtd::char16>& lhs, const basic_string & rhs) {
3077 auto result = lhs;
3078 if constexpr(std::is_same_v<xtd::char16, char_t>) result += rhs.chars();
3079 else result += __xtd_convert_to_string<xtd::char16>(rhs.chars());
3080 return result;
3081 }
3086 friend basic_string operator +(const std::basic_string<xtd::char32>& lhs, const basic_string & rhs) {
3087 auto result = lhs;
3088 if constexpr(std::is_same_v<xtd::char32, char_t>) result += rhs.chars();
3089 else result += __xtd_convert_to_string<xtd::char32>(rhs.chars());
3090 return result;
3091 }
3096 friend basic_string operator +(const std::basic_string<xtd::char8>& lhs, const basic_string & rhs) {
3097 auto result = lhs;
3098 if constexpr(std::is_same_v<xtd::char8, char_t>) result += rhs.chars();
3099 else result += __xtd_convert_to_string<xtd::char8>(rhs.chars());
3100 return result;
3101 }
3106 friend basic_string operator +(const std::basic_string<xtd::wchar>& lhs, const basic_string & rhs) {
3107 auto result = lhs;
3108 if constexpr(std::is_same_v<xtd::wchar, char_t>) result += rhs.chars();
3109 else result += __xtd_convert_to_string<xtd::wchar>(rhs.chars());
3110 return result;
3111 }
3112
3117 friend basic_string operator +(const basic_string & lhs, const char* rhs) {
3118 auto result = lhs;
3119 result += rhs;
3120 return result;
3121 }
3126 friend basic_string operator +(const basic_string & lhs, const xtd::char16 * rhs) {
3127 auto result = lhs;
3128 result += rhs;
3129 return result;
3130 }
3135 friend basic_string operator +(const basic_string & lhs, const xtd::char32 * rhs) {
3136 auto result = lhs;
3137 result += rhs;
3138 return result;
3139 }
3144 friend basic_string operator +(const basic_string & lhs, const xtd::char8 * rhs) {
3145 auto result = lhs;
3146 result += rhs;
3147 return result;
3148 }
3153 friend basic_string operator +(const basic_string & lhs, const xtd::wchar * rhs) {
3154 auto result = lhs;
3155 result += rhs;
3156 return result;
3157 }
3158
3163 friend basic_string operator +(basic_string&& lhs, const char* rhs) {
3164 auto result = std::move(lhs);
3165 result += rhs;
3166 return result;
3167 }
3172 friend basic_string operator +(basic_string&& lhs, const xtd::char16 * rhs) {
3173 auto result = std::move(lhs);
3174 result += rhs;
3175 return result;
3176 }
3181 friend basic_string operator +(basic_string&& lhs, const xtd::char32 * rhs) {
3182 auto result = std::move(lhs);
3183 result += rhs;
3184 return result;
3185 }
3190 friend basic_string operator +(basic_string&& lhs, const xtd::char8 * rhs) {
3191 auto result = std::move(lhs);
3192 result += rhs;
3193 return result;
3194 }
3199 friend basic_string operator +(basic_string&& lhs, const xtd::wchar * rhs) {
3200 auto result = std::move(lhs);
3201 result += rhs;
3202 return result;
3203 }
3204
3209 friend basic_string operator +(const char* lhs, const basic_string & rhs) {
3210 auto result = basic_string(lhs);
3211 result += rhs;
3212 return result;
3213 }
3218 friend basic_string operator +(const xtd::char16 * lhs, const basic_string & rhs) {
3219 auto result = basic_string(lhs);
3220 result += rhs;
3221 return result;
3222 }
3227 friend basic_string operator +(const xtd::char32 * lhs, const basic_string & rhs) {
3228 auto result = basic_string(lhs);
3229 result += rhs;
3230 return result;
3231 }
3236 friend basic_string operator +(const xtd::char8 * lhs, const basic_string & rhs) {
3237 auto result = basic_string(lhs);
3238 result += rhs;
3239 return result;
3240 }
3245 friend basic_string operator +(const xtd::wchar * lhs, const basic_string & rhs) {
3246 auto result = basic_string(lhs);
3247 result += rhs;
3248 return result;
3249 }
3250
3255 friend basic_string operator +(const char* lhs, basic_string&& rhs) {
3256 auto result = basic_string(lhs);
3257 result += std::move(rhs);
3258 return result;
3259 }
3264 friend basic_string operator +(const xtd::char16 * lhs, basic_string&& rhs) {
3265 auto result = basic_string(lhs);
3266 result += std::move(rhs);
3267 return result;
3268 }
3273 friend basic_string operator +(const xtd::char32 * lhs, basic_string&& rhs) {
3274 auto result = basic_string(lhs);
3275 result += std::move(rhs);
3276 return result;
3277 }
3282 friend basic_string operator +(const xtd::char8 * lhs, basic_string&& rhs) {
3283 auto result = basic_string(lhs);
3284 result += std::move(rhs);
3285 return result;
3286 }
3291 friend basic_string operator +(const xtd::wchar * lhs, basic_string&& rhs) {
3292 auto result = basic_string(lhs);
3293 result += std::move(rhs);
3294 return result;
3295 }
3296
3301 friend basic_string operator +(const basic_string & lhs, const char rhs) {
3302 auto result = lhs;
3303 result += rhs;
3304 return result;
3305 }
3310 friend basic_string operator +(const basic_string & lhs, const xtd::char16 rhs) {
3311 auto result = lhs;
3312 result += rhs;
3313 return result;
3314 }
3319 friend basic_string operator +(const basic_string & lhs, const xtd::char32 rhs) {
3320 auto result = lhs;
3321 result += rhs;
3322 return result;
3323 }
3328 friend basic_string operator +(const basic_string & lhs, const xtd::char8 rhs) {
3329 auto result = lhs;
3330 result += rhs;
3331 return result;
3332 }
3337 friend basic_string operator +(const basic_string & lhs, const xtd::wchar rhs) {
3338 auto result = lhs;
3339 result += rhs;
3340 return result;
3341 }
3342
3347 friend basic_string operator +(basic_string&& lhs, const char rhs) {
3348 auto result = std::move(lhs);
3349 result += rhs;
3350 return result;
3351 }
3356 friend basic_string operator +(basic_string&& lhs, const xtd::char16 rhs) {
3357 auto result = std::move(lhs);
3358 result += rhs;
3359 return result;
3360 }
3365 friend basic_string operator +(basic_string&& lhs, const xtd::char32 rhs) {
3366 auto result = std::move(lhs);
3367 result += rhs;
3368 return result;
3369 }
3374 friend basic_string operator +(basic_string&& lhs, const xtd::char8 rhs) {
3375 auto result = std::move(lhs);
3376 result += rhs;
3377 return result;
3378 }
3383 friend basic_string operator +(basic_string&& lhs, const xtd::wchar rhs) {
3384 auto result = std::move(lhs);
3385 result += rhs;
3386 return result;
3387 }
3388
3393 friend basic_string operator +(char lhs, const basic_string & rhs) {
3394 auto result = basic_string(1, lhs);
3395 result += rhs;
3396 return result;
3397 }
3402 friend basic_string operator +(xtd::char16 lhs, const basic_string & rhs) {
3403 auto result = basic_string(1, lhs);
3404 result += rhs;
3405 return result;
3406 }
3411 friend basic_string operator +(xtd::char32 lhs, const basic_string & rhs) {
3412 auto result = basic_string(1, lhs);
3413 result += rhs;
3414 return result;
3415 }
3420 friend basic_string operator +(xtd::char8 lhs, const basic_string & rhs) {
3421 auto result = basic_string(1, lhs);
3422 result += rhs;
3423 return result;
3424 }
3429 friend basic_string operator +(xtd::wchar lhs, const basic_string & rhs) {
3430 auto result = basic_string(1, lhs);
3431 result += rhs;
3432 return result;
3433 }
3434
3439 friend basic_string operator +(char lhs, basic_string&& rhs) {
3440 auto result = basic_string(1, lhs);
3441 result += std::move(rhs);
3442 return result;
3443 }
3448 friend basic_string operator +(xtd::char16 lhs, basic_string&& rhs) {
3449 auto result = basic_string(1, lhs);
3450 result += std::move(rhs);
3451 return result;
3452 }
3457 friend basic_string operator +(xtd::char32 lhs, basic_string&& rhs) {
3458 auto result = basic_string(1, lhs);
3459 result += std::move(rhs);
3460 return result;
3461 }
3466 friend basic_string operator +(xtd::char8 lhs, basic_string&& rhs) {
3467 auto result = basic_string(1, lhs);
3468 result += std::move(rhs);
3469 return result;
3470 }
3475 friend basic_string operator +(xtd::wchar lhs, basic_string&& rhs) {
3476 auto result = basic_string(1, lhs);
3477 result += std::move(rhs);
3478 return result;
3479 }
3480
3489 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
3490 friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string & str) {
3491 if constexpr(std::is_same_v<char, char_t>) return stream << str.chars();
3492 else return stream << __xtd_convert_to_string<char>(str.chars());
3493 }
3500 friend std::basic_ostream<xtd::wchar>& operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string & str) {return stream << str.to_wstring().chars();}
3501
3510 friend std::basic_istream<char>& operator >>(std::basic_istream<char>& stream, basic_string & str) {
3511 auto s = std::basic_string<char> {};
3512 stream >> s;
3513 str = s;
3514 return stream;
3515 }
3524 friend std::basic_istream<xtd::wchar>& operator >>(std::basic_istream<xtd::wchar>& stream, basic_string & str) {
3525 auto s = std::basic_string<xtd::wchar> {};
3526 stream >> s;
3527 str = s;
3528 return stream;
3529 }
3531
3533
3537 [[deprecated("Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 0.4.0.")]]
3538 bool is_empty() const noexcept {return is_empty(self_);}
3544
3546
3547 template<class object_t>
3548 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 0.4.0.")]]
3549 static basic_string class_name() {return get_class_name(full_class_name<object_t>());}
3554 template<class object_t>
3555 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 0.4.0.")]]
3556 static basic_string class_name(const object_t& object) {return get_class_name(full_class_name(object));}
3561 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 0.4.0.")]]
3562 static basic_string class_name(const std::type_info & info) {return __xtd_get_class_name(info);}
3567 template<class object_t>
3568 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 0.4.0.")]]
3569 static basic_string full_class_name() {return demangle(typeid(object_t).name());}
3574 template<class object_t>
3575 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 0.4.0.")]]
3576 static basic_string full_class_name(const object_t& object) {return demangle(typeid(object).name());}
3581 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 0.4.0.")]]
3582 static basic_string full_class_name(const std::type_info & info) {return __xtd_get_full_class_name(info);}
3584
3585 private:
3586 friend class basic_string<char>;
3587 friend class basic_string<xtd::char16>;
3588 friend class basic_string<xtd::char32>;
3589 friend class basic_string<xtd::char8>;
3590 friend class basic_string<xtd::wchar>;
3591
3592 static const xtd::array<value_type> default_split_separators;
3593 static const xtd::array<value_type> default_trim_chars;
3594
3595 template<class arg_t>
3596 static auto convert_param(arg_t&& arg) noexcept {
3597 if constexpr(std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, std::string>::value) return std::forward<arg_t>(arg).c_str();
3598 else if constexpr(std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, std::u16string>::value) return std::forward<arg_t>(arg).c_str();
3599 else if constexpr(std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, std::u32string>::value) return std::forward<arg_t>(arg).c_str();
3600 else if constexpr(std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, std::u8string>::value) return std::forward<arg_t>(arg).c_str();
3601 else if constexpr(std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, std::wstring>::value) return std::forward<arg_t>(arg).c_str();
3602 else if constexpr(std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, basic_string>::value) return std::forward<arg_t>(arg).c_str();
3603 else return std::forward<arg_t>(arg);
3604 }
3605
3606 static basic_string get_class_name(const basic_string & full_name) {
3607 auto length = full_name.last_index_of("<");
3608 if (length == npos) length = full_name.length();
3609 if (full_name.last_index_of("::", 0, length) == npos) return full_name;
3610 return full_name.substring(full_name.last_index_of("::", 0, length) + 2);
3611 }
3612
3613 base_type chars_;
3614 };
3615}
3616
3617#define __XTD_BASIC_STRING_INTERNAL__
3618#include "basic_string_.hpp"
3619#undef __XTD_BASIC_STRING_INTERNAL__
Contains xtd::array definitions.
Contains __format_information struct.
Contains __format method.
Contains string definitions.
Contains __xtd_std_version definitions.
Contains xtd::basic_string class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:63
Represents text as a sequence of character units.
Definition basic_string.hpp:71
xtd::size index_of(value_type value) const noexcept
Reports the index of the first occurrence of the specified character in this basic_string.
Definition basic_string.hpp:1402
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:1526
bool ends_with(const basic_string &value, xtd::string_comparison comparison_type) const noexcept
Determines whether the end of this basic_string matches the specified basic_string when compared usin...
Definition basic_string.hpp:1125
static basic_string class_name(const object_t &object)
Gets the class name of the specified object.
Definition basic_string.hpp:3556
size_type find_last_not_of(const_pointer s, size_type pos, size_type count) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1323
allocator_type get_allocator() const
Returns the allocator associated with the string.
Definition basic_string.hpp:1351
xtd::size index_of(value_type value, xtd::size start_index, xtd::size count) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1414
xtd::size index_of(value_type value, xtd::size start_index) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1407
size_type find_first_of(const basic_string &str) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.hpp:1177
xtd::size index_of_any(const xtd::array< value_type > &values, xtd::size start_index) const
Reports the index of the first occurrence in this instance of any character in a specified array of c...
size_type find_last_of(char_t ch, size_type pos) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.hpp:1303
bool ends_with(value_type value, bool ignore_case) const noexcept
Determines whether the end of this basic_string matches the specified character, ignoring or honoring...
Definition basic_string.hpp:1108
enumerator_type get_enumerator() const noexcept override
Returns an enumerator that iterates through a collection.
Definition basic_string.hpp:1361
size_type find_last_not_of(char_t ch, size_type pos) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1347
size_type rfind(const_pointer s) const
Finds the last substring that is equal to the given character sequence. The search begins at xtd::bas...
Definition basic_string.hpp:1637
virtual const base_type & get_base_type() const noexcept
Returns the underlying base type.
Definition basic_string.hpp:1355
size_type find_first_not_of(const_pointer s, size_type pos) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1248
xtd::size last_index_of(const basic_string &value, xtd::size start_index) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1465
size_type find_last_of(const_pointer s) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.hpp:1285
static basic_string full_class_name(const std::type_info &info)
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition basic_string.hpp:3582
size_type find_last_of(const_pointer s, size_type pos) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.hpp:1292
size_type find_first_not_of(const basic_string &str) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1221
virtual bool contains(const basic_string &value) const noexcept
Returns a value indicating whether a specified substring occurs within this basic_string.
Definition basic_string.hpp:1079
size_type find_first_of(const basic_string &str, size_type pos) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.hpp:1183
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:1449
size_type find_first_of(const_pointer s, size_type pos) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.hpp:1204
int32 compare(size_type pos1, size_type count1, const_pointer s, size_type count2) const
Compares two character sequences.
Definition basic_string.hpp:1047
xtd::size last_index_of(const basic_string &value, xtd::size start_index, xtd::size count) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1472
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...
size_type find_first_not_of(char_t ch) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1253
int32 compare_to(const basic_string &value) const noexcept override
Compares this instance with a specified xtd::basic_string object and indicates whether this instance ...
Definition basic_string.hpp:1070
basic_string quoted() const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML.
Definition basic_string.hpp:1553
size_type find(const_pointer s) const
Finds the first substring equal to the given character sequence. Search begins at 0,...
Definition basic_string.hpp:1153
basic_string remove(xtd::size start_index) const
Deletes all the characters from this basic_string beginning at a specified position and continuing th...
Definition basic_string.hpp:1574
size_type find_last_not_of(char_t ch) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1341
basic_string remove(xtd::size start_index, xtd::size count) const
Deletes all the characters from this basic_string beginning at a specified position and continuing th...
Definition basic_string.hpp:1579
xtd::size last_index_of(value_type value) const noexcept
Reports the index of the last occurrence of the specified character in this tring.
Definition basic_string.hpp:1480
static basic_string class_name()
Gets the class name of the object_t.
Definition basic_string.hpp:3549
static basic_string class_name(const std::type_info &info)
Gets the class name of the specified object.
Definition basic_string.hpp:3562
size_type find_last_not_of(const_pointer s) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1329
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string (""). /.
Definition basic_string.hpp:3538
size_type find(value_type ch) const
Finds the first substring equal to the given character sequence. Search begins at 0,...
Definition basic_string.hpp:1165
basic_string quoted(value_type delimiter) const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified...
Definition basic_string.hpp:1558
int32 compare_to(const object &value) const
Compares this instance with a specified xtd::object and indicates whether this instance precedes,...
Definition basic_string.hpp:1058
basic_string pad_right(xtd::size total_width, char32 padding_char) const noexcept
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.hpp:1547
basic_string replace(const basic_string &old_string, const basic_string &new_string) const noexcept
Replaces all occurrences of a specified basic_string in this basic_string with another specified basi...
Definition basic_string.hpp:1596
xtd::size get_hash_code() const noexcept override
Returns the hash code for this basic_string.
Definition basic_string.hpp:1359
virtual bool contains(value_type value) const noexcept
Returns a value indicating whether a specified char occurs within this basic_string.
Definition basic_string.hpp:1075
size_type find_last_not_of(const basic_string &str) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1309
size_type find_first_not_of(const basic_string &str, size_type pos) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1227
bool ends_with(value_type value) const noexcept
Determines whether the end of this basic_string matches the specified character.
Definition basic_string.hpp:1103
xtd::size last_index_of(value_type value, xtd::size start_index, xtd::size count) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1494
size_type find_first_of(const_pointer s, size_type pos, size_type count) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.hpp:1191
xtd::size index_of(const basic_string &value, xtd::size start_index, xtd::size count) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1394
size_type find(const basic_string &str) const
Finds the first substring equal to the given character sequence. Search begins at 0,...
Definition basic_string.hpp:1133
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...
xtd::size index_of(const basic_string &value) const noexcept
Reports the index of the first occurrence of the specified basic_string in this basic_string.
Definition basic_string.hpp:1382
size_type find_first_not_of(char_t ch, size_type pos) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1259
bool equals(const object &obj) const noexcept override
Determines whether this instance and a specified object, which must also be a xtd::basic_string objec...
Definition basic_string.hpp:1084
size_type find_first_of(char_t ch) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.hpp:1209
size_type find_first_not_of(const_pointer s) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1241
size_type find_first_not_of(const_pointer s, size_type pos, size_type count) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1235
basic_string replace(value_type old_char, value_type new_char) const noexcept
Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.
Definition basic_string.hpp:1590
xtd::size index_of_any(const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const
Reports the index of the first occurrence in this instance of any character in a specified array of c...
bool ends_with(const basic_string &value, bool ignore_case) const noexcept
Determines whether the end of this basic_string instance matches the specified basic_string,...
Definition basic_string.hpp:1120
bool equals(const basic_string &value, bool ignore_case) const noexcept
Determines whether this instance and another specified xtd::basic_string object have the same value,...
Definition basic_string.hpp:1095
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:1540
size_type find_last_of(const basic_string &str, size_type pos) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.hpp:1271
static basic_string full_class_name()
Definition basic_string.hpp:3569
xtd::size last_index_of_any(const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
bool ends_with(const basic_string &value) const noexcept
Determines whether the end of this basic_string matches the specified basic_string.
Definition basic_string.hpp:1115
size_type find_first_of(const_pointer s) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.hpp:1197
static basic_string full_class_name(const object_t &object)
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition basic_string.hpp:3576
xtd::size last_index_of(const basic_string &value) const noexcept
Reports the index of the last occurrence of the specified basic_string in this basic_string.
Definition basic_string.hpp:1459
basic_string pad_left(xtd::size total_width, char32 padding_char) const noexcept
Right-aligns the characters in this basic_string, padding with spaces on the left for a specified tot...
Definition basic_string.hpp:1533
bool equals(const basic_string &value) const noexcept override
Determines whether this instance and another specified xtd::basic_string object have the same value.
Definition basic_string.hpp:1089
size_type find_last_of(char_t ch) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.hpp:1297
size_type find_last_not_of(const_pointer s, size_type pos) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1336
xtd::size last_index_of_any(const xtd::array< value_type > &values, xtd::size start_index) const
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
size_type find(value_type ch, size_type pos) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.hpp:1171
size_type find_last_of(const basic_string &str) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.hpp:1265
size_type find_last_of(const_pointer s, size_type pos, size_type count) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.hpp:1279
size_type find_last_not_of(const basic_string &str, size_type pos) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.hpp:1315
size_type find(const basic_string &str, size_type pos) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.hpp:1139
xtd::size index_of(const basic_string &value, xtd::size start_index) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1387
size_type find_first_of(char_t ch, size_type pos) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.hpp:1215
basic_string quoted(value_type delimiter, value_type escape) const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified...
Definition basic_string.hpp:1564
xtd::size last_index_of(value_type value, xtd::size start_index) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:1486
size_type find(const_pointer s, size_type pos, size_type count) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.hpp:1147
size_type find(const_pointer s, size_type pos) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.hpp:1160
size_type rfind(const_pointer s, size_type pos) const
Finds the last substring that is equal to the given character sequence. The search begins at pos and ...
Definition basic_string.hpp:1644
auto append(const source_t &element) const noexcept
Appends a value to the end of the sequence.
Definition enumerable.hpp:144
auto concat(const ienumerable< char_t > &second) const noexcept
Definition enumerable.hpp:185
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
char_t value_type
Definition ienumerable.hpp:46
typename xtd::collections::generic::extensions::enumerable_iterators< char_t, xtd::collections::generic::ienumerable< char_t > >::const_iterator const_iterator
Definition ienumerable.hpp:50
typename xtd::collections::generic::extensions::enumerable_iterators< char_t, xtd::collections::generic::ienumerable< char_t > >::iterator iterator
Definition ienumerable.hpp:48
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
static void throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current())
Throws an exption with specified exception case.
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:22
object()=default
Create a new instance of the ultimate base class object.
virtual xtd::string to_string() const noexcept
Returns a xtd::string that represents the current object.
Contains xtd::collections::generic::ienumerable <type_t> interface.
xtd::string format(const xtd::string &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition format.hpp:20
xtd::string sprintf(const xtd::string &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to basic_string using the specified f...
Definition sprintf.hpp:73
@ argument
The argument is not valid.
Definition exception_case.hpp:31
@ index_out_of_range
The index is out of range.
Definition exception_case.hpp:61
@ argument_out_of_range
The argument is out of range.
Definition exception_case.hpp:35
@ null_pointer
The pointer is null.
Definition exception_case.hpp:79
#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
constexpr xtd::size epos
Represents the index of the last valid element in a collection.
Definition epos.hpp:33
constexpr xtd::size bpos
Represents the index of the firsy valid element in a collection.
Definition bpos.hpp:25
xtd::string name() noexcept
Gets the thread name of the current thread.
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
null_ptr null
Represents a null pointer value.
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_comparison
Specifies the culture, case, and sort rules to be used by certain overloads of the xtd::string::compa...
Definition string_comparison.hpp:14
string_split_options
Specifies whether applicable xtd::string::split method overloads include or omit empty substrings fro...
Definition string_split_options.hpp:14
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.hpp:34
bool try_parse(const std::basic_string< char > &str, value_t &value) noexcept
Convert a string into a type.
Definition parse.hpp:416
@ ordinal
Compare strings using ordinal (binary) sort rules.
Definition string_comparison.hpp:24
@ ordinal_ignore_case
Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared...
Definition string_comparison.hpp:26
@ s
The S key.
Definition console_key.hpp:124
@ a
The A key.
Definition console_key.hpp:88
@ c
The C key.
Definition console_key.hpp:92
@ i
The I key.
Definition console_key.hpp:104
@ b
The B key.
Definition console_key.hpp:90
@ separator
The Separator key.
Definition console_key.hpp:172
@ escape
The ESC (ESCAPE) key.
Definition console_key.hpp:34
@ stream
Supports reliable, two-way, connection-based byte streams without the duplication of data and without...
Definition socket_type.hpp:36
size_type
Specifies how rows or columns of user interface (UI) elements should be sized relative to their conta...
Definition size_type.hpp:22
Contains xtd::hash_code class.
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
const_reference operator[](size_type index) const
Gets the element at the specified zero-based index.
Definition read_only_span.hpp:400
constexpr size_type length() const noexcept
Returns the length of the current read_only_span.
Definition read_only_span.hpp:229
constexpr const_pointer data() const noexcept
Gets direct access to the underlying contiguous storage.
Definition read_only_span.hpp:201
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::null pointer valiue.
Contains xtd::object class.
Contains xtd::parse methods.
Contains xtd::string_comparison enum class.
Contains xtd::string_split_options enum class.
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:38
Contains xtd::to_string methods.
Contains xtd fundamental types.
Contains unused_ keyword.