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 "unused.hpp"
28#include <cctype>
29#include <iomanip>
30#include <ostream>
31#include <sstream>
32#include <string>
33
35template<class ...args_t>
36void __basic_string_extract_format_arg(const std::locale& loc, xtd::basic_string<char>& fmt, xtd::array<__format_information<char >>& formats, args_t&&... args);
37template<class target_t, class source_t>
38std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str) noexcept;
39template<class target_t, class source_t>
40std::basic_string<target_t> __xtd_convert_to_string(const std::basic_string<source_t>& str) noexcept;
41std::basic_string<char> __xtd_demangle(const std::basic_string<char>& value) noexcept;
42std::basic_string<char> __xtd_get_class_name(const std::type_info& value) noexcept;
43std::basic_string<char> __xtd_get_full_class_name(const std::type_info& value) noexcept;
45
47namespace xtd {
66 template<class char_t, class traits_t, class allocator_t>
67 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> {
68 public:
70
74 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
76 using traits_type = typename base_type::traits_type;
78 using value_type = typename base_type::value_type;
80 using allocator_type = typename base_type::allocator_type;
82 using size_type = typename base_type::size_type;
84 using difference_type = typename base_type::difference_type;
86 using reference = typename base_type::reference;
88 using const_reference = typename base_type::const_reference;
90 using pointer = typename base_type::pointer;
92 using const_pointer = typename base_type::const_pointer;
100 using reverse_iterator = typename base_type::reverse_iterator;
102 using const_reverse_iterator = typename base_type::const_reverse_iterator;
104 using enumerator_type = typename xtd::collections::generic::enumerator<value_type>;
106
108
112 static const basic_string empty_string;
113
122 inline static constexpr size_type npos = base_type::npos;
123
132 static inline constexpr xtd::size bpos = 0;
133
150 static inline constexpr xtd::size epos = npos - 1;
152
154
157 basic_string() = default;
160 basic_string(basic_string&&) = default;
163 basic_string(std::basic_string<char_t>&& str) : chars_ {std::move(str)} {}
166 basic_string(const basic_string<char>& str) noexcept {
167 if constexpr(std::is_same_v<char, char_t>) chars_ = str.chars_;
168 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
169 }
172 basic_string(const basic_string<xtd::char16>& str) noexcept {
173 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str.chars_;
174 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
175 }
178 basic_string(const basic_string<xtd::char32>& str) noexcept {
179 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str.chars_;
180 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
181 }
184 basic_string(const basic_string<xtd::char8>& str) noexcept {
185 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str.chars_;
186 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
187 }
190 basic_string(const basic_string<xtd::wchar>& str) noexcept {
191 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str.chars_;
192 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
193 }
196 basic_string(const std::basic_string<char>& str) noexcept { // Can't be explicit by design.
197 if constexpr(std::is_same_v<char, char_t>) chars_ = str;
198 else chars_ = __xtd_convert_to_string<value_type>(str);
199 }
202 basic_string(const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
203 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str;
204 else chars_ = __xtd_convert_to_string<value_type>(str);
205 }
208 basic_string(const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
209 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str;
210 else chars_ = __xtd_convert_to_string<value_type>(str);
211 }
214 basic_string(const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
215 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str;
216 else chars_ = __xtd_convert_to_string<value_type>(str);
217 }
220 basic_string(const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
221 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str;
222 else chars_ = __xtd_convert_to_string<value_type>(str);
223 }
227 basic_string(char character, xtd::size count) : basic_string(std::basic_string<char>(count, character)) {}
231 basic_string(xtd::char16 character, xtd::size count) : basic_string(std::basic_string<xtd::char16>(count, character)) {}
235 basic_string(xtd::char32 character, xtd::size count) : basic_string(std::basic_string<xtd::char32>(count, character)) {}
239 basic_string(xtd::char8 character, xtd::size count) : basic_string(std::basic_string<xtd::char8>(count, character)) {}
243 basic_string(xtd::wchar character, xtd::size count) : basic_string(std::basic_string<xtd::wchar>(count, character)) {}
246 basic_string(const char* str) { // Can't be explicit by design.
248 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
249 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
250 }
253 basic_string(const xtd::char16 * str) { // Can't be explicit by design.
255 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
256 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
257 }
260 basic_string(const xtd::char32 * str) { // Can't be explicit by design.
262 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
263 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
264 }
267 basic_string(const xtd::char8 * str) { // Can't be explicit by design.
269 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
270 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
271 }
274 basic_string(const xtd::wchar * str) { // Can't be explicit by design.
276 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
277 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
278 }
279
282 basic_string(const char* str, xtd::size count) {
284 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count);
285 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count));
286 }
291 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count);
292 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count));
293 }
298 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count);
299 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count));
300 }
303 basic_string(const xtd::char8 * str, xtd::size count) {
305 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count);
306 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count));
307 }
310 basic_string(const xtd::wchar * str, xtd::size count) {
312 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count);
313 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
314 }
318 template<class input_iterator_t>
319 basic_string(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
322 basic_string(const std::basic_string_view<char_t>& str) : chars_(str) {}
325 basic_string(std::initializer_list<char> il) : basic_string(std::basic_string<char>(il)) {}
328 basic_string(std::initializer_list<xtd::char16> il) : basic_string(std::basic_string<xtd::char16>(il)) {}
331 basic_string(std::initializer_list<xtd::char32> il) : basic_string(std::basic_string<xtd::char32>(il)) {}
334 basic_string(std::initializer_list<xtd::char8> il) : basic_string(std::basic_string<xtd::char8>(il)) {}
337 basic_string(std::initializer_list<xtd::wchar> il) : basic_string(std::basic_string<xtd::wchar>(il)) {}
339
341
351 const_pointer c_str() const noexcept {return chars_.c_str();}
352
355 const base_type& chars() const noexcept {return chars_;}
358 base_type& chars() noexcept {return chars_;}
359
363 virtual size_type count() const noexcept {return chars_.size();}
364
372 const_pointer data() const noexcept {return chars_.data();}
373
376 virtual bool empty() const noexcept {return length() == 0;}
377
381 virtual size_type length() const noexcept {return chars_.size();}
382
386 virtual size_type size() const noexcept {return chars_.size();}
388
390
410 int32 compare(const basic_string & str) const {return chars_.compare(str);}
432 int32 compare(size_type pos1, size_type count1, const basic_string & str) const {return chars_.compare(pos1, count1, str);}
456 int32 compare(size_type pos1, size_type count1, const basic_string & str, size_type pos2) const {return chars_.compare(pos1, count1, str, pos2);}
481 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);}
500 int32 compare(const_pointer s) const {return chars_.compare(s);}
522 int32 compare(size_type pos1, size_type count1, const_pointer s) const {return chars_.compare(pos1, count1, s);}
545 int32 compare(size_type pos1, size_type count1, const_pointer s, size_type count2) const {return chars_.compare(pos1, count1, s, count2);}
546
556 int32 compare_to(const object & value) const {
558 return compare_to(static_cast<const basic_string&>(value));
559 }
560
568 int32 compare_to(const basic_string & value) const noexcept override {return chars_.compare(value.chars_);}
569
573 virtual bool contains(value_type value) const noexcept {return find(value) != npos;}
577 virtual bool contains(const basic_string & value) const noexcept {return find(value) != npos;}
578
582 bool equals(const object & obj) const noexcept override {return dynamic_cast<const basic_string*>(&obj) && equals(static_cast<const basic_string&>(obj));}
587 bool equals(const basic_string & value) const noexcept override {return equals(value, false);}
593 bool equals(const basic_string & value, bool ignore_case) const noexcept {
594 if (ignore_case) return to_upper().chars_ == value.to_upper().chars_;
595 return chars_ == value.chars_;
596 }
597
601 bool ends_with(value_type value) const noexcept {return ends_with(value, false);}
606 bool ends_with(value_type value, bool ignore_case) const noexcept {
607 if (ignore_case) return to_lower().rfind(static_cast<value_type>(tolower(value))) == length() - 1;
608 return chars_.rfind(value) == length() - 1;
609 }
610
613 bool ends_with(const basic_string & value) const noexcept {return ends_with(value, xtd::string_comparison::ordinal);}
618 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);}
623 bool ends_with(const basic_string & value, xtd::string_comparison comparison_type) const noexcept {
624 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.rfind(value.to_lower()) + value.to_lower().length() == length();
625 return chars_.rfind(value) + value.length() == length();
626 }
627
631 size_type find(const basic_string & str) const {return chars_.find(str);}
637 size_type find(const basic_string & str, size_type pos) const {return chars_.find(str, pos);}
645 size_type find(const_pointer s, size_type pos, size_type count) const {return chars_.find(s, pos, count);}
651 size_type find(const_pointer s) const {return chars_.find(s);}
658 size_type find(const_pointer s, size_type pos) const {return chars_.find(s, pos);}
663 size_type find(value_type ch) const {return chars_.find(ch);}
669 size_type find(value_type ch, size_type pos) const {return chars_.find(ch, pos);}
670
675 size_type find_first_of(const basic_string & str) const {return chars_.find_first_of(str);}
681 size_type find_first_of(const basic_string & str, size_type pos) const {return chars_.find_first_of(str, pos);}
689 size_type find_first_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_first_of(s, pos, count);}
695 size_type find_first_of(const_pointer s) const {return chars_.find_first_of(s);}
702 size_type find_first_of(const_pointer s, size_type pos) const {return chars_.find_first_of(s, pos);}
707 size_type find_first_of(char_t ch) const {return chars_.find_first_of(ch);}
713 size_type find_first_of(char_t ch, size_type pos) const {return chars_.find_first_of(ch, pos);}
714
719 size_type find_first_not_of(const basic_string & str) const {return chars_.find_first_not_of(str);}
725 size_type find_first_not_of(const basic_string & str, size_type pos) const {return chars_.find_first_not_of(str, pos);}
733 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);}
739 size_type find_first_not_of(const_pointer s) const {return chars_.find_first_not_of(s);}
746 size_type find_first_not_of(const_pointer s, size_type pos) const {return chars_.find_first_not_of(s, pos);}
751 size_type find_first_not_of(char_t ch) const {return chars_.find_first_not_of(ch);}
757 size_type find_first_not_of(char_t ch, size_type pos) const {return chars_.find_first_not_of(ch, pos);}
758
763 size_type find_last_of(const basic_string & str) const {return chars_.find_last_of(str);}
769 size_type find_last_of(const basic_string & str, size_type pos) const {return chars_.find_last_of(str, pos);}
777 size_type find_last_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_last_of(s, pos, count);}
783 size_type find_last_of(const_pointer s) const {return chars_.find_last_of(s);}
790 size_type find_last_of(const_pointer s, size_type pos) const {return chars_.find_last_of(s, pos);}
795 size_type find_last_of(char_t ch) const {return chars_.find_last_of(ch);}
801 size_type find_last_of(char_t ch, size_type pos) const {return chars_.find_last_of(ch, pos);}
802
807 size_type find_last_not_of(const basic_string & str) const {return chars_.find_last_not_of(str);}
813 size_type find_last_not_of(const basic_string & str, size_type pos) const {return chars_.find_last_not_of(str, pos);}
821 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);}
827 size_type find_last_not_of(const_pointer s) const {return chars_.find_last_not_of(s);}
834 size_type find_last_not_of(const_pointer s, size_type pos) const {return chars_.find_last_not_of(s, pos);}
839 size_type find_last_not_of(char_t ch) const {return chars_.find_last_not_of(ch);}
845 size_type find_last_not_of(char_t ch, size_type pos) const {return chars_.find_last_not_of(ch, pos);}
846
849 allocator_type get_allocator() const {return chars_.get_allocator();}
850
853 virtual const base_type& get_base_type() const noexcept {return chars_;}
854
857 xtd::size get_hash_code() const noexcept override {return xtd::hash_code::combine(chars_);}
858
859 enumerator_type get_enumerator() const noexcept override {
860 struct basic_string_enumerator : public xtd::collections::generic::ienumerator<value_type> {
861 explicit basic_string_enumerator(const basic_string & chars) : chars_(chars) {}
862 const value_type& current() const override {
864 return chars_[index_];
865 }
866 bool move_next() override {return ++index_ < chars_.length();}
867 void reset() override {index_ = basic_string::npos;}
868
869 private:
870 const basic_string& chars_;
871 size_type index_ = basic_string::npos;
872 };
874 }
875
879 xtd::size index_of(const basic_string & value) const noexcept {return index_of(value, 0, length());}
884 xtd::size index_of(const basic_string & value, xtd::size start_index) const {return index_of(value, start_index, length() - start_index);}
891 xtd::size index_of(const basic_string & value, xtd::size start_index, xtd::size count) const {
893 auto result = find(value, start_index);
894 return result > start_index + count ? npos : result;
895 }
896
899 xtd::size index_of(value_type value) const noexcept {return index_of(value, 0, length());}
904 xtd::size index_of(value_type value, xtd::size start_index) const {return index_of(value, start_index, length() - start_index);}
913 auto result = find(value, start_index);
914 return result > start_index + count ? npos : result;
915 }
916
920 xtd::size index_of_any(const xtd::array<value_type>& values) const noexcept;
926 xtd::size index_of_any(const xtd::array<value_type>& values, xtd::size start_index) const;
935 xtd::size index_of_any(const std::initializer_list<value_type>& values) const noexcept;
936 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
937 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
939
946 basic_string insert(xtd::size start_index, const basic_string & value) const {
948 auto result = self_;
949 result.chars_.insert(start_index, value);
950 return result;
951 }
952
956 xtd::size last_index_of(const basic_string & value) const noexcept {return last_index_of(value, 0, length());}
962 xtd::size last_index_of(const basic_string & value, xtd::size start_index) const {return last_index_of(value, start_index, length() - start_index);}
969 xtd::size last_index_of(const basic_string & value, xtd::size start_index, xtd::size count) const {
971 auto result = chars_.rfind(value, start_index + count - value.length());
972 return result < start_index ? npos : result;
973 }
974
977 xtd::size last_index_of(value_type value) const noexcept {return last_index_of(value, 0, length());}
983 xtd::size last_index_of(value_type value, xtd::size start_index) const {return last_index_of(value, start_index, length() - start_index);}
993 auto result = chars_.rfind(value, start_index + count - 1);
994 return result < start_index ? npos : result;
995 }
996
1013 xtd::size last_index_of_any(const std::initializer_list<value_type>& values) const noexcept;
1014 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
1015 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
1017
1023 basic_string pad_left(xtd::size total_width) const noexcept {return pad_left(total_width, ' ');}
1030 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_;}
1031
1037 basic_string pad_right(xtd::size total_width) const noexcept {return pad_right(total_width, ' ');}
1044 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());}
1045
1050 basic_string quoted() const {return quoted('"', '\\');}
1055 basic_string quoted(value_type delimiter) const {return quoted(delimiter, '\\');}
1062 std::wstringstream ss;
1063 if constexpr(std::is_same_v<xtd::wchar, value_type>) ss << std::quoted(chars_, delimiter, escape);
1064 else ss << std::quoted(__xtd_convert_to_string<xtd::wchar>(chars_), static_cast<xtd::wchar>(delimiter), static_cast<xtd::wchar>(escape));
1065 return ss.str();
1066 }
1067
1071 basic_string remove(xtd::size start_index) const {return remove(start_index, length() - start_index);}
1078 auto result = self_;
1079 result.chars_.erase(start_index, count);
1080 return result;
1081 }
1082
1087 basic_string replace(value_type old_char, value_type new_char) const noexcept {return replace(string(old_char, 1), string(new_char, 1));}
1093 basic_string replace(const basic_string & old_string, const basic_string & new_string) const noexcept {
1094 auto result = self_;
1095 auto old_size = old_string.length();
1096 auto new_size = new_string.length();
1097 auto index = xtd::size {0};
1098 while (true) {
1099 index = result.find(old_string, index);
1100 if (index == npos) break;
1101 if (old_size == new_size) result.chars_.replace(index, old_size, new_string);
1102 else {
1103 result.chars_.erase(index, old_string.length());
1104 result.chars_.insert(index, new_string);
1105 }
1106 index += new_string.length();
1107 }
1108 return result;
1109 }
1110
1114 size_type rfind(const basic_string & str) const {return chars_.rfind(str);}
1120 size_type rfind(const basic_string & str, size_type pos) const {return chars_.rfind(str, pos);}
1128 size_type rfind(const_pointer s, size_type pos, size_type count) const {return chars_.rfind(s, pos, count);}
1134 size_type rfind(const_pointer s) const {return chars_.rfind(s);}
1141 size_type rfind(const_pointer s, size_type pos) const {return chars_.rfind(s, pos);}
1146 size_type rfind(value_type ch) const {return chars_.rfind(ch);}
1152 size_type rfind(value_type ch, size_type pos) const {return chars_.rfind(ch, pos);}
1153
1208 xtd::array<basic_string> split(const xtd::array<value_type>& separators) const noexcept;
1225 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::string_split_options options) const noexcept;
1234 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count) const noexcept;
1246 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count, xtd::string_split_options options) const noexcept;
1247
1252 bool starts_with(value_type value) const noexcept {return starts_with(value, false);}
1258 bool starts_with(value_type value, bool ignore_case) const noexcept {
1259 if (ignore_case) return to_lower().find(static_cast<value_type>(tolower(value))) == 0;
1260 return find(value) == 0;
1261 }
1262
1266 bool starts_with(const basic_string & value) const noexcept {return starts_with(value, string_comparison::ordinal);}
1272 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);}
1277 bool starts_with(const basic_string & value, xtd::string_comparison comparison_type) const noexcept {
1278 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().find(value.to_lower()) == 0;
1279 return find(value) == 0;
1280 }
1281
1286 basic_string substr() const {return chars_.substr();}
1292 basic_string substr(size_type pos) const {
1294 return chars_.substr(pos);
1295 }
1296
1302 basic_string substr(size_type pos, size_type count) const {
1304 return chars_.substr(pos, count);
1305 }
1306
1312 basic_string substring(xtd::size start_index) const {
1314 return substr(start_index);
1315 }
1316
1322 if (start_index > self_.length() || start_index + length > self_.length()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1323 return substr(start_index, length);
1324 }
1325
1332 xtd::array<value_type> to_array(xtd::size start_index) const;
1337 xtd::array<value_type> to_array(xtd::size start_index, xtd::size length) const;
1338
1341 xtd::array<value_type> to_char_array() const noexcept;
1347
1350 basic_string to_lower() const noexcept {
1351 auto result = basic_string::empty_string;
1352 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::tolower(c));});
1353 return result;
1354 }
1355
1359 basic_string<char> to_string() const noexcept override {
1360 if constexpr(std::is_same_v<char, char_t>) return chars_;
1361 else return __xtd_convert_to_string<char>(chars_);
1362 }
1363
1366 basic_string to_title_case() const noexcept;
1367
1371 if constexpr(std::is_same_v<xtd::char16, char_t>) return chars_;
1372 else return __xtd_convert_to_string<xtd::char16>(chars_);
1373 }
1374
1378 if constexpr(std::is_same_v<xtd::char32, char_t>) return chars_;
1379 else return __xtd_convert_to_string<xtd::char32>(chars_);
1380 }
1381
1385 if constexpr(std::is_same_v<xtd::char8, char_t>) return chars_;
1386 else return __xtd_convert_to_string<xtd::char8>(chars_);
1387 }
1388
1391 basic_string to_upper() const noexcept {
1392 auto result = basic_string::empty_string;
1393 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::toupper(c));});
1394 return result;
1395 }
1396
1400 if constexpr(std::is_same_v<xtd::wchar, char_t>) return chars_;
1401 else return __xtd_convert_to_string<xtd::wchar>(chars_);
1402 }
1403
1408 basic_string trim() const noexcept {return trim(default_trim_chars);}
1413 basic_string trim(value_type trim_char) const noexcept;
1418 basic_string trim(const xtd::array<value_type>& trim_chars) const noexcept;
1419
1424 basic_string trim_end() const noexcept {return trim_end(default_trim_chars);}
1429 basic_string trim_end(value_type trim_char) const noexcept;
1434 basic_string trim_end(const xtd::array<value_type>& trim_chars) const noexcept;
1435
1440 basic_string trim_start() const noexcept {return trim_start(default_trim_chars);}
1445 basic_string trim_start(value_type trim_char) const noexcept;
1450 basic_string trim_start(const xtd::array<value_type>& trim_chars) const noexcept;
1452
1454
1465 static int32 compare(const basic_string & str_a, const basic_string & str_b) noexcept {return compare(str_a, str_b, false);}
1476 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);}
1487 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);}
1500 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);}
1514 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);}
1528 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));}
1529
1536 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;}
1543 template<class object_a_t, class object_b_t, class object_c_t, class object_d_t>
1544 inline 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);}
1550 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;}
1556 template<class object_a_t, class object_b_t, class object_c_t>
1557 inline 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);}
1562 static basic_string concat(const basic_string & str_a, const basic_string & str_b) noexcept {return str_a + str_b;}
1567 template<class object_a_t, class object_b_t>
1568 inline static basic_string concat(object_a_t obj_a, object_b_t obj_b) noexcept {return format("{}{}", obj_a, obj_b);}
1572 static basic_string concat(const xtd::array<basic_string>& values) noexcept;
1574 static basic_string concat(const xtd::array<const_pointer>& values) noexcept;
1575 template<class other_char_t>
1576 inline static basic_string concat(const xtd::array<const other_char_t*>& values) noexcept;
1577 static basic_string concat(const std::initializer_list<basic_string>& values) noexcept {
1578 auto result = basic_string::empty_string;
1579 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
1580 return result;
1581 }
1582 static basic_string concat(const std::initializer_list<const_pointer>& values) noexcept {
1583 auto result = basic_string::empty_string;
1584 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
1585 return result;
1586 }
1587 template<class other_char_t>
1588 inline static basic_string concat(const std::initializer_list<const other_char_t*>& values) noexcept {
1589 auto result = basic_string::empty_string;
1590 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
1591 return result;
1592 }
1597 template<class object_t>
1598 inline static basic_string concat(const xtd::array<object_t>& args) noexcept;
1600 template<class object_t>
1601 inline static basic_string concat(const std::initializer_list<object_t>& args) noexcept {
1602 basic_string result;
1603 for (const auto& arg : args)
1604 result += format("{}", arg);
1605 return result;
1606 }
1611 template<class value_t>
1612 inline static basic_string concat(value_t value) noexcept {
1613 return format("{}", value);
1614 }
1615
1636 static basic_string demangle(const basic_string & name) {
1637 if constexpr(std::is_same_v<char, char_t>) return __xtd_demangle(name.chars());
1638 else return __xtd_demangle(__xtd_convert_to_string<char>(name.chars()));
1639 }
1640
1646 static bool equals(const basic_string & a, const basic_string & b) noexcept {return a.equals(b);}
1652 template<class char_a_t, class char_b_t>
1653 inline static bool equals(const char_a_t* a, const char_b_t* b) noexcept {return basic_string {a}.equals(basic_string {b});}
1654
1661 static bool equals(const basic_string & a, const basic_string & b, bool ignore_case) noexcept {return a.equals(b, ignore_case);}
1668 template<class char_a_t, class char_b_t>
1669 inline 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);}
1670
1677 template<class ...args_t>
1678 inline static basic_string format(const basic_string<char>& fmt, args_t&& ... args);
1679
1687 template<class ...args_t>
1688 inline static basic_string format(const std::locale & loc, const basic_string<char>& fmt, args_t&& ... args);
1689
1693 static bool is_empty(const xtd::basic_string<value_type, traits_type, allocator_type>& string) noexcept {return !string.length();}
1694
1701 template<class collection_t>
1702 inline static basic_string join(const basic_string & separator, const collection_t& values) noexcept {
1703 xtd::size i = 0;
1704 basic_string result;
1705 for (const auto& item : values)
1706 result += format("{}{}", (i++ != 0 ? separator : basic_string {}), item);
1707 return result;
1708 }
1709
1716 template<class collection_t>
1717 inline static basic_string join(const basic_string & separator, const collection_t& values, xtd::size index) {return join(separator, values, index, values.size() - index);}
1726 template<class collection_t>
1727 inline static basic_string join(const basic_string & separator, const collection_t& values, xtd::size index, xtd::size count) {
1728 if (index > values.size() || index + count > values.size()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1729 xtd::size i = 0;
1730 basic_string result;
1731 for (const auto& item : values) {
1732 if (i >= index) result += format("{}{}", (i != index ? separator : basic_string {}), item);
1733 if (++i >= index + count) break;
1734 }
1735 return result;
1736 }
1737
1739 template<class value_t>
1740 inline static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values) noexcept;
1741 template<class value_t>
1742 inline static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values, xtd::size index);
1743 template<class value_t>
1744 inline static basic_string join(const basic_string & separator, const std::initializer_list<value_t>& values, xtd::size index, xtd::size count);
1746
1750 template<class value_t>
1751 inline static value_t parse(const basic_string & str) {
1752 if constexpr(std::is_same_v<char, char_t>) return xtd::parse<value_t>(str.chars());
1753 else return xtd::parse<value_t>(__xtd_convert_to_string<char>(str.chars()));
1754 }
1755
1815 template<class ...args_t>
1816 inline 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)) ...);}
1817
1822 template<class value_t>
1823 inline static bool try_parse(const basic_string & str, value_t& value) noexcept {
1824 try {
1825 value = parse<value_t>(str);
1826 return true;
1827 } catch (...) {
1828 return false;
1829 }
1830 }
1831
1832
1834
1840 const_reference operator [](xtd::size index) const {
1842 return chars_[index == epos ? length() - 1 : index];
1843 }
1844
1847 operator const base_type& () const noexcept {return chars_;}
1848
1853 if constexpr(std::is_same<char_t, char>::value) chars_ = str.chars_;
1854 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1855 return self_;
1856 }
1857
1861 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str.chars_;
1862 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1863 return self_;
1864 }
1865
1869 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str.chars_;
1870 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1871 return self_;
1872 }
1873
1877 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str.chars_;
1878 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1879 return self_;
1880 }
1881
1885 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str.chars_;
1886 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1887 return self_;
1888 }
1889
1894 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str.chars_);
1895 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1896 return self_;
1897 }
1898
1902 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str.chars_);
1903 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1904 return self_;
1905 }
1906
1910 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str.chars_);
1911 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1912 return self_;
1913 }
1914
1918 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str.chars_);
1919 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1920 return self_;
1921 }
1922
1926 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str.chars_);
1927 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1928 return self_;
1929 }
1930
1934 basic_string& operator =(const std::basic_string<char>& str) noexcept {
1935 if constexpr(std::is_same<char_t, char>::value) chars_ = str;
1936 else chars_ = __xtd_convert_to_string<value_type>(str);
1937 return self_;
1938 }
1939
1942 basic_string& operator =(const std::basic_string<xtd::char16>& str) noexcept {
1943 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str;
1944 else chars_ = __xtd_convert_to_string<value_type>(str);
1945 return self_;
1946 }
1947
1950 basic_string& operator =(const std::basic_string<xtd::char32>& str) noexcept {
1951 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str;
1952 else chars_ = __xtd_convert_to_string<value_type>(str);
1953 return self_;
1954 }
1955
1958 basic_string& operator =(const std::basic_string<xtd::char8>& str) noexcept {
1959 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str;
1960 else chars_ = __xtd_convert_to_string<value_type>(str);
1961 return self_;
1962 }
1963
1966 basic_string& operator =(const std::basic_string<xtd::wchar>& str) noexcept {
1967 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str;
1968 else chars_ = __xtd_convert_to_string<value_type>(str);
1969 return self_;
1970 }
1971
1975 basic_string& operator =(std::basic_string<char>&& str) noexcept {
1976 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str);
1977 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1978 return self_;
1979 }
1980
1983 basic_string& operator =(std::basic_string<xtd::char16>&& str) noexcept {
1984 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str);
1985 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1986 return self_;
1987 }
1988
1991 basic_string& operator =(std::basic_string<xtd::char32>&& str) noexcept {
1992 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str);
1993 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1994 return self_;
1995 }
1996
1999 basic_string& operator =(std::basic_string<xtd::char8>&& str) noexcept {
2000 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str);
2001 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2002 return self_;
2003 }
2004
2007 basic_string& operator =(std::basic_string<xtd::wchar>&& str) noexcept {
2008 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str);
2009 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2010 return self_;
2011 }
2012
2017 basic_string& operator =(const char* str) {
2019 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
2020 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
2021 return self_;
2022 }
2023
2029 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
2030 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
2031 return self_;
2032 }
2033
2039 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
2040 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
2041 return self_;
2042 }
2043
2049 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
2050 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
2051 return self_;
2052 }
2053
2059 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
2060 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
2061 return self_;
2062 }
2063
2067 basic_string& operator =(char character) {
2068 self_ = basic_string(character, 1);
2069 return self_;
2070 }
2071
2075 self_ = basic_string(character, 1);
2076 return self_;
2077 }
2078
2082 self_ = basic_string(character, 1);
2083 return self_;
2084 }
2085
2089 self_ = basic_string(character, 1);
2090 return self_;
2091 }
2092
2096 self_ = basic_string(character, 1);
2097 return self_;
2098 }
2099
2103 basic_string& operator =(const std::initializer_list<char>& il) {
2104 self_ = basic_string(il);
2105 return self_;
2106 }
2107
2110 basic_string& operator =(const std::initializer_list<xtd::char16>& il) {
2111 self_ = basic_string(il);
2112 return self_;
2113 }
2114
2117 basic_string& operator =(const std::initializer_list<xtd::char32>& il) {
2118 self_ = basic_string(il);
2119 return self_;
2120 }
2121
2124 basic_string& operator =(const std::initializer_list<xtd::char8>& il) {
2125 self_ = basic_string(il);
2126 return self_;
2127 }
2128
2131 basic_string& operator =(const std::initializer_list<xtd::wchar>& il) {
2132 self_ = basic_string(il);
2133 return self_;
2134 }
2135
2140 if constexpr(std::is_same_v<char, char_t>) chars_ += str.chars_;
2141 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2142 return self_;
2143 }
2144
2148 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str.chars_;
2149 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2150 return self_;
2151 }
2152
2156 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str.chars_;
2157 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2158 return self_;
2159 }
2160
2164 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str.chars_;
2165 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2166 return self_;
2167 }
2168
2172 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str.chars_;
2173 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2174 return self_;
2175 }
2176
2181 if constexpr(std::is_same_v<char, char_t>) chars_ += std::move(str.chars_);
2182 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2183 return self_;
2184 }
2185
2189 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += std::move(str.chars_);
2190 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2191 return self_;
2192 }
2193
2197 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += std::move(str.chars_);
2198 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2199 return self_;
2200 }
2201
2205 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += std::move(str.chars_);
2206 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2207 return self_;
2208 }
2209
2213 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += std::move(str.chars_);
2214 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2215 return self_;
2216 }
2217
2221 basic_string& operator +=(const std::basic_string<char>& str) {
2222 if constexpr(std::is_same_v<char, char_t>) chars_ += str;
2223 else chars_ += __xtd_convert_to_string<value_type>(str);
2224 return self_;
2225 }
2226
2229 basic_string& operator +=(const std::basic_string<xtd::char16>& str) {
2230 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str;
2231 else chars_ += __xtd_convert_to_string<value_type>(str);
2232 return self_;
2233 }
2234
2237 basic_string& operator +=(const std::basic_string<xtd::char32>& str) {
2238 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str;
2239 else chars_ += __xtd_convert_to_string<value_type>(str);
2240 return self_;
2241 }
2242
2245 basic_string& operator +=(const std::basic_string<xtd::char8>& str) {
2246 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str;
2247 else chars_ += __xtd_convert_to_string<value_type>(str);
2248 return self_;
2249 }
2250
2253 basic_string& operator +=(const std::basic_string<xtd::wchar>& str) {
2254 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str;
2255 else chars_ += __xtd_convert_to_string<value_type>(str);
2256 return self_;
2257 }
2258
2262 basic_string& operator +=(const char* str) {
2263 chars_ += basic_string(str).chars_;
2264 return self_;
2265 }
2266
2270 chars_.append(basic_string(str).chars_); return self_;
2271 }
2272
2276 chars_ += basic_string(str).chars_;
2277 return self_;
2278 }
2279
2283 chars_ += basic_string(str).chars_;
2284 return self_;
2285 }
2286
2290 chars_ += basic_string(str).chars_;
2291 return self_;
2292 }
2293
2297 chars_ += basic_string(ch, 1).chars_;
2298 return self_;
2299 }
2300
2304 chars_ += basic_string(ch, 1).chars_;
2305 return self_;
2306 }
2307
2311 chars_ += basic_string(ch, 1).chars_;
2312 return self_;
2313 }
2314
2318 chars_ += basic_string(ch, 1).chars_;
2319 return self_;
2320 }
2321
2325 chars_ += basic_string(ch, 1).chars_;
2326 return self_;
2327 }
2328
2333 friend basic_string operator +(const basic_string & lhs, const basic_string<char>& rhs) {
2334 auto result = lhs;
2335 result += rhs;
2336 return result;
2337 }
2338
2343 auto result = lhs;
2344 result += rhs;
2345 return result;
2346 }
2347
2352 auto result = lhs;
2353 result += rhs;
2354 return result;
2355 }
2356
2361 auto result = lhs;
2362 result += rhs;
2363 return result;
2364 }
2365
2370 auto result = lhs;
2371 result += rhs;
2372 return result;
2373 }
2374
2380 auto result = std::move(lhs);
2381 result += std::move(rhs);
2382 return result;
2383 }
2384
2389 auto result = std::move(lhs);
2390 result += std::move(rhs);
2391 return result;
2392 }
2393
2398 auto result = std::move(lhs);
2399 result += std::move(rhs);
2400 return result;
2401 }
2402
2407 auto result = std::move(lhs);
2408 result += std::move(rhs);
2409 return result;
2410 }
2411
2416 auto result = std::move(lhs);
2417 result += std::move(rhs);
2418 return result;
2419 }
2420
2426 auto result = std::move(lhs);
2427 result += rhs;
2428 return result;
2429 }
2430
2435 auto result = std::move(lhs);
2436 result += rhs;
2437 return result;
2438 }
2439
2444 auto result = std::move(lhs);
2445 result += rhs;
2446 return result;
2447 }
2448
2453 auto result = std::move(lhs);
2454 result += rhs;
2455 return result;
2456 }
2457
2462 auto result = std::move(lhs);
2463 result += rhs;
2464 return result;
2465 }
2466
2472 auto result = lhs;
2473 result += std::move(rhs);
2474 return result;
2475 }
2476
2481 auto result = lhs;
2482 result += std::move(rhs);
2483 return result;
2484 }
2485
2490 auto result = lhs;
2491 result += std::move(rhs);
2492 return result;
2493 }
2494
2499 auto result = lhs;
2500 result += std::move(rhs);
2501 return result;
2502 }
2503
2508 auto result = lhs;
2509 result += std::move(rhs);
2510 return result;
2511 }
2512
2517 friend basic_string operator +(const basic_string & lhs, const std::basic_string<char>& rhs) {
2518 auto result = lhs;
2519 result += rhs;
2520 return result;
2521 }
2522
2526 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char16>& rhs) {
2527 auto result = lhs;
2528 result += rhs;
2529 return result;
2530 }
2531
2535 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char32>& rhs) {
2536 auto result = lhs;
2537 result += rhs;
2538 return result;
2539 }
2540
2544 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::char8>& rhs) {
2545 auto result = lhs;
2546 result += rhs;
2547 return result;
2548 }
2549
2553 friend basic_string operator +(const basic_string & lhs, const std::basic_string<xtd::wchar>& rhs) {
2554 auto result = lhs;
2555 result += rhs;
2556 return result;
2557 }
2558
2563 friend basic_string operator +(const std::basic_string<char>& lhs, const basic_string & rhs) {
2564 auto result = lhs;
2565 if constexpr(std::is_same_v<char, char_t>) result += rhs.chars();
2566 else result += __xtd_convert_to_string<char>(rhs.chars());
2567 return result;
2568 }
2569
2573 friend basic_string operator +(const std::basic_string<xtd::char16>& lhs, const basic_string & rhs) {
2574 auto result = lhs;
2575 if constexpr(std::is_same_v<xtd::char16, char_t>) result += rhs.chars();
2576 else result += __xtd_convert_to_string<xtd::char16>(rhs.chars());
2577 return result;
2578 }
2579
2583 friend basic_string operator +(const std::basic_string<xtd::char32>& lhs, const basic_string & rhs) {
2584 auto result = lhs;
2585 if constexpr(std::is_same_v<xtd::char32, char_t>) result += rhs.chars();
2586 else result += __xtd_convert_to_string<xtd::char32>(rhs.chars());
2587 return result;
2588 }
2589
2593 friend basic_string operator +(const std::basic_string<xtd::char8>& lhs, const basic_string & rhs) {
2594 auto result = lhs;
2595 if constexpr(std::is_same_v<xtd::char8, char_t>) result += rhs.chars();
2596 else result += __xtd_convert_to_string<xtd::char8>(rhs.chars());
2597 return result;
2598 }
2599
2603 friend basic_string operator +(const std::basic_string<xtd::wchar>& lhs, const basic_string & rhs) {
2604 auto result = lhs;
2605 if constexpr(std::is_same_v<xtd::wchar, char_t>) result += rhs.chars();
2606 else result += __xtd_convert_to_string<xtd::wchar>(rhs.chars());
2607 return result;
2608 }
2609
2614 friend basic_string operator +(const basic_string & lhs, const char* rhs) {
2615 auto result = lhs;
2616 result += rhs;
2617 return result;
2618 }
2619
2623 friend basic_string operator +(const basic_string & lhs, const xtd::char16 * rhs) {
2624 auto result = lhs;
2625 result += rhs;
2626 return result;
2627 }
2628
2632 friend basic_string operator +(const basic_string & lhs, const xtd::char32 * rhs) {
2633 auto result = lhs;
2634 result += rhs;
2635 return result;
2636 }
2637
2641 friend basic_string operator +(const basic_string & lhs, const xtd::char8 * rhs) {
2642 auto result = lhs;
2643 result += rhs;
2644 return result;
2645 }
2646
2650 friend basic_string operator +(const basic_string & lhs, const xtd::wchar * rhs) {
2651 auto result = lhs;
2652 result += rhs;
2653 return result;
2654 }
2655
2660 friend basic_string operator +(basic_string&& lhs, const char* rhs) {
2661 auto result = std::move(lhs);
2662 result += rhs;
2663 return result;
2664 }
2665
2670 auto result = std::move(lhs);
2671 result += rhs;
2672 return result;
2673 }
2674
2679 auto result = std::move(lhs);
2680 result += rhs;
2681 return result;
2682 }
2683
2687 friend basic_string operator +(basic_string&& lhs, const xtd::char8 * rhs) {
2688 auto result = std::move(lhs);
2689 result += rhs;
2690 return result;
2691 }
2692
2696 friend basic_string operator +(basic_string&& lhs, const xtd::wchar * rhs) {
2697 auto result = std::move(lhs);
2698 result += rhs;
2699 return result;
2700 }
2701
2706 friend basic_string operator +(const char* lhs, const basic_string & rhs) {
2707 auto result = basic_string(lhs);
2708 result += rhs;
2709 return result;
2710 }
2711
2715 friend basic_string operator +(const xtd::char16 * lhs, const basic_string & rhs) {
2716 auto result = basic_string(lhs);
2717 result += rhs;
2718 return result;
2719 }
2720
2724 friend basic_string operator +(const xtd::char32 * lhs, const basic_string & rhs) {
2725 auto result = basic_string(lhs);
2726 result += rhs;
2727 return result;
2728 }
2729
2733 friend basic_string operator +(const xtd::char8 * lhs, const basic_string & rhs) {
2734 auto result = basic_string(lhs);
2735 result += rhs;
2736 return result;
2737 }
2738
2742 friend basic_string operator +(const xtd::wchar * lhs, const basic_string & rhs) {
2743 auto result = basic_string(lhs);
2744 result += rhs;
2745 return result;
2746 }
2747
2752 friend basic_string operator +(const char* lhs, basic_string&& rhs) {
2753 auto result = basic_string(lhs);
2754 result += std::move(rhs);
2755 return result;
2756 }
2757
2762 auto result = basic_string(lhs);
2763 result += std::move(rhs);
2764 return result;
2765 }
2766
2771 auto result = basic_string(lhs);
2772 result += std::move(rhs);
2773 return result;
2774 }
2775
2779 friend basic_string operator +(const xtd::char8 * lhs, basic_string&& rhs) {
2780 auto result = basic_string(lhs);
2781 result += std::move(rhs);
2782 return result;
2783 }
2784
2788 friend basic_string operator +(const xtd::wchar * lhs, basic_string&& rhs) {
2789 auto result = basic_string(lhs);
2790 result += std::move(rhs);
2791 return result;
2792 }
2793
2798 friend basic_string operator +(const basic_string & lhs, const char rhs) {
2799 auto result = lhs;
2800 result += rhs;
2801 return result;
2802 }
2803
2807 friend basic_string operator +(const basic_string & lhs, const xtd::char16 rhs) {
2808 auto result = lhs;
2809 result += rhs;
2810 return result;
2811 }
2812
2816 friend basic_string operator +(const basic_string & lhs, const xtd::char32 rhs) {
2817 auto result = lhs;
2818 result += rhs;
2819 return result;
2820 }
2821
2825 friend basic_string operator +(const basic_string & lhs, const xtd::char8 rhs) {
2826 auto result = lhs;
2827 result += rhs;
2828 return result;
2829 }
2830
2834 friend basic_string operator +(const basic_string & lhs, const xtd::wchar rhs) {
2835 auto result = lhs;
2836 result += rhs;
2837 return result;
2838 }
2839
2844 friend basic_string operator +(basic_string&& lhs, const char rhs) {
2845 auto result = std::move(lhs);
2846 result += rhs;
2847 return result;
2848 }
2849
2854 auto result = std::move(lhs);
2855 result += rhs;
2856 return result;
2857 }
2858
2863 auto result = std::move(lhs);
2864 result += rhs;
2865 return result;
2866 }
2867
2872 auto result = std::move(lhs);
2873 result += rhs;
2874 return result;
2875 }
2876
2881 auto result = std::move(lhs);
2882 result += rhs;
2883 return result;
2884 }
2885
2890 friend basic_string operator +(char lhs, const basic_string & rhs) {
2891 auto result = basic_string(lhs, 1);
2892 result += rhs;
2893 return result;
2894 }
2895
2900 auto result = basic_string(lhs, 1);
2901 result += rhs;
2902 return result;
2903 }
2904
2909 auto result = basic_string(lhs, 1);
2910 result += rhs;
2911 return result;
2912 }
2913
2918 auto result = basic_string(lhs, 1);
2919 result += rhs;
2920 return result;
2921 }
2922
2927 auto result = basic_string(lhs, 1);
2928 result += rhs;
2929 return result;
2930 }
2931
2936 friend basic_string operator +(char lhs, basic_string&& rhs) {
2937 auto result = basic_string(lhs, 1);
2938 result += std::move(rhs);
2939 return result;
2940 }
2941
2946 auto result = basic_string(lhs, 1);
2947 result += std::move(rhs);
2948 return result;
2949 }
2950
2955 auto result = basic_string(lhs, 1);
2956 result += std::move(rhs);
2957 return result;
2958 }
2959
2964 auto result = basic_string(lhs, 1);
2965 result += std::move(rhs);
2966 return result;
2967 }
2968
2973 auto result = basic_string(lhs, 1);
2974 result += std::move(rhs);
2975 return result;
2976 }
2977
2986 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
2987 friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string & str) {
2988 if constexpr(std::is_same_v<char, char_t>) return stream << str.chars();
2989 else return stream << __xtd_convert_to_string<char>(str.chars());
2990 }
2991
2997 friend std::basic_ostream<xtd::wchar>& operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string & str) {return stream << str.to_wstring().chars();}
2998
3007 friend std::basic_istream<char>& operator >>(std::basic_istream<char>& stream, basic_string & str) {
3008 auto s = std::basic_string<char> {};
3009 stream >> s;
3010 str = s;
3011 return stream;
3012 }
3013
3021 friend std::basic_istream<xtd::wchar>& operator >>(std::basic_istream<xtd::wchar>& stream, basic_string & str) {
3022 auto s = std::basic_string<xtd::wchar> {};
3023 stream >> s;
3024 str = s;
3025 return stream;
3026 }
3027
3028
3030
3034 [[deprecated("Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 0.4.0.")]]
3035 bool is_empty() const noexcept {return is_empty(self_);}
3041
3043
3044 template<class object_t>
3045 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 0.4.0.")]]
3046 static basic_string class_name() {return get_class_name(full_class_name<object_t>());}
3051 template<class object_t>
3052 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 0.4.0.")]]
3053 static basic_string class_name(const object_t& object) {return get_class_name(full_class_name(object));}
3058 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 0.4.0.")]]
3059 static basic_string class_name(const std::type_info & info) {return __xtd_get_class_name(info);}
3064 template<class object_t>
3065 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 0.4.0.")]]
3066 static basic_string full_class_name() {return demangle(typeid(object_t).name());}
3071 template<class object_t>
3072 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 0.4.0.")]]
3073 static basic_string full_class_name(const object_t& object) {return demangle(typeid(object).name());}
3078 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 0.4.0.")]]
3079 static basic_string full_class_name(const std::type_info & info) {return __xtd_get_full_class_name(info);}
3081
3082 private:
3083 friend class basic_string<char>;
3084 friend class basic_string<xtd::char16>;
3085 friend class basic_string<xtd::char32>;
3086 friend class basic_string<xtd::char8>;
3087 friend class basic_string<xtd::wchar>;
3088
3089 static const xtd::array<value_type> default_split_separators;
3090 static const xtd::array<value_type> default_trim_chars;
3091
3092 template<class arg_t>
3093 inline static auto convert_param(arg_t&& arg) noexcept {
3094 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();
3095 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();
3096 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();
3097 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();
3098 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();
3099 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();
3100 else return std::forward<arg_t>(arg);
3101 }
3102
3103 static basic_string get_class_name(const basic_string & full_name) {
3104 auto length = full_name.last_index_of("<");
3105 if (length == npos) length = full_name.length();
3106 if (full_name.last_index_of("::", 0, length) == npos) return full_name;
3107 return full_name.substring(full_name.last_index_of("::", 0, length) + 2);
3108 }
3109
3110 base_type chars_;
3111 };
3112}
3113
3114#define __XTD_BASIC_STRING_INTERNAL__
3115#include "basic_string_.hpp"
3116#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:64
Represents text as a sequence of character units.
Definition basic_string.hpp:67
basic_string trim(value_type trim_char) const noexcept
Removes all leading and trailing occurrences of a character specified from the specified xtd::basic_s...
static basic_string concat(object_a_t obj_a, object_b_t obj_b) noexcept
Concatenates two specified instances of object.
Definition basic_string.hpp:1568
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:899
static int32 compare(const basic_string &str_a, const basic_string &str_b, xtd::string_comparison comparison_type) noexcept
Compares two specified basic_string objects using the specified rules, and returns an integer that in...
Definition basic_string.hpp:1487
basic_string trim_end(const xtd::array< value_type > &trim_chars) const noexcept
Removes all trailing occurrences of a set of characters specified in an array from the specified xtd:...
basic_string to_lower() const noexcept
Returns a copy of the current xtd::basic_string converted to lowercase.
Definition basic_string.hpp:1350
static value_t parse(const basic_string &str)
Converts a basic_string into a value_t type.
Definition basic_string.hpp:1751
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:1023
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:623
static basic_string class_name(const object_t &object)
Gets the class name of the specified object.
Definition basic_string.hpp:3053
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:821
allocator_type get_allocator() const
Returns the allocator associated with the string.
Definition basic_string.hpp:849
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:911
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:904
basic_string trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified xtd::basic_...
Definition basic_string.hpp:1408
xtd::array< basic_string > split() const noexcept
Splits this basic_string into substrings that are based on the default white-space characters....
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:675
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...
basic_string substring(xtd::size start_index, xtd::size length) const
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.hpp:1321
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:801
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:606
enumerator_type get_enumerator() const noexcept override
Returns an enumerator that iterates through a collection.
Definition basic_string.hpp:859
static basic_string demangle(const basic_string &name)
Gets demangled basic_string of name,.
Definition basic_string.hpp:1636
size_type rfind(const_pointer s, size_type pos, size_type count) const
Finds the last substring that is equal to the given character sequence. The search begins at pos and ...
Definition basic_string.hpp:1128
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:845
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:1134
size_type rfind(const basic_string &str) const
Finds the last substring that is equal to the given character sequence. The search begins at xtd::bas...
Definition basic_string.hpp:1114
static bool try_parse(const basic_string &str, value_t &value) noexcept
Try to convert a basic_string into a value_t type.
Definition basic_string.hpp:1823
virtual const base_type & get_base_type() const noexcept
Returns the underlying base type.
Definition basic_string.hpp:853
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:746
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:962
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:783
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:3079
friend std::basic_istream< char > & operator>>(std::basic_istream< char > &stream, basic_string &str)
Input stream operator. Behaves as a FormattedInputFunction. After constructing and checking the sentr...
Definition basic_string.hpp:3007
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:790
static basic_string join(const basic_string &separator, const collection_t &values) noexcept
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:1702
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:719
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
Concatenates four specified instances of object.
Definition basic_string.hpp:1544
bool starts_with(const basic_string &value) const noexcept
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.hpp:1266
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:577
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:681
static bool equals(const basic_string &a, const basic_string &b, bool ignore_case) noexcept
Determines whether two specified xtd::basic_string objects have the same value, ignoring or honoring ...
Definition basic_string.hpp:1661
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:946
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:702
basic_string to_upper() const noexcept
Returns a copy of the current xtd::basic_string converted to uppercase.
Definition basic_string.hpp:1391
int32 compare(size_type pos1, size_type count1, const_pointer s, size_type count2) const
Compares two character sequences.
Definition basic_string.hpp:545
basic_string trim_start(value_type trim_char) const noexcept
Removes all leading occurrences of a character specified from the specified xtd::basic_string .
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:969
static basic_string join(const basic_string &separator, const collection_t &values, xtd::size index, xtd::size count)
Concatenates a specified separator basic_string between each element of a specified Object array,...
Definition basic_string.hpp:1727
basic_string substring(xtd::size start_index) const
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.hpp:1312
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:751
basic_string substr(size_type pos, size_type count) const
Returns a substring [pos, pos + count). If the requested substring extends past the end of the string...
Definition basic_string.hpp:1302
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:568
xtd::array< value_type > to_char_array() const noexcept
basic_string quoted() const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML.
Definition basic_string.hpp:1050
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)
Compares substrings of two specified basic_string objects using the specified rules,...
Definition basic_string.hpp:1528
basic_string< char > to_string() const noexcept override
Converts the value of this instance to a xtd::basic_string <char>.
Definition basic_string.hpp:1359
static basic_string join(const basic_string &separator, const collection_t &values, xtd::size index)
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:1717
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:651
basic_string< xtd::wchar > to_wstring() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::wchar>.
Definition basic_string.hpp:1399
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:1071
friend std::basic_ostream< char > & operator<<(std::basic_ostream< char > &stream, const basic_string &str)
Output stream operator. Behaves as a FormattedOutputFunction. After constructing and checking the sen...
Definition basic_string.hpp:2987
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:839
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:1076
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:977
static basic_string class_name()
Gets the class name of the object_t.
Definition basic_string.hpp:3046
static basic_string class_name(const std::type_info &info)
Gets the class name of the specified object.
Definition basic_string.hpp:3059
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:827
basic_string trim_start(const xtd::array< value_type > &trim_chars) const noexcept
Removes all leading occurrences of a set of characters specified in an array from the specified xtd::...
static bool equals(const basic_string &a, const basic_string &b) noexcept
Determines whether two specified xtd::basic_string objects have the same value.
Definition basic_string.hpp:1646
bool is_empty() const noexcept
Name Public Deprecated Methods.
Definition basic_string.hpp:3035
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:663
size_type rfind(value_type ch, 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:1152
static int32 compare(const basic_string &str_a, const basic_string &str_b, bool ignore_case) noexcept
Compares two specified basic_string objects, ignoring or honoring their case, and returns an integer ...
Definition basic_string.hpp:1476
static int32 compare(const basic_string &str_a, const basic_string &str_b) noexcept
Compares two specified basic_string objects and returns an integer that indicates their relative posi...
Definition basic_string.hpp:1465
static basic_string concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c) noexcept
Concatenates three specified instances of basic_string.
Definition basic_string.hpp:1550
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:1055
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:556
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:1044
static bool equals(const char_a_t *a, const char_b_t *b, bool ignore_case) noexcept
Determines whether two specified xtd::basic_string objects have the same value, ignoring or honoring ...
Definition basic_string.hpp:1669
static basic_string concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept
Concatenates three specified instances of object.
Definition basic_string.hpp:1557
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:1093
xtd::size get_hash_code() const noexcept override
Returns the hash code for this basic_string.
Definition basic_string.hpp:857
bool starts_with(value_type value, bool ignore_case) const noexcept
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.hpp:1258
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:573
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:807
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:725
bool ends_with(value_type value) const noexcept
Determines whether the end of this basic_string matches the specified character.
Definition basic_string.hpp:601
size_type rfind(value_type ch) const
Finds the last substring that is equal to the given character sequence. The search begins at xtd::bas...
Definition basic_string.hpp:1146
static basic_string concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c, const basic_string &str_d) noexcept
Concatenates four specified instances of basic_string.
Definition basic_string.hpp:1536
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:991
basic_string & operator=(const basic_string< char > &str) noexcept
Copy assignment operator. Replaces the contents with a copy of the contents of str.
Definition basic_string.hpp:1852
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:689
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:891
static basic_string concat(const basic_string &str_a, const basic_string &str_b) noexcept
Concatenates two specified instances of basic_string.
Definition basic_string.hpp:1562
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:631
basic_string trim_end() const noexcept
Removes all trailing occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:1424
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...
static bool equals(const char_a_t *a, const char_b_t *b) noexcept
Determines whether two specified xtd::basic_string objects have the same value.
Definition basic_string.hpp:1653
static int32 compare(const basic_string &str_a, xtd::size index_a, const basic_string &str_b, xtd::size index_b, xtd::size length)
Compares substrings of two specified basic_string objects and returns an integer that indicates their...
Definition basic_string.hpp:1500
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:879
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:757
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:582
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:707
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:739
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:733
basic_string substr(size_type pos) const
Returns a substring [pos, pos + count). If the requested substring extends past the end of the string...
Definition basic_string.hpp:1292
basic_string to_title_case() const noexcept
Converts the current basic_string to title case (except for words that are entirely in uppercase,...
basic_string 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:1087
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:618
static basic_string concat(const xtd::array< object_t > &args) noexcept
Concatenates the basic_string representations of the elements in a specified object array.
static bool is_empty(const xtd::basic_string< value_type, traits_type, allocator_type > &string) noexcept
Indicates whether the specifeid basic_string is an empty basic_string ("").
Definition basic_string.hpp:1693
basic_string & operator+=(const basic_string< char > &str)
Addition assignment operator. Appends additional characters to the string.
Definition basic_string.hpp:2139
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:593
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:1037
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:769
static basic_string full_class_name()
Definition basic_string.hpp:3066
basic_string trim_end(value_type trim_char) const noexcept
Removes all trailing occurrences of a character specified from the specified xtd::basic_string .
static basic_string concat(value_t value) noexcept
Creates the basic_string representation of a specified object.
Definition basic_string.hpp:1612
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...
static basic_string concat(const xtd::array< basic_string > &values) noexcept
Concatenates the elements of a specified basic_string array.
basic_string trim_start() const noexcept
Removes all leading occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:1440
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:613
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:695
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:3073
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:956
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:1030
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:587
bool starts_with(value_type value) const noexcept
Definition basic_string.hpp:1252
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:795
size_type rfind(const basic_string &str, 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:1120
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)
Compares substrings of two specified basic_string objects, ignoring or honoring their case,...
Definition basic_string.hpp:1514
basic_string trim(const xtd::array< value_type > &trim_chars) const noexcept
Removes all leading and trailing occurrences of a set of characters specified in an array from the sp...
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:834
basic_string< xtd::char8 > to_u8string() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::char8>.
Definition basic_string.hpp:1384
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:669
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:763
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:777
basic_string substr() const
Returns a substring [pos, pos + count). If the requested substring extends past the end of the string...
Definition basic_string.hpp:1286
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:813
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:637
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:884
friend basic_string operator+(const basic_string &lhs, const basic_string< char > &rhs)
Addition operator. Returns a string containing characters from lhs followed by the characters from rh...
Definition basic_string.hpp:2333
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:713
bool starts_with(const basic_string &value, bool ignore_case) const noexcept
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.hpp:1272
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:1061
basic_string< xtd::char16 > to_u16string() const noexcept
Definition basic_string.hpp:1370
xtd::array< value_type > to_array() const noexcept
Copies the characters in this instance to a Unicode character array.
basic_string< xtd::char32 > to_u32string() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::char32>.
Definition basic_string.hpp:1377
const_reference operator[](xtd::size index) const
Returns a reference to the character at specified location index.
Definition basic_string.hpp:1840
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:983
bool starts_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:1277
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:645
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:658
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:1141
auto count() const noexcept -> xtd::size
Definition enumerable.hpp:209
auto append(const source_t &element) const noexcept
Appends a value to the end of the sequence.
Definition enumerable.hpp:144
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.
Contains xtd::collections::generic::ienumerable <type_t> interface.
static basic_string sprintf(const basic_string &fmt, args_t &&... args) noexcept
Writes the text representation of the specified arguments list, to basic_string using the specified f...
Definition basic_string.hpp:1816
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
static basic_string format(const std::locale &loc, const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
@ 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
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
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
@ 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
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
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
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.
Contains unused_ keyword.