xtd 1.0.0
Loading...
Searching...
No Matches
basic_string.hpp
Go to the documentation of this file.
1
4#pragma once
6#define __XTD_CORE_INTERNAL__
11#undef __XTD_CORE_INTERNAL__
12#define __XTD_STD_INTERNAL__
14#undef __XTD_STD_INTERNAL__
17#include "hash_code.hpp"
18#include "icomparable.hpp"
19#include "iequatable.hpp"
20#include "null.hpp"
21#include "string_comparison.hpp"
23#include "types.hpp"
24#include "object.hpp"
25#include "parse.hpp"
26#include "types.hpp"
27#include <cctype>
28#include <iomanip>
29#include <ostream>
30#include <sstream>
31#include <string>
32
34template<typename ...args_t>
35void __basic_string_extract_format_arg(const std::locale& loc, xtd::basic_string<char>& fmt, xtd::array<__format_information<char >>& formats, args_t&&... args);
36template<typename target_t, typename source_t>
37std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str) noexcept;
38template<typename target_t, typename source_t>
39std::basic_string<target_t> __xtd_convert_to_string(const std::basic_string<source_t>& str) noexcept;
40std::basic_string<char> __xtd_demangle(const std::basic_string<char>& value) noexcept;
41std::basic_string<char> __xtd_get_class_name(const std::type_info& value) noexcept;
42std::basic_string<char> __xtd_get_full_class_name(const std::type_info& value) noexcept;
44
46namespace xtd {
65 template<typename char_t, typename traits_t, typename allocator_t>
66 class basic_string : public object, public xtd::icomparable<basic_string<char_t, traits_t, allocator_t>>, public xtd::iequatable<basic_string<char_t, traits_t, allocator_t >>, public xtd::collections::generic::ienumerable<char_t> {
67 public:
69
73 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
75 using traits_type = typename base_type::traits_type;
77 using value_type = typename base_type::value_type;
79 using allocator_type = typename base_type::allocator_type;
81 using size_type = typename base_type::size_type;
83 using difference_type = typename base_type::difference_type;
85 using reference = typename base_type::reference;
87 using const_reference = typename base_type::const_reference;
89 using pointer = typename base_type::pointer;
91 using const_pointer = typename base_type::const_pointer;
99 using reverse_iterator = typename base_type::reverse_iterator;
101 using const_reverse_iterator = typename base_type::const_reverse_iterator;
105
107
112
121 inline static constexpr size_type npos = base_type::npos;
122
131 static inline constexpr xtd::usize bpos = 0;
132
149 static inline constexpr xtd::usize epos = npos - 1;
151
153
156 basic_string() = default;
162 basic_string(std::basic_string<char_t>&& str) : chars_ {std::move(str)} {}
165 basic_string(const basic_string<char>& str) noexcept {
166 if constexpr(std::is_same_v<char, char_t>) chars_ = str.chars_;
167 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
168 }
169
172 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str.chars_;
173 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
174 }
175
178 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str.chars_;
179 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
180 }
181
184 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str.chars_;
185 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
186 }
187
190 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str.chars_;
191 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
192 }
193
195 basic_string(const std::basic_string<char>& str) noexcept { // Can't be explicit by design.
196 if constexpr(std::is_same_v<char, char_t>) chars_ = str;
197 else chars_ = __xtd_convert_to_string<value_type>(str);
198 }
199
201 basic_string(const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
202 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str;
203 else chars_ = __xtd_convert_to_string<value_type>(str);
204 }
205
207 basic_string(const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
208 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str;
209 else chars_ = __xtd_convert_to_string<value_type>(str);
210 }
211
213 basic_string(const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
214 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str;
215 else chars_ = __xtd_convert_to_string<value_type>(str);
216 }
217
219 basic_string(const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
220 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str;
221 else chars_ = __xtd_convert_to_string<value_type>(str);
222 }
223
245 basic_string(const char* str) { // Can't be explicit by design.
247 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
248 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
249 }
250
252 basic_string(const xtd::char16* str) { // Can't be explicit by design.
254 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
255 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
256 }
257
259 basic_string(const xtd::char32* str) { // Can't be explicit by design.
261 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
262 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
263 }
264
266 basic_string(const xtd::char8* str) { // Can't be explicit by design.
268 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
269 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
270 }
271
273 basic_string(const xtd::wchar* str) { // Can't be explicit by design.
275 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
276 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
277 }
278
281 basic_string(const char* str, xtd::usize count) {
283 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count);
284 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count));
285 }
286
290 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count);
291 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count));
292 }
293
297 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count);
298 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count));
299 }
300
304 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count);
305 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count));
306 }
307
311 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count);
312 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
313 }
314
317 template<typename input_iterator_t>
318 basic_string(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
321 basic_string(const xtd::collections::generic::ienumerable<char_t>& items) : chars_(items.begin(), items.end()) {}
324 basic_string(const std::basic_string_view<char_t>& str) : chars_(str) {}
327 basic_string(std::initializer_list<char> il) : basic_string(std::basic_string<char>(il)) {}
330 basic_string(std::initializer_list<xtd::char16> il) : basic_string(std::basic_string<xtd::char16>(il)) {}
333 basic_string(std::initializer_list<xtd::char32> il) : basic_string(std::basic_string<xtd::char32>(il)) {}
336 basic_string(std::initializer_list<xtd::char8> il) : basic_string(std::basic_string<xtd::char8>(il)) {}
339 basic_string(std::initializer_list<xtd::wchar> il) : basic_string(std::basic_string<xtd::wchar>(il)) {}
341
343
353 [[nodiscard]] auto c_str() const noexcept -> const_pointer {return chars_.c_str();}
354
357 [[nodiscard]] auto chars() const noexcept -> const base_type& {return chars_;}
360 [[nodiscard]] auto chars() noexcept -> base_type& {return chars_;}
361
365 [[nodiscard]] virtual auto count() const noexcept -> size_type {return chars_.size();}
366
374 [[nodiscard]] auto data() const noexcept -> const_pointer {return chars_.data();}
375
378 [[nodiscard]] virtual auto empty() const noexcept -> bool {return length() == 0;}
379
383 [[nodiscard]] virtual auto length() const noexcept -> size_type {return chars_.size();}
384
388 [[nodiscard]] virtual auto size() const noexcept -> size_type {return chars_.size();}
390
392
403 [[nodiscard]] auto compare_to(const object& value) const -> xtd::int32 {
405 return compare_to(static_cast<const basic_string&>(value));
406 }
407
415 [[nodiscard]] auto compare_to(const basic_string& value) const noexcept -> xtd::int32 override {return chars_.compare(value.chars_);}
416
420 [[nodiscard]] virtual auto contains(value_type value) const noexcept -> bool {return chars_.find(value) != npos;}
424 [[nodiscard]] virtual auto contains(const basic_string& value) const noexcept -> bool {return chars_.find(value) != npos;}
425
429 [[nodiscard]] auto equals(const object& obj) const noexcept -> bool override {return dynamic_cast<const basic_string*>(&obj) && equals(static_cast<const basic_string&>(obj));}
434 [[nodiscard]] auto equals(const basic_string& value) const noexcept -> bool override {return equals(value, false);}
440 [[nodiscard]] auto equals(const basic_string& value, bool ignore_case) const noexcept -> bool {
441 if (ignore_case) return to_upper().chars_ == value.to_upper().chars_;
442 return chars_ == value.chars_;
443 }
444
448 [[nodiscard]] auto ends_with(value_type value) const noexcept -> bool {return ends_with(value, false);}
453 [[nodiscard]] auto ends_with(value_type value, bool ignore_case) const noexcept -> bool {
454 if (ignore_case) return to_lower().chars_.rfind(static_cast<value_type>(tolower(value))) == length() - 1;
455 return chars_.rfind(value) == length() - 1;
456 }
457
460 [[nodiscard]] auto ends_with(const basic_string& value) const noexcept -> bool {return ends_with(value, xtd::string_comparison::ordinal);}
465 [[nodiscard]] auto ends_with(const basic_string& value, bool ignore_case) const noexcept -> bool {return ends_with(value, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
470 [[nodiscard]] auto ends_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept -> bool {
471 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.rfind(value.to_lower()) + value.to_lower().length() == length();
472 return chars_.rfind(value) + value.length() == length();
473 }
474
477 [[nodiscard]] virtual auto get_base_type() const noexcept -> const base_type& {return chars_;}
478
481 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override {return xtd::hash_code::combine(chars_);}
482
483 [[nodiscard]] auto get_enumerator() const noexcept -> enumerator_type override {
484 struct basic_string_enumerator : public xtd::collections::generic::ienumerator<value_type> {
485 explicit basic_string_enumerator(const basic_string& chars) : chars_(chars) {}
486 [[nodiscard]] const value_type& current() const override {
488 return chars_[index_];
489 }
490 bool move_next() override {return ++index_ < chars_.length();}
491 void reset() override {index_ = basic_string::npos;}
492
493 private:
494 const basic_string& chars_;
496 };
498 }
499
503 [[nodiscard]] auto index_of(const basic_string& value) const noexcept -> xtd::usize {return index_of(value, 0, length());}
508 [[nodiscard]] auto index_of(const basic_string& value, xtd::usize start_index) const -> xtd::usize {return index_of(value, start_index, length() - start_index);}
515 [[nodiscard]] auto index_of(const basic_string& value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
517 auto result = chars_.find(value, start_index);
518 return result > start_index + count ? npos : result;
519 }
520
523 [[nodiscard]] auto index_of(value_type value) const noexcept -> xtd::usize {return index_of(value, 0, length());}
528 [[nodiscard]] auto index_of(value_type value, xtd::usize start_index) const -> xtd::usize {return index_of(value, start_index, length() - start_index);}
535 [[nodiscard]] auto index_of(value_type value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
537 auto result = chars_.find(value, start_index);
538 return result > start_index + count ? npos : result;
539 }
540
544 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values) const noexcept -> xtd::usize;
550 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values, xtd::usize start_index) const -> xtd::usize;
557 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
559 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values) const noexcept -> xtd::usize;
560 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index) const -> xtd::usize;
561 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
563
570 auto insert(xtd::usize start_index, const basic_string& value) const -> basic_string {
572 auto result = self_;
573 result.chars_.insert(start_index, value);
574 return result;
575 }
576
580 [[nodiscard]] auto last_index_of(const basic_string& value) const noexcept -> xtd::usize {return last_index_of(value, 0, length());}
586 [[nodiscard]] auto last_index_of(const basic_string& value, xtd::usize start_index) const -> xtd::usize {return last_index_of(value, start_index, length() - start_index);}
593 [[nodiscard]] auto last_index_of(const basic_string& value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
595 auto result = chars_.rfind(value, start_index + count - value.length());
596 return result < start_index ? npos : result;
597 }
598
601 [[nodiscard]] auto last_index_of(value_type value) const noexcept -> xtd::usize {return last_index_of(value, 0, length());}
607 [[nodiscard]] auto last_index_of(value_type value, xtd::usize start_index) const -> xtd::usize {return last_index_of(value, start_index, length() - start_index);}
615 [[nodiscard]] auto last_index_of(value_type value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
617 auto result = chars_.rfind(value, start_index + count - 1);
618 return result < start_index ? npos : result;
619 }
620
624 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values) const noexcept -> xtd::usize;
629 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values, xtd::usize start_index) const -> xtd::usize;
635 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
637 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values) const noexcept -> xtd::usize;
638 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index) const -> xtd::usize;
639 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
641
647 [[nodiscard]] auto pad_left(xtd::usize total_width) const noexcept -> basic_string {return pad_left(total_width, ' ');}
654 [[nodiscard]] auto pad_left(xtd::usize total_width, char32 padding_char) const noexcept -> basic_string {return total_width < length() ? self_ : basic_string(padding_char, total_width - length()) + self_;}
655
661 [[nodiscard]] auto pad_right(xtd::usize total_width) const noexcept -> basic_string {return pad_right(total_width, ' ');}
668 [[nodiscard]] auto pad_right(xtd::usize total_width, char32 padding_char) const noexcept -> basic_string {return total_width < length() ? self_ : self_ + basic_string(padding_char, total_width - length());}
669
674 [[nodiscard]] auto quoted() const -> basic_string {return quoted('"', '\\');}
679 [[nodiscard]] auto quoted(value_type delimiter) const -> basic_string {return quoted(delimiter, '\\');}
685 [[nodiscard]] auto quoted(value_type delimiter, value_type escape) const -> basic_string {
686 std::wstringstream ss;
687 if constexpr(std::is_same_v<xtd::wchar, value_type>) ss << std::quoted(chars_, delimiter, escape);
688 else ss << std::quoted(__xtd_convert_to_string<xtd::wchar>(chars_), static_cast<xtd::wchar>(delimiter), static_cast<xtd::wchar>(escape));
689 return ss.str();
690 }
691
695 [[nodiscard]] auto remove(xtd::usize start_index) const -> basic_string {return remove(start_index, length() - start_index);}
700 [[nodiscard]] auto remove(xtd::usize start_index, xtd::usize count) const -> basic_string {
702 auto result = self_;
703 result.chars_.erase(start_index, count);
704 return result;
705 }
706
711 [[nodiscard]] auto replace(value_type old_char, value_type new_char) const noexcept -> basic_string {return replace(string(old_char, 1), string(new_char, 1));}
717 [[nodiscard]] auto replace(const basic_string& old_string, const basic_string& new_string) const noexcept -> basic_string {
718 auto result = self_;
719 auto old_size = old_string.length();
720 auto new_size = new_string.length();
721 auto index = xtd::usize {0};
722 while (true) {
723 index = result.chars_.find(old_string, index);
724 if (index == npos) break;
725 if (old_size == new_size) result.chars_.replace(index, old_size, new_string);
726 else {
727 result.chars_.erase(index, old_string.length());
728 result.chars_.insert(index, new_string);
729 }
730 index += new_string.length();
731 }
732 return result;
733 }
734
739 [[nodiscard]] auto split() const noexcept -> xtd::array<basic_string>;
745 [[nodiscard]] auto split(value_type separator) const noexcept -> xtd::array<basic_string>;
762 [[nodiscard]] auto split(value_type separator, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
771 [[nodiscard]] auto split(value_type separator, xtd::usize count) const noexcept -> xtd::array<basic_string>;
783 [[nodiscard]] auto split(value_type separator, xtd::usize count, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
789 [[nodiscard]] auto split(const xtd::array<value_type>& separators) const noexcept -> xtd::array<basic_string>;
806 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
815 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::usize count) const noexcept -> xtd::array<basic_string>;
827 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::usize count, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
828
833 [[nodiscard]] bool starts_with(value_type value) const noexcept {return starts_with(value, false);}
839 [[nodiscard]] bool starts_with(value_type value, bool ignore_case) const noexcept {
840 if (ignore_case) return to_lower().chars_.find(static_cast<value_type>(tolower(value))) == 0;
841 return chars_.find(value) == 0;
842 }
843
847 [[nodiscard]] auto starts_with(const basic_string& value) const noexcept -> bool {return starts_with(value, string_comparison::ordinal);}
853 [[nodiscard]] auto starts_with(const basic_string& value, bool ignore_case) const noexcept -> bool {return starts_with(value, ignore_case ? string_comparison::ordinal_ignore_case : string_comparison::ordinal);}
858 [[nodiscard]] auto starts_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept -> bool {
859 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.find(value.to_lower()) == 0;
860 return chars_.find(value) == 0;
861 }
862
868 [[nodiscard]] auto substring(xtd::usize start_index) const -> basic_string {
870 return chars_.substr(start_index);
871 }
872
877 [[nodiscard]] auto substring(xtd::usize start_index, xtd::usize length) const -> basic_string {
879 return chars_.substr(start_index, length);
880 }
881
884 [[nodiscard]] auto to_array() const noexcept -> xtd::array<value_type>;
888 [[nodiscard]] auto to_array(xtd::usize start_index) const -> xtd::array<value_type>;
893 [[nodiscard]] auto to_array(xtd::usize start_index, xtd::usize length) const -> xtd::array<value_type>;
894
897 [[nodiscard]] auto to_char_array() const noexcept -> xtd::array<value_type>;
902 [[nodiscard]] auto to_char_array(xtd::usize start_index, xtd::usize length) const -> xtd::array<value_type>;
903
906 [[nodiscard]] auto to_lower() const noexcept -> basic_string {
907 auto result = basic_string::empty_string;
908 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::tolower(c));});
909 return result;
910 }
911
915 [[nodiscard]] auto to_string() const noexcept -> basic_string<char> override {
916 if constexpr(std::is_same_v<char, char_t>) return chars_;
917 else return __xtd_convert_to_string<char>(chars_);
918 }
919
922 [[nodiscard]] auto to_title_case() const noexcept -> basic_string;
923
926 [[nodiscard]] auto to_u16string() const noexcept -> basic_string<xtd::char16> {
927 if constexpr(std::is_same_v<xtd::char16, char_t>) return chars_;
928 else return __xtd_convert_to_string<xtd::char16>(chars_);
929 }
930
933 [[nodiscard]] auto to_u32string() const noexcept -> basic_string<xtd::char32> {
934 if constexpr(std::is_same_v<xtd::char32, char_t>) return chars_;
935 else return __xtd_convert_to_string<xtd::char32>(chars_);
936 }
937
940 [[nodiscard]] auto to_u8string() const noexcept -> basic_string<xtd::char8> {
941 if constexpr(std::is_same_v<xtd::char8, char_t>) return chars_;
942 else return __xtd_convert_to_string<xtd::char8>(chars_);
943 }
944
947 [[nodiscard]] auto to_upper() const noexcept -> basic_string {
948 auto result = basic_string::empty_string;
949 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::toupper(c));});
950 return result;
951 }
952
955 [[nodiscard]] auto to_wstring() const noexcept -> basic_string<xtd::wchar> {
956 if constexpr(std::is_same_v<xtd::wchar, char_t>) return chars_;
957 else return __xtd_convert_to_string<xtd::wchar>(chars_);
958 }
959
964 [[nodiscard]] auto trim() const noexcept -> basic_string {return trim(default_trim_chars);}
969 [[nodiscard]] auto trim(value_type trim_char) const noexcept -> basic_string;
974 [[nodiscard]] auto trim(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
975
980 [[nodiscard]] auto trim_end() const noexcept -> basic_string {return trim_end(default_trim_chars);}
985 [[nodiscard]] auto trim_end(value_type trim_char) const noexcept -> basic_string;
990 [[nodiscard]] auto trim_end(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
991
996 [[nodiscard]] auto trim_start() const noexcept -> basic_string {return trim_start(default_trim_chars);}
1001 [[nodiscard]] auto trim_start(value_type trim_char) const noexcept -> basic_string;
1006 [[nodiscard]] auto trim_start(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
1008
1010
1021 [[nodiscard]] static auto compare(const basic_string& str_a, const basic_string& str_b) noexcept -> xtd::int32 {return compare(str_a, str_b, false);}
1032 [[nodiscard]] static auto compare(const basic_string& str_a, const basic_string& str_b, bool ignore_case) noexcept -> xtd::int32 {return compare(str_a, str_b, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
1043 [[nodiscard]] static auto compare(const basic_string& str_a, const basic_string& str_b, xtd::string_comparison comparison_type) noexcept -> xtd::int32 {return comparison_type == xtd::string_comparison::ordinal_ignore_case ? str_a.to_lower().chars_.compare(str_b.to_lower()) : str_a.chars_.compare(str_b);}
1056 [[nodiscard]] static auto compare(const basic_string& str_a, xtd::usize index_a, const basic_string& str_b, xtd::usize index_b, xtd::usize length) -> xtd::int32 {return compare(str_a, index_a, str_b, index_b, length, false);}
1070 [[nodiscard]] static auto compare(const basic_string& str_a, xtd::usize index_a, const basic_string& str_b, xtd::usize index_b, xtd::usize length, bool ignore_case) -> xtd::int32 {return compare(str_a, index_a, str_b, index_b, length, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
1084 [[nodiscard]] static auto compare(const basic_string& str_a, xtd::usize index_a, const basic_string& str_b, xtd::usize index_b, xtd::usize length, xtd::string_comparison comparison_type) -> xtd::int32 {return comparison_type == xtd::string_comparison::ordinal_ignore_case ? str_a.substring(index_a, length).to_lower().chars_.compare(str_b.substring(index_b, length).to_lower()) : str_a.substring(index_a, length).chars_.compare(str_b.substring(index_b, length));}
1085
1092 [[nodiscard]] static auto concat(const basic_string& str_a, const basic_string& str_b, const basic_string& str_c, const basic_string& str_d) noexcept -> basic_string {return str_a + str_b + str_c + str_d;}
1099 template<typename object_a_t, typename object_b_t, typename object_c_t, typename object_d_t>
1100 [[nodiscard]] static auto concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c, object_d_t obj_d) noexcept -> basic_string {return format("{}{}{}{}", obj_a, obj_b, obj_c, obj_d);}
1106 [[nodiscard]] static auto concat(const basic_string& str_a, const basic_string& str_b, const basic_string& str_c) noexcept -> basic_string {return str_a + str_b + str_c;}
1112 template<typename object_a_t, typename object_b_t, typename object_c_t>
1113 [[nodiscard]] static auto concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept -> basic_string {return format("{}{}{}", obj_a, obj_b, obj_c);}
1118 [[nodiscard]] static auto concat(const basic_string& str_a, const basic_string& str_b) noexcept -> basic_string {return str_a + str_b;}
1123 template<typename object_a_t, typename object_b_t>
1124 [[nodiscard]] static auto concat(object_a_t obj_a, object_b_t obj_b) noexcept -> basic_string {return format("{}{}", obj_a, obj_b);}
1128 [[nodiscard]] static auto concat(const xtd::array<basic_string>& values) noexcept -> basic_string;
1130 [[nodiscard]] static auto concat(const xtd::array<const_pointer>& values) noexcept -> basic_string;
1131 template<typename other_char_t>
1132 [[nodiscard]] static auto concat(const xtd::array<const other_char_t*>& values) noexcept -> basic_string;
1133 [[nodiscard]] static auto concat(const std::initializer_list<basic_string>& values) noexcept -> basic_string {
1134 auto result = basic_string::empty_string;
1135 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1136 return result;
1137 }
1138 [[nodiscard]] static auto concat(const std::initializer_list<const_pointer>& values) noexcept -> basic_string {
1139 auto result = basic_string::empty_string;
1140 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1141 return result;
1142 }
1143 template<typename other_char_t>
1144 [[nodiscard]] static auto concat(const std::initializer_list<const other_char_t*>& values) noexcept -> basic_string {
1145 auto result = basic_string::empty_string;
1146 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1147 return result;
1148 }
1153 template<typename object_t>
1154 [[nodiscard]] static auto concat(const xtd::array<object_t>& args) noexcept -> basic_string;
1156 template<typename object_t>
1157 [[nodiscard]] static auto concat(const std::initializer_list<object_t>& args) noexcept -> basic_string {
1158 basic_string result;
1159 for (const auto& arg : args)
1160 result += format("{}", arg);
1161 return result;
1162 }
1167 template<typename value_t>
1168 [[nodiscard]] static auto concat(value_t value) noexcept -> basic_string {
1169 return format("{}", value);
1170 }
1171
1192 [[nodiscard]] static auto demangle(const basic_string& name) -> basic_string {
1193 if constexpr(std::is_same_v<char, char_t>) return __xtd_demangle(name.chars());
1194 else return __xtd_demangle(__xtd_convert_to_string<char>(name.chars()));
1195 }
1196
1202 [[nodiscard]] static auto equals(const basic_string& a, const basic_string& b) noexcept -> bool {return a.equals(b);}
1208 template<typename char_a_t, typename char_b_t>
1209 [[nodiscard]] static auto equals(const char_a_t* a, const char_b_t* b) noexcept -> bool {return basic_string {a}.equals(basic_string {b});}
1210
1217 [[nodiscard]] static auto equals(const basic_string& a, const basic_string& b, bool ignore_case) noexcept -> bool {return a.equals(b, ignore_case);}
1224 template<typename char_a_t, typename char_b_t>
1225 [[nodiscard]] static auto equals(const char_a_t* a, const char_b_t* b, bool ignore_case) noexcept -> bool {return basic_string {a}.equals(basic_string {b}, ignore_case);}
1226
1233 template<typename ...args_t>
1234 [[nodiscard]] static auto format(const basic_string<char>& fmt, args_t&& ... args) -> basic_string;
1235
1243 template<typename ...args_t>
1244 [[nodiscard]] static auto format(const std::locale& loc, const basic_string<char>& fmt, args_t&& ... args) -> basic_string;
1245
1249 [[nodiscard]] static auto is_empty(const xtd::basic_string<value_type, traits_type, allocator_type>& string) noexcept -> bool {return !string.length();}
1250
1257 template<typename collection_t>
1258 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values) noexcept -> basic_string {
1259 xtd::usize i = 0;
1260 basic_string result;
1261 for (const auto& item : values)
1262 result += format("{}{}", (i++ != 0 ? separator : basic_string {}), item);
1263 return result;
1264 }
1265
1272 template<typename collection_t>
1273 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values, xtd::usize index) -> basic_string {return join(separator, values, index, values.size() - index);}
1282 template<typename collection_t>
1283 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values, xtd::usize index, xtd::usize count) -> basic_string {
1284 if (index > values.size() || index + count > values.size()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1285 xtd::usize i = 0;
1286 basic_string result;
1287 for (const auto& item : values) {
1288 if (i >= index) result += format("{}{}", (i != index ? separator : basic_string {}), item);
1289 if (++i >= index + count) break;
1290 }
1291 return result;
1292 }
1293
1295 template<typename value_t>
1296 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values) noexcept -> basic_string;
1297 template<typename value_t>
1298 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::usize index) -> basic_string;
1299 template<typename value_t>
1300 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::usize index, xtd::usize count) -> basic_string;
1302
1306 template<typename value_t>
1307 [[nodiscard]] static auto parse(const basic_string& str) -> value_t {
1308 if constexpr(std::is_same_v<char, char_t>) return xtd::parse<value_t>(str.chars());
1309 else return xtd::parse<value_t>(__xtd_convert_to_string<char>(str.chars()));
1310 }
1311
1371 template<typename ...args_t>
1372 [[nodiscard]] static auto sprintf(const basic_string& fmt, args_t&& ... args) noexcept -> basic_string {return __sprintf(fmt.chars().c_str(), convert_param(std::forward<args_t>(args)) ...);}
1373
1378 template<typename value_t>
1379 [[nodiscard]] static auto try_parse(const basic_string& str, value_t& value) noexcept -> bool {
1380 try {
1381 value = parse<value_t>(str);
1382 return true;
1383 } catch (...) {
1384 return false;
1385 }
1386 }
1387
1388
1390
1398 return chars_[index == epos ? length() - 1 : index];
1399 }
1400
1403 operator const base_type& () const noexcept {return chars_;}
1404
1408 auto operator =(const basic_string<char>& str) noexcept -> basic_string& {
1409 if constexpr(std::is_same<char_t, char>::value) chars_ = str.chars_;
1410 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1411 return self_;
1412 }
1413
1416 auto operator =(const basic_string<xtd::char16>& str) noexcept -> basic_string& {
1417 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str.chars_;
1418 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1419 return self_;
1420 }
1421
1424 auto operator =(const basic_string<xtd::char32>& str) noexcept -> basic_string& {
1425 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str.chars_;
1426 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1427 return self_;
1428 }
1429
1432 auto operator =(const basic_string<xtd::char8>& str) noexcept -> basic_string& {
1433 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str.chars_;
1434 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1435 return self_;
1436 }
1437
1440 auto operator =(const basic_string<xtd::wchar>& str) noexcept -> basic_string& {
1441 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str.chars_;
1442 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1443 return self_;
1444 }
1445
1449 auto operator =(basic_string<char>&& str) noexcept -> basic_string& {
1450 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str.chars_);
1451 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1452 return self_;
1453 }
1454
1458 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str.chars_);
1459 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1460 return self_;
1461 }
1462
1466 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str.chars_);
1467 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1468 return self_;
1469 }
1470
1474 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str.chars_);
1475 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1476 return self_;
1477 }
1478
1482 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str.chars_);
1483 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1484 return self_;
1485 }
1486
1490 auto operator =(const std::basic_string<char>& str) noexcept -> basic_string& {
1491 if constexpr(std::is_same<char_t, char>::value) chars_ = str;
1492 else chars_ = __xtd_convert_to_string<value_type>(str);
1493 return self_;
1494 }
1495
1498 auto operator =(const std::basic_string<xtd::char16>& str) noexcept -> basic_string& {
1499 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str;
1500 else chars_ = __xtd_convert_to_string<value_type>(str);
1501 return self_;
1502 }
1503
1506 auto operator =(const std::basic_string<xtd::char32>& str) noexcept -> basic_string& {
1507 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str;
1508 else chars_ = __xtd_convert_to_string<value_type>(str);
1509 return self_;
1510 }
1511
1514 auto operator =(const std::basic_string<xtd::char8>& str) noexcept -> basic_string& {
1515 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str;
1516 else chars_ = __xtd_convert_to_string<value_type>(str);
1517 return self_;
1518 }
1519
1522 auto operator =(const std::basic_string<xtd::wchar>& str) noexcept -> basic_string& {
1523 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str;
1524 else chars_ = __xtd_convert_to_string<value_type>(str);
1525 return self_;
1526 }
1527
1531 auto operator =(std::basic_string<char>&& str) noexcept -> basic_string& {
1532 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str);
1533 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1534 return self_;
1535 }
1536
1539 auto operator =(std::basic_string<xtd::char16>&& str) noexcept -> basic_string& {
1540 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str);
1541 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1542 return self_;
1543 }
1544
1547 auto operator =(std::basic_string<xtd::char32>&& str) noexcept -> basic_string& {
1548 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str);
1549 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1550 return self_;
1551 }
1552
1555 auto operator =(std::basic_string<xtd::char8>&& str) noexcept -> basic_string& {
1556 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str);
1557 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1558 return self_;
1559 }
1560
1563 auto operator =(std::basic_string<xtd::wchar>&& str) noexcept -> basic_string& {
1564 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str);
1565 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1566 return self_;
1567 }
1568
1573 auto operator =(const char* str) -> basic_string& {
1575 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
1576 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
1577 return self_;
1578 }
1579
1583 auto operator =(const xtd::char16* str) -> basic_string& {
1585 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
1586 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
1587 return self_;
1588 }
1589
1593 auto operator =(const xtd::char32* str) -> basic_string& {
1595 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
1596 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
1597 return self_;
1598 }
1599
1603 auto operator =(const xtd::char8* str) -> basic_string& {
1605 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
1606 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
1607 return self_;
1608 }
1609
1613 auto operator =(const xtd::wchar* str) -> basic_string& {
1615 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
1616 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
1617 return self_;
1618 }
1619
1625 return self_;
1626 }
1627
1632 return self_;
1633 }
1634
1639 return self_;
1640 }
1641
1646 return self_;
1647 }
1648
1653 return self_;
1654 }
1655
1659 auto operator =(const std::initializer_list<char>& il) -> basic_string& {
1660 self_ = basic_string(il);
1661 return self_;
1662 }
1663
1666 auto operator =(const std::initializer_list<xtd::char16>& il) -> basic_string& {
1667 self_ = basic_string(il);
1668 return self_;
1669 }
1670
1673 auto operator =(const std::initializer_list<xtd::char32>& il) -> basic_string& {
1674 self_ = basic_string(il);
1675 return self_;
1676 }
1677
1680 auto operator =(const std::initializer_list<xtd::char8>& il) -> basic_string& {
1681 self_ = basic_string(il);
1682 return self_;
1683 }
1684
1687 auto operator =(const std::initializer_list<xtd::wchar>& il) -> basic_string& {
1688 self_ = basic_string(il);
1689 return self_;
1690 }
1691
1696 if constexpr(std::is_same_v<char, char_t>) chars_ += str.chars_;
1697 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1698 return self_;
1699 }
1700
1704 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str.chars_;
1705 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1706 return self_;
1707 }
1708
1712 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str.chars_;
1713 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1714 return self_;
1715 }
1716
1720 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str.chars_;
1721 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1722 return self_;
1723 }
1724
1728 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str.chars_;
1729 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1730 return self_;
1731 }
1732
1737 if constexpr(std::is_same_v<char, char_t>) chars_ += std::move(str.chars_);
1738 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1739 return self_;
1740 }
1741
1745 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += std::move(str.chars_);
1746 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1747 return self_;
1748 }
1749
1753 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += std::move(str.chars_);
1754 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1755 return self_;
1756 }
1757
1761 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += std::move(str.chars_);
1762 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1763 return self_;
1764 }
1765
1769 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += std::move(str.chars_);
1770 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1771 return self_;
1772 }
1773
1777 auto operator +=(const std::basic_string<char>& str) -> basic_string& {
1778 if constexpr(std::is_same_v<char, char_t>) chars_ += str;
1779 else chars_ += __xtd_convert_to_string<value_type>(str);
1780 return self_;
1781 }
1782
1785 auto operator +=(const std::basic_string<xtd::char16>& str) -> basic_string& {
1786 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str;
1787 else chars_ += __xtd_convert_to_string<value_type>(str);
1788 return self_;
1789 }
1790
1793 auto operator +=(const std::basic_string<xtd::char32>& str) -> basic_string& {
1794 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str;
1795 else chars_ += __xtd_convert_to_string<value_type>(str);
1796 return self_;
1797 }
1798
1801 auto operator +=(const std::basic_string<xtd::char8>& str) -> basic_string& {
1802 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str;
1803 else chars_ += __xtd_convert_to_string<value_type>(str);
1804 return self_;
1805 }
1806
1809 auto operator +=(const std::basic_string<xtd::wchar>& str) -> basic_string& {
1810 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str;
1811 else chars_ += __xtd_convert_to_string<value_type>(str);
1812 return self_;
1813 }
1814
1818 auto operator +=(const char* str) -> basic_string& {
1819 chars_ += basic_string(str).chars_;
1820 return self_;
1821 }
1822
1825 auto operator +=(const xtd::char16* str) -> basic_string& {
1826 chars_.append(basic_string(str).chars_); return self_;
1827 }
1828
1831 auto operator +=(const xtd::char32* str) -> basic_string& {
1832 chars_ += basic_string(str).chars_;
1833 return self_;
1834 }
1835
1838 auto operator +=(const xtd::char8* str) -> basic_string& {
1839 chars_ += basic_string(str).chars_;
1840 return self_;
1841 }
1842
1845 auto operator +=(const xtd::wchar* str) -> basic_string& {
1846 chars_ += basic_string(str).chars_;
1847 return self_;
1848 }
1849
1852 auto operator +=(char ch) -> basic_string& {
1853 chars_ += basic_string(ch, 1).chars_;
1854 return self_;
1855 }
1856
1860 chars_ += basic_string(ch, 1).chars_;
1861 return self_;
1862 }
1863
1867 chars_ += basic_string(ch, 1).chars_;
1868 return self_;
1869 }
1870
1874 chars_ += basic_string(ch, 1).chars_;
1875 return self_;
1876 }
1877
1881 chars_ += basic_string(ch, 1).chars_;
1882 return self_;
1883 }
1884
1889 friend auto operator +(const basic_string& lhs, const basic_string<char>& rhs) -> basic_string {
1890 auto result = lhs;
1891 result += rhs;
1892 return result;
1893 }
1894
1898 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char16>& rhs) -> basic_string {
1899 auto result = lhs;
1900 result += rhs;
1901 return result;
1902 }
1903
1907 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char32>& rhs) -> basic_string {
1908 auto result = lhs;
1909 result += rhs;
1910 return result;
1911 }
1912
1916 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char8>& rhs) -> basic_string {
1917 auto result = lhs;
1918 result += rhs;
1919 return result;
1920 }
1921
1925 friend auto operator +(const basic_string& lhs, const basic_string<xtd::wchar>& rhs) -> basic_string {
1926 auto result = lhs;
1927 result += rhs;
1928 return result;
1929 }
1930
1936 auto result = std::move(lhs);
1937 result += std::move(rhs);
1938 return result;
1939 }
1940
1945 auto result = std::move(lhs);
1946 result += std::move(rhs);
1947 return result;
1948 }
1949
1954 auto result = std::move(lhs);
1955 result += std::move(rhs);
1956 return result;
1957 }
1958
1963 auto result = std::move(lhs);
1964 result += std::move(rhs);
1965 return result;
1966 }
1967
1972 auto result = std::move(lhs);
1973 result += std::move(rhs);
1974 return result;
1975 }
1976
1981 friend auto operator +(basic_string&& lhs, const basic_string<char>& rhs) -> basic_string {
1982 auto result = std::move(lhs);
1983 result += rhs;
1984 return result;
1985 }
1986
1991 auto result = std::move(lhs);
1992 result += rhs;
1993 return result;
1994 }
1995
2000 auto result = std::move(lhs);
2001 result += rhs;
2002 return result;
2003 }
2004
2009 auto result = std::move(lhs);
2010 result += rhs;
2011 return result;
2012 }
2013
2018 auto result = std::move(lhs);
2019 result += rhs;
2020 return result;
2021 }
2022
2027 friend auto operator +(const basic_string& lhs, basic_string<char>&& rhs) -> basic_string {
2028 auto result = lhs;
2029 result += std::move(rhs);
2030 return result;
2031 }
2032
2037 auto result = lhs;
2038 result += std::move(rhs);
2039 return result;
2040 }
2041
2046 auto result = lhs;
2047 result += std::move(rhs);
2048 return result;
2049 }
2050
2055 auto result = lhs;
2056 result += std::move(rhs);
2057 return result;
2058 }
2059
2064 auto result = lhs;
2065 result += std::move(rhs);
2066 return result;
2067 }
2068
2073 friend auto operator +(const basic_string& lhs, const std::basic_string<char>& rhs) -> basic_string {
2074 auto result = lhs;
2075 result += rhs;
2076 return result;
2077 }
2078
2082 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char16>& rhs) -> basic_string {
2083 auto result = lhs;
2084 result += rhs;
2085 return result;
2086 }
2087
2091 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char32>& rhs) -> basic_string {
2092 auto result = lhs;
2093 result += rhs;
2094 return result;
2095 }
2096
2100 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char8>& rhs) -> basic_string {
2101 auto result = lhs;
2102 result += rhs;
2103 return result;
2104 }
2105
2109 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::wchar>& rhs) -> basic_string {
2110 auto result = lhs;
2111 result += rhs;
2112 return result;
2113 }
2114
2119 friend auto operator +(const std::basic_string<char>& lhs, const basic_string& rhs) -> basic_string {
2120 auto result = lhs;
2121 if constexpr(std::is_same_v<char, char_t>) result += rhs.chars();
2122 else result += __xtd_convert_to_string<char>(rhs.chars());
2123 return result;
2124 }
2125
2129 friend auto operator +(const std::basic_string<xtd::char16>& lhs, const basic_string& rhs) -> basic_string {
2130 auto result = lhs;
2131 if constexpr(std::is_same_v<xtd::char16, char_t>) result += rhs.chars();
2132 else result += __xtd_convert_to_string<xtd::char16>(rhs.chars());
2133 return result;
2134 }
2135
2139 friend auto operator +(const std::basic_string<xtd::char32>& lhs, const basic_string& rhs) -> basic_string {
2140 auto result = lhs;
2141 if constexpr(std::is_same_v<xtd::char32, char_t>) result += rhs.chars();
2142 else result += __xtd_convert_to_string<xtd::char32>(rhs.chars());
2143 return result;
2144 }
2145
2149 friend auto operator +(const std::basic_string<xtd::char8>& lhs, const basic_string& rhs) -> basic_string {
2150 auto result = lhs;
2151 if constexpr(std::is_same_v<xtd::char8, char_t>) result += rhs.chars();
2152 else result += __xtd_convert_to_string<xtd::char8>(rhs.chars());
2153 return result;
2154 }
2155
2159 friend auto operator +(const std::basic_string<xtd::wchar>& lhs, const basic_string& rhs) -> basic_string {
2160 auto result = lhs;
2161 if constexpr(std::is_same_v<xtd::wchar, char_t>) result += rhs.chars();
2162 else result += __xtd_convert_to_string<xtd::wchar>(rhs.chars());
2163 return result;
2164 }
2165
2170 friend auto operator +(const basic_string& lhs, const char* rhs) -> basic_string {
2171 auto result = lhs;
2172 result += rhs;
2173 return result;
2174 }
2175
2179 friend auto operator +(const basic_string& lhs, const xtd::char16* rhs) -> basic_string {
2180 auto result = lhs;
2181 result += rhs;
2182 return result;
2183 }
2184
2188 friend auto operator +(const basic_string& lhs, const xtd::char32* rhs) -> basic_string {
2189 auto result = lhs;
2190 result += rhs;
2191 return result;
2192 }
2193
2197 friend auto operator +(const basic_string& lhs, const xtd::char8* rhs) -> basic_string {
2198 auto result = lhs;
2199 result += rhs;
2200 return result;
2201 }
2202
2206 friend auto operator +(const basic_string& lhs, const xtd::wchar* rhs) -> basic_string {
2207 auto result = lhs;
2208 result += rhs;
2209 return result;
2210 }
2211
2216 friend auto operator +(basic_string&& lhs, const char* rhs) -> basic_string {
2217 auto result = std::move(lhs);
2218 result += rhs;
2219 return result;
2220 }
2221
2225 friend auto operator +(basic_string&& lhs, const xtd::char16* rhs) -> basic_string {
2226 auto result = std::move(lhs);
2227 result += rhs;
2228 return result;
2229 }
2230
2234 friend auto operator +(basic_string&& lhs, const xtd::char32* rhs) -> basic_string {
2235 auto result = std::move(lhs);
2236 result += rhs;
2237 return result;
2238 }
2239
2243 friend auto operator +(basic_string&& lhs, const xtd::char8* rhs) -> basic_string {
2244 auto result = std::move(lhs);
2245 result += rhs;
2246 return result;
2247 }
2248
2252 friend auto operator +(basic_string&& lhs, const xtd::wchar* rhs) -> basic_string {
2253 auto result = std::move(lhs);
2254 result += rhs;
2255 return result;
2256 }
2257
2262 friend auto operator +(const char* lhs, const basic_string& rhs) -> basic_string {
2263 auto result = basic_string(lhs);
2264 result += rhs;
2265 return result;
2266 }
2267
2271 friend auto operator +(const xtd::char16* lhs, const basic_string& rhs) -> basic_string {
2272 auto result = basic_string(lhs);
2273 result += rhs;
2274 return result;
2275 }
2276
2280 friend auto operator +(const xtd::char32* lhs, const basic_string& rhs) -> basic_string {
2281 auto result = basic_string(lhs);
2282 result += rhs;
2283 return result;
2284 }
2285
2289 friend auto operator +(const xtd::char8* lhs, const basic_string& rhs) -> basic_string {
2290 auto result = basic_string(lhs);
2291 result += rhs;
2292 return result;
2293 }
2294
2298 friend auto operator +(const xtd::wchar* lhs, const basic_string& rhs) -> basic_string {
2299 auto result = basic_string(lhs);
2300 result += rhs;
2301 return result;
2302 }
2303
2308 friend auto operator +(const char* lhs, basic_string&& rhs) -> basic_string {
2309 auto result = basic_string(lhs);
2310 result += std::move(rhs);
2311 return result;
2312 }
2313
2317 friend auto operator +(const xtd::char16* lhs, basic_string&& rhs) -> basic_string {
2318 auto result = basic_string(lhs);
2319 result += std::move(rhs);
2320 return result;
2321 }
2322
2326 friend auto operator +(const xtd::char32* lhs, basic_string&& rhs) -> basic_string {
2327 auto result = basic_string(lhs);
2328 result += std::move(rhs);
2329 return result;
2330 }
2331
2335 friend auto operator +(const xtd::char8* lhs, basic_string&& rhs) -> basic_string {
2336 auto result = basic_string(lhs);
2337 result += std::move(rhs);
2338 return result;
2339 }
2340
2344 friend auto operator +(const xtd::wchar* lhs, basic_string&& rhs) -> basic_string {
2345 auto result = basic_string(lhs);
2346 result += std::move(rhs);
2347 return result;
2348 }
2349
2354 friend auto operator +(const basic_string& lhs, const char rhs) -> basic_string {
2355 auto result = lhs;
2356 result += rhs;
2357 return result;
2358 }
2359
2363 friend auto operator +(const basic_string& lhs, const xtd::char16 rhs) -> basic_string {
2364 auto result = lhs;
2365 result += rhs;
2366 return result;
2367 }
2368
2372 friend auto operator +(const basic_string& lhs, const xtd::char32 rhs) -> basic_string {
2373 auto result = lhs;
2374 result += rhs;
2375 return result;
2376 }
2377
2381 friend auto operator +(const basic_string& lhs, const xtd::char8 rhs) -> basic_string {
2382 auto result = lhs;
2383 result += rhs;
2384 return result;
2385 }
2386
2390 friend auto operator +(const basic_string& lhs, const xtd::wchar rhs) -> basic_string {
2391 auto result = lhs;
2392 result += rhs;
2393 return result;
2394 }
2395
2400 friend auto operator +(basic_string&& lhs, const char rhs) -> basic_string {
2401 auto result = std::move(lhs);
2402 result += rhs;
2403 return result;
2404 }
2405
2409 friend auto operator +(basic_string&& lhs, const xtd::char16 rhs) -> basic_string {
2410 auto result = std::move(lhs);
2411 result += rhs;
2412 return result;
2413 }
2414
2418 friend auto operator +(basic_string&& lhs, const xtd::char32 rhs) -> basic_string {
2419 auto result = std::move(lhs);
2420 result += rhs;
2421 return result;
2422 }
2423
2427 friend auto operator +(basic_string&& lhs, const xtd::char8 rhs) -> basic_string {
2428 auto result = std::move(lhs);
2429 result += rhs;
2430 return result;
2431 }
2432
2436 friend auto operator +(basic_string&& lhs, const xtd::wchar rhs) -> basic_string {
2437 auto result = std::move(lhs);
2438 result += rhs;
2439 return result;
2440 }
2441
2446 friend auto operator +(char lhs, const basic_string& rhs) -> basic_string {
2447 auto result = basic_string(lhs, 1);
2448 result += rhs;
2449 return result;
2450 }
2451
2455 friend auto operator +(xtd::char16 lhs, const basic_string& rhs) -> basic_string {
2456 auto result = basic_string(lhs, 1);
2457 result += rhs;
2458 return result;
2459 }
2460
2464 friend auto operator +(xtd::char32 lhs, const basic_string& rhs) -> basic_string {
2465 auto result = basic_string(lhs, 1);
2466 result += rhs;
2467 return result;
2468 }
2469
2473 friend auto operator +(xtd::char8 lhs, const basic_string& rhs) -> basic_string {
2474 auto result = basic_string(lhs, 1);
2475 result += rhs;
2476 return result;
2477 }
2478
2482 friend auto operator +(xtd::wchar lhs, const basic_string& rhs) -> basic_string {
2483 auto result = basic_string(lhs, 1);
2484 result += rhs;
2485 return result;
2486 }
2487
2492 friend auto operator +(char lhs, basic_string&& rhs) -> basic_string {
2493 auto result = basic_string(lhs, 1);
2494 result += std::move(rhs);
2495 return result;
2496 }
2497
2502 auto result = basic_string(lhs, 1);
2503 result += std::move(rhs);
2504 return result;
2505 }
2506
2511 auto result = basic_string(lhs, 1);
2512 result += std::move(rhs);
2513 return result;
2514 }
2515
2519 friend auto operator +(xtd::char8 lhs, basic_string&& rhs) -> basic_string {
2520 auto result = basic_string(lhs, 1);
2521 result += std::move(rhs);
2522 return result;
2523 }
2524
2528 friend auto operator +(xtd::wchar lhs, basic_string&& rhs) -> basic_string {
2529 auto result = basic_string(lhs, 1);
2530 result += std::move(rhs);
2531 return result;
2532 }
2533
2542 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
2543 friend auto operator <<(std::basic_ostream<char>& stream, const basic_string& str) -> std::basic_ostream<char>& {
2544 if constexpr(std::is_same_v<char, char_t>) return stream << str.chars();
2545 else return stream << __xtd_convert_to_string<char>(str.chars());
2546 }
2547
2553 friend auto operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string& str) -> std::basic_ostream<xtd::wchar>& {return stream << str.to_wstring().chars();}
2554
2563 friend auto operator >>(std::basic_istream<char>& stream, basic_string& str) -> std::basic_istream<char>& {
2564 auto s = std::basic_string<char> {};
2565 stream >> s;
2566 str = s;
2567 return stream;
2568 }
2569
2577 friend auto operator >>(std::basic_istream<xtd::wchar>& stream, basic_string& str) -> std::basic_istream<xtd::wchar>& {
2578 auto s = std::basic_string<xtd::wchar> {};
2579 stream >> s;
2580 str = s;
2581 return stream;
2582 }
2583
2584
2586
2590 [[deprecated("Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 1.2.0.")]]
2591 [[nodiscard]] auto is_empty() const noexcept -> bool {return is_empty(self_);}
2597
2599
2600 template<typename object_t>
2601 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 1.2.0.")]]
2602 [[nodiscard]] static auto class_name() -> basic_string {return get_class_name(full_class_name<object_t>());}
2607 template<typename object_t>
2608 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 1.2.0.")]]
2609 [[nodiscard]] static auto class_name(const object_t& object) -> basic_string {return get_class_name(full_class_name(object));}
2614 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 1.2.0.")]]
2615 [[nodiscard]] static auto class_name(const std::type_info& info) -> basic_string {return __xtd_get_class_name(info);}
2620 template<typename object_t>
2621 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 1.2.0.")]]
2622 [[nodiscard]] static auto full_class_name() -> basic_string {return demangle(typeid(object_t).name());}
2627 template<typename object_t>
2628 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 1.2.0.")]]
2629 [[nodiscard]] static auto full_class_name(const object_t& object) -> basic_string {return demangle(typeid(object).name());}
2634 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 1.2.0.")]]
2635 [[nodiscard]] static auto full_class_name(const std::type_info& info) -> basic_string {return __xtd_get_full_class_name(info);}
2637
2638 private:
2639 friend class basic_string<char>;
2640 friend class basic_string<xtd::char16>;
2641 friend class basic_string<xtd::char32>;
2642 friend class basic_string<xtd::char8>;
2643 friend class basic_string<xtd::wchar>;
2644
2645 static const xtd::array<value_type> default_split_separators;
2646 static const xtd::array<value_type> default_trim_chars;
2647
2648 template<typename arg_t>
2649 [[nodiscard]] static auto convert_param(arg_t&& arg) noexcept {
2650 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();
2651 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();
2652 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();
2653 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();
2654 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();
2655 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();
2656 else return std::forward<arg_t>(arg);
2657 }
2658
2659 [[nodiscard]] static auto get_class_name(const basic_string& full_name) -> basic_string {
2660 auto length = full_name.last_index_of("<");
2661 if (length == npos) length = full_name.length();
2662 if (full_name.last_index_of("::", 0, length) == npos) return full_name;
2663 return full_name.substring(full_name.last_index_of("::", 0, length) + 2);
2664 }
2665
2666 base_type chars_;
2667 };
2668}
2669
2670#define __XTD_BASIC_STRING_INTERNAL__
2671#include "basic_string_.hpp"
2672#undef __XTD_BASIC_STRING_INTERNAL__
2673
2675namespace std {
2676 template<typename char_t>
2677 struct hash<xtd::basic_string<char_t>> {
2678 auto operator()(const xtd::basic_string<char_t>& s) const noexcept -> xtd::usize {return s.get_hash_code();}
2679 };
2680}
Contains xtd::basic_string class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents text as a sequence of character units.
Definition basic_string.hpp:66
basic_string(const basic_string< xtd::char32 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:177
std::basic_string< char_t, traits_t, allocator_t > base_type
Represents the basic string base type.
Definition basic_string.hpp:73
auto remove(xtd::usize start_index, xtd::usize count) const -> basic_string
Deletes all the characters from this basic_string beginning at a specified position and continuing th...
Definition basic_string.hpp:700
static auto parse(const basic_string &str) -> value_t
Converts a basic_string into a value_t type.
Definition basic_string.hpp:1307
auto last_index_of(const basic_string &value) const noexcept -> xtd::usize
Reports the index of the last occurrence of the specified basic_string in this basic_string.
Definition basic_string.hpp:580
auto trim_end(value_type trim_char) const noexcept -> basic_string
Removes all trailing occurrences of a character specified from the specified xtd::basic_string .
auto substring(xtd::usize start_index) const -> basic_string
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.hpp:868
auto trim(const xtd::array< value_type > &trim_chars) const noexcept -> basic_string
Removes all leading and trailing occurrences of a set of characters specified in an array from the sp...
auto replace(const basic_string &old_string, const basic_string &new_string) const noexcept -> basic_string
Replaces all occurrences of a specified basic_string in this basic_string with another specified basi...
Definition basic_string.hpp:717
auto quoted(value_type delimiter, value_type escape) const -> basic_string
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified...
Definition basic_string.hpp:685
static auto concat(object_a_t obj_a, object_b_t obj_b) noexcept -> basic_string
Concatenates two specified instances of object.
Definition basic_string.hpp:1124
static auto class_name() -> basic_string
Gets the class name of the object_t.
Definition basic_string.hpp:2602
auto compare_to(const object &value) const -> xtd::int32
Compares this instance with a specified xtd::object and indicates whether this instance precedes,...
Definition basic_string.hpp:403
static auto compare(const basic_string &str_a, xtd::usize index_a, const basic_string &str_b, xtd::usize index_b, xtd::usize length) -> xtd::int32
Compares substrings of two specified basic_string objects and returns an integer that indicates their...
Definition basic_string.hpp:1056
auto to_u32string() const noexcept -> basic_string< xtd::char32 >
Converts the value of this instance to a xtd::basic_string <xtd::char32>.
Definition basic_string.hpp:933
static const basic_string empty_string
Definition basic_string.hpp:111
auto chars() noexcept -> base_type &
Returns a reference to the underlying base type.
Definition basic_string.hpp:360
auto operator=(const basic_string< char > &str) noexcept -> basic_string &
Copy assignment operator. Replaces the contents with a copy of the contents of str.
Definition basic_string.hpp:1408
static auto equals(const basic_string &a, const basic_string &b) noexcept -> bool
Determines whether two specified xtd::basic_string objects have the same value.
Definition basic_string.hpp:1202
auto to_array() const noexcept -> xtd::array< value_type >
Copies the characters in this instance to a Unicode character array.
friend auto operator<<(std::basic_ostream< char > &stream, const basic_string &str) -> std::basic_ostream< char > &
Output stream operator. Behaves as a FormattedOutputFunction. After constructing and checking the sen...
Definition basic_string.hpp:2543
basic_string(xtd::wchar character, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:242
basic_string(const xtd::char32 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:259
auto to_u16string() const noexcept -> basic_string< xtd::char16 >
Definition basic_string.hpp:926
typename base_type::allocator_type allocator_type
Represents the basic string allocator type.
Definition basic_string.hpp:79
auto index_of(value_type value) const noexcept -> xtd::usize
Reports the index of the first occurrence of the specified character in this basic_string.
Definition basic_string.hpp:523
basic_string(const xtd::wchar *str, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:309
auto trim_start(const xtd::array< value_type > &trim_chars) const noexcept -> basic_string
Removes all leading occurrences of a set of characters specified in an array from the specified xtd::...
auto to_upper() const noexcept -> basic_string
Returns a copy of the current xtd::basic_string converted to uppercase.
Definition basic_string.hpp:947
static auto compare(const basic_string &str_a, const basic_string &str_b) noexcept -> xtd::int32
Compares two specified basic_string objects and returns an integer that indicates their relative posi...
Definition basic_string.hpp:1021
static auto full_class_name() -> basic_string
Definition basic_string.hpp:2622
virtual auto contains(const basic_string &value) const noexcept -> bool
Returns a value indicating whether a specified substring occurs within this basic_string.
Definition basic_string.hpp:424
auto starts_with(const basic_string &value, bool ignore_case) const noexcept -> bool
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.hpp:853
friend auto operator+(const basic_string &lhs, const basic_string< char > &rhs) -> basic_string
Addition operator. Returns a string containing characters from lhs followed by the characters from rh...
Definition basic_string.hpp:1889
basic_string(const std::basic_string_view< char_t > &str)
Initializes a new instance of xtd::basic_string with specified std::basic_string_view.
Definition basic_string.hpp:324
typename xtd::collections::generic::enumerator< value_type > enumerator_type
Represents the basic string enumerator type.
Definition basic_string.hpp:103
auto quoted(value_type delimiter) const -> basic_string
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified...
Definition basic_string.hpp:679
basic_string(const basic_string< xtd::char8 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:183
static auto join(const basic_string &separator, const collection_t &values) noexcept -> basic_string
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:1258
static auto join(const basic_string &separator, const collection_t &values, xtd::usize index) -> basic_string
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:1273
auto trim_end(const xtd::array< value_type > &trim_chars) const noexcept -> basic_string
Removes all trailing occurrences of a set of characters specified in an array from the specified xtd:...
auto equals(const basic_string &value, bool ignore_case) const noexcept -> bool
Determines whether this instance and another specified xtd::basic_string object have the same value,...
Definition basic_string.hpp:440
auto compare_to(const basic_string &value) const noexcept -> xtd::int32 override
Compares this instance with a specified xtd::basic_string object and indicates whether this instance ...
Definition basic_string.hpp:415
basic_string(input_iterator_t first, input_iterator_t last)
Initializes a new instance of xtd::basic_string with specified first and last iterators of substring.
Definition basic_string.hpp:318
auto starts_with(const basic_string &value, xtd::string_comparison comparison_type) const noexcept -> bool
Determines whether the end of this basic_string matches the specified basic_string when compared usin...
Definition basic_string.hpp:858
auto last_index_of_any(const xtd::array< value_type > &values, xtd::usize start_index) const -> xtd::usize
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
typename base_type::const_pointer const_pointer
Represents the basic string const pointer type.
Definition basic_string.hpp:91
basic_string(std::initializer_list< xtd::wchar > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:339
friend auto operator>>(std::basic_istream< char > &stream, basic_string &str) -> std::basic_istream< char > &
Input stream operator. Behaves as a FormattedInputFunction. After constructing and checking the sentr...
Definition basic_string.hpp:2563
auto trim(value_type trim_char) const noexcept -> basic_string
Removes all leading and trailing occurrences of a character specified from the specified xtd::basic_s...
basic_string(const xtd::char32 *str, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:295
auto operator[](xtd::usize index) const -> const_reference
Returns a reference to the character at specified location index.
Definition basic_string.hpp:1396
basic_string(const basic_string< xtd::char16 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:171
auto substring(xtd::usize start_index, xtd::usize length) const -> basic_string
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.hpp:877
basic_string(const std::basic_string< char > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:195
virtual auto length() const noexcept -> size_type
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:383
typename base_type::traits_type traits_type
Represents the basic string traits type.
Definition basic_string.hpp:75
virtual auto get_base_type() const noexcept -> const base_type &
Returns the underlying base type.
Definition basic_string.hpp:477
static auto compare(const basic_string &str_a, xtd::usize index_a, const basic_string &str_b, xtd::usize index_b, xtd::usize length, xtd::string_comparison comparison_type) -> xtd::int32
Compares substrings of two specified basic_string objects using the specified rules,...
Definition basic_string.hpp:1084
typename base_type::pointer pointer
Represents the basic string pointer type.
Definition basic_string.hpp:89
typename base_type::const_reference const_reference
Represents the basic string const referecne type.
Definition basic_string.hpp:87
basic_string(std::initializer_list< xtd::char32 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:333
auto ends_with(const basic_string &value) const noexcept -> bool
Determines whether the end of this basic_string matches the specified basic_string.
Definition basic_string.hpp:460
basic_string(const std::basic_string< xtd::char16 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:201
auto last_index_of_any(const xtd::array< value_type > &values, xtd::usize start_index, xtd::usize count) const -> xtd::usize
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
auto to_u8string() const noexcept -> basic_string< xtd::char8 >
Converts the value of this instance to a xtd::basic_string <xtd::char8>.
Definition basic_string.hpp:940
virtual auto contains(value_type value) const noexcept -> bool
Returns a value indicating whether a specified char occurs within this basic_string.
Definition basic_string.hpp:420
static auto concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c, object_d_t obj_d) noexcept -> basic_string
Concatenates four specified instances of object.
Definition basic_string.hpp:1100
auto pad_right(xtd::usize total_width) const noexcept -> basic_string
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.hpp:661
static auto compare(const basic_string &str_a, xtd::usize index_a, const basic_string &str_b, xtd::usize index_b, xtd::usize length, bool ignore_case) -> xtd::int32
Compares substrings of two specified basic_string objects, ignoring or honoring their case,...
Definition basic_string.hpp:1070
auto to_lower() const noexcept -> basic_string
Returns a copy of the current xtd::basic_string converted to lowercase.
Definition basic_string.hpp:906
auto pad_right(xtd::usize total_width, char32 padding_char) const noexcept -> basic_string
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.hpp:668
basic_string(const char *str, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:281
basic_string(const basic_string< xtd::wchar > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:189
static auto concat(const xtd::array< basic_string > &values) noexcept -> basic_string
Concatenates the elements of a specified basic_string array.
basic_string(xtd::char8 character, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:238
static auto full_class_name(const object_t &object) -> basic_string
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition basic_string.hpp:2629
static auto compare(const basic_string &str_a, const basic_string &str_b, xtd::string_comparison comparison_type) noexcept -> xtd::int32
Compares two specified basic_string objects using the specified rules, and returns an integer that in...
Definition basic_string.hpp:1043
auto index_of(value_type value, xtd::usize start_index) const -> xtd::usize
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:528
typename xtd::collections::generic::ienumerable< char_t >::iterator iterator
Represents the basic string iterator type.
Definition basic_string.hpp:94
typename base_type::const_reverse_iterator const_reverse_iterator
Represents the basic string const reverse iterator type.
Definition basic_string.hpp:101
static auto concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c, const basic_string &str_d) noexcept -> basic_string
Concatenates four specified instances of basic_string.
Definition basic_string.hpp:1092
auto index_of(const basic_string &value, xtd::usize start_index) const -> xtd::usize
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:508
basic_string(const char *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:245
static constexpr xtd::usize bpos
Definition basic_string.hpp:131
auto last_index_of(value_type value) const noexcept -> xtd::usize
Reports the index of the last occurrence of the specified character in this tring.
Definition basic_string.hpp:601
auto to_wstring() const noexcept -> basic_string< xtd::wchar >
Converts the value of this instance to a xtd::basic_string <xtd::wchar>.
Definition basic_string.hpp:955
auto c_str() const noexcept -> const_pointer
Returns a pointer to a null-terminated character array with data equivalent to those stored in the st...
Definition basic_string.hpp:353
basic_string(const xtd::char16 *str, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:288
basic_string(std::initializer_list< char > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:327
auto to_title_case() const noexcept -> basic_string
Converts the current basic_string to title case (except for words that are entirely in uppercase,...
static auto concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c) noexcept -> basic_string
Concatenates three specified instances of basic_string.
Definition basic_string.hpp:1106
static auto join(const basic_string &separator, const collection_t &values, xtd::usize index, xtd::usize count) -> basic_string
Concatenates a specified separator basic_string between each element of a specified Object array,...
Definition basic_string.hpp:1283
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:839
typename base_type::size_type size_type
Represents the basic string size type.
Definition basic_string.hpp:81
auto last_index_of(const basic_string &value, xtd::usize start_index) const -> xtd::usize
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:586
auto ends_with(const basic_string &value, bool ignore_case) const noexcept -> bool
Determines whether the end of this basic_string instance matches the specified basic_string,...
Definition basic_string.hpp:465
static auto try_parse(const basic_string &str, value_t &value) noexcept -> bool
Try to convert a basic_string into a value_t type.
Definition basic_string.hpp:1379
basic_string(const xtd::wchar *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:273
auto replace(value_type old_char, value_type new_char) const noexcept -> basic_string
Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.
Definition basic_string.hpp:711
auto trim_start() const noexcept -> basic_string
Removes all leading occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:996
auto last_index_of(value_type value, xtd::usize start_index, xtd::usize count) const -> xtd::usize
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:615
auto equals(const object &obj) const noexcept -> bool override
Determines whether this instance and a specified object, which must also be a xtd::basic_string objec...
Definition basic_string.hpp:429
basic_string(basic_string &&)=default
Initializes a new instance of xtd::basic_string with specified string to move.
static constexpr size_type npos
Definition basic_string.hpp:121
auto trim_start(value_type trim_char) const noexcept -> basic_string
Removes all leading occurrences of a character specified from the specified xtd::basic_string .
basic_string(xtd::char16 character, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:230
virtual auto empty() const noexcept -> bool
Checks whether the container is empty.
Definition basic_string.hpp:378
static auto equals(const char_a_t *a, const char_b_t *b, bool ignore_case) noexcept -> bool
Determines whether two specified xtd::basic_string objects have the same value, ignoring or honoring ...
Definition basic_string.hpp:1225
basic_string(xtd::char32 character, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:234
basic_string(const basic_string< char > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:165
static auto concat(const xtd::array< object_t > &args) noexcept -> basic_string
Concatenates the basic_string representations of the elements in a specified object array.
static auto full_class_name(const std::type_info &info) -> basic_string
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition basic_string.hpp:2635
auto operator+=(const basic_string< char > &str) -> basic_string &
Addition assignment operator. Appends additional characters to the string.
Definition basic_string.hpp:1695
basic_string(const xtd::char8 *str, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:302
static auto class_name(const std::type_info &info) -> basic_string
Gets the class name of the specified object.
Definition basic_string.hpp:2615
static auto concat(value_t value) noexcept -> basic_string
Creates the basic_string representation of a specified object.
Definition basic_string.hpp:1168
auto last_index_of(const basic_string &value, xtd::usize start_index, xtd::usize count) const -> xtd::usize
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:593
auto trim() const noexcept -> basic_string
Removes all leading and trailing occurrences of white-space characters from the specified xtd::basic_...
Definition basic_string.hpp:964
auto ends_with(value_type value, bool ignore_case) const noexcept -> bool
Determines whether the end of this basic_string matches the specified character, ignoring or honoring...
Definition basic_string.hpp:453
auto insert(xtd::usize start_index, const basic_string &value) const -> basic_string
Inserts a specified instance of basic_string at a specified index position in this instance.
Definition basic_string.hpp:570
auto quoted() const -> basic_string
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML.
Definition basic_string.hpp:674
basic_string(const xtd::char16 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:252
typename base_type::value_type value_type
Represents the basic string value type.
Definition basic_string.hpp:77
typename base_type::reverse_iterator reverse_iterator
Represents the basic string reverse iterator type.
Definition basic_string.hpp:99
auto remove(xtd::usize start_index) const -> basic_string
Deletes all the characters from this basic_string beginning at a specified position and continuing th...
Definition basic_string.hpp:695
auto ends_with(value_type value) const noexcept -> bool
Determines whether the end of this basic_string matches the specified character.
Definition basic_string.hpp:448
basic_string(std::initializer_list< xtd::char16 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:330
auto to_char_array() const noexcept -> xtd::array< value_type >
auto pad_left(xtd::usize total_width, char32 padding_char) const noexcept -> basic_string
Right-aligns the characters in this basic_string, padding with spaces on the left for a specified tot...
Definition basic_string.hpp:654
basic_string(std::initializer_list< xtd::char8 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:336
auto index_of_any(const xtd::array< value_type > &values, xtd::usize start_index, xtd::usize count) const -> xtd::usize
Reports the index of the first occurrence in this instance of any character in a specified array of c...
static auto demangle(const basic_string &name) -> basic_string
Gets demangled basic_string of name,.
Definition basic_string.hpp:1192
auto equals(const basic_string &value) const noexcept -> bool override
Determines whether this instance and another specified xtd::basic_string object have the same value.
Definition basic_string.hpp:434
auto trim_end() const noexcept -> basic_string
Removes all trailing occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.hpp:980
basic_string()=default
Initializes a new instance of xtd::basic_string.
auto index_of_any(const xtd::array< value_type > &values, xtd::usize start_index) const -> xtd::usize
Reports the index of the first occurrence in this instance of any character in a specified array of c...
bool starts_with(value_type value) const noexcept
Definition basic_string.hpp:833
static auto concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept -> basic_string
Concatenates three specified instances of object.
Definition basic_string.hpp:1113
static auto compare(const basic_string &str_a, const basic_string &str_b, bool ignore_case) noexcept -> xtd::int32
Compares two specified basic_string objects, ignoring or honoring their case, and returns an integer ...
Definition basic_string.hpp:1032
basic_string(const xtd::char8 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:266
auto index_of_any(const xtd::array< value_type > &values) const noexcept -> xtd::usize
Reports the index of the first occurrence in this instance of any character in a specified array of c...
static auto concat(const basic_string &str_a, const basic_string &str_b) noexcept -> basic_string
Concatenates two specified instances of basic_string.
Definition basic_string.hpp:1118
auto last_index_of(value_type value, xtd::usize start_index) const -> xtd::usize
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:607
auto is_empty() const noexcept -> bool
Name Public Deprecated Methods.
Definition basic_string.hpp:2591
auto data() const noexcept -> const_pointer
Returns a pointer to the underlying array serving as character storage. The pointer is such that the ...
Definition basic_string.hpp:374
auto index_of(value_type value, xtd::usize start_index, xtd::usize count) const -> xtd::usize
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:535
auto starts_with(const basic_string &value) const noexcept -> bool
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.hpp:847
auto split() const noexcept -> xtd::array< basic_string >
Splits this basic_string into substrings that are based on the default white-space characters....
auto get_hash_code() const noexcept -> xtd::usize override
Returns the hash code for this basic_string.
Definition basic_string.hpp:481
auto to_string() const noexcept -> basic_string< char > override
Converts the value of this instance to a xtd::basic_string <char>.
Definition basic_string.hpp:915
auto get_enumerator() const noexcept -> enumerator_type override
Returns an enumerator that iterates through a collection.
Definition basic_string.hpp:483
typename base_type::reference reference
Represents the basic string referecne type.
Definition basic_string.hpp:85
static auto equals(const char_a_t *a, const char_b_t *b) noexcept -> bool
Determines whether two specified xtd::basic_string objects have the same value.
Definition basic_string.hpp:1209
basic_string(const std::basic_string< xtd::wchar > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:219
virtual auto count() const noexcept -> size_type
Definition basic_string.hpp:365
basic_string(char character, xtd::usize count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:226
auto ends_with(const basic_string &value, xtd::string_comparison comparison_type) const noexcept -> bool
Determines whether the end of this basic_string matches the specified basic_string when compared usin...
Definition basic_string.hpp:470
static auto equals(const basic_string &a, const basic_string &b, bool ignore_case) noexcept -> bool
Determines whether two specified xtd::basic_string objects have the same value, ignoring or honoring ...
Definition basic_string.hpp:1217
typename xtd::collections::generic::ienumerable< char_t >::const_iterator const_iterator
Represents the basic string const iterator type.
Definition basic_string.hpp:97
typename base_type::difference_type difference_type
Represents the basic string difference type.
Definition basic_string.hpp:83
auto pad_left(xtd::usize total_width) const noexcept -> basic_string
Right-aligns the characters in this basic_string, padding with spaces on the left for a specified tot...
Definition basic_string.hpp:647
basic_string(const std::basic_string< xtd::char32 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:207
auto last_index_of_any(const xtd::array< value_type > &values) const noexcept -> xtd::usize
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
basic_string(const std::basic_string< xtd::char8 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:213
auto chars() const noexcept -> const base_type &
Returns a reference to the underlying base type.
Definition basic_string.hpp:357
basic_string(const xtd::collections::generic::ienumerable< char_t > &items)
Initializes a new instance of xtd::basic_string with specified ienumerable.
Definition basic_string.hpp:321
static auto is_empty(const xtd::basic_string< value_type, traits_type, allocator_type > &string) noexcept -> bool
Indicates whether the specifeid basic_string is an empty basic_string ("").
Definition basic_string.hpp:1249
basic_string(std::basic_string< char_t > &&str)
Initializes a new instance of xtd::basic_string with specified string to move.
Definition basic_string.hpp:162
static auto class_name(const object_t &object) -> basic_string
Gets the class name of the specified object.
Definition basic_string.hpp:2609
static constexpr xtd::usize epos
Definition basic_string.hpp:149
auto index_of(const basic_string &value) const noexcept -> xtd::usize
Reports the index of the first occurrence of the specified basic_string in this basic_string.
Definition basic_string.hpp:503
virtual auto size() const noexcept -> size_type
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:388
auto index_of(const basic_string &value, xtd::usize start_index, xtd::usize count) const -> xtd::usize
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:515
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.hpp:40
typename xtd::collections::generic::extensions::enumerable_iterators< xtd::any_object, xtd::collections::generic::ienumerable< xtd::any_object > >::const_iterator const_iterator
Definition ienumerable.hpp:50
typename xtd::collections::generic::extensions::enumerable_iterators< xtd::any_object, xtd::collections::generic::ienumerable< xtd::any_object > >::iterator iterator
Definition ienumerable.hpp:48
Supports a simple iteration over a generic collection.
Definition ienumerator.hpp:58
static auto combine(args_t... values) noexcept -> xtd::usize
Combines values into a hash code.
Definition hash_code.hpp:70
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:22
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.hpp:23
object()=default
Create a new instance of the ultimate base class object.
Definition character.hpp:17
Contains xtd::collections::generic::ienumerable <type_t> interface.
static auto sprintf(const basic_string &fmt, args_t &&... args) noexcept -> basic_string
Writes the text representation of the specified arguments list, to basic_string using the specified f...
Definition basic_string.hpp:1372
static auto format(const basic_string< char > &fmt, args_t &&... args) -> basic_string
Writes the text representation of the specified arguments list, to string using the specified format ...
static auto format(const std::locale &loc, const basic_string< char > &fmt, args_t &&... args) -> basic_string
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
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:25
std::size_t usize
Represents an unsigned size of any object in bytes.
Definition usize.hpp:22
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
auto parse(const std::string &str) -> value_t
Convert a string into a type.
Definition parse.hpp:34
auto new_ptr(args_t &&... args) -> xtd::ptr< type_t >
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
@ 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
auto first() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:249
auto begin() const -> const_iterator
Returns an iterator to the beginning.
Definition read_only_span.hpp:186
auto last() const -> read_only_span< type_t, count >
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:274
auto end() const -> const_iterator
Returns an iterator to the end.
Definition read_only_span.hpp:205
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:39
Contains xtd fundamental types.