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 "types.hpp"
27#include <cctype>
28#include <iomanip>
29#include <ostream>
30#include <sstream>
31#include <string>
32
34template<class ...args_t>
35void __basic_string_extract_format_arg(const std::locale& loc, xtd::basic_string<char>& fmt, xtd::array<__format_information<char >>& formats, args_t&&... args);
36template<class target_t, class source_t>
37std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str) noexcept;
38template<class target_t, class source_t>
39std::basic_string<target_t> __xtd_convert_to_string(const std::basic_string<source_t>& str) noexcept;
40std::basic_string<char> __xtd_demangle(const std::basic_string<char>& value) noexcept;
41std::basic_string<char> __xtd_get_class_name(const std::type_info& value) noexcept;
42std::basic_string<char> __xtd_get_full_class_name(const std::type_info& value) noexcept;
44
46namespace xtd {
65 template<class char_t, class traits_t, class allocator_t>
66 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> {
67 public:
69
73 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
75 using traits_type = typename base_type::traits_type;
77 using value_type = typename base_type::value_type;
79 using allocator_type = typename base_type::allocator_type;
81 using size_type = typename base_type::size_type;
83 using difference_type = typename base_type::difference_type;
85 using reference = typename base_type::reference;
87 using const_reference = typename base_type::const_reference;
89 using pointer = typename base_type::pointer;
91 using const_pointer = typename base_type::const_pointer;
99 using reverse_iterator = typename base_type::reverse_iterator;
101 using const_reverse_iterator = typename base_type::const_reverse_iterator;
105
107
112
121 inline static constexpr size_type npos = base_type::npos;
122
131 static inline constexpr xtd::size bpos = 0;
132
149 static inline constexpr xtd::size epos = npos - 1;
151
153
156 basic_string() = default;
162 basic_string(std::basic_string<char_t>&& str) : chars_ {std::move(str)} {}
165 basic_string(const basic_string<char>& str) noexcept {
166 if constexpr(std::is_same_v<char, char_t>) chars_ = str.chars_;
167 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
168 }
169
172 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str.chars_;
173 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
174 }
175
178 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str.chars_;
179 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
180 }
181
184 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str.chars_;
185 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
186 }
187
190 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str.chars_;
191 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
192 }
193
195 basic_string(const std::basic_string<char>& str) noexcept { // Can't be explicit by design.
196 if constexpr(std::is_same_v<char, char_t>) chars_ = str;
197 else chars_ = __xtd_convert_to_string<value_type>(str);
198 }
199
201 basic_string(const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
202 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str;
203 else chars_ = __xtd_convert_to_string<value_type>(str);
204 }
205
207 basic_string(const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
208 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str;
209 else chars_ = __xtd_convert_to_string<value_type>(str);
210 }
211
213 basic_string(const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
214 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str;
215 else chars_ = __xtd_convert_to_string<value_type>(str);
216 }
217
219 basic_string(const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
220 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str;
221 else chars_ = __xtd_convert_to_string<value_type>(str);
222 }
223
226 basic_string(char character, xtd::size count) : basic_string(std::basic_string<char>(count, character)) {}
245 basic_string(const char* str) { // Can't be explicit by design.
247 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
248 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
249 }
250
252 basic_string(const xtd::char16 * str) { // Can't be explicit by design.
254 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
255 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
256 }
257
259 basic_string(const xtd::char32 * str) { // Can't be explicit by design.
261 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
262 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
263 }
264
266 basic_string(const xtd::char8 * str) { // Can't be explicit by design.
268 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
269 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
270 }
271
273 basic_string(const xtd::wchar * str) { // Can't be explicit by design.
275 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
276 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
277 }
278
281 basic_string(const char* str, xtd::size count) {
283 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count);
284 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count));
285 }
286
290 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count);
291 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count));
292 }
293
297 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count);
298 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count));
299 }
300
304 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count);
305 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count));
306 }
307
311 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count);
312 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
313 }
314
317 template<class input_iterator_t>
318 basic_string(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
321 basic_string(const std::basic_string_view<char_t>& str) : chars_(str) {}
324 basic_string(std::initializer_list<char> il) : basic_string(std::basic_string<char>(il)) {}
327 basic_string(std::initializer_list<xtd::char16> il) : basic_string(std::basic_string<xtd::char16>(il)) {}
330 basic_string(std::initializer_list<xtd::char32> il) : basic_string(std::basic_string<xtd::char32>(il)) {}
333 basic_string(std::initializer_list<xtd::char8> il) : basic_string(std::basic_string<xtd::char8>(il)) {}
336 basic_string(std::initializer_list<xtd::wchar> il) : basic_string(std::basic_string<xtd::wchar>(il)) {}
338
340
350 const_pointer c_str() const noexcept {return chars_.c_str();}
351
354 const base_type& chars() const noexcept {return chars_;}
357 base_type& chars() noexcept {return chars_;}
358
362 virtual size_type count() const noexcept {return chars_.size();}
363
371 const_pointer data() const noexcept {return chars_.data();}
372
375 virtual bool empty() const noexcept {return length() == 0;}
376
380 virtual size_type length() const noexcept {return chars_.size();}
381
385 virtual size_type size() const noexcept {return chars_.size();}
387
389
409 int32 compare(const basic_string & str) const {return chars_.compare(str);}
431 int32 compare(size_type pos1, size_type count1, const basic_string & str) const {return chars_.compare(pos1, count1, str);}
455 int32 compare(size_type pos1, size_type count1, const basic_string & str, size_type pos2) const {return chars_.compare(pos1, count1, str, pos2);}
480 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);}
499 int32 compare(const_pointer s) const {return chars_.compare(s);}
521 int32 compare(size_type pos1, size_type count1, const_pointer s) const {return chars_.compare(pos1, count1, s);}
544 int32 compare(size_type pos1, size_type count1, const_pointer s, size_type count2) const {return chars_.compare(pos1, count1, s, count2);}
545
555 int32 compare_to(const object & value) const {
557 return compare_to(static_cast<const basic_string&>(value));
558 }
567 int32 compare_to(const basic_string & value) const noexcept override {return chars_.compare(value.chars_);}
568
572 virtual bool contains(value_type value) const noexcept {return find(value) != npos;}
576 virtual bool contains(const basic_string & value) const noexcept {return find(value) != npos;}
577
581 bool equals(const object & obj) const noexcept override {return dynamic_cast<const basic_string*>(&obj) && equals(static_cast<const basic_string&>(obj));}
586 bool equals(const basic_string & value) const noexcept override {return equals(value, false);}
592 bool equals(const basic_string & value, bool ignore_case) const noexcept {
593 if (ignore_case) return to_upper().chars_ == value.to_upper().chars_;
594 return chars_ == value.chars_;
595 }
596
600 bool ends_with(value_type value) const noexcept {return ends_with(value, false);}
605 bool ends_with(value_type value, bool ignore_case) const noexcept {
606 if (ignore_case) return to_lower().rfind(static_cast<value_type>(tolower(value))) == length() - 1;
607 return chars_.rfind(value) == length() - 1;
608 }
612 bool ends_with(const basic_string & value) const noexcept {return ends_with(value, xtd::string_comparison::ordinal);}
617 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);}
622 bool ends_with(const basic_string & value, xtd::string_comparison comparison_type) const noexcept {
623 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.rfind(value.to_lower()) + value.to_lower().length() == length();
624 return chars_.rfind(value) + value.length() == length();
625 }
626
630 size_type find(const basic_string & str) const {return chars_.find(str);}
636 size_type find(const basic_string & str, size_type pos) const {return chars_.find(str, pos);}
644 size_type find(const_pointer s, size_type pos, size_type count) const {return chars_.find(s, pos, count);}
650 size_type find(const_pointer s) const {return chars_.find(s);}
657 size_type find(const_pointer s, size_type pos) const {return chars_.find(s, pos);}
662 size_type find(value_type ch) const {return chars_.find(ch);}
668 size_type find(value_type ch, size_type pos) const {return chars_.find(ch, pos);}
669
674 size_type find_first_of(const basic_string & str) const {return chars_.find_first_of(str);}
680 size_type find_first_of(const basic_string & str, size_type pos) const {return chars_.find_first_of(str, pos);}
688 size_type find_first_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_first_of(s, pos, count);}
694 size_type find_first_of(const_pointer s) const {return chars_.find_first_of(s);}
701 size_type find_first_of(const_pointer s, size_type pos) const {return chars_.find_first_of(s, pos);}
706 size_type find_first_of(char_t ch) const {return chars_.find_first_of(ch);}
712 size_type find_first_of(char_t ch, size_type pos) const {return chars_.find_first_of(ch, pos);}
713
718 size_type find_first_not_of(const basic_string & str) const {return chars_.find_first_not_of(str);}
724 size_type find_first_not_of(const basic_string & str, size_type pos) const {return chars_.find_first_not_of(str, pos);}
732 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);}
738 size_type find_first_not_of(const_pointer s) const {return chars_.find_first_not_of(s);}
745 size_type find_first_not_of(const_pointer s, size_type pos) const {return chars_.find_first_not_of(s, pos);}
750 size_type find_first_not_of(char_t ch) const {return chars_.find_first_not_of(ch);}
756 size_type find_first_not_of(char_t ch, size_type pos) const {return chars_.find_first_not_of(ch, pos);}
757
762 size_type find_last_of(const basic_string & str) const {return chars_.find_last_of(str);}
768 size_type find_last_of(const basic_string & str, size_type pos) const {return chars_.find_last_of(str, pos);}
776 size_type find_last_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_last_of(s, pos, count);}
782 size_type find_last_of(const_pointer s) const {return chars_.find_last_of(s);}
789 size_type find_last_of(const_pointer s, size_type pos) const {return chars_.find_last_of(s, pos);}
794 size_type find_last_of(char_t ch) const {return chars_.find_last_of(ch);}
800 size_type find_last_of(char_t ch, size_type pos) const {return chars_.find_last_of(ch, pos);}
801
806 size_type find_last_not_of(const basic_string & str) const {return chars_.find_last_not_of(str);}
812 size_type find_last_not_of(const basic_string & str, size_type pos) const {return chars_.find_last_not_of(str, pos);}
820 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);}
826 size_type find_last_not_of(const_pointer s) const {return chars_.find_last_not_of(s);}
833 size_type find_last_not_of(const_pointer s, size_type pos) const {return chars_.find_last_not_of(s, pos);}
838 size_type find_last_not_of(char_t ch) const {return chars_.find_last_not_of(ch);}
844 size_type find_last_not_of(char_t ch, size_type pos) const {return chars_.find_last_not_of(ch, pos);}
845
848 allocator_type get_allocator() const {return chars_.get_allocator();}
849
852 virtual const base_type& get_base_type() const noexcept {return chars_;}
853
856 xtd::size get_hash_code() const noexcept override {return xtd::hash_code::combine(chars_);}
857
858 enumerator_type get_enumerator() const noexcept override {
859 struct basic_string_enumerator : public xtd::collections::generic::ienumerator<value_type> {
860 explicit basic_string_enumerator(const basic_string & chars) : chars_(chars) {}
861 const value_type& current() const override {
863 return chars_[index_];
864 }
865 bool move_next() override {return ++index_ < chars_.length();}
866 void reset() override {index_ = basic_string::npos;}
867
868 private:
869 const basic_string& chars_;
870 size_type index_ = basic_string::npos;
871 };
873 }
874
878 xtd::size index_of(const basic_string & value) const noexcept {return index_of(value, 0, length());}
883 xtd::size index_of(const basic_string & value, xtd::size start_index) const {return index_of(value, start_index, length() - start_index);}
890 xtd::size index_of(const basic_string & value, xtd::size start_index, xtd::size count) const {
892 auto result = find(value, start_index);
893 return result > start_index + count ? npos : result;
894 }
898 xtd::size index_of(value_type value) const noexcept {return index_of(value, 0, length());}
903 xtd::size index_of(value_type value, xtd::size start_index) const {return index_of(value, start_index, length() - start_index);}
910 xtd::size index_of(value_type value, xtd::size start_index, xtd::size count) const {
912 auto result = find(value, start_index);
913 return result > start_index + count ? npos : result;
914 }
915
919 xtd::size index_of_any(const xtd::array<value_type>& values) const noexcept;
925 xtd::size index_of_any(const xtd::array<value_type>& values, xtd::size start_index) const;
932 xtd::size index_of_any(const xtd::array<value_type>& values, xtd::size start_index, xtd::size count) const;
934 xtd::size index_of_any(const std::initializer_list<value_type>& values) const noexcept;
935 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
936 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
938
945 basic_string insert(xtd::size start_index, const basic_string & value) const {
947 auto result = self_;
948 result.chars_.insert(start_index, value);
949 return result;
950 }
951
955 xtd::size last_index_of(const basic_string & value) const noexcept {return last_index_of(value, 0, length());}
961 xtd::size last_index_of(const basic_string & value, xtd::size start_index) const {return last_index_of(value, start_index, length() - start_index);}
968 xtd::size last_index_of(const basic_string & value, xtd::size start_index, xtd::size count) const {
970 auto result = chars_.rfind(value, start_index + count - value.length());
971 return result < start_index ? npos : result;
972 }
976 xtd::size last_index_of(value_type value) const noexcept {return last_index_of(value, 0, length());}
982 xtd::size last_index_of(value_type value, xtd::size start_index) const {return last_index_of(value, start_index, length() - start_index);}
990 xtd::size last_index_of(value_type value, xtd::size start_index, xtd::size count) const {
992 auto result = chars_.rfind(value, start_index + count - 1);
993 return result < start_index ? npos : result;
994 }
995
999 xtd::size last_index_of_any(const xtd::array<value_type>& values) const noexcept;
1004 xtd::size last_index_of_any(const xtd::array<value_type>& values, xtd::size start_index) const;
1010 xtd::size last_index_of_any(const xtd::array<value_type>& values, xtd::size start_index, xtd::size count) const;
1012 xtd::size last_index_of_any(const std::initializer_list<value_type>& values) const noexcept;
1013 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
1014 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
1016
1022 basic_string pad_left(xtd::size total_width) const noexcept {return pad_left(total_width, ' ');}
1029 basic_string pad_left(xtd::size total_width, char32 padding_char) const noexcept {return total_width < length() ? self_ : basic_string(padding_char, total_width - length()) + self_;}
1030
1036 basic_string pad_right(xtd::size total_width) const noexcept {return pad_right(total_width, ' ');}
1043 basic_string pad_right(xtd::size total_width, char32 padding_char) const noexcept {return total_width < length() ? self_ : self_ + basic_string(padding_char, total_width - length());}
1044
1049 basic_string quoted() const {return quoted('"', '\\');}
1054 basic_string quoted(value_type delimiter) const {return quoted(delimiter, '\\');}
1060 basic_string quoted(value_type delimiter, value_type escape) const {
1061 std::wstringstream ss;
1062 if constexpr(std::is_same_v<xtd::wchar, value_type>) ss << std::quoted(chars_, delimiter, escape);
1063 else ss << std::quoted(__xtd_convert_to_string<xtd::wchar>(chars_), static_cast<xtd::wchar>(delimiter), static_cast<xtd::wchar>(escape));
1064 return ss.str();
1065 }
1066
1070 basic_string remove(xtd::size start_index) const {return remove(start_index, length() - start_index);}
1075 basic_string remove(xtd::size start_index, xtd::size count) const {
1077 auto result = self_;
1078 result.chars_.erase(start_index, count);
1079 return result;
1080 }
1081
1086 basic_string replace(value_type old_char, value_type new_char) const noexcept {return replace(string(old_char, 1), string(new_char, 1));}
1092 basic_string replace(const basic_string & old_string, const basic_string & new_string) const noexcept {
1093 auto result = self_;
1094 auto old_size = old_string.length();
1095 auto new_size = new_string.length();
1096 auto index = xtd::size {0};
1097 while (true) {
1098 index = result.find(old_string, index);
1099 if (index == npos) break;
1100 if (old_size == new_size) result.chars_.replace(index, old_size, new_string);
1101 else {
1102 result.chars_.erase(index, old_string.length());
1103 result.chars_.insert(index, new_string);
1104 }
1105 index += new_string.length();
1106 }
1107 return result;
1108 }
1109
1113 size_type rfind(const basic_string & str) const {return chars_.rfind(str);}
1119 size_type rfind(const basic_string & str, size_type pos) const {return chars_.rfind(str, pos);}
1127 size_type rfind(const_pointer s, size_type pos, size_type count) const {return chars_.rfind(s, pos, count);}
1133 size_type rfind(const_pointer s) const {return chars_.rfind(s);}
1140 size_type rfind(const_pointer s, size_type pos) const {return chars_.rfind(s, pos);}
1145 size_type rfind(value_type ch) const {return chars_.rfind(ch);}
1151 size_type rfind(value_type ch, size_type pos) const {return chars_.rfind(ch, pos);}
1152
1157 xtd::array<basic_string> split() const noexcept;
1163 xtd::array<basic_string> split(value_type separator) const noexcept;
1180 xtd::array<basic_string> split(value_type separator, xtd::string_split_options options) const noexcept;
1189 xtd::array<basic_string> split(value_type separator, xtd::size count) const noexcept;
1201 xtd::array<basic_string> split(value_type separator, xtd::size count, xtd::string_split_options options) const noexcept;
1207 xtd::array<basic_string> split(const xtd::array<value_type>& separators) const noexcept;
1224 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::string_split_options options) const noexcept;
1233 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count) const noexcept;
1245 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count, xtd::string_split_options options) const noexcept;
1246
1251 bool starts_with(value_type value) const noexcept {return starts_with(value, false);}
1257 bool starts_with(value_type value, bool ignore_case) const noexcept {
1258 if (ignore_case) return to_lower().find(static_cast<value_type>(tolower(value))) == 0;
1259 return find(value) == 0;
1260 }
1265 bool starts_with(const basic_string & value) const noexcept {return starts_with(value, string_comparison::ordinal);}
1271 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);}
1276 bool starts_with(const basic_string & value, xtd::string_comparison comparison_type) const noexcept {
1277 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().find(value.to_lower()) == 0;
1278 return find(value) == 0;
1279 }
1280
1285 basic_string substr() const {return chars_.substr();}
1291 basic_string substr(size_type pos) const {
1293 return chars_.substr(pos);
1294 }
1301 basic_string substr(size_type pos, size_type count) const {
1303 return chars_.substr(pos, count);
1304 }
1305
1311 basic_string substring(xtd::size start_index) const {
1313 return substr(start_index);
1314 }
1320 basic_string substring(xtd::size start_index, xtd::size length) const {
1321 if (start_index > self_.length() || start_index + length > self_.length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1322 return substr(start_index, length);
1323 }
1324
1327 xtd::array<value_type> to_array() const noexcept;
1331 xtd::array<value_type> to_array(xtd::size start_index) const;
1336 xtd::array<value_type> to_array(xtd::size start_index, xtd::size length) const;
1337
1340 xtd::array<value_type> to_char_array() const noexcept;
1345 xtd::array<value_type> to_char_array(xtd::size start_index, xtd::size length) const;
1346
1349 basic_string to_lower() const noexcept {
1350 auto result = basic_string::empty_string;
1351 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::tolower(c));});
1352 return result;
1353 }
1354
1358 basic_string<char> to_string() const noexcept override {
1359 if constexpr(std::is_same_v<char, char_t>) return chars_;
1360 else return __xtd_convert_to_string<char>(chars_);
1361 }
1362
1365 basic_string to_title_case() const noexcept;
1366
1369 basic_string<xtd::char16> to_u16string() const noexcept {
1370 if constexpr(std::is_same_v<xtd::char16, char_t>) return chars_;
1371 else return __xtd_convert_to_string<xtd::char16>(chars_);
1372 }
1373
1376 basic_string<xtd::char32> to_u32string() const noexcept {
1377 if constexpr(std::is_same_v<xtd::char32, char_t>) return chars_;
1378 else return __xtd_convert_to_string<xtd::char32>(chars_);
1379 }
1380
1383 basic_string<xtd::char8> to_u8string() const noexcept {
1384 if constexpr(std::is_same_v<xtd::char8, char_t>) return chars_;
1385 else return __xtd_convert_to_string<xtd::char8>(chars_);
1386 }
1387
1390 basic_string to_upper() const noexcept {
1391 auto result = basic_string::empty_string;
1392 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::toupper(c));});
1393 return result;
1394 }
1395
1398 basic_string<xtd::wchar> to_wstring() const noexcept {
1399 if constexpr(std::is_same_v<xtd::wchar, char_t>) return chars_;
1400 else return __xtd_convert_to_string<xtd::wchar>(chars_);
1401 }
1402
1407 basic_string trim() const noexcept {return trim(default_trim_chars);}
1412 basic_string trim(value_type trim_char) const noexcept;
1417 basic_string trim(const xtd::array<value_type>& trim_chars) const noexcept;
1418
1423 basic_string trim_end() const noexcept {return trim_end(default_trim_chars);}
1428 basic_string trim_end(value_type trim_char) const noexcept;
1433 basic_string trim_end(const xtd::array<value_type>& trim_chars) const noexcept;
1434
1439 basic_string trim_start() const noexcept {return trim_start(default_trim_chars);}
1444 basic_string trim_start(value_type trim_char) const noexcept;
1449 basic_string trim_start(const xtd::array<value_type>& trim_chars) const noexcept;
1451
1453
1464 static int32 compare(const basic_string & str_a, const basic_string & str_b) noexcept {return compare(str_a, str_b, false);}
1475 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);}
1486 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);}
1499 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);}
1513 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);}
1527 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));}
1528
1535 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;}
1542 template<class object_a_t, class object_b_t, class object_c_t, class object_d_t>
1543 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);}
1549 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;}
1555 template<class object_a_t, class object_b_t, class object_c_t>
1556 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);}
1561 static basic_string concat(const basic_string & str_a, const basic_string & str_b) noexcept {return str_a + str_b;}
1566 template<class object_a_t, class object_b_t>
1567 static basic_string concat(object_a_t obj_a, object_b_t obj_b) noexcept {return format("{}{}", obj_a, obj_b);}
1571 static basic_string concat(const xtd::array<basic_string>& values) noexcept;
1573 static basic_string concat(const xtd::array<const_pointer>& values) noexcept;
1574 template<class other_char_t>
1575 static basic_string concat(const xtd::array<const other_char_t*>& values) noexcept;
1576 static basic_string concat(const std::initializer_list<basic_string>& values) noexcept {
1577 auto result = basic_string::empty_string;
1578 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
1579 return result;
1580 }
1581 static basic_string concat(const std::initializer_list<const_pointer>& values) noexcept {
1582 auto result = basic_string::empty_string;
1583 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
1584 return result;
1585 }
1586 template<class other_char_t>
1587 static basic_string concat(const std::initializer_list<const other_char_t*>& values) noexcept {
1588 auto result = basic_string::empty_string;
1589 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
1590 return result;
1591 }
1596 template<class object_t>
1597 static basic_string concat(const xtd::array<object_t>& args) noexcept;
1599 template<class object_t>
1600 static basic_string concat(const std::initializer_list<object_t>& args) noexcept {
1601 basic_string result;
1602 for (const auto& arg : args)
1603 result += format("{}", arg);
1604 return result;
1605 }
1610 template<class value_t>
1611 static basic_string concat(value_t value) noexcept {
1612 return format("{}", value);
1613 }
1614
1635 static basic_string demangle(const basic_string & name) {
1636 if constexpr(std::is_same_v<char, char_t>) return __xtd_demangle(name.chars());
1637 else return __xtd_demangle(__xtd_convert_to_string<char>(name.chars()));
1638 }
1639
1645 static bool equals(const basic_string & a, const basic_string & b) noexcept {return a.equals(b);}
1651 template<class char_a_t, class char_b_t>
1652 static bool equals(const char_a_t* a, const char_b_t* b) noexcept {return basic_string {a}.equals(basic_string {b});}
1653
1660 static bool equals(const basic_string & a, const basic_string & b, bool ignore_case) noexcept {return a.equals(b, ignore_case);}
1667 template<class char_a_t, class char_b_t>
1668 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);}
1669
1676 template<class ...args_t>
1677 static basic_string format(const basic_string<char>& fmt, args_t&& ... args);
1678
1686 template<class ...args_t>
1687 static basic_string format(const std::locale & loc, const basic_string<char>& fmt, args_t&& ... args);
1688
1692 static bool is_empty(const xtd::basic_string<value_type, traits_type, allocator_type>& string) noexcept {return !string.length();}
1693
1700 template<class collection_t>
1701 static basic_string join(const basic_string & separator, const collection_t& values) noexcept {
1702 xtd::size i = 0;
1703 basic_string result;
1704 for (const auto& item : values)
1705 result += format("{}{}", (i++ != 0 ? separator : basic_string {}), item);
1706 return result;
1707 }
1715 template<class collection_t>
1716 static basic_string join(const basic_string & separator, const collection_t& values, xtd::size index) {return join(separator, values, index, values.size() - index);}
1725 template<class collection_t>
1726 static basic_string join(const basic_string & separator, const collection_t& values, xtd::size index, xtd::size count) {
1727 if (index > values.size() || index + count > values.size()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1728 xtd::size i = 0;
1729 basic_string result;
1730 for (const auto& item : values) {
1731 if (i >= index) result += format("{}{}", (i != index ? separator : basic_string {}), item);
1732 if (++i >= index + count) break;
1733 }
1734 return result;
1735 }
1736
1738 template<class value_t>
1739 static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values) noexcept;
1740 template<class value_t>
1741 static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values, xtd::size index);
1742 template<class value_t>
1743 static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values, xtd::size index, xtd::size count);
1745
1749 template<class value_t>
1750 static value_t parse(const basic_string & str) {
1751 if constexpr(std::is_same_v<char, char_t>) return xtd::parse<value_t>(str.chars());
1752 else return xtd::parse<value_t>(__xtd_convert_to_string<char>(str.chars()));
1753 }
1754
1814 template<class ...args_t>
1815 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)) ...);}
1816
1821 template<class value_t>
1822 static bool try_parse(const basic_string & str, value_t& value) noexcept {
1823 try {
1824 value = parse<value_t>(str);
1825 return true;
1826 } catch (...) {
1827 return false;
1828 }
1829 }
1831
1833
1841 return chars_[index == epos ? length() - 1 : index];
1842 }
1843
1846 operator const base_type& () const noexcept {return chars_;}
1847
1851 basic_string& operator =(const basic_string<char>& str) noexcept {
1852 if constexpr(std::is_same<char_t, char>::value) chars_ = str.chars_;
1853 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1854 return self_;
1855 }
1859 basic_string& operator =(const basic_string<xtd::char16>& str) noexcept {
1860 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str.chars_;
1861 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1862 return self_;
1863 }
1867 basic_string& operator =(const basic_string<xtd::char32>& str) noexcept {
1868 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str.chars_;
1869 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1870 return self_;
1871 }
1875 basic_string& operator =(const basic_string<xtd::char8>& str) noexcept {
1876 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str.chars_;
1877 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1878 return self_;
1879 }
1883 basic_string& operator =(const basic_string<xtd::wchar>& str) noexcept {
1884 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str.chars_;
1885 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1886 return self_;
1887 }
1888
1892 basic_string& operator =(basic_string<char>&& str) noexcept {
1893 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str.chars_);
1894 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1895 return self_;
1896 }
1900 basic_string& operator =(basic_string<xtd::char16>&& str) noexcept {
1901 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str.chars_);
1902 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1903 return self_;
1904 }
1908 basic_string& operator =(basic_string<xtd::char32>&& str) noexcept {
1909 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str.chars_);
1910 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1911 return self_;
1912 }
1916 basic_string& operator =(basic_string<xtd::char8>&& str) noexcept {
1917 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str.chars_);
1918 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1919 return self_;
1920 }
1924 basic_string& operator =(basic_string<xtd::wchar>&& str) noexcept {
1925 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str.chars_);
1926 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1927 return self_;
1928 }
1929
1933 basic_string& operator =(const std::basic_string<char>& str) noexcept {
1934 if constexpr(std::is_same<char_t, char>::value) chars_ = str;
1935 else chars_ = __xtd_convert_to_string<value_type>(str);
1936 return self_;
1937 }
1941 basic_string& operator =(const std::basic_string<xtd::char16>& str) noexcept {
1942 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str;
1943 else chars_ = __xtd_convert_to_string<value_type>(str);
1944 return self_;
1945 }
1949 basic_string& operator =(const std::basic_string<xtd::char32>& str) noexcept {
1950 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str;
1951 else chars_ = __xtd_convert_to_string<value_type>(str);
1952 return self_;
1953 }
1957 basic_string& operator =(const std::basic_string<xtd::char8>& str) noexcept {
1958 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str;
1959 else chars_ = __xtd_convert_to_string<value_type>(str);
1960 return self_;
1961 }
1965 basic_string& operator =(const std::basic_string<xtd::wchar>& str) noexcept {
1966 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str;
1967 else chars_ = __xtd_convert_to_string<value_type>(str);
1968 return self_;
1969 }
1970
1974 basic_string& operator =(std::basic_string<char>&& str) noexcept {
1975 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str);
1976 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1977 return self_;
1978 }
1982 basic_string& operator =(std::basic_string<xtd::char16>&& str) noexcept {
1983 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str);
1984 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1985 return self_;
1986 }
1990 basic_string& operator =(std::basic_string<xtd::char32>&& str) noexcept {
1991 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str);
1992 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1993 return self_;
1994 }
1998 basic_string& operator =(std::basic_string<xtd::char8>&& str) noexcept {
1999 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str);
2000 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2001 return self_;
2002 }
2006 basic_string& operator =(std::basic_string<xtd::wchar>&& str) noexcept {
2007 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str);
2008 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2009 return self_;
2010 }
2011
2016 basic_string& operator =(const char* str) {
2018 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
2019 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
2020 return self_;
2021 }
2026 basic_string& operator =(const xtd::char16 * str) {
2028 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
2029 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
2030 return self_;
2031 }
2036 basic_string& operator =(const xtd::char32 * str) {
2038 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
2039 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
2040 return self_;
2041 }
2046 basic_string& operator =(const xtd::char8 * str) {
2048 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
2049 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
2050 return self_;
2051 }
2056 basic_string& operator =(const xtd::wchar * str) {
2058 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
2059 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
2060 return self_;
2061 }
2062
2066 basic_string& operator =(char character) {
2067 self_ = basic_string(character, 1);
2068 return self_;
2069 }
2073 basic_string& operator =(xtd::char16 character) {
2074 self_ = basic_string(character, 1);
2075 return self_;
2076 }
2080 basic_string& operator =(xtd::char32 character) {
2081 self_ = basic_string(character, 1);
2082 return self_;
2083 }
2087 basic_string& operator =(xtd::char8 character) {
2088 self_ = basic_string(character, 1);
2089 return self_;
2090 }
2094 basic_string& operator =(xtd::wchar character) {
2095 self_ = basic_string(character, 1);
2096 return self_;
2097 }
2098
2102 basic_string& operator =(const std::initializer_list<char>& il) {
2103 self_ = basic_string(il);
2104 return self_;
2105 }
2109 basic_string& operator =(const std::initializer_list<xtd::char16>& il) {
2110 self_ = basic_string(il);
2111 return self_;
2112 }
2116 basic_string& operator =(const std::initializer_list<xtd::char32>& il) {
2117 self_ = basic_string(il);
2118 return self_;
2119 }
2123 basic_string& operator =(const std::initializer_list<xtd::char8>& il) {
2124 self_ = basic_string(il);
2125 return self_;
2126 }
2130 basic_string& operator =(const std::initializer_list<xtd::wchar>& il) {
2131 self_ = basic_string(il);
2132 return self_;
2133 }
2134
2138 basic_string& operator +=(const basic_string<char>& str) {
2139 if constexpr(std::is_same_v<char, char_t>) chars_ += str.chars_;
2140 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2141 return self_;
2142 }
2146 basic_string& operator +=(const basic_string<xtd::char16>& str) {
2147 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str.chars_;
2148 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2149 return self_;
2150 }
2154 basic_string& operator +=(const basic_string<xtd::char32>& str) {
2155 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str.chars_;
2156 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2157 return self_;
2158 }
2162 basic_string& operator +=(const basic_string<xtd::char8>& str) {
2163 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str.chars_;
2164 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2165 return self_;
2166 }
2170 basic_string& operator +=(const basic_string<xtd::wchar>& str) {
2171 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str.chars_;
2172 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2173 return self_;
2174 }
2175
2179 basic_string& operator +=(basic_string<char>&& str) {
2180 if constexpr(std::is_same_v<char, char_t>) chars_ += std::move(str.chars_);
2181 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2182 return self_;
2183 }
2187 basic_string& operator +=(basic_string<xtd::char16>&& str) {
2188 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += std::move(str.chars_);
2189 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2190 return self_;
2191 }
2195 basic_string& operator +=(basic_string<xtd::char32>&& str) {
2196 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += std::move(str.chars_);
2197 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2198 return self_;
2199 }
2203 basic_string& operator +=(basic_string<xtd::char8>&& str) {
2204 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += std::move(str.chars_);
2205 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2206 return self_;
2207 }
2211 basic_string& operator +=(basic_string<xtd::wchar>&& str) {
2212 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += std::move(str.chars_);
2213 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2214 return self_;
2215 }
2216
2220 basic_string& operator +=(const std::basic_string<char>& str) {
2221 if constexpr(std::is_same_v<char, char_t>) chars_ += str;
2222 else chars_ += __xtd_convert_to_string<value_type>(str);
2223 return self_;
2224 }
2228 basic_string& operator +=(const std::basic_string<xtd::char16>& str) {
2229 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str;
2230 else chars_ += __xtd_convert_to_string<value_type>(str);
2231 return self_;
2232 }
2236 basic_string& operator +=(const std::basic_string<xtd::char32>& str) {
2237 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str;
2238 else chars_ += __xtd_convert_to_string<value_type>(str);
2239 return self_;
2240 }
2244 basic_string& operator +=(const std::basic_string<xtd::char8>& str) {
2245 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str;
2246 else chars_ += __xtd_convert_to_string<value_type>(str);
2247 return self_;
2248 }
2252 basic_string& operator +=(const std::basic_string<xtd::wchar>& str) {
2253 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str;
2254 else chars_ += __xtd_convert_to_string<value_type>(str);
2255 return self_;
2256 }
2257
2261 basic_string& operator +=(const char* str) {
2262 chars_ += basic_string(str).chars_;
2263 return self_;
2264 }
2268 basic_string& operator +=(const xtd::char16 * str) {
2269 chars_.append(basic_string(str).chars_); return self_;
2270 }
2274 basic_string& operator +=(const xtd::char32 * str) {
2275 chars_ += basic_string(str).chars_;
2276 return self_;
2277 }
2281 basic_string& operator +=(const xtd::char8 * str) {
2282 chars_ += basic_string(str).chars_;
2283 return self_;
2284 }
2288 basic_string& operator +=(const xtd::wchar * str) {
2289 chars_ += basic_string(str).chars_;
2290 return self_;
2291 }
2295 basic_string& operator +=(char ch) {
2296 chars_ += basic_string(ch, 1).chars_;
2297 return self_;
2298 }
2302 basic_string& operator +=(xtd::char16 ch) {
2303 chars_ += basic_string(ch, 1).chars_;
2304 return self_;
2305 }
2309 basic_string& operator +=(xtd::char32 ch) {
2310 chars_ += basic_string(ch, 1).chars_;
2311 return self_;
2312 }
2316 basic_string& operator +=(xtd::char8 ch) {
2317 chars_ += basic_string(ch, 1).chars_;
2318 return self_;
2319 }
2323 basic_string& operator +=(xtd::wchar ch) {
2324 chars_ += basic_string(ch, 1).chars_;
2325 return self_;
2326 }
2327
2332 friend basic_string operator +(const basic_string & lhs, const basic_string<char>& rhs) {
2333 auto result = lhs;
2334 result += rhs;
2335 return result;
2336 }
2341 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::char16>& rhs) {
2342 auto result = lhs;
2343 result += rhs;
2344 return result;
2345 }
2350 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::char32>& rhs) {
2351 auto result = lhs;
2352 result += rhs;
2353 return result;
2354 }
2359 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::char8>& rhs) {
2360 auto result = lhs;
2361 result += rhs;
2362 return result;
2363 }
2368 friend basic_string operator +(const basic_string & lhs, const basic_string<xtd::wchar>& rhs) {
2369 auto result = lhs;
2370 result += rhs;
2371 return result;
2372 }
2373
2378 friend basic_string operator +(basic_string&& lhs, basic_string<char>&& rhs) {
2379 auto result = std::move(lhs);
2380 result += std::move(rhs);
2381 return result;
2382 }
2387 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::char16>&& rhs) {
2388 auto result = std::move(lhs);
2389 result += std::move(rhs);
2390 return result;
2391 }
2396 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::char32>&& rhs) {
2397 auto result = std::move(lhs);
2398 result += std::move(rhs);
2399 return result;
2400 }
2405 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::char8>&& rhs) {
2406 auto result = std::move(lhs);
2407 result += std::move(rhs);
2408 return result;
2409 }
2414 friend basic_string operator +(basic_string&& lhs, basic_string<xtd::wchar>&& rhs) {
2415 auto result = std::move(lhs);
2416 result += std::move(rhs);
2417 return result;
2418 }
2419
2424 friend basic_string operator +(basic_string&& lhs, const basic_string<char>& rhs) {
2425 auto result = std::move(lhs);
2426 result += rhs;
2427 return result;
2428 }
2433 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::char16>& rhs) {
2434 auto result = std::move(lhs);
2435 result += rhs;
2436 return result;
2437 }
2442 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::char32>& rhs) {
2443 auto result = std::move(lhs);
2444 result += rhs;
2445 return result;
2446 }
2451 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::char8>& rhs) {
2452 auto result = std::move(lhs);
2453 result += rhs;
2454 return result;
2455 }
2460 friend basic_string operator +(basic_string&& lhs, const basic_string<xtd::wchar>& rhs) {
2461 auto result = std::move(lhs);
2462 result += rhs;
2463 return result;
2464 }
2465
2470 friend basic_string operator +(const basic_string & lhs, basic_string<char>&& rhs) {
2471 auto result = lhs;
2472 result += std::move(rhs);
2473 return result;
2474 }
2479 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::char16>&& rhs) {
2480 auto result = lhs;
2481 result += std::move(rhs);
2482 return result;
2483 }
2488 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::char32>&& rhs) {
2489 auto result = lhs;
2490 result += std::move(rhs);
2491 return result;
2492 }
2497 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::char8>&& rhs) {
2498 auto result = lhs;
2499 result += std::move(rhs);
2500 return result;
2501 }
2506 friend basic_string operator +(const basic_string & lhs, basic_string<xtd::wchar>&& rhs) {
2507 auto result = lhs;
2508 result += std::move(rhs);
2509 return result;
2510 }
2511
2516 friend basic_string operator +(const basic_string & lhs, const std::basic_string<char>& rhs) {
2517 auto result = lhs;
2518 result += rhs;
2519 return result;
2520 }
2525 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char16>& rhs) {
2526 auto result = lhs;
2527 result += rhs;
2528 return result;
2529 }
2534 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char32>& rhs) {
2535 auto result = lhs;
2536 result += rhs;
2537 return result;
2538 }
2543 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char8>& rhs) {
2544 auto result = lhs;
2545 result += rhs;
2546 return result;
2547 }
2552 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::wchar>& rhs) {
2553 auto result = lhs;
2554 result += rhs;
2555 return result;
2556 }
2557
2562 friend basic_string operator +(const std::basic_string<char>& lhs, const basic_string & rhs) {
2563 auto result = lhs;
2564 if constexpr(std::is_same_v<char, char_t>) result += rhs.chars();
2565 else result += __xtd_convert_to_string<char>(rhs.chars());
2566 return result;
2567 }
2572 friend basic_string operator +(const std::basic_string<xtd::char16>& lhs, const basic_string & rhs) {
2573 auto result = lhs;
2574 if constexpr(std::is_same_v<xtd::char16, char_t>) result += rhs.chars();
2575 else result += __xtd_convert_to_string<xtd::char16>(rhs.chars());
2576 return result;
2577 }
2582 friend basic_string operator +(const std::basic_string<xtd::char32>& lhs, const basic_string & rhs) {
2583 auto result = lhs;
2584 if constexpr(std::is_same_v<xtd::char32, char_t>) result += rhs.chars();
2585 else result += __xtd_convert_to_string<xtd::char32>(rhs.chars());
2586 return result;
2587 }
2592 friend basic_string operator +(const std::basic_string<xtd::char8>& lhs, const basic_string & rhs) {
2593 auto result = lhs;
2594 if constexpr(std::is_same_v<xtd::char8, char_t>) result += rhs.chars();
2595 else result += __xtd_convert_to_string<xtd::char8>(rhs.chars());
2596 return result;
2597 }
2602 friend basic_string operator +(const std::basic_string<xtd::wchar>& lhs, const basic_string & rhs) {
2603 auto result = lhs;
2604 if constexpr(std::is_same_v<xtd::wchar, char_t>) result += rhs.chars();
2605 else result += __xtd_convert_to_string<xtd::wchar>(rhs.chars());
2606 return result;
2607 }
2608
2613 friend basic_string operator +(const basic_string & lhs, const char* rhs) {
2614 auto result = lhs;
2615 result += rhs;
2616 return result;
2617 }
2622 friend basic_string operator +(const basic_string & lhs, const xtd::char16 * rhs) {
2623 auto result = lhs;
2624 result += rhs;
2625 return result;
2626 }
2631 friend basic_string operator +(const basic_string & lhs, const xtd::char32 * rhs) {
2632 auto result = lhs;
2633 result += rhs;
2634 return result;
2635 }
2640 friend basic_string operator +(const basic_string & lhs, const xtd::char8 * rhs) {
2641 auto result = lhs;
2642 result += rhs;
2643 return result;
2644 }
2649 friend basic_string operator +(const basic_string & lhs, const xtd::wchar * rhs) {
2650 auto result = lhs;
2651 result += rhs;
2652 return result;
2653 }
2654
2659 friend basic_string operator +(basic_string&& lhs, const char* rhs) {
2660 auto result = std::move(lhs);
2661 result += rhs;
2662 return result;
2663 }
2668 friend basic_string operator +(basic_string&& lhs, const xtd::char16 * rhs) {
2669 auto result = std::move(lhs);
2670 result += rhs;
2671 return result;
2672 }
2677 friend basic_string operator +(basic_string&& lhs, const xtd::char32 * rhs) {
2678 auto result = std::move(lhs);
2679 result += rhs;
2680 return result;
2681 }
2686 friend basic_string operator +(basic_string&& lhs, const xtd::char8 * rhs) {
2687 auto result = std::move(lhs);
2688 result += rhs;
2689 return result;
2690 }
2695 friend basic_string operator +(basic_string&& lhs, const xtd::wchar * rhs) {
2696 auto result = std::move(lhs);
2697 result += rhs;
2698 return result;
2699 }
2700
2705 friend basic_string operator +(const char* lhs, const basic_string & rhs) {
2706 auto result = basic_string(lhs);
2707 result += rhs;
2708 return result;
2709 }
2714 friend basic_string operator +(const xtd::char16 * lhs, const basic_string & rhs) {
2715 auto result = basic_string(lhs);
2716 result += rhs;
2717 return result;
2718 }
2723 friend basic_string operator +(const xtd::char32 * lhs, const basic_string & rhs) {
2724 auto result = basic_string(lhs);
2725 result += rhs;
2726 return result;
2727 }
2732 friend basic_string operator +(const xtd::char8 * lhs, const basic_string & rhs) {
2733 auto result = basic_string(lhs);
2734 result += rhs;
2735 return result;
2736 }
2741 friend basic_string operator +(const xtd::wchar * lhs, const basic_string & rhs) {
2742 auto result = basic_string(lhs);
2743 result += rhs;
2744 return result;
2745 }
2746
2751 friend basic_string operator +(const char* lhs, basic_string&& rhs) {
2752 auto result = basic_string(lhs);
2753 result += std::move(rhs);
2754 return result;
2755 }
2760 friend basic_string operator +(const xtd::char16 * lhs, basic_string&& rhs) {
2761 auto result = basic_string(lhs);
2762 result += std::move(rhs);
2763 return result;
2764 }
2769 friend basic_string operator +(const xtd::char32 * lhs, basic_string&& rhs) {
2770 auto result = basic_string(lhs);
2771 result += std::move(rhs);
2772 return result;
2773 }
2778 friend basic_string operator +(const xtd::char8 * lhs, basic_string&& rhs) {
2779 auto result = basic_string(lhs);
2780 result += std::move(rhs);
2781 return result;
2782 }
2787 friend basic_string operator +(const xtd::wchar * lhs, basic_string&& rhs) {
2788 auto result = basic_string(lhs);
2789 result += std::move(rhs);
2790 return result;
2791 }
2792
2797 friend basic_string operator +(const basic_string & lhs, const char rhs) {
2798 auto result = lhs;
2799 result += rhs;
2800 return result;
2801 }
2806 friend basic_string operator +(const basic_string & lhs, const xtd::char16 rhs) {
2807 auto result = lhs;
2808 result += rhs;
2809 return result;
2810 }
2815 friend basic_string operator +(const basic_string & lhs, const xtd::char32 rhs) {
2816 auto result = lhs;
2817 result += rhs;
2818 return result;
2819 }
2824 friend basic_string operator +(const basic_string & lhs, const xtd::char8 rhs) {
2825 auto result = lhs;
2826 result += rhs;
2827 return result;
2828 }
2833 friend basic_string operator +(const basic_string & lhs, const xtd::wchar rhs) {
2834 auto result = lhs;
2835 result += rhs;
2836 return result;
2837 }
2838
2843 friend basic_string operator +(basic_string&& lhs, const char rhs) {
2844 auto result = std::move(lhs);
2845 result += rhs;
2846 return result;
2847 }
2852 friend basic_string operator +(basic_string&& lhs, const xtd::char16 rhs) {
2853 auto result = std::move(lhs);
2854 result += rhs;
2855 return result;
2856 }
2861 friend basic_string operator +(basic_string&& lhs, const xtd::char32 rhs) {
2862 auto result = std::move(lhs);
2863 result += rhs;
2864 return result;
2865 }
2870 friend basic_string operator +(basic_string&& lhs, const xtd::char8 rhs) {
2871 auto result = std::move(lhs);
2872 result += rhs;
2873 return result;
2874 }
2879 friend basic_string operator +(basic_string&& lhs, const xtd::wchar rhs) {
2880 auto result = std::move(lhs);
2881 result += rhs;
2882 return result;
2883 }
2884
2889 friend basic_string operator +(char lhs, const basic_string & rhs) {
2890 auto result = basic_string(lhs, 1);
2891 result += rhs;
2892 return result;
2893 }
2898 friend basic_string operator +(xtd::char16 lhs, const basic_string & rhs) {
2899 auto result = basic_string(lhs, 1);
2900 result += rhs;
2901 return result;
2902 }
2907 friend basic_string operator +(xtd::char32 lhs, const basic_string & rhs) {
2908 auto result = basic_string(lhs, 1);
2909 result += rhs;
2910 return result;
2911 }
2916 friend basic_string operator +(xtd::char8 lhs, const basic_string & rhs) {
2917 auto result = basic_string(lhs, 1);
2918 result += rhs;
2919 return result;
2920 }
2925 friend basic_string operator +(xtd::wchar lhs, const basic_string & rhs) {
2926 auto result = basic_string(lhs, 1);
2927 result += rhs;
2928 return result;
2929 }
2930
2935 friend basic_string operator +(char lhs, basic_string&& rhs) {
2936 auto result = basic_string(lhs, 1);
2937 result += std::move(rhs);
2938 return result;
2939 }
2944 friend basic_string operator +(xtd::char16 lhs, basic_string&& rhs) {
2945 auto result = basic_string(lhs, 1);
2946 result += std::move(rhs);
2947 return result;
2948 }
2953 friend basic_string operator +(xtd::char32 lhs, basic_string&& rhs) {
2954 auto result = basic_string(lhs, 1);
2955 result += std::move(rhs);
2956 return result;
2957 }
2962 friend basic_string operator +(xtd::char8 lhs, basic_string&& rhs) {
2963 auto result = basic_string(lhs, 1);
2964 result += std::move(rhs);
2965 return result;
2966 }
2971 friend basic_string operator +(xtd::wchar lhs, basic_string&& rhs) {
2972 auto result = basic_string(lhs, 1);
2973 result += std::move(rhs);
2974 return result;
2975 }
2976
2985 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
2986 friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string & str) {
2987 if constexpr(std::is_same_v<char, char_t>) return stream << str.chars();
2988 else return stream << __xtd_convert_to_string<char>(str.chars());
2989 }
2996 friend std::basic_ostream<xtd::wchar>& operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string & str) {return stream << str.to_wstring().chars();}
2997
3006 friend std::basic_istream<char>& operator >>(std::basic_istream<char>& stream, basic_string & str) {
3007 auto s = std::basic_string<char> {};
3008 stream >> s;
3009 str = s;
3010 return stream;
3011 }
3020 friend std::basic_istream<xtd::wchar>& operator >>(std::basic_istream<xtd::wchar>& stream, basic_string & str) {
3021 auto s = std::basic_string<xtd::wchar> {};
3022 stream >> s;
3023 str = s;
3024 return stream;
3025 }
3027
3029
3033 [[deprecated("Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 0.4.0.")]]
3034 bool is_empty() const noexcept {return is_empty(self_);}
3040
3042
3043 template<class object_t>
3044 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 0.4.0.")]]
3045 static basic_string class_name() {return get_class_name(full_class_name<object_t>());}
3050 template<class object_t>
3051 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 0.4.0.")]]
3052 static basic_string class_name(const object_t& object) {return get_class_name(full_class_name(object));}
3057 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 0.4.0.")]]
3058 static basic_string class_name(const std::type_info & info) {return __xtd_get_class_name(info);}
3063 template<class object_t>
3064 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 0.4.0.")]]
3065 static basic_string full_class_name() {return demangle(typeid(object_t).name());}
3070 template<class object_t>
3071 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 0.4.0.")]]
3072 static basic_string full_class_name(const object_t& object) {return demangle(typeid(object).name());}
3077 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 0.4.0.")]]
3078 static basic_string full_class_name(const std::type_info & info) {return __xtd_get_full_class_name(info);}
3080
3081 private:
3082 friend class basic_string<char>;
3083 friend class basic_string<xtd::char16>;
3084 friend class basic_string<xtd::char32>;
3085 friend class basic_string<xtd::char8>;
3086 friend class basic_string<xtd::wchar>;
3087
3088 static const xtd::array<value_type> default_split_separators;
3089 static const xtd::array<value_type> default_trim_chars;
3090
3091 template<class arg_t>
3092 static auto convert_param(arg_t&& arg) noexcept {
3093 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();
3094 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();
3095 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();
3096 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();
3097 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();
3098 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();
3099 else return std::forward<arg_t>(arg);
3100 }
3101
3102 static basic_string get_class_name(const basic_string & full_name) {
3103 auto length = full_name.last_index_of("<");
3104 if (length == npos) length = full_name.length();
3105 if (full_name.last_index_of("::", 0, length) == npos) return full_name;
3106 return full_name.substring(full_name.last_index_of("::", 0, length) + 2);
3107 }
3108
3109 base_type chars_;
3110 };
3111}
3112
3113#define __XTD_BASIC_STRING_INTERNAL__
3114#include "basic_string_.hpp"
3115#undef __XTD_BASIC_STRING_INTERNAL__
3116
3118namespace std {
3119 template<typename char_t>
3120 struct hash<xtd::basic_string<char_t>> {
3121 xtd::size operator()(const xtd::basic_string<char_t>& s) const noexcept {return s.get_hash_code();}
3122 };
3123}
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:64
Represents text as a sequence of character units.
Definition basic_string.hpp:66
basic_string(const basic_string< xtd::char32 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:177
basic_string(const xtd::char8 *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:302
std::basic_string< char_t, traits_t, allocator_t > base_type
Represents the basic string base type.
Definition basic_string.hpp:73
static const basic_string empty_string
Definition basic_string.hpp:111
static basic_string class_name(const object_t &object)
Gets the class name of the specified object.
Definition basic_string.hpp:3052
basic_string(const xtd::char32 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:259
typename base_type::allocator_type allocator_type
Represents the basic string allocator type.
Definition basic_string.hpp:79
basic_string(char character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:226
basic_string(const char *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:281
basic_string(const std::basic_string_view< char_t > &str)
Initializes a new instance of xtd::basic_string with specified std::basic_string_view.
Definition basic_string.hpp:321
basic_string(xtd::wchar character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:242
int32 compare(size_type pos1, size_type count1, const basic_string &str) const
Compares two character sequences.
Definition basic_string.hpp:431
typename xtd::collections::generic::enumerator< value_type > enumerator_type
Represents the basic string enumerator type.
Definition basic_string.hpp:103
basic_string(const basic_string< xtd::char8 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:183
basic_string(input_iterator_t first, input_iterator_t last)
Initializes a new instance of xtd::basic_string with specified first and last iterators of substring.
Definition basic_string.hpp:318
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:3078
typename base_type::const_pointer const_pointer
Represents the basic string const pointer type.
Definition basic_string.hpp:91
basic_string(std::initializer_list< xtd::wchar > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:336
basic_string(const basic_string< xtd::char16 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:171
basic_string(const std::basic_string< char > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:195
typename base_type::traits_type traits_type
Represents the basic string traits type.
Definition basic_string.hpp:75
const base_type & chars() const noexcept
Returns a reference to the underlying base type.
Definition basic_string.hpp:354
virtual size_type size() const noexcept
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:385
typename base_type::pointer pointer
Represents the basic string pointer type.
Definition basic_string.hpp:89
typename base_type::const_reference const_reference
Represents the basic string const referecne type.
Definition basic_string.hpp:87
basic_string(std::initializer_list< xtd::char32 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:330
basic_string(const std::basic_string< xtd::char16 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:201
basic_string(const xtd::wchar *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:309
static basic_string class_name()
Gets the class name of the object_t.
Definition basic_string.hpp:3045
static basic_string class_name(const std::type_info &info)
Gets the class name of the specified object.
Definition basic_string.hpp:3058
basic_string(const basic_string< xtd::wchar > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:189
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string (""). /.
Definition basic_string.hpp:3034
typename xtd::collections::generic::ienumerable< char_t >::iterator iterator
Represents the basic string iterator type.
Definition basic_string.hpp:94
typename base_type::const_reverse_iterator const_reverse_iterator
Represents the basic string const reverse iterator type.
Definition basic_string.hpp:101
basic_string(const char *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:245
int32 compare(size_type pos1, size_type count1, const basic_string &str, size_type pos2, size_type count2) const
Compares two character sequences.
Definition basic_string.hpp:480
basic_string(std::initializer_list< char > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:324
virtual size_type count() const noexcept
Definition basic_string.hpp:362
typename base_type::size_type size_type
Represents the basic string size type.
Definition basic_string.hpp:81
basic_string(xtd::char8 character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:238
basic_string(const xtd::wchar *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:273
static constexpr xtd::size epos
Definition basic_string.hpp:149
const_pointer data() const noexcept
Returns a pointer to the underlying array serving as character storage. The pointer is such that the ...
Definition basic_string.hpp:371
basic_string(basic_string &&)=default
Initializes a new instance of xtd::basic_string with specified string to move.
static constexpr size_type npos
Definition basic_string.hpp:121
basic_string(const basic_string< char > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:165
basic_string(xtd::char16 character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:230
int32 compare(const_pointer s) const
Compares two character sequences.
Definition basic_string.hpp:499
virtual size_type length() const noexcept
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:380
base_type & chars() noexcept
Returns a reference to the underlying base type.
Definition basic_string.hpp:357
basic_string(const xtd::char16 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:252
typename base_type::value_type value_type
Represents the basic string value type.
Definition basic_string.hpp:77
typename base_type::reverse_iterator reverse_iterator
Represents the basic string reverse iterator type.
Definition basic_string.hpp:99
basic_string(const xtd::char16 *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:288
static basic_string full_class_name()
Definition basic_string.hpp:3065
basic_string(std::initializer_list< xtd::char16 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:327
int32 compare(size_type pos1, size_type count1, const basic_string &str, size_type pos2) const
Compares two character sequences.
Definition basic_string.hpp:455
basic_string(std::initializer_list< xtd::char8 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:333
static constexpr xtd::size bpos
Definition basic_string.hpp:131
basic_string()=default
Initializes a new instance of xtd::basic_string.
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:3072
basic_string(const xtd::char8 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:266
basic_string(xtd::char32 character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:234
int32 compare(const basic_string &str) const
Compares two character sequences.
Definition basic_string.hpp:409
const_pointer c_str() const noexcept
Returns a pointer to a null-terminated character array with data equivalent to those stored in the st...
Definition basic_string.hpp:350
typename base_type::reference reference
Represents the basic string referecne type.
Definition basic_string.hpp:85
basic_string(const std::basic_string< xtd::wchar > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:219
typename xtd::collections::generic::ienumerable< char_t >::const_iterator const_iterator
Represents the basic string const iterator type.
Definition basic_string.hpp:97
typename base_type::difference_type difference_type
Represents the basic string difference type.
Definition basic_string.hpp:83
basic_string(const std::basic_string< xtd::char32 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:207
basic_string(const xtd::char32 *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:295
basic_string(const std::basic_string< xtd::char8 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:213
virtual bool empty() const noexcept
Checks whether the container is empty.
Definition basic_string.hpp:375
basic_string(std::basic_string< char_t > &&str)
Initializes a new instance of xtd::basic_string with specified string to move.
Definition basic_string.hpp:162
auto contains(const char_t &value) const noexcept -> bool
Definition enumerable.hpp:192
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
virtual auto get_enumerator() const -> xtd::collections::generic::enumerator< char_t >=0
typename xtd::collections::generic::extensions::enumerable_iterators< xtd::any_object, xtd::collections::generic::ienumerable< xtd::any_object > >::const_iterator const_iterator
Definition ienumerable.hpp:50
typename xtd::collections::generic::extensions::enumerable_iterators< xtd::any_object, xtd::collections::generic::ienumerable< xtd::any_object > >::iterator iterator
Definition ienumerable.hpp:48
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
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:22
virtual int32 compare_to(const basic_string< char_t, traits_t, allocator_t > &obj) const noexcept=0
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
virtual bool equals(const object &obj) const noexcept
Determines whether the specified object is equal to the current object.
virtual xtd::size get_hash_code() const noexcept
Serves as a hash function for a particular type.
object()=default
Create a new instance of the ultimate base class object.
virtual xtd::string to_string() const
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:21
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
@ invalid_operation
The operation is not valid.
Definition exception_case.hpp:65
#define self_
The self_ expression is a reference value expression whose value is the reference of the implicit obj...
Definition self.hpp:20
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
@ current
Specifies the current position within a stream.
Definition seek_origin.hpp:20
@ 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
@ insert
The INS (INSERT) key.
Definition console_key.hpp:62
@ 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.
virtual auto remove(const type_t &item) -> bool=0
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
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 fundamental types.