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 "index.hpp"
21#include "null.hpp"
22#include "string_comparison.hpp"
24#include "types.hpp"
25#include "object.hpp"
26#include "parse.hpp"
27#include "types.hpp"
28#include <cctype>
29#include <iomanip>
30#include <ostream>
31#include <sstream>
32#include <string>
33
35template<typename ...args_t>
36void __basic_string_extract_format_arg(const std::locale& loc, xtd::basic_string<char>& fmt, xtd::array<__format_information<char >>& formats, args_t&&... args);
37template<typename target_t, typename source_t>
38std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str) noexcept;
39template<typename target_t, typename source_t>
40std::basic_string<target_t> __xtd_convert_to_string(const std::basic_string<source_t>& str) noexcept;
41std::basic_string<char> __xtd_demangle(const std::basic_string<char>& value) noexcept;
42std::basic_string<char> __xtd_get_class_name(const std::type_info& value) noexcept;
43std::basic_string<char> __xtd_get_full_class_name(const std::type_info& value) noexcept;
45
47namespace xtd {
66 template<typename char_t, typename traits_t, typename allocator_t>
67 class basic_string : public object, public xtd::icomparable<basic_string<char_t, traits_t, allocator_t>>, public xtd::iequatable<basic_string<char_t, traits_t, allocator_t >>, public xtd::collections::generic::ienumerable<char_t> {
68 public:
70
74 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
76 using traits_type = typename base_type::traits_type;
78 using value_type = typename base_type::value_type;
80 using allocator_type = typename base_type::allocator_type;
82 using size_type = typename base_type::size_type;
84 using difference_type = typename base_type::difference_type;
86 using reference = typename base_type::reference;
88 using const_reference = typename base_type::const_reference;
90 using pointer = typename base_type::pointer;
92 using const_pointer = typename base_type::const_pointer;
100 using reverse_iterator = typename base_type::reverse_iterator;
102 using const_reverse_iterator = typename base_type::const_reverse_iterator;
106
108
113
122 inline static constexpr size_type npos = base_type::npos;
123
132 static inline constexpr xtd::usize bpos = 0;
133
150 static inline constexpr xtd::usize epos = npos - 1;
152
154
157 basic_string() = default;
163 basic_string(std::basic_string<char_t>&& str) : chars_ {std::move(str)} {}
166 basic_string(const basic_string<char>& str) noexcept {
167 if constexpr(std::is_same_v<char, char_t>) chars_ = str.chars_;
168 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
169 }
170
173 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str.chars_;
174 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
175 }
176
179 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str.chars_;
180 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
181 }
182
185 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str.chars_;
186 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
187 }
188
191 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str.chars_;
192 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
193 }
194
196 basic_string(const std::basic_string<char>& str) noexcept { // Can't be explicit by design.
197 if constexpr(std::is_same_v<char, char_t>) chars_ = str;
198 else chars_ = __xtd_convert_to_string<value_type>(str);
199 }
200
202 basic_string(const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
203 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str;
204 else chars_ = __xtd_convert_to_string<value_type>(str);
205 }
206
208 basic_string(const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
209 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str;
210 else chars_ = __xtd_convert_to_string<value_type>(str);
211 }
212
214 basic_string(const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
215 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str;
216 else chars_ = __xtd_convert_to_string<value_type>(str);
217 }
218
220 basic_string(const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
221 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str;
222 else chars_ = __xtd_convert_to_string<value_type>(str);
223 }
224
246 basic_string(const char* str) { // Can't be explicit by design.
248 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
249 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
250 }
251
253 basic_string(const xtd::char16* str) { // Can't be explicit by design.
255 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
256 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
257 }
258
260 basic_string(const xtd::char32* str) { // Can't be explicit by design.
262 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
263 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
264 }
265
267 basic_string(const xtd::char8* str) { // Can't be explicit by design.
269 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
270 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
271 }
272
274 basic_string(const xtd::wchar* str) { // Can't be explicit by design.
276 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
277 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
278 }
279
282 basic_string(const char* str, xtd::usize count) {
284 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count);
285 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count));
286 }
287
291 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count);
292 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count));
293 }
294
298 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count);
299 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count));
300 }
301
305 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count);
306 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count));
307 }
308
312 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count);
313 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
314 }
315
318 template<typename input_iterator_t>
319 basic_string(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
322 basic_string(const xtd::collections::generic::ienumerable<char_t>& items) : chars_(items.begin(), items.end()) {}
325 basic_string(const std::basic_string_view<char_t>& str) : chars_(str) {}
328 basic_string(std::initializer_list<char> il) : basic_string(std::basic_string<char>(il)) {}
331 basic_string(std::initializer_list<xtd::char16> il) : basic_string(std::basic_string<xtd::char16>(il)) {}
334 basic_string(std::initializer_list<xtd::char32> il) : basic_string(std::basic_string<xtd::char32>(il)) {}
337 basic_string(std::initializer_list<xtd::char8> il) : basic_string(std::basic_string<xtd::char8>(il)) {}
340 basic_string(std::initializer_list<xtd::wchar> il) : basic_string(std::basic_string<xtd::wchar>(il)) {}
342
344
354 [[nodiscard]] auto c_str() const noexcept -> const_pointer {return chars_.c_str();}
355
358 [[nodiscard]] auto chars() const noexcept -> const base_type& {return chars_;}
361 [[nodiscard]] auto chars() noexcept -> base_type& {return chars_;}
362
366 [[nodiscard]] virtual auto count() const noexcept -> size_type {return chars_.size();}
367
375 [[nodiscard]] auto data() const noexcept -> const_pointer {return chars_.data();}
376
379 [[nodiscard]] virtual auto empty() const noexcept -> bool {return length() == 0;}
380
384 [[nodiscard]] virtual auto length() const noexcept -> size_type {return chars_.size();}
385
389 [[nodiscard]] virtual auto size() const noexcept -> size_type {return chars_.size();}
391
393
404 [[nodiscard]] auto compare_to(const object& value) const -> xtd::int32 {
406 return compare_to(static_cast<const basic_string&>(value));
407 }
408
416 [[nodiscard]] auto compare_to(const basic_string& value) const noexcept -> xtd::int32 override {return chars_.compare(value.chars_);}
417
421 [[nodiscard]] virtual auto contains(value_type value) const noexcept -> bool {return chars_.find(value) != npos;}
425 [[nodiscard]] virtual auto contains(const basic_string& value) const noexcept -> bool {return chars_.find(value) != npos;}
426
430 [[nodiscard]] auto equals(const object& obj) const noexcept -> bool override {return dynamic_cast<const basic_string*>(&obj) && equals(static_cast<const basic_string&>(obj));}
435 [[nodiscard]] auto equals(const basic_string& value) const noexcept -> bool override {return equals(value, false);}
441 [[nodiscard]] auto equals(const basic_string& value, bool ignore_case) const noexcept -> bool {
442 if (ignore_case) return to_upper().chars_ == value.to_upper().chars_;
443 return chars_ == value.chars_;
444 }
445
449 [[nodiscard]] auto ends_with(value_type value) const noexcept -> bool {return ends_with(value, false);}
454 [[nodiscard]] auto ends_with(value_type value, bool ignore_case) const noexcept -> bool {
455 if (ignore_case) return to_lower().chars_.rfind(static_cast<value_type>(tolower(value))) == length() - 1;
456 return chars_.rfind(value) == length() - 1;
457 }
458
461 [[nodiscard]] auto ends_with(const basic_string& value) const noexcept -> bool {return ends_with(value, xtd::string_comparison::ordinal);}
466 [[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);}
471 [[nodiscard]] auto ends_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept -> bool {
472 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.rfind(value.to_lower()) + value.to_lower().length() == length();
473 return chars_.rfind(value) + value.length() == length();
474 }
475
478 [[nodiscard]] virtual auto get_base_type() const noexcept -> const base_type& {return chars_;}
479
482 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::usize override {return xtd::hash_code::combine(chars_);}
483
484 [[nodiscard]] auto get_enumerator() const noexcept -> enumerator_type override {
485 struct basic_string_enumerator : public xtd::collections::generic::ienumerator<value_type> {
486 explicit basic_string_enumerator(const basic_string& chars) : chars_(chars) {}
487 [[nodiscard]] const value_type& current() const override {
489 return chars_[index_];
490 }
491 bool move_next() override {return ++index_ < chars_.length();}
492 void reset() override {index_ = basic_string::npos;}
493
494 private:
495 const basic_string& chars_;
497 };
499 }
500
504 [[nodiscard]] auto index_of(const basic_string& value) const noexcept -> xtd::usize {return index_of(value, 0, length());}
509 [[nodiscard]] auto index_of(const basic_string& value, xtd::usize start_index) const -> xtd::usize {return index_of(value, start_index, length() - start_index);}
516 [[nodiscard]] auto index_of(const basic_string& value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
518 auto result = chars_.find(value, start_index);
519 return result > start_index + count ? npos : result;
520 }
521
524 [[nodiscard]] auto index_of(value_type value) const noexcept -> xtd::usize {return index_of(value, 0, length());}
529 [[nodiscard]] auto index_of(value_type value, xtd::usize start_index) const -> xtd::usize {return index_of(value, start_index, length() - start_index);}
536 [[nodiscard]] auto index_of(value_type value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
538 auto result = chars_.find(value, start_index);
539 return result > start_index + count ? npos : result;
540 }
541
545 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values) const noexcept -> xtd::usize;
551 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values, xtd::usize start_index) const -> xtd::usize;
558 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
560 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values) const noexcept -> xtd::usize;
561 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index) const -> xtd::usize;
562 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
564
571 auto insert(xtd::usize start_index, const basic_string& value) const -> basic_string {
573 auto result = self_;
574 result.chars_.insert(start_index, value);
575 return result;
576 }
577
581 [[nodiscard]] auto last_index_of(const basic_string& value) const noexcept -> xtd::usize {return last_index_of(value, 0, length());}
587 [[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);}
594 [[nodiscard]] auto last_index_of(const basic_string& value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
596 auto result = chars_.rfind(value, start_index + count - value.length());
597 return result < start_index ? npos : result;
598 }
599
602 [[nodiscard]] auto last_index_of(value_type value) const noexcept -> xtd::usize {return last_index_of(value, 0, length());}
608 [[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);}
616 [[nodiscard]] auto last_index_of(value_type value, xtd::usize start_index, xtd::usize count) const -> xtd::usize {
618 auto result = chars_.rfind(value, start_index + count - 1);
619 return result < start_index ? npos : result;
620 }
621
625 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values) const noexcept -> xtd::usize;
630 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values, xtd::usize start_index) const -> xtd::usize;
636 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
638 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values) const noexcept -> xtd::usize;
639 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index) const -> xtd::usize;
640 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values, xtd::usize start_index, xtd::usize count) const -> xtd::usize;
642
648 [[nodiscard]] auto pad_left(xtd::usize total_width) const noexcept -> basic_string {return pad_left(total_width, ' ');}
655 [[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_;}
656
662 [[nodiscard]] auto pad_right(xtd::usize total_width) const noexcept -> basic_string {return pad_right(total_width, ' ');}
669 [[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());}
670
675 [[nodiscard]] auto quoted() const -> basic_string {return quoted('"', '\\');}
680 [[nodiscard]] auto quoted(value_type delimiter) const -> basic_string {return quoted(delimiter, '\\');}
686 [[nodiscard]] auto quoted(value_type delimiter, value_type escape) const -> basic_string {
687 std::wstringstream ss;
688 if constexpr(std::is_same_v<xtd::wchar, value_type>) ss << std::quoted(chars_, delimiter, escape);
689 else ss << std::quoted(__xtd_convert_to_string<xtd::wchar>(chars_), static_cast<xtd::wchar>(delimiter), static_cast<xtd::wchar>(escape));
690 return ss.str();
691 }
692
696 [[nodiscard]] auto remove(xtd::usize start_index) const -> basic_string {return remove(start_index, length() - start_index);}
701 [[nodiscard]] auto remove(xtd::usize start_index, xtd::usize count) const -> basic_string {
703 auto result = self_;
704 result.chars_.erase(start_index, count);
705 return result;
706 }
707
712 [[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));}
718 [[nodiscard]] auto replace(const basic_string& old_string, const basic_string& new_string) const noexcept -> basic_string {
719 auto result = self_;
720 auto old_size = old_string.length();
721 auto new_size = new_string.length();
722 auto index = xtd::usize {0};
723 while (true) {
724 index = result.chars_.find(old_string, index);
725 if (index == npos) break;
726 if (old_size == new_size) result.chars_.replace(index, old_size, new_string);
727 else {
728 result.chars_.erase(index, old_string.length());
729 result.chars_.insert(index, new_string);
730 }
731 index += new_string.length();
732 }
733 return result;
734 }
735
740 [[nodiscard]] auto split() const noexcept -> xtd::array<basic_string>;
746 [[nodiscard]] auto split(value_type separator) const noexcept -> xtd::array<basic_string>;
763 [[nodiscard]] auto split(value_type separator, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
772 [[nodiscard]] auto split(value_type separator, xtd::usize count) const noexcept -> xtd::array<basic_string>;
784 [[nodiscard]] auto split(value_type separator, xtd::usize count, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
790 [[nodiscard]] auto split(const xtd::array<value_type>& separators) const noexcept -> xtd::array<basic_string>;
807 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
816 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::usize count) const noexcept -> xtd::array<basic_string>;
828 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::usize count, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
829
834 [[nodiscard]] bool starts_with(value_type value) const noexcept {return starts_with(value, false);}
840 [[nodiscard]] bool starts_with(value_type value, bool ignore_case) const noexcept {
841 if (ignore_case) return to_lower().chars_.find(static_cast<value_type>(tolower(value))) == 0;
842 return chars_.find(value) == 0;
843 }
844
848 [[nodiscard]] auto starts_with(const basic_string& value) const noexcept -> bool {return starts_with(value, string_comparison::ordinal);}
854 [[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);}
859 [[nodiscard]] auto starts_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept -> bool {
860 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.find(value.to_lower()) == 0;
861 return chars_.find(value) == 0;
862 }
863
869 [[nodiscard]] auto substring(xtd::usize start_index) const -> basic_string {
871 return chars_.substr(start_index);
872 }
873
878 [[nodiscard]] auto substring(xtd::usize start_index, xtd::usize length) const -> basic_string {
880 return chars_.substr(start_index, length);
881 }
882
885 [[nodiscard]] auto to_array() const noexcept -> xtd::array<value_type>;
889 [[nodiscard]] auto to_array(xtd::usize start_index) const -> xtd::array<value_type>;
894 [[nodiscard]] auto to_array(xtd::usize start_index, xtd::usize length) const -> xtd::array<value_type>;
895
898 [[nodiscard]] auto to_char_array() const noexcept -> xtd::array<value_type>;
903 [[nodiscard]] auto to_char_array(xtd::usize start_index, xtd::usize length) const -> xtd::array<value_type>;
904
907 [[nodiscard]] auto to_lower() const noexcept -> basic_string {
908 auto result = basic_string::empty_string;
909 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::tolower(c));});
910 return result;
911 }
912
916 [[nodiscard]] auto to_string() const noexcept -> basic_string<char> override {
917 if constexpr(std::is_same_v<char, char_t>) return chars_;
918 else return __xtd_convert_to_string<char>(chars_);
919 }
920
923 [[nodiscard]] auto to_title_case() const noexcept -> basic_string;
924
927 [[nodiscard]] auto to_u16string() const noexcept -> basic_string<xtd::char16> {
928 if constexpr(std::is_same_v<xtd::char16, char_t>) return chars_;
929 else return __xtd_convert_to_string<xtd::char16>(chars_);
930 }
931
934 [[nodiscard]] auto to_u32string() const noexcept -> basic_string<xtd::char32> {
935 if constexpr(std::is_same_v<xtd::char32, char_t>) return chars_;
936 else return __xtd_convert_to_string<xtd::char32>(chars_);
937 }
938
941 [[nodiscard]] auto to_u8string() const noexcept -> basic_string<xtd::char8> {
942 if constexpr(std::is_same_v<xtd::char8, char_t>) return chars_;
943 else return __xtd_convert_to_string<xtd::char8>(chars_);
944 }
945
948 [[nodiscard]] auto to_upper() const noexcept -> basic_string {
949 auto result = basic_string::empty_string;
950 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::toupper(c));});
951 return result;
952 }
953
956 [[nodiscard]] auto to_wstring() const noexcept -> basic_string<xtd::wchar> {
957 if constexpr(std::is_same_v<xtd::wchar, char_t>) return chars_;
958 else return __xtd_convert_to_string<xtd::wchar>(chars_);
959 }
960
965 [[nodiscard]] auto trim() const noexcept -> basic_string {return trim(default_trim_chars);}
970 [[nodiscard]] auto trim(value_type trim_char) const noexcept -> basic_string;
975 [[nodiscard]] auto trim(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
976
981 [[nodiscard]] auto trim_end() const noexcept -> basic_string {return trim_end(default_trim_chars);}
986 [[nodiscard]] auto trim_end(value_type trim_char) const noexcept -> basic_string;
991 [[nodiscard]] auto trim_end(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
992
997 [[nodiscard]] auto trim_start() const noexcept -> basic_string {return trim_start(default_trim_chars);}
1002 [[nodiscard]] auto trim_start(value_type trim_char) const noexcept -> basic_string;
1007 [[nodiscard]] auto trim_start(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
1009
1011
1022 [[nodiscard]] static auto compare(const basic_string& str_a, const basic_string& str_b) noexcept -> xtd::int32 {return compare(str_a, str_b, false);}
1033 [[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);}
1044 [[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);}
1057 [[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);}
1071 [[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);}
1085 [[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));}
1086
1093 [[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;}
1100 template<typename object_a_t, typename object_b_t, typename object_c_t, typename object_d_t>
1101 [[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);}
1107 [[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;}
1113 template<typename object_a_t, typename object_b_t, typename object_c_t>
1114 [[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);}
1119 [[nodiscard]] static auto concat(const basic_string& str_a, const basic_string& str_b) noexcept -> basic_string {return str_a + str_b;}
1124 template<typename object_a_t, typename object_b_t>
1125 [[nodiscard]] static auto concat(object_a_t obj_a, object_b_t obj_b) noexcept -> basic_string {return format("{}{}", obj_a, obj_b);}
1129 [[nodiscard]] static auto concat(const xtd::array<basic_string>& values) noexcept -> basic_string;
1131 [[nodiscard]] static auto concat(const xtd::array<const_pointer>& values) noexcept -> basic_string;
1132 template<typename other_char_t>
1133 [[nodiscard]] static auto concat(const xtd::array<const other_char_t*>& values) noexcept -> basic_string;
1134 [[nodiscard]] static auto concat(const std::initializer_list<basic_string>& values) noexcept -> basic_string {
1135 auto result = basic_string::empty_string;
1136 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1137 return result;
1138 }
1139 [[nodiscard]] static auto concat(const std::initializer_list<const_pointer>& values) noexcept -> basic_string {
1140 auto result = basic_string::empty_string;
1141 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1142 return result;
1143 }
1144 template<typename other_char_t>
1145 [[nodiscard]] static auto concat(const std::initializer_list<const other_char_t*>& values) noexcept -> basic_string {
1146 auto result = basic_string::empty_string;
1147 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1148 return result;
1149 }
1154 template<typename object_t>
1155 [[nodiscard]] static auto concat(const xtd::array<object_t>& args) noexcept -> basic_string;
1157 template<typename object_t>
1158 [[nodiscard]] static auto concat(const std::initializer_list<object_t>& args) noexcept -> basic_string {
1159 basic_string result;
1160 for (const auto& arg : args)
1161 result += format("{}", arg);
1162 return result;
1163 }
1168 template<typename value_t>
1169 [[nodiscard]] static auto concat(value_t value) noexcept -> basic_string {
1170 return format("{}", value);
1171 }
1172
1193 [[nodiscard]] static auto demangle(const basic_string& name) -> basic_string {
1194 if constexpr(std::is_same_v<char, char_t>) return __xtd_demangle(name.chars());
1195 else return __xtd_demangle(__xtd_convert_to_string<char>(name.chars()));
1196 }
1197
1203 [[nodiscard]] static auto equals(const basic_string& a, const basic_string& b) noexcept -> bool {return a.equals(b);}
1209 template<typename char_a_t, typename char_b_t>
1210 [[nodiscard]] static auto equals(const char_a_t* a, const char_b_t* b) noexcept -> bool {return basic_string {a}.equals(basic_string {b});}
1211
1218 [[nodiscard]] static auto equals(const basic_string& a, const basic_string& b, bool ignore_case) noexcept -> bool {return a.equals(b, ignore_case);}
1225 template<typename char_a_t, typename char_b_t>
1226 [[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);}
1227
1234 template<typename ...args_t>
1235 [[nodiscard]] static auto format(const basic_string<char>& fmt, args_t&& ... args) -> basic_string;
1236
1244 template<typename ...args_t>
1245 [[nodiscard]] static auto format(const std::locale& loc, const basic_string<char>& fmt, args_t&& ... args) -> basic_string;
1246
1250 [[nodiscard]] static auto is_empty(const xtd::basic_string<value_type, traits_type, allocator_type>& string) noexcept -> bool {return !string.length();}
1251
1258 template<typename collection_t>
1259 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values) noexcept -> basic_string {
1260 xtd::usize i = 0;
1261 basic_string result;
1262 for (const auto& item : values)
1263 result += format("{}{}", (i++ != 0 ? separator : basic_string {}), item);
1264 return result;
1265 }
1266
1273 template<typename collection_t>
1274 [[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);}
1283 template<typename collection_t>
1284 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values, xtd::usize index, xtd::usize count) -> basic_string {
1285 if (index > values.size() || index + count > values.size()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1286 xtd::usize i = 0;
1287 basic_string result;
1288 for (const auto& item : values) {
1289 if (i >= index) result += format("{}{}", (i != index ? separator : basic_string {}), item);
1290 if (++i >= index + count) break;
1291 }
1292 return result;
1293 }
1294
1296 template<typename value_t>
1297 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values) noexcept -> basic_string;
1298 template<typename value_t>
1299 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::usize index) -> basic_string;
1300 template<typename value_t>
1301 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::usize index, xtd::usize count) -> basic_string;
1303
1307 template<typename value_t>
1308 [[nodiscard]] static auto parse(const basic_string& str) -> value_t {
1309 if constexpr(std::is_same_v<char, char_t>) return xtd::parse<value_t>(str.chars());
1310 else return xtd::parse<value_t>(__xtd_convert_to_string<char>(str.chars()));
1311 }
1312
1372 template<typename ...args_t>
1373 [[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)) ...);}
1374
1379 template<typename value_t>
1380 [[nodiscard]] static auto try_parse(const basic_string& str, value_t& value) noexcept -> bool {
1381 try {
1382 value = parse<value_t>(str);
1383 return true;
1384 } catch (...) {
1385 return false;
1386 }
1387 }
1388
1389
1391
1397 auto operator [](xtd::index index) const -> const_reference {
1398 return operator [](index.get_offset(length()));
1399 }
1400
1406 return chars_[index];
1407 }
1408
1411 operator const base_type& () const noexcept {return chars_;}
1412
1416 auto operator =(const basic_string<char>& str) noexcept -> basic_string& {
1417 if constexpr(std::is_same<char_t, char>::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::char16>& str) noexcept -> basic_string& {
1425 if constexpr(std::is_same<char_t, xtd::char16>::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::char32>& str) noexcept -> basic_string& {
1433 if constexpr(std::is_same<char_t, xtd::char32>::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::char8>& str) noexcept -> basic_string& {
1441 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str.chars_;
1442 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1443 return self_;
1444 }
1445
1448 auto operator =(const basic_string<xtd::wchar>& str) noexcept -> basic_string& {
1449 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str.chars_;
1450 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1451 return self_;
1452 }
1453
1457 auto operator =(basic_string<char>&& str) noexcept -> basic_string& {
1458 if constexpr(std::is_same<char_t, char>::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::char16>::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::char32>::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::char8>::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 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str.chars_);
1491 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1492 return self_;
1493 }
1494
1498 auto operator =(const std::basic_string<char>& str) noexcept -> basic_string& {
1499 if constexpr(std::is_same<char_t, char>::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::char16>& str) noexcept -> basic_string& {
1507 if constexpr(std::is_same<char_t, xtd::char16>::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::char32>& str) noexcept -> basic_string& {
1515 if constexpr(std::is_same<char_t, xtd::char32>::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::char8>& str) noexcept -> basic_string& {
1523 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str;
1524 else chars_ = __xtd_convert_to_string<value_type>(str);
1525 return self_;
1526 }
1527
1530 auto operator =(const std::basic_string<xtd::wchar>& str) noexcept -> basic_string& {
1531 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str;
1532 else chars_ = __xtd_convert_to_string<value_type>(str);
1533 return self_;
1534 }
1535
1539 auto operator =(std::basic_string<char>&& str) noexcept -> basic_string& {
1540 if constexpr(std::is_same<char_t, char>::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::char16>&& str) noexcept -> basic_string& {
1548 if constexpr(std::is_same<char_t, xtd::char16>::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::char32>&& str) noexcept -> basic_string& {
1556 if constexpr(std::is_same<char_t, xtd::char32>::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::char8>&& str) noexcept -> basic_string& {
1564 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str);
1565 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1566 return self_;
1567 }
1568
1571 auto operator =(std::basic_string<xtd::wchar>&& str) noexcept -> basic_string& {
1572 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str);
1573 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1574 return self_;
1575 }
1576
1581 auto operator =(const char* str) -> basic_string& {
1583 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
1584 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
1585 return self_;
1586 }
1587
1591 auto operator =(const xtd::char16* str) -> basic_string& {
1593 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
1594 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
1595 return self_;
1596 }
1597
1601 auto operator =(const xtd::char32* str) -> basic_string& {
1603 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
1604 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
1605 return self_;
1606 }
1607
1611 auto operator =(const xtd::char8* str) -> basic_string& {
1613 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
1614 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
1615 return self_;
1616 }
1617
1621 auto operator =(const xtd::wchar* str) -> basic_string& {
1623 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
1624 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
1625 return self_;
1626 }
1627
1633 return self_;
1634 }
1635
1640 return self_;
1641 }
1642
1647 return self_;
1648 }
1649
1654 return self_;
1655 }
1656
1661 return self_;
1662 }
1663
1667 auto operator =(const std::initializer_list<char>& il) -> basic_string& {
1668 self_ = basic_string(il);
1669 return self_;
1670 }
1671
1674 auto operator =(const std::initializer_list<xtd::char16>& il) -> basic_string& {
1675 self_ = basic_string(il);
1676 return self_;
1677 }
1678
1681 auto operator =(const std::initializer_list<xtd::char32>& il) -> basic_string& {
1682 self_ = basic_string(il);
1683 return self_;
1684 }
1685
1688 auto operator =(const std::initializer_list<xtd::char8>& il) -> basic_string& {
1689 self_ = basic_string(il);
1690 return self_;
1691 }
1692
1695 auto operator =(const std::initializer_list<xtd::wchar>& il) -> basic_string& {
1696 self_ = basic_string(il);
1697 return self_;
1698 }
1699
1704 if constexpr(std::is_same_v<char, 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::char16, 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::char32, 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::char8, char_t>) chars_ += str.chars_;
1729 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1730 return self_;
1731 }
1732
1736 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str.chars_;
1737 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1738 return self_;
1739 }
1740
1745 if constexpr(std::is_same_v<char, 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::char16, 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::char32, 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::char8, 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 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += std::move(str.chars_);
1778 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1779 return self_;
1780 }
1781
1785 auto operator +=(const std::basic_string<char>& str) -> basic_string& {
1786 if constexpr(std::is_same_v<char, 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::char16>& str) -> basic_string& {
1794 if constexpr(std::is_same_v<xtd::char16, 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::char32>& str) -> basic_string& {
1802 if constexpr(std::is_same_v<xtd::char32, 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::char8>& str) -> basic_string& {
1810 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str;
1811 else chars_ += __xtd_convert_to_string<value_type>(str);
1812 return self_;
1813 }
1814
1817 auto operator +=(const std::basic_string<xtd::wchar>& str) -> basic_string& {
1818 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str;
1819 else chars_ += __xtd_convert_to_string<value_type>(str);
1820 return self_;
1821 }
1822
1826 auto operator +=(const char* str) -> basic_string& {
1827 chars_ += basic_string(str).chars_;
1828 return self_;
1829 }
1830
1833 auto operator +=(const xtd::char16* str) -> basic_string& {
1834 chars_.append(basic_string(str).chars_); return self_;
1835 }
1836
1839 auto operator +=(const xtd::char32* str) -> basic_string& {
1840 chars_ += basic_string(str).chars_;
1841 return self_;
1842 }
1843
1846 auto operator +=(const xtd::char8* str) -> basic_string& {
1847 chars_ += basic_string(str).chars_;
1848 return self_;
1849 }
1850
1853 auto operator +=(const xtd::wchar* str) -> basic_string& {
1854 chars_ += basic_string(str).chars_;
1855 return self_;
1856 }
1857
1860 auto operator +=(char ch) -> basic_string& {
1861 chars_ += basic_string(ch, 1).chars_;
1862 return self_;
1863 }
1864
1868 chars_ += basic_string(ch, 1).chars_;
1869 return self_;
1870 }
1871
1875 chars_ += basic_string(ch, 1).chars_;
1876 return self_;
1877 }
1878
1882 chars_ += basic_string(ch, 1).chars_;
1883 return self_;
1884 }
1885
1889 chars_ += basic_string(ch, 1).chars_;
1890 return self_;
1891 }
1892
1897 friend auto operator +(const basic_string& lhs, const basic_string<char>& rhs) -> basic_string {
1898 auto result = lhs;
1899 result += rhs;
1900 return result;
1901 }
1902
1906 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char16>& rhs) -> basic_string {
1907 auto result = lhs;
1908 result += rhs;
1909 return result;
1910 }
1911
1915 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char32>& rhs) -> basic_string {
1916 auto result = lhs;
1917 result += rhs;
1918 return result;
1919 }
1920
1924 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char8>& rhs) -> basic_string {
1925 auto result = lhs;
1926 result += rhs;
1927 return result;
1928 }
1929
1933 friend auto operator +(const basic_string& lhs, const basic_string<xtd::wchar>& rhs) -> basic_string {
1934 auto result = lhs;
1935 result += rhs;
1936 return result;
1937 }
1938
1944 auto result = std::move(lhs);
1945 result += std::move(rhs);
1946 return result;
1947 }
1948
1953 auto result = std::move(lhs);
1954 result += std::move(rhs);
1955 return result;
1956 }
1957
1962 auto result = std::move(lhs);
1963 result += std::move(rhs);
1964 return result;
1965 }
1966
1971 auto result = std::move(lhs);
1972 result += std::move(rhs);
1973 return result;
1974 }
1975
1980 auto result = std::move(lhs);
1981 result += std::move(rhs);
1982 return result;
1983 }
1984
1989 friend auto operator +(basic_string&& lhs, const basic_string<char>& rhs) -> basic_string {
1990 auto result = std::move(lhs);
1991 result += rhs;
1992 return result;
1993 }
1994
1999 auto result = std::move(lhs);
2000 result += rhs;
2001 return result;
2002 }
2003
2008 auto result = std::move(lhs);
2009 result += rhs;
2010 return result;
2011 }
2012
2017 auto result = std::move(lhs);
2018 result += rhs;
2019 return result;
2020 }
2021
2026 auto result = std::move(lhs);
2027 result += rhs;
2028 return result;
2029 }
2030
2035 friend auto operator +(const basic_string& lhs, basic_string<char>&& rhs) -> basic_string {
2036 auto result = lhs;
2037 result += std::move(rhs);
2038 return result;
2039 }
2040
2045 auto result = lhs;
2046 result += std::move(rhs);
2047 return result;
2048 }
2049
2054 auto result = lhs;
2055 result += std::move(rhs);
2056 return result;
2057 }
2058
2063 auto result = lhs;
2064 result += std::move(rhs);
2065 return result;
2066 }
2067
2072 auto result = lhs;
2073 result += std::move(rhs);
2074 return result;
2075 }
2076
2081 friend auto operator +(const basic_string& lhs, const std::basic_string<char>& rhs) -> basic_string {
2082 auto result = lhs;
2083 result += rhs;
2084 return result;
2085 }
2086
2090 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char16>& rhs) -> basic_string {
2091 auto result = lhs;
2092 result += rhs;
2093 return result;
2094 }
2095
2099 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char32>& rhs) -> basic_string {
2100 auto result = lhs;
2101 result += rhs;
2102 return result;
2103 }
2104
2108 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char8>& rhs) -> basic_string {
2109 auto result = lhs;
2110 result += rhs;
2111 return result;
2112 }
2113
2117 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::wchar>& rhs) -> basic_string {
2118 auto result = lhs;
2119 result += rhs;
2120 return result;
2121 }
2122
2127 friend auto operator +(const std::basic_string<char>& lhs, const basic_string& rhs) -> basic_string {
2128 auto result = lhs;
2129 if constexpr(std::is_same_v<char, char_t>) result += rhs.chars();
2130 else result += __xtd_convert_to_string<char>(rhs.chars());
2131 return result;
2132 }
2133
2137 friend auto operator +(const std::basic_string<xtd::char16>& lhs, const basic_string& rhs) -> basic_string {
2138 auto result = lhs;
2139 if constexpr(std::is_same_v<xtd::char16, char_t>) result += rhs.chars();
2140 else result += __xtd_convert_to_string<xtd::char16>(rhs.chars());
2141 return result;
2142 }
2143
2147 friend auto operator +(const std::basic_string<xtd::char32>& lhs, const basic_string& rhs) -> basic_string {
2148 auto result = lhs;
2149 if constexpr(std::is_same_v<xtd::char32, char_t>) result += rhs.chars();
2150 else result += __xtd_convert_to_string<xtd::char32>(rhs.chars());
2151 return result;
2152 }
2153
2157 friend auto operator +(const std::basic_string<xtd::char8>& lhs, const basic_string& rhs) -> basic_string {
2158 auto result = lhs;
2159 if constexpr(std::is_same_v<xtd::char8, char_t>) result += rhs.chars();
2160 else result += __xtd_convert_to_string<xtd::char8>(rhs.chars());
2161 return result;
2162 }
2163
2167 friend auto operator +(const std::basic_string<xtd::wchar>& lhs, const basic_string& rhs) -> basic_string {
2168 auto result = lhs;
2169 if constexpr(std::is_same_v<xtd::wchar, char_t>) result += rhs.chars();
2170 else result += __xtd_convert_to_string<xtd::wchar>(rhs.chars());
2171 return result;
2172 }
2173
2178 friend auto operator +(const basic_string& lhs, const char* rhs) -> basic_string {
2179 auto result = lhs;
2180 result += rhs;
2181 return result;
2182 }
2183
2187 friend auto operator +(const basic_string& lhs, const xtd::char16* rhs) -> basic_string {
2188 auto result = lhs;
2189 result += rhs;
2190 return result;
2191 }
2192
2196 friend auto operator +(const basic_string& lhs, const xtd::char32* rhs) -> basic_string {
2197 auto result = lhs;
2198 result += rhs;
2199 return result;
2200 }
2201
2205 friend auto operator +(const basic_string& lhs, const xtd::char8* rhs) -> basic_string {
2206 auto result = lhs;
2207 result += rhs;
2208 return result;
2209 }
2210
2214 friend auto operator +(const basic_string& lhs, const xtd::wchar* rhs) -> basic_string {
2215 auto result = lhs;
2216 result += rhs;
2217 return result;
2218 }
2219
2224 friend auto operator +(basic_string&& lhs, const char* rhs) -> basic_string {
2225 auto result = std::move(lhs);
2226 result += rhs;
2227 return result;
2228 }
2229
2233 friend auto operator +(basic_string&& lhs, const xtd::char16* rhs) -> basic_string {
2234 auto result = std::move(lhs);
2235 result += rhs;
2236 return result;
2237 }
2238
2242 friend auto operator +(basic_string&& lhs, const xtd::char32* rhs) -> basic_string {
2243 auto result = std::move(lhs);
2244 result += rhs;
2245 return result;
2246 }
2247
2251 friend auto operator +(basic_string&& lhs, const xtd::char8* rhs) -> basic_string {
2252 auto result = std::move(lhs);
2253 result += rhs;
2254 return result;
2255 }
2256
2260 friend auto operator +(basic_string&& lhs, const xtd::wchar* rhs) -> basic_string {
2261 auto result = std::move(lhs);
2262 result += rhs;
2263 return result;
2264 }
2265
2270 friend auto operator +(const char* lhs, const basic_string& rhs) -> basic_string {
2271 auto result = basic_string(lhs);
2272 result += rhs;
2273 return result;
2274 }
2275
2279 friend auto operator +(const xtd::char16* lhs, const basic_string& rhs) -> basic_string {
2280 auto result = basic_string(lhs);
2281 result += rhs;
2282 return result;
2283 }
2284
2288 friend auto operator +(const xtd::char32* lhs, const basic_string& rhs) -> basic_string {
2289 auto result = basic_string(lhs);
2290 result += rhs;
2291 return result;
2292 }
2293
2297 friend auto operator +(const xtd::char8* lhs, const basic_string& rhs) -> basic_string {
2298 auto result = basic_string(lhs);
2299 result += rhs;
2300 return result;
2301 }
2302
2306 friend auto operator +(const xtd::wchar* lhs, const basic_string& rhs) -> basic_string {
2307 auto result = basic_string(lhs);
2308 result += rhs;
2309 return result;
2310 }
2311
2316 friend auto operator +(const char* lhs, basic_string&& rhs) -> basic_string {
2317 auto result = basic_string(lhs);
2318 result += std::move(rhs);
2319 return result;
2320 }
2321
2325 friend auto operator +(const xtd::char16* lhs, basic_string&& rhs) -> basic_string {
2326 auto result = basic_string(lhs);
2327 result += std::move(rhs);
2328 return result;
2329 }
2330
2334 friend auto operator +(const xtd::char32* lhs, basic_string&& rhs) -> basic_string {
2335 auto result = basic_string(lhs);
2336 result += std::move(rhs);
2337 return result;
2338 }
2339
2343 friend auto operator +(const xtd::char8* lhs, basic_string&& rhs) -> basic_string {
2344 auto result = basic_string(lhs);
2345 result += std::move(rhs);
2346 return result;
2347 }
2348
2352 friend auto operator +(const xtd::wchar* lhs, basic_string&& rhs) -> basic_string {
2353 auto result = basic_string(lhs);
2354 result += std::move(rhs);
2355 return result;
2356 }
2357
2362 friend auto operator +(const basic_string& lhs, const char rhs) -> basic_string {
2363 auto result = lhs;
2364 result += rhs;
2365 return result;
2366 }
2367
2371 friend auto operator +(const basic_string& lhs, const xtd::char16 rhs) -> basic_string {
2372 auto result = lhs;
2373 result += rhs;
2374 return result;
2375 }
2376
2380 friend auto operator +(const basic_string& lhs, const xtd::char32 rhs) -> basic_string {
2381 auto result = lhs;
2382 result += rhs;
2383 return result;
2384 }
2385
2389 friend auto operator +(const basic_string& lhs, const xtd::char8 rhs) -> basic_string {
2390 auto result = lhs;
2391 result += rhs;
2392 return result;
2393 }
2394
2398 friend auto operator +(const basic_string& lhs, const xtd::wchar rhs) -> basic_string {
2399 auto result = lhs;
2400 result += rhs;
2401 return result;
2402 }
2403
2408 friend auto operator +(basic_string&& lhs, const char rhs) -> basic_string {
2409 auto result = std::move(lhs);
2410 result += rhs;
2411 return result;
2412 }
2413
2417 friend auto operator +(basic_string&& lhs, const xtd::char16 rhs) -> basic_string {
2418 auto result = std::move(lhs);
2419 result += rhs;
2420 return result;
2421 }
2422
2426 friend auto operator +(basic_string&& lhs, const xtd::char32 rhs) -> basic_string {
2427 auto result = std::move(lhs);
2428 result += rhs;
2429 return result;
2430 }
2431
2435 friend auto operator +(basic_string&& lhs, const xtd::char8 rhs) -> basic_string {
2436 auto result = std::move(lhs);
2437 result += rhs;
2438 return result;
2439 }
2440
2444 friend auto operator +(basic_string&& lhs, const xtd::wchar rhs) -> basic_string {
2445 auto result = std::move(lhs);
2446 result += rhs;
2447 return result;
2448 }
2449
2454 friend auto operator +(char lhs, const basic_string& rhs) -> basic_string {
2455 auto result = basic_string(lhs, 1);
2456 result += rhs;
2457 return result;
2458 }
2459
2463 friend auto operator +(xtd::char16 lhs, const basic_string& rhs) -> basic_string {
2464 auto result = basic_string(lhs, 1);
2465 result += rhs;
2466 return result;
2467 }
2468
2472 friend auto operator +(xtd::char32 lhs, const basic_string& rhs) -> basic_string {
2473 auto result = basic_string(lhs, 1);
2474 result += rhs;
2475 return result;
2476 }
2477
2481 friend auto operator +(xtd::char8 lhs, const basic_string& rhs) -> basic_string {
2482 auto result = basic_string(lhs, 1);
2483 result += rhs;
2484 return result;
2485 }
2486
2490 friend auto operator +(xtd::wchar lhs, const basic_string& rhs) -> basic_string {
2491 auto result = basic_string(lhs, 1);
2492 result += rhs;
2493 return result;
2494 }
2495
2500 friend auto operator +(char lhs, basic_string&& rhs) -> basic_string {
2501 auto result = basic_string(lhs, 1);
2502 result += std::move(rhs);
2503 return result;
2504 }
2505
2510 auto result = basic_string(lhs, 1);
2511 result += std::move(rhs);
2512 return result;
2513 }
2514
2519 auto result = basic_string(lhs, 1);
2520 result += std::move(rhs);
2521 return result;
2522 }
2523
2527 friend auto operator +(xtd::char8 lhs, basic_string&& rhs) -> basic_string {
2528 auto result = basic_string(lhs, 1);
2529 result += std::move(rhs);
2530 return result;
2531 }
2532
2536 friend auto operator +(xtd::wchar lhs, basic_string&& rhs) -> basic_string {
2537 auto result = basic_string(lhs, 1);
2538 result += std::move(rhs);
2539 return result;
2540 }
2541
2550 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
2551 friend auto operator <<(std::basic_ostream<char>& stream, const basic_string& str) -> std::basic_ostream<char>& {
2552 if constexpr(std::is_same_v<char, char_t>) return stream << str.chars();
2553 else return stream << __xtd_convert_to_string<char>(str.chars());
2554 }
2555
2561 friend auto operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string& str) -> std::basic_ostream<xtd::wchar>& {return stream << str.to_wstring().chars();}
2562
2571 friend auto operator >>(std::basic_istream<char>& stream, basic_string& str) -> std::basic_istream<char>& {
2572 auto s = std::basic_string<char> {};
2573 stream >> s;
2574 str = s;
2575 return stream;
2576 }
2577
2585 friend auto operator >>(std::basic_istream<xtd::wchar>& stream, basic_string& str) -> std::basic_istream<xtd::wchar>& {
2586 auto s = std::basic_string<xtd::wchar> {};
2587 stream >> s;
2588 str = s;
2589 return stream;
2590 }
2591
2592
2594
2598 [[deprecated("Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 1.2.0.")]]
2599 [[nodiscard]] auto is_empty() const noexcept -> bool {return is_empty(self_);}
2605
2607
2608 template<typename object_t>
2609 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 1.2.0.")]]
2610 [[nodiscard]] static auto class_name() -> basic_string {return get_class_name(full_class_name<object_t>());}
2615 template<typename object_t>
2616 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 1.2.0.")]]
2617 [[nodiscard]] static auto class_name(const object_t& object) -> basic_string {return get_class_name(full_class_name(object));}
2622 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 1.2.0.")]]
2623 [[nodiscard]] static auto class_name(const std::type_info& info) -> basic_string {return __xtd_get_class_name(info);}
2628 template<typename object_t>
2629 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 1.2.0.")]]
2630 [[nodiscard]] static auto full_class_name() -> basic_string {return demangle(typeid(object_t).name());}
2635 template<typename object_t>
2636 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 1.2.0.")]]
2637 [[nodiscard]] static auto full_class_name(const object_t& object) -> basic_string {return demangle(typeid(object).name());}
2642 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 1.2.0.")]]
2643 [[nodiscard]] static auto full_class_name(const std::type_info& info) -> basic_string {return __xtd_get_full_class_name(info);}
2645
2646 private:
2647 friend class basic_string<char>;
2648 friend class basic_string<xtd::char16>;
2649 friend class basic_string<xtd::char32>;
2650 friend class basic_string<xtd::char8>;
2651 friend class basic_string<xtd::wchar>;
2652
2653 static const xtd::array<value_type> default_split_separators;
2654 static const xtd::array<value_type> default_trim_chars;
2655
2656 template<typename arg_t>
2657 [[nodiscard]] static auto convert_param(arg_t&& arg) noexcept {
2658 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();
2659 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();
2660 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();
2661 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();
2662 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();
2663 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();
2664 else return std::forward<arg_t>(arg);
2665 }
2666
2667 [[nodiscard]] static auto get_class_name(const basic_string& full_name) -> basic_string {
2668 auto length = full_name.last_index_of("<");
2669 if (length == npos) length = full_name.length();
2670 if (full_name.last_index_of("::", 0, length) == npos) return full_name;
2671 return full_name.substring(full_name.last_index_of("::", 0, length) + 2);
2672 }
2673
2674 base_type chars_;
2675 };
2676}
2677
2678#define __XTD_BASIC_STRING_INTERNAL__
2679#include "basic_string_.hpp"
2680#undef __XTD_BASIC_STRING_INTERNAL__
2681
2683namespace std {
2684 template<typename char_t>
2685 struct hash<xtd::basic_string<char_t>> {
2686 auto operator()(const xtd::basic_string<char_t>& s) const noexcept -> xtd::usize {return s.get_hash_code();}
2687 };
2688}
Contains xtd::basic_string class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents text as a sequence of character units.
Definition basic_string.hpp:67
basic_string(const basic_string< xtd::char32 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:178
std::basic_string< char_t, traits_t, allocator_t > base_type
Represents the basic string base type.
Definition basic_string.hpp:74
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:701
static auto parse(const basic_string &str) -> value_t
Converts a basic_string into a value_t type.
Definition basic_string.hpp:1308
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:581
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:869
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:718
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:686
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:1125
static auto class_name() -> basic_string
Gets the class name of the object_t.
Definition basic_string.hpp:2610
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:404
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:1057
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:934
static const basic_string empty_string
Definition basic_string.hpp:112
auto chars() noexcept -> base_type &
Returns a reference to the underlying base type.
Definition basic_string.hpp:361
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:1416
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:1203
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:2551
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:243
basic_string(const xtd::char32 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:260
auto to_u16string() const noexcept -> basic_string< xtd::char16 >
Definition basic_string.hpp:927
typename base_type::allocator_type allocator_type
Represents the basic string allocator type.
Definition basic_string.hpp:80
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:524
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:310
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:948
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:1022
static auto full_class_name() -> basic_string
Definition basic_string.hpp:2630
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:425
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:854
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:1897
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:325
typename xtd::collections::generic::enumerator< value_type > enumerator_type
Represents the basic string enumerator type.
Definition basic_string.hpp:104
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:680
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:184
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:1259
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:1274
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:441
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:416
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:319
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:859
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:92
basic_string(std::initializer_list< xtd::wchar > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:340
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:2571
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:296
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:172
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:878
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:196
virtual auto length() const noexcept -> size_type
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:384
typename base_type::traits_type traits_type
Represents the basic string traits type.
Definition basic_string.hpp:76
virtual auto get_base_type() const noexcept -> const base_type &
Returns the underlying base type.
Definition basic_string.hpp:478
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:1085
typename base_type::pointer pointer
Represents the basic string pointer type.
Definition basic_string.hpp:90
typename base_type::const_reference const_reference
Represents the basic string const referecne type.
Definition basic_string.hpp:88
basic_string(std::initializer_list< xtd::char32 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:334
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:461
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:202
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:941
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:421
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:1101
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:662
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:1071
auto to_lower() const noexcept -> basic_string
Returns a copy of the current xtd::basic_string converted to lowercase.
Definition basic_string.hpp:907
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:669
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:282
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:190
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:239
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:2637
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:1044
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:529
typename xtd::collections::generic::ienumerable< char_t >::iterator iterator
Represents the basic string iterator type.
Definition basic_string.hpp:95
typename base_type::const_reverse_iterator const_reverse_iterator
Represents the basic string const reverse iterator type.
Definition basic_string.hpp:102
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:1093
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:509
basic_string(const char *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:246
static constexpr xtd::usize bpos
Definition basic_string.hpp:132
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:602
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:956
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:354
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:289
basic_string(std::initializer_list< char > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:328
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:1107
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:1284
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:840
typename base_type::size_type size_type
Represents the basic string size type.
Definition basic_string.hpp:82
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:587
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:466
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:1380
basic_string(const xtd::wchar *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:274
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:712
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:997
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:616
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:430
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:122
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:231
virtual auto empty() const noexcept -> bool
Checks whether the container is empty.
Definition basic_string.hpp:379
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:1226
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:235
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:166
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:2643
auto operator+=(const basic_string< char > &str) -> basic_string &
Addition assignment operator. Appends additional characters to the string.
Definition basic_string.hpp:1703
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:303
static auto class_name(const std::type_info &info) -> basic_string
Gets the class name of the specified object.
Definition basic_string.hpp:2623
static auto concat(value_t value) noexcept -> basic_string
Creates the basic_string representation of a specified object.
Definition basic_string.hpp:1169
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:594
auto operator[](xtd::index index) const -> const_reference
Returns a reference to the character at specified location index.
Definition basic_string.hpp:1397
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:965
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:454
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:571
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:675
basic_string(const xtd::char16 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:253
typename base_type::value_type value_type
Represents the basic string value type.
Definition basic_string.hpp:78
typename base_type::reverse_iterator reverse_iterator
Represents the basic string reverse iterator type.
Definition basic_string.hpp:100
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:696
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:449
basic_string(std::initializer_list< xtd::char16 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:331
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:655
basic_string(std::initializer_list< xtd::char8 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:337
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:1193
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:435
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:981
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:834
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:1114
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:1033
basic_string(const xtd::char8 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:267
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:1119
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:608
auto is_empty() const noexcept -> bool
Name Public Deprecated Methods.
Definition basic_string.hpp:2599
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:375
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:536
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:848
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:482
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:916
auto get_enumerator() const noexcept -> enumerator_type override
Returns an enumerator that iterates through a collection.
Definition basic_string.hpp:484
typename base_type::reference reference
Represents the basic string referecne type.
Definition basic_string.hpp:86
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:1210
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:220
virtual auto count() const noexcept -> size_type
Definition basic_string.hpp:366
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:227
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:471
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:1218
typename xtd::collections::generic::ienumerable< char_t >::const_iterator const_iterator
Represents the basic string const iterator type.
Definition basic_string.hpp:98
typename base_type::difference_type difference_type
Represents the basic string difference type.
Definition basic_string.hpp:84
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:648
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:208
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:214
auto chars() const noexcept -> const base_type &
Returns a reference to the underlying base type.
Definition basic_string.hpp:358
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:322
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:1250
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:163
static auto class_name(const object_t &object) -> basic_string
Gets the class name of the specified object.
Definition basic_string.hpp:2617
static constexpr xtd::usize epos
Definition basic_string.hpp:150
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:504
virtual auto size() const noexcept -> size_type
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:389
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:516
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:1373
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.
Contains xtd::index struct.
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:262
auto begin() const -> const_iterator
Returns an iterator to the beginning.
Definition read_only_span.hpp:199
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:287
auto end() const -> const_iterator
Returns an iterator to the end.
Definition read_only_span.hpp:218
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.