xtd 0.2.0
Loading...
Searching...
No Matches
basic_string.hpp
Go to the documentation of this file.
1
4#pragma once
6#define __XTD_CORE_INTERNAL__
11#undef __XTD_CORE_INTERNAL__
12#define __XTD_STD_INTERNAL__
14#undef __XTD_STD_INTERNAL__
17#include "hash_code.hpp"
18#include "icomparable.hpp"
19#include "iequatable.hpp"
20#include "null.hpp"
21#include "string_comparison.hpp"
23#include "types.hpp"
24#include "object.hpp"
25#include "parse.hpp"
26#include "types.hpp"
27#include <cctype>
28#include <iomanip>
29#include <ostream>
30#include <sstream>
31#include <string>
32
34template<typename ...args_t>
35void __basic_string_extract_format_arg(const std::locale& loc, xtd::basic_string<char>& fmt, xtd::array<__format_information<char >>& formats, args_t&&... args);
36template<typename target_t, typename source_t>
37std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str) noexcept;
38template<typename target_t, typename source_t>
39std::basic_string<target_t> __xtd_convert_to_string(const std::basic_string<source_t>& str) noexcept;
40std::basic_string<char> __xtd_demangle(const std::basic_string<char>& value) noexcept;
41std::basic_string<char> __xtd_get_class_name(const std::type_info& value) noexcept;
42std::basic_string<char> __xtd_get_full_class_name(const std::type_info& value) noexcept;
44
46namespace xtd {
65 template<typename char_t, typename traits_t, typename allocator_t>
66 class basic_string : public object, public xtd::icomparable<basic_string<char_t, traits_t, allocator_t>>, public xtd::iequatable<basic_string<char_t, traits_t, allocator_t >>, public xtd::collections::generic::ienumerable<char_t> {
67 public:
69
73 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
75 using traits_type = typename base_type::traits_type;
77 using value_type = typename base_type::value_type;
79 using allocator_type = typename base_type::allocator_type;
81 using size_type = typename base_type::size_type;
83 using difference_type = typename base_type::difference_type;
85 using reference = typename base_type::reference;
87 using const_reference = typename base_type::const_reference;
89 using pointer = typename base_type::pointer;
91 using const_pointer = typename base_type::const_pointer;
99 using reverse_iterator = typename base_type::reverse_iterator;
101 using const_reverse_iterator = typename base_type::const_reverse_iterator;
105
107
112
121 inline static constexpr size_type npos = base_type::npos;
122
131 static inline constexpr xtd::size bpos = 0;
132
149 static inline constexpr xtd::size epos = npos - 1;
151
153
156 basic_string() = default;
162 basic_string(std::basic_string<char_t>&& str) : chars_ {std::move(str)} {}
165 basic_string(const basic_string<char>& str) noexcept {
166 if constexpr(std::is_same_v<char, char_t>) chars_ = str.chars_;
167 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
168 }
169
172 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str.chars_;
173 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
174 }
175
178 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str.chars_;
179 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
180 }
181
184 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str.chars_;
185 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
186 }
187
190 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str.chars_;
191 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
192 }
193
195 basic_string(const std::basic_string<char>& str) noexcept { // Can't be explicit by design.
196 if constexpr(std::is_same_v<char, char_t>) chars_ = str;
197 else chars_ = __xtd_convert_to_string<value_type>(str);
198 }
199
201 basic_string(const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
202 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = str;
203 else chars_ = __xtd_convert_to_string<value_type>(str);
204 }
205
207 basic_string(const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
208 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = str;
209 else chars_ = __xtd_convert_to_string<value_type>(str);
210 }
211
213 basic_string(const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
214 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = str;
215 else chars_ = __xtd_convert_to_string<value_type>(str);
216 }
217
219 basic_string(const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
220 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = str;
221 else chars_ = __xtd_convert_to_string<value_type>(str);
222 }
223
245 basic_string(const char* str) { // Can't be explicit by design.
247 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
248 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
249 }
250
252 basic_string(const xtd::char16* str) { // Can't be explicit by design.
254 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
255 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
256 }
257
259 basic_string(const xtd::char32* str) { // Can't be explicit by design.
261 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
262 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
263 }
264
266 basic_string(const xtd::char8* str) { // Can't be explicit by design.
268 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
269 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
270 }
271
273 basic_string(const xtd::wchar* str) { // Can't be explicit by design.
275 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
276 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
277 }
278
281 basic_string(const char* str, xtd::size count) {
283 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count);
284 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count));
285 }
286
290 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count);
291 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count));
292 }
293
297 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count);
298 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count));
299 }
300
304 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count);
305 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count));
306 }
307
311 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count);
312 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
313 }
314
317 template<typename input_iterator_t>
318 basic_string(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
321 basic_string(const std::basic_string_view<char_t>& str) : chars_(str) {}
324 basic_string(std::initializer_list<char> il) : basic_string(std::basic_string<char>(il)) {}
327 basic_string(std::initializer_list<xtd::char16> il) : basic_string(std::basic_string<xtd::char16>(il)) {}
330 basic_string(std::initializer_list<xtd::char32> il) : basic_string(std::basic_string<xtd::char32>(il)) {}
333 basic_string(std::initializer_list<xtd::char8> il) : basic_string(std::basic_string<xtd::char8>(il)) {}
336 basic_string(std::initializer_list<xtd::wchar> il) : basic_string(std::basic_string<xtd::wchar>(il)) {}
338
340
350 [[nodiscard]] auto c_str() const noexcept -> const_pointer {return chars_.c_str();}
351
354 [[nodiscard]] auto chars() const noexcept -> const base_type& {return chars_;}
357 [[nodiscard]] auto chars() noexcept -> base_type& {return chars_;}
358
362 [[nodiscard]] virtual auto count() const noexcept -> size_type {return chars_.size();}
363
371 [[nodiscard]] auto data() const noexcept -> const_pointer {return chars_.data();}
372
375 [[nodiscard]] virtual auto empty() const noexcept -> bool {return length() == 0;}
376
380 [[nodiscard]] virtual auto length() const noexcept -> size_type {return chars_.size();}
381
385 [[nodiscard]] virtual auto size() const noexcept -> size_type {return chars_.size();}
387
389
400 [[nodiscard]] auto compare_to(const object& value) const -> xtd::int32 {
402 return compare_to(static_cast<const basic_string&>(value));
403 }
404
412 [[nodiscard]] auto compare_to(const basic_string& value) const noexcept -> xtd::int32 override {return chars_.compare(value.chars_);}
413
417 [[nodiscard]] virtual auto contains(value_type value) const noexcept -> bool {return chars_.find(value) != npos;}
421 [[nodiscard]] virtual auto contains(const basic_string& value) const noexcept -> bool {return chars_.find(value) != npos;}
422
426 [[nodiscard]] auto equals(const object& obj) const noexcept -> bool override {return dynamic_cast<const basic_string*>(&obj) && equals(static_cast<const basic_string&>(obj));}
431 [[nodiscard]] auto equals(const basic_string& value) const noexcept -> bool override {return equals(value, false);}
437 [[nodiscard]] auto equals(const basic_string& value, bool ignore_case) const noexcept -> bool {
438 if (ignore_case) return to_upper().chars_ == value.to_upper().chars_;
439 return chars_ == value.chars_;
440 }
441
445 [[nodiscard]] auto ends_with(value_type value) const noexcept -> bool {return ends_with(value, false);}
450 [[nodiscard]] auto ends_with(value_type value, bool ignore_case) const noexcept -> bool {
451 if (ignore_case) return to_lower().chars_.rfind(static_cast<value_type>(tolower(value))) == length() - 1;
452 return chars_.rfind(value) == length() - 1;
453 }
454
457 [[nodiscard]] auto ends_with(const basic_string& value) const noexcept -> bool {return ends_with(value, xtd::string_comparison::ordinal);}
462 [[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);}
467 [[nodiscard]] auto ends_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept -> bool {
468 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.rfind(value.to_lower()) + value.to_lower().length() == length();
469 return chars_.rfind(value) + value.length() == length();
470 }
471
474 [[nodiscard]] virtual auto get_base_type() const noexcept -> const base_type& {return chars_;}
475
478 [[nodiscard]] auto get_hash_code() const noexcept -> xtd::size override {return xtd::hash_code::combine(chars_);}
479
480 [[nodiscard]] auto get_enumerator() const noexcept -> enumerator_type override {
481 struct basic_string_enumerator : public xtd::collections::generic::ienumerator<value_type> {
482 explicit basic_string_enumerator(const basic_string& chars) : chars_(chars) {}
483 [[nodiscard]] const value_type& current() const override {
485 return chars_[index_];
486 }
487 bool move_next() override {return ++index_ < chars_.length();}
488 void reset() override {index_ = basic_string::npos;}
489
490 private:
491 const basic_string& chars_;
493 };
495 }
496
500 [[nodiscard]] auto index_of(const basic_string& value) const noexcept -> xtd::size {return index_of(value, 0, length());}
505 [[nodiscard]] auto index_of(const basic_string& value, xtd::size start_index) const -> xtd::size {return index_of(value, start_index, length() - start_index);}
512 [[nodiscard]] auto index_of(const basic_string& value, xtd::size start_index, xtd::size count) const -> xtd::size {
514 auto result = chars_.find(value, start_index);
515 return result > start_index + count ? npos : result;
516 }
517
520 [[nodiscard]] auto index_of(value_type value) const noexcept -> xtd::size {return index_of(value, 0, length());}
525 [[nodiscard]] auto index_of(value_type value, xtd::size start_index) const -> xtd::size {return index_of(value, start_index, length() - start_index);}
532 [[nodiscard]] auto index_of(value_type value, xtd::size start_index, xtd::size count) const -> xtd::size {
534 auto result = chars_.find(value, start_index);
535 return result > start_index + count ? npos : result;
536 }
537
541 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values) const noexcept -> xtd::size;
547 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values, xtd::size start_index) const -> xtd::size;
554 [[nodiscard]] auto index_of_any(const xtd::array<value_type>& values, xtd::size start_index, xtd::size count) const -> xtd::size;
556 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values) const noexcept -> xtd::size;
557 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const -> xtd::size;
558 [[nodiscard]] auto index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const -> xtd::size;
560
567 auto insert(xtd::size start_index, const basic_string& value) const -> basic_string {
569 auto result = self_;
570 result.chars_.insert(start_index, value);
571 return result;
572 }
573
577 [[nodiscard]] auto last_index_of(const basic_string& value) const noexcept -> xtd::size {return last_index_of(value, 0, length());}
583 [[nodiscard]] auto last_index_of(const basic_string& value, xtd::size start_index) const -> xtd::size {return last_index_of(value, start_index, length() - start_index);}
590 [[nodiscard]] auto last_index_of(const basic_string& value, xtd::size start_index, xtd::size count) const -> xtd::size {
592 auto result = chars_.rfind(value, start_index + count - value.length());
593 return result < start_index ? npos : result;
594 }
595
598 [[nodiscard]] auto last_index_of(value_type value) const noexcept -> xtd::size {return last_index_of(value, 0, length());}
604 [[nodiscard]] auto last_index_of(value_type value, xtd::size start_index) const -> xtd::size {return last_index_of(value, start_index, length() - start_index);}
612 [[nodiscard]] auto last_index_of(value_type value, xtd::size start_index, xtd::size count) const -> xtd::size {
614 auto result = chars_.rfind(value, start_index + count - 1);
615 return result < start_index ? npos : result;
616 }
617
621 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values) const noexcept -> xtd::size;
626 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values, xtd::size start_index) const -> xtd::size;
632 [[nodiscard]] auto last_index_of_any(const xtd::array<value_type>& values, xtd::size start_index, xtd::size count) const -> xtd::size;
634 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values) const noexcept -> xtd::size;
635 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const -> xtd::size;
636 [[nodiscard]] auto last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const -> xtd::size;
638
644 [[nodiscard]] auto pad_left(xtd::size total_width) const noexcept -> basic_string {return pad_left(total_width, ' ');}
651 [[nodiscard]] auto pad_left(xtd::size total_width, char32 padding_char) const noexcept -> basic_string {return total_width < length() ? self_ : basic_string(padding_char, total_width - length()) + self_;}
652
658 [[nodiscard]] auto pad_right(xtd::size total_width) const noexcept -> basic_string {return pad_right(total_width, ' ');}
665 [[nodiscard]] auto pad_right(xtd::size total_width, char32 padding_char) const noexcept -> basic_string {return total_width < length() ? self_ : self_ + basic_string(padding_char, total_width - length());}
666
671 [[nodiscard]] auto quoted() const -> basic_string {return quoted('"', '\\');}
676 [[nodiscard]] auto quoted(value_type delimiter) const -> basic_string {return quoted(delimiter, '\\');}
682 [[nodiscard]] auto quoted(value_type delimiter, value_type escape) const -> basic_string {
683 std::wstringstream ss;
684 if constexpr(std::is_same_v<xtd::wchar, value_type>) ss << std::quoted(chars_, delimiter, escape);
685 else ss << std::quoted(__xtd_convert_to_string<xtd::wchar>(chars_), static_cast<xtd::wchar>(delimiter), static_cast<xtd::wchar>(escape));
686 return ss.str();
687 }
688
692 [[nodiscard]] auto remove(xtd::size start_index) const -> basic_string {return remove(start_index, length() - start_index);}
697 [[nodiscard]] auto remove(xtd::size start_index, xtd::size count) const -> basic_string {
699 auto result = self_;
700 result.chars_.erase(start_index, count);
701 return result;
702 }
703
708 [[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));}
714 [[nodiscard]] auto replace(const basic_string& old_string, const basic_string& new_string) const noexcept -> basic_string {
715 auto result = self_;
716 auto old_size = old_string.length();
717 auto new_size = new_string.length();
718 auto index = xtd::size {0};
719 while (true) {
720 index = result.chars_.find(old_string, index);
721 if (index == npos) break;
722 if (old_size == new_size) result.chars_.replace(index, old_size, new_string);
723 else {
724 result.chars_.erase(index, old_string.length());
725 result.chars_.insert(index, new_string);
726 }
727 index += new_string.length();
728 }
729 return result;
730 }
731
736 [[nodiscard]] auto split() const noexcept -> xtd::array<basic_string>;
742 [[nodiscard]] auto split(value_type separator) const noexcept -> xtd::array<basic_string>;
759 [[nodiscard]] auto split(value_type separator, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
768 [[nodiscard]] auto split(value_type separator, xtd::size count) const noexcept -> xtd::array<basic_string>;
780 [[nodiscard]] auto split(value_type separator, xtd::size count, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
786 [[nodiscard]] auto split(const xtd::array<value_type>& separators) const noexcept -> xtd::array<basic_string>;
803 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
812 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::size count) const noexcept -> xtd::array<basic_string>;
824 [[nodiscard]] auto split(const xtd::array<value_type>& separators, xtd::size count, xtd::string_split_options options) const noexcept -> xtd::array<basic_string>;
825
830 [[nodiscard]] bool starts_with(value_type value) const noexcept {return starts_with(value, false);}
836 [[nodiscard]] bool starts_with(value_type value, bool ignore_case) const noexcept {
837 if (ignore_case) return to_lower().chars_.find(static_cast<value_type>(tolower(value))) == 0;
838 return chars_.find(value) == 0;
839 }
840
844 [[nodiscard]] auto starts_with(const basic_string& value) const noexcept -> bool {return starts_with(value, string_comparison::ordinal);}
850 [[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);}
855 [[nodiscard]] auto starts_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept -> bool {
856 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().chars_.find(value.to_lower()) == 0;
857 return chars_.find(value) == 0;
858 }
859
865 [[nodiscard]] auto substring(xtd::size start_index) const -> basic_string {
867 return chars_.substr(start_index);
868 }
869
874 [[nodiscard]] auto substring(xtd::size start_index, xtd::size length) const -> basic_string {
876 return chars_.substr(start_index, length);
877 }
878
881 [[nodiscard]] auto to_array() const noexcept -> xtd::array<value_type>;
885 [[nodiscard]] auto to_array(xtd::size start_index) const -> xtd::array<value_type>;
890 [[nodiscard]] auto to_array(xtd::size start_index, xtd::size length) const -> xtd::array<value_type>;
891
894 [[nodiscard]] auto to_char_array() const noexcept -> xtd::array<value_type>;
899 [[nodiscard]] auto to_char_array(xtd::size start_index, xtd::size length) const -> xtd::array<value_type>;
900
903 [[nodiscard]] auto to_lower() const noexcept -> basic_string {
904 auto result = basic_string::empty_string;
905 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::tolower(c));});
906 return result;
907 }
908
912 [[nodiscard]] auto to_string() const noexcept -> basic_string<char> override {
913 if constexpr(std::is_same_v<char, char_t>) return chars_;
914 else return __xtd_convert_to_string<char>(chars_);
915 }
916
919 [[nodiscard]] auto to_title_case() const noexcept -> basic_string;
920
923 [[nodiscard]] auto to_u16string() const noexcept -> basic_string<xtd::char16> {
924 if constexpr(std::is_same_v<xtd::char16, char_t>) return chars_;
925 else return __xtd_convert_to_string<xtd::char16>(chars_);
926 }
927
930 [[nodiscard]] auto to_u32string() const noexcept -> basic_string<xtd::char32> {
931 if constexpr(std::is_same_v<xtd::char32, char_t>) return chars_;
932 else return __xtd_convert_to_string<xtd::char32>(chars_);
933 }
934
937 [[nodiscard]] auto to_u8string() const noexcept -> basic_string<xtd::char8> {
938 if constexpr(std::is_same_v<xtd::char8, char_t>) return chars_;
939 else return __xtd_convert_to_string<xtd::char8>(chars_);
940 }
941
944 [[nodiscard]] auto to_upper() const noexcept -> basic_string {
945 auto result = basic_string::empty_string;
946 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::toupper(c));});
947 return result;
948 }
949
952 [[nodiscard]] auto to_wstring() const noexcept -> basic_string<xtd::wchar> {
953 if constexpr(std::is_same_v<xtd::wchar, char_t>) return chars_;
954 else return __xtd_convert_to_string<xtd::wchar>(chars_);
955 }
956
961 [[nodiscard]] auto trim() const noexcept -> basic_string {return trim(default_trim_chars);}
966 [[nodiscard]] auto trim(value_type trim_char) const noexcept -> basic_string;
971 [[nodiscard]] auto trim(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
972
977 [[nodiscard]] auto trim_end() const noexcept -> basic_string {return trim_end(default_trim_chars);}
982 [[nodiscard]] auto trim_end(value_type trim_char) const noexcept -> basic_string;
987 [[nodiscard]] auto trim_end(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
988
993 [[nodiscard]] auto trim_start() const noexcept -> basic_string {return trim_start(default_trim_chars);}
998 [[nodiscard]] auto trim_start(value_type trim_char) const noexcept -> basic_string;
1003 [[nodiscard]] auto trim_start(const xtd::array<value_type>& trim_chars) const noexcept -> basic_string;
1005
1007
1018 [[nodiscard]] static auto compare(const basic_string& str_a, const basic_string& str_b) noexcept -> xtd::int32 {return compare(str_a, str_b, false);}
1029 [[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);}
1040 [[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);}
1053 [[nodiscard]] static auto compare(const basic_string& str_a, xtd::size index_a, const basic_string& str_b, xtd::size index_b, xtd::size length) -> xtd::int32 {return compare(str_a, index_a, str_b, index_b, length, false);}
1067 [[nodiscard]] static auto compare(const basic_string& str_a, xtd::size index_a, const basic_string& str_b, xtd::size index_b, xtd::size length, bool ignore_case) -> 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);}
1081 [[nodiscard]] static auto compare(const basic_string& str_a, xtd::size index_a, const basic_string& str_b, xtd::size index_b, xtd::size length, xtd::string_comparison comparison_type) -> 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));}
1082
1089 [[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;}
1096 template<typename object_a_t, typename object_b_t, typename object_c_t, typename object_d_t>
1097 [[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);}
1103 [[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;}
1109 template<typename object_a_t, typename object_b_t, typename object_c_t>
1110 [[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);}
1115 [[nodiscard]] static auto concat(const basic_string& str_a, const basic_string& str_b) noexcept -> basic_string {return str_a + str_b;}
1120 template<typename object_a_t, typename object_b_t>
1121 [[nodiscard]] static auto concat(object_a_t obj_a, object_b_t obj_b) noexcept -> basic_string {return format("{}{}", obj_a, obj_b);}
1125 [[nodiscard]] static auto concat(const xtd::array<basic_string>& values) noexcept -> basic_string;
1127 [[nodiscard]] static auto concat(const xtd::array<const_pointer>& values) noexcept -> basic_string;
1128 template<typename other_char_t>
1129 [[nodiscard]] static auto concat(const xtd::array<const other_char_t*>& values) noexcept -> basic_string;
1130 [[nodiscard]] static auto concat(const std::initializer_list<basic_string>& values) noexcept -> basic_string {
1131 auto result = basic_string::empty_string;
1132 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1133 return result;
1134 }
1135 [[nodiscard]] static auto concat(const std::initializer_list<const_pointer>& values) noexcept -> basic_string {
1136 auto result = basic_string::empty_string;
1137 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1138 return result;
1139 }
1140 template<typename other_char_t>
1141 [[nodiscard]] static auto concat(const std::initializer_list<const other_char_t*>& values) noexcept -> basic_string {
1142 auto result = basic_string::empty_string;
1143 std::for_each(values.begin(), values.end(), [&](const auto& item) {result += item;});
1144 return result;
1145 }
1150 template<typename object_t>
1151 [[nodiscard]] static auto concat(const xtd::array<object_t>& args) noexcept -> basic_string;
1153 template<typename object_t>
1154 [[nodiscard]] static auto concat(const std::initializer_list<object_t>& args) noexcept -> basic_string {
1155 basic_string result;
1156 for (const auto& arg : args)
1157 result += format("{}", arg);
1158 return result;
1159 }
1164 template<typename value_t>
1165 [[nodiscard]] static auto concat(value_t value) noexcept -> basic_string {
1166 return format("{}", value);
1167 }
1168
1189 [[nodiscard]] static auto demangle(const basic_string& name) -> basic_string {
1190 if constexpr(std::is_same_v<char, char_t>) return __xtd_demangle(name.chars());
1191 else return __xtd_demangle(__xtd_convert_to_string<char>(name.chars()));
1192 }
1193
1199 [[nodiscard]] static auto equals(const basic_string& a, const basic_string& b) noexcept -> bool {return a.equals(b);}
1205 template<typename char_a_t, typename char_b_t>
1206 [[nodiscard]] static auto equals(const char_a_t* a, const char_b_t* b) noexcept -> bool {return basic_string {a}.equals(basic_string {b});}
1207
1214 [[nodiscard]] static auto equals(const basic_string& a, const basic_string& b, bool ignore_case) noexcept -> bool {return a.equals(b, ignore_case);}
1221 template<typename char_a_t, typename char_b_t>
1222 [[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);}
1223
1230 template<typename ...args_t>
1231 [[nodiscard]] static auto format(const basic_string<char>& fmt, args_t&& ... args) -> basic_string;
1232
1240 template<typename ...args_t>
1241 [[nodiscard]] static auto format(const std::locale& loc, const basic_string<char>& fmt, args_t&& ... args) -> basic_string;
1242
1246 [[nodiscard]] static auto is_empty(const xtd::basic_string<value_type, traits_type, allocator_type>& string) noexcept -> bool {return !string.length();}
1247
1254 template<typename collection_t>
1255 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values) noexcept -> basic_string {
1256 xtd::size i = 0;
1257 basic_string result;
1258 for (const auto& item : values)
1259 result += format("{}{}", (i++ != 0 ? separator : basic_string {}), item);
1260 return result;
1261 }
1262
1269 template<typename collection_t>
1270 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values, xtd::size index) -> basic_string {return join(separator, values, index, values.size() - index);}
1279 template<typename collection_t>
1280 [[nodiscard]] static auto join(const basic_string& separator, const collection_t& values, xtd::size index, xtd::size count) -> basic_string {
1281 if (index > values.size() || index + count > values.size()) xtd::helpers::throw_helper::throws(xtd::helpers::exception_case::argument_out_of_range);
1282 xtd::size i = 0;
1283 basic_string result;
1284 for (const auto& item : values) {
1285 if (i >= index) result += format("{}{}", (i != index ? separator : basic_string {}), item);
1286 if (++i >= index + count) break;
1287 }
1288 return result;
1289 }
1290
1292 template<typename value_t>
1293 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values) noexcept -> basic_string;
1294 template<typename value_t>
1295 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::size index) -> basic_string;
1296 template<typename value_t>
1297 [[nodiscard]] static auto join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::size index, xtd::size count) -> basic_string;
1299
1303 template<typename value_t>
1304 [[nodiscard]] static auto parse(const basic_string& str) -> value_t {
1305 if constexpr(std::is_same_v<char, char_t>) return xtd::parse<value_t>(str.chars());
1306 else return xtd::parse<value_t>(__xtd_convert_to_string<char>(str.chars()));
1307 }
1308
1368 template<typename ...args_t>
1369 [[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)) ...);}
1370
1375 template<typename value_t>
1376 static auto try_parse(const basic_string& str, value_t& value) noexcept -> bool {
1377 try {
1378 value = parse<value_t>(str);
1379 return true;
1380 } catch (...) {
1381 return false;
1382 }
1383 }
1384
1385
1387
1395 return chars_[index == epos ? length() - 1 : index];
1396 }
1397
1400 operator const base_type& () const noexcept {return chars_;}
1401
1405 auto operator =(const basic_string<char>& str) noexcept -> basic_string& {
1406 if constexpr(std::is_same<char_t, char>::value) chars_ = str.chars_;
1407 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1408 return self_;
1409 }
1410
1413 auto operator =(const basic_string<xtd::char16>& str) noexcept -> basic_string& {
1414 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str.chars_;
1415 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1416 return self_;
1417 }
1418
1421 auto operator =(const basic_string<xtd::char32>& str) noexcept -> basic_string& {
1422 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str.chars_;
1423 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1424 return self_;
1425 }
1426
1429 auto operator =(const basic_string<xtd::char8>& str) noexcept -> basic_string& {
1430 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str.chars_;
1431 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1432 return self_;
1433 }
1434
1437 auto operator =(const basic_string<xtd::wchar>& str) noexcept -> basic_string& {
1438 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str.chars_;
1439 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
1440 return self_;
1441 }
1442
1446 auto operator =(basic_string<char>&& str) noexcept -> basic_string& {
1447 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str.chars_);
1448 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1449 return self_;
1450 }
1451
1455 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str.chars_);
1456 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1457 return self_;
1458 }
1459
1463 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str.chars_);
1464 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1465 return self_;
1466 }
1467
1471 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str.chars_);
1472 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1473 return self_;
1474 }
1475
1479 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str.chars_);
1480 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
1481 return self_;
1482 }
1483
1487 auto operator =(const std::basic_string<char>& str) noexcept -> basic_string& {
1488 if constexpr(std::is_same<char_t, char>::value) chars_ = str;
1489 else chars_ = __xtd_convert_to_string<value_type>(str);
1490 return self_;
1491 }
1492
1495 auto operator =(const std::basic_string<xtd::char16>& str) noexcept -> basic_string& {
1496 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str;
1497 else chars_ = __xtd_convert_to_string<value_type>(str);
1498 return self_;
1499 }
1500
1503 auto operator =(const std::basic_string<xtd::char32>& str) noexcept -> basic_string& {
1504 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str;
1505 else chars_ = __xtd_convert_to_string<value_type>(str);
1506 return self_;
1507 }
1508
1511 auto operator =(const std::basic_string<xtd::char8>& str) noexcept -> basic_string& {
1512 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str;
1513 else chars_ = __xtd_convert_to_string<value_type>(str);
1514 return self_;
1515 }
1516
1519 auto operator =(const std::basic_string<xtd::wchar>& str) noexcept -> basic_string& {
1520 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str;
1521 else chars_ = __xtd_convert_to_string<value_type>(str);
1522 return self_;
1523 }
1524
1528 auto operator =(std::basic_string<char>&& str) noexcept -> basic_string& {
1529 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str);
1530 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1531 return self_;
1532 }
1533
1536 auto operator =(std::basic_string<xtd::char16>&& str) noexcept -> basic_string& {
1537 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str);
1538 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1539 return self_;
1540 }
1541
1544 auto operator =(std::basic_string<xtd::char32>&& str) noexcept -> basic_string& {
1545 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str);
1546 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1547 return self_;
1548 }
1549
1552 auto operator =(std::basic_string<xtd::char8>&& str) noexcept -> basic_string& {
1553 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str);
1554 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1555 return self_;
1556 }
1557
1560 auto operator =(std::basic_string<xtd::wchar>&& str) noexcept -> basic_string& {
1561 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str);
1562 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
1563 return self_;
1564 }
1565
1570 auto operator =(const char* str) -> basic_string& {
1572 if constexpr(std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
1573 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
1574 return self_;
1575 }
1576
1580 auto operator =(const xtd::char16* str) -> basic_string& {
1582 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
1583 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
1584 return self_;
1585 }
1586
1590 auto operator =(const xtd::char32* str) -> basic_string& {
1592 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
1593 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
1594 return self_;
1595 }
1596
1600 auto operator =(const xtd::char8* str) -> basic_string& {
1602 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
1603 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
1604 return self_;
1605 }
1606
1610 auto operator =(const xtd::wchar* str) -> basic_string& {
1612 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
1613 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
1614 return self_;
1615 }
1616
1622 return self_;
1623 }
1624
1629 return self_;
1630 }
1631
1636 return self_;
1637 }
1638
1643 return self_;
1644 }
1645
1650 return self_;
1651 }
1652
1656 auto operator =(const std::initializer_list<char>& il) -> basic_string& {
1657 self_ = basic_string(il);
1658 return self_;
1659 }
1660
1663 auto operator =(const std::initializer_list<xtd::char16>& il) -> basic_string& {
1664 self_ = basic_string(il);
1665 return self_;
1666 }
1667
1670 auto operator =(const std::initializer_list<xtd::char32>& il) -> basic_string& {
1671 self_ = basic_string(il);
1672 return self_;
1673 }
1674
1677 auto operator =(const std::initializer_list<xtd::char8>& il) -> basic_string& {
1678 self_ = basic_string(il);
1679 return self_;
1680 }
1681
1684 auto operator =(const std::initializer_list<xtd::wchar>& il) -> basic_string& {
1685 self_ = basic_string(il);
1686 return self_;
1687 }
1688
1693 if constexpr(std::is_same_v<char, char_t>) chars_ += str.chars_;
1694 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1695 return self_;
1696 }
1697
1701 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str.chars_;
1702 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1703 return self_;
1704 }
1705
1709 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str.chars_;
1710 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1711 return self_;
1712 }
1713
1717 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str.chars_;
1718 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1719 return self_;
1720 }
1721
1725 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str.chars_;
1726 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
1727 return self_;
1728 }
1729
1734 if constexpr(std::is_same_v<char, char_t>) chars_ += std::move(str.chars_);
1735 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1736 return self_;
1737 }
1738
1742 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += std::move(str.chars_);
1743 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1744 return self_;
1745 }
1746
1750 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += std::move(str.chars_);
1751 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1752 return self_;
1753 }
1754
1758 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += std::move(str.chars_);
1759 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1760 return self_;
1761 }
1762
1766 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += std::move(str.chars_);
1767 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
1768 return self_;
1769 }
1770
1774 auto operator +=(const std::basic_string<char>& str) -> basic_string& {
1775 if constexpr(std::is_same_v<char, char_t>) chars_ += str;
1776 else chars_ += __xtd_convert_to_string<value_type>(str);
1777 return self_;
1778 }
1779
1782 auto operator +=(const std::basic_string<xtd::char16>& str) -> basic_string& {
1783 if constexpr(std::is_same_v<xtd::char16, char_t>) chars_ += str;
1784 else chars_ += __xtd_convert_to_string<value_type>(str);
1785 return self_;
1786 }
1787
1790 auto operator +=(const std::basic_string<xtd::char32>& str) -> basic_string& {
1791 if constexpr(std::is_same_v<xtd::char32, char_t>) chars_ += str;
1792 else chars_ += __xtd_convert_to_string<value_type>(str);
1793 return self_;
1794 }
1795
1798 auto operator +=(const std::basic_string<xtd::char8>& str) -> basic_string& {
1799 if constexpr(std::is_same_v<xtd::char8, char_t>) chars_ += str;
1800 else chars_ += __xtd_convert_to_string<value_type>(str);
1801 return self_;
1802 }
1803
1806 auto operator +=(const std::basic_string<xtd::wchar>& str) -> basic_string& {
1807 if constexpr(std::is_same_v<xtd::wchar, char_t>) chars_ += str;
1808 else chars_ += __xtd_convert_to_string<value_type>(str);
1809 return self_;
1810 }
1811
1815 auto operator +=(const char* str) -> basic_string& {
1816 chars_ += basic_string(str).chars_;
1817 return self_;
1818 }
1819
1822 auto operator +=(const xtd::char16* str) -> basic_string& {
1823 chars_.append(basic_string(str).chars_); return self_;
1824 }
1825
1828 auto operator +=(const xtd::char32* str) -> basic_string& {
1829 chars_ += basic_string(str).chars_;
1830 return self_;
1831 }
1832
1835 auto operator +=(const xtd::char8* str) -> basic_string& {
1836 chars_ += basic_string(str).chars_;
1837 return self_;
1838 }
1839
1842 auto operator +=(const xtd::wchar* str) -> basic_string& {
1843 chars_ += basic_string(str).chars_;
1844 return self_;
1845 }
1846
1849 auto operator +=(char ch) -> basic_string& {
1850 chars_ += basic_string(ch, 1).chars_;
1851 return self_;
1852 }
1853
1857 chars_ += basic_string(ch, 1).chars_;
1858 return self_;
1859 }
1860
1864 chars_ += basic_string(ch, 1).chars_;
1865 return self_;
1866 }
1867
1871 chars_ += basic_string(ch, 1).chars_;
1872 return self_;
1873 }
1874
1878 chars_ += basic_string(ch, 1).chars_;
1879 return self_;
1880 }
1881
1886 friend auto operator +(const basic_string& lhs, const basic_string<char>& rhs) -> basic_string {
1887 auto result = lhs;
1888 result += rhs;
1889 return result;
1890 }
1891
1895 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char16>& rhs) -> basic_string {
1896 auto result = lhs;
1897 result += rhs;
1898 return result;
1899 }
1900
1904 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char32>& rhs) -> basic_string {
1905 auto result = lhs;
1906 result += rhs;
1907 return result;
1908 }
1909
1913 friend auto operator +(const basic_string& lhs, const basic_string<xtd::char8>& rhs) -> basic_string {
1914 auto result = lhs;
1915 result += rhs;
1916 return result;
1917 }
1918
1922 friend auto operator +(const basic_string& lhs, const basic_string<xtd::wchar>& rhs) -> basic_string {
1923 auto result = lhs;
1924 result += rhs;
1925 return result;
1926 }
1927
1933 auto result = std::move(lhs);
1934 result += std::move(rhs);
1935 return result;
1936 }
1937
1942 auto result = std::move(lhs);
1943 result += std::move(rhs);
1944 return result;
1945 }
1946
1951 auto result = std::move(lhs);
1952 result += std::move(rhs);
1953 return result;
1954 }
1955
1960 auto result = std::move(lhs);
1961 result += std::move(rhs);
1962 return result;
1963 }
1964
1969 auto result = std::move(lhs);
1970 result += std::move(rhs);
1971 return result;
1972 }
1973
1978 friend auto operator +(basic_string&& lhs, const basic_string<char>& rhs) -> basic_string {
1979 auto result = std::move(lhs);
1980 result += rhs;
1981 return result;
1982 }
1983
1988 auto result = std::move(lhs);
1989 result += rhs;
1990 return result;
1991 }
1992
1997 auto result = std::move(lhs);
1998 result += rhs;
1999 return result;
2000 }
2001
2006 auto result = std::move(lhs);
2007 result += rhs;
2008 return result;
2009 }
2010
2015 auto result = std::move(lhs);
2016 result += rhs;
2017 return result;
2018 }
2019
2024 friend auto operator +(const basic_string& lhs, basic_string<char>&& rhs) -> basic_string {
2025 auto result = lhs;
2026 result += std::move(rhs);
2027 return result;
2028 }
2029
2034 auto result = lhs;
2035 result += std::move(rhs);
2036 return result;
2037 }
2038
2043 auto result = lhs;
2044 result += std::move(rhs);
2045 return result;
2046 }
2047
2052 auto result = lhs;
2053 result += std::move(rhs);
2054 return result;
2055 }
2056
2061 auto result = lhs;
2062 result += std::move(rhs);
2063 return result;
2064 }
2065
2070 friend auto operator +(const basic_string& lhs, const std::basic_string<char>& rhs) -> basic_string {
2071 auto result = lhs;
2072 result += rhs;
2073 return result;
2074 }
2075
2079 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char16>& rhs) -> basic_string {
2080 auto result = lhs;
2081 result += rhs;
2082 return result;
2083 }
2084
2088 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char32>& rhs) -> basic_string {
2089 auto result = lhs;
2090 result += rhs;
2091 return result;
2092 }
2093
2097 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::char8>& rhs) -> basic_string {
2098 auto result = lhs;
2099 result += rhs;
2100 return result;
2101 }
2102
2106 friend auto operator +(const basic_string& lhs, const std::basic_string<xtd::wchar>& rhs) -> basic_string {
2107 auto result = lhs;
2108 result += rhs;
2109 return result;
2110 }
2111
2116 friend auto operator +(const std::basic_string<char>& lhs, const basic_string& rhs) -> basic_string {
2117 auto result = lhs;
2118 if constexpr(std::is_same_v<char, char_t>) result += rhs.chars();
2119 else result += __xtd_convert_to_string<char>(rhs.chars());
2120 return result;
2121 }
2122
2126 friend auto operator +(const std::basic_string<xtd::char16>& lhs, const basic_string& rhs) -> basic_string {
2127 auto result = lhs;
2128 if constexpr(std::is_same_v<xtd::char16, char_t>) result += rhs.chars();
2129 else result += __xtd_convert_to_string<xtd::char16>(rhs.chars());
2130 return result;
2131 }
2132
2136 friend auto operator +(const std::basic_string<xtd::char32>& lhs, const basic_string& rhs) -> basic_string {
2137 auto result = lhs;
2138 if constexpr(std::is_same_v<xtd::char32, char_t>) result += rhs.chars();
2139 else result += __xtd_convert_to_string<xtd::char32>(rhs.chars());
2140 return result;
2141 }
2142
2146 friend auto operator +(const std::basic_string<xtd::char8>& lhs, const basic_string& rhs) -> basic_string {
2147 auto result = lhs;
2148 if constexpr(std::is_same_v<xtd::char8, char_t>) result += rhs.chars();
2149 else result += __xtd_convert_to_string<xtd::char8>(rhs.chars());
2150 return result;
2151 }
2152
2156 friend auto operator +(const std::basic_string<xtd::wchar>& lhs, const basic_string& rhs) -> basic_string {
2157 auto result = lhs;
2158 if constexpr(std::is_same_v<xtd::wchar, char_t>) result += rhs.chars();
2159 else result += __xtd_convert_to_string<xtd::wchar>(rhs.chars());
2160 return result;
2161 }
2162
2167 friend auto operator +(const basic_string& lhs, const char* rhs) -> basic_string {
2168 auto result = lhs;
2169 result += rhs;
2170 return result;
2171 }
2172
2176 friend auto operator +(const basic_string& lhs, const xtd::char16* rhs) -> basic_string {
2177 auto result = lhs;
2178 result += rhs;
2179 return result;
2180 }
2181
2185 friend auto operator +(const basic_string& lhs, const xtd::char32* rhs) -> basic_string {
2186 auto result = lhs;
2187 result += rhs;
2188 return result;
2189 }
2190
2194 friend auto operator +(const basic_string& lhs, const xtd::char8* rhs) -> basic_string {
2195 auto result = lhs;
2196 result += rhs;
2197 return result;
2198 }
2199
2203 friend auto operator +(const basic_string& lhs, const xtd::wchar* rhs) -> basic_string {
2204 auto result = lhs;
2205 result += rhs;
2206 return result;
2207 }
2208
2213 friend auto operator +(basic_string&& lhs, const char* rhs) -> basic_string {
2214 auto result = std::move(lhs);
2215 result += rhs;
2216 return result;
2217 }
2218
2222 friend auto operator +(basic_string&& lhs, const xtd::char16* rhs) -> basic_string {
2223 auto result = std::move(lhs);
2224 result += rhs;
2225 return result;
2226 }
2227
2231 friend auto operator +(basic_string&& lhs, const xtd::char32* rhs) -> basic_string {
2232 auto result = std::move(lhs);
2233 result += rhs;
2234 return result;
2235 }
2236
2240 friend auto operator +(basic_string&& lhs, const xtd::char8* rhs) -> basic_string {
2241 auto result = std::move(lhs);
2242 result += rhs;
2243 return result;
2244 }
2245
2249 friend auto operator +(basic_string&& lhs, const xtd::wchar* rhs) -> basic_string {
2250 auto result = std::move(lhs);
2251 result += rhs;
2252 return result;
2253 }
2254
2259 friend auto operator +(const char* lhs, const basic_string& rhs) -> basic_string {
2260 auto result = basic_string(lhs);
2261 result += rhs;
2262 return result;
2263 }
2264
2268 friend auto operator +(const xtd::char16* lhs, const basic_string& rhs) -> basic_string {
2269 auto result = basic_string(lhs);
2270 result += rhs;
2271 return result;
2272 }
2273
2277 friend auto operator +(const xtd::char32* lhs, const basic_string& rhs) -> basic_string {
2278 auto result = basic_string(lhs);
2279 result += rhs;
2280 return result;
2281 }
2282
2286 friend auto operator +(const xtd::char8* lhs, const basic_string& rhs) -> basic_string {
2287 auto result = basic_string(lhs);
2288 result += rhs;
2289 return result;
2290 }
2291
2295 friend auto operator +(const xtd::wchar* lhs, const basic_string& rhs) -> basic_string {
2296 auto result = basic_string(lhs);
2297 result += rhs;
2298 return result;
2299 }
2300
2305 friend auto operator +(const char* lhs, basic_string&& rhs) -> basic_string {
2306 auto result = basic_string(lhs);
2307 result += std::move(rhs);
2308 return result;
2309 }
2310
2314 friend auto operator +(const xtd::char16* lhs, basic_string&& rhs) -> basic_string {
2315 auto result = basic_string(lhs);
2316 result += std::move(rhs);
2317 return result;
2318 }
2319
2323 friend auto operator +(const xtd::char32* lhs, basic_string&& rhs) -> basic_string {
2324 auto result = basic_string(lhs);
2325 result += std::move(rhs);
2326 return result;
2327 }
2328
2332 friend auto operator +(const xtd::char8* lhs, basic_string&& rhs) -> basic_string {
2333 auto result = basic_string(lhs);
2334 result += std::move(rhs);
2335 return result;
2336 }
2337
2341 friend auto operator +(const xtd::wchar* lhs, basic_string&& rhs) -> basic_string {
2342 auto result = basic_string(lhs);
2343 result += std::move(rhs);
2344 return result;
2345 }
2346
2351 friend auto operator +(const basic_string& lhs, const char rhs) -> basic_string {
2352 auto result = lhs;
2353 result += rhs;
2354 return result;
2355 }
2356
2360 friend auto operator +(const basic_string& lhs, const xtd::char16 rhs) -> basic_string {
2361 auto result = lhs;
2362 result += rhs;
2363 return result;
2364 }
2365
2369 friend auto operator +(const basic_string& lhs, const xtd::char32 rhs) -> basic_string {
2370 auto result = lhs;
2371 result += rhs;
2372 return result;
2373 }
2374
2378 friend auto operator +(const basic_string& lhs, const xtd::char8 rhs) -> basic_string {
2379 auto result = lhs;
2380 result += rhs;
2381 return result;
2382 }
2383
2387 friend auto operator +(const basic_string& lhs, const xtd::wchar rhs) -> basic_string {
2388 auto result = lhs;
2389 result += rhs;
2390 return result;
2391 }
2392
2397 friend auto operator +(basic_string&& lhs, const char rhs) -> basic_string {
2398 auto result = std::move(lhs);
2399 result += rhs;
2400 return result;
2401 }
2402
2406 friend auto operator +(basic_string&& lhs, const xtd::char16 rhs) -> basic_string {
2407 auto result = std::move(lhs);
2408 result += rhs;
2409 return result;
2410 }
2411
2415 friend auto operator +(basic_string&& lhs, const xtd::char32 rhs) -> basic_string {
2416 auto result = std::move(lhs);
2417 result += rhs;
2418 return result;
2419 }
2420
2424 friend auto operator +(basic_string&& lhs, const xtd::char8 rhs) -> basic_string {
2425 auto result = std::move(lhs);
2426 result += rhs;
2427 return result;
2428 }
2429
2433 friend auto operator +(basic_string&& lhs, const xtd::wchar rhs) -> basic_string {
2434 auto result = std::move(lhs);
2435 result += rhs;
2436 return result;
2437 }
2438
2443 friend auto operator +(char lhs, const basic_string& rhs) -> basic_string {
2444 auto result = basic_string(lhs, 1);
2445 result += rhs;
2446 return result;
2447 }
2448
2452 friend auto operator +(xtd::char16 lhs, const basic_string& rhs) -> basic_string {
2453 auto result = basic_string(lhs, 1);
2454 result += rhs;
2455 return result;
2456 }
2457
2461 friend auto operator +(xtd::char32 lhs, const basic_string& rhs) -> basic_string {
2462 auto result = basic_string(lhs, 1);
2463 result += rhs;
2464 return result;
2465 }
2466
2470 friend auto operator +(xtd::char8 lhs, const basic_string& rhs) -> basic_string {
2471 auto result = basic_string(lhs, 1);
2472 result += rhs;
2473 return result;
2474 }
2475
2479 friend auto operator +(xtd::wchar lhs, const basic_string& rhs) -> basic_string {
2480 auto result = basic_string(lhs, 1);
2481 result += rhs;
2482 return result;
2483 }
2484
2489 friend auto operator +(char lhs, basic_string&& rhs) -> basic_string {
2490 auto result = basic_string(lhs, 1);
2491 result += std::move(rhs);
2492 return result;
2493 }
2494
2499 auto result = basic_string(lhs, 1);
2500 result += std::move(rhs);
2501 return result;
2502 }
2503
2508 auto result = basic_string(lhs, 1);
2509 result += std::move(rhs);
2510 return result;
2511 }
2512
2516 friend auto operator +(xtd::char8 lhs, basic_string&& rhs) -> basic_string {
2517 auto result = basic_string(lhs, 1);
2518 result += std::move(rhs);
2519 return result;
2520 }
2521
2525 friend auto operator +(xtd::wchar lhs, basic_string&& rhs) -> basic_string {
2526 auto result = basic_string(lhs, 1);
2527 result += std::move(rhs);
2528 return result;
2529 }
2530
2539 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
2540 friend auto operator <<(std::basic_ostream<char>& stream, const basic_string& str) -> std::basic_ostream<char>& {
2541 if constexpr(std::is_same_v<char, char_t>) return stream << str.chars();
2542 else return stream << __xtd_convert_to_string<char>(str.chars());
2543 }
2544
2550 friend auto operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string& str) -> std::basic_ostream<xtd::wchar>& {return stream << str.to_wstring().chars();}
2551
2560 friend auto operator >>(std::basic_istream<char>& stream, basic_string& str) -> std::basic_istream<char>& {
2561 auto s = std::basic_string<char> {};
2562 stream >> s;
2563 str = s;
2564 return stream;
2565 }
2566
2574 friend auto operator >>(std::basic_istream<xtd::wchar>& stream, basic_string& str) -> std::basic_istream<xtd::wchar>& {
2575 auto s = std::basic_string<xtd::wchar> {};
2576 stream >> s;
2577 str = s;
2578 return stream;
2579 }
2580
2581
2583
2587 [[deprecated("Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 0.4.0.")]]
2588 [[nodiscard]] auto is_empty() const noexcept -> bool {return is_empty(self_);}
2594
2596
2597 template<typename object_t>
2598 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 0.4.0.")]]
2599 [[nodiscard]] static auto class_name() -> basic_string {return get_class_name(full_class_name<object_t>());}
2604 template<typename object_t>
2605 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 0.4.0.")]]
2606 [[nodiscard]] static auto class_name(const object_t& object) -> basic_string {return get_class_name(full_class_name(object));}
2611 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 0.4.0.")]]
2612 [[nodiscard]] static auto class_name(const std::type_info& info) -> basic_string {return __xtd_get_class_name(info);}
2617 template<typename object_t>
2618 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 0.4.0.")]]
2619 [[nodiscard]] static auto full_class_name() -> basic_string {return demangle(typeid(object_t).name());}
2624 template<typename object_t>
2625 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 0.4.0.")]]
2626 [[nodiscard]] static auto full_class_name(const object_t& object) -> basic_string {return demangle(typeid(object).name());}
2631 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 0.4.0.")]]
2632 [[nodiscard]] static auto full_class_name(const std::type_info& info) -> basic_string {return __xtd_get_full_class_name(info);}
2634
2635 private:
2636 friend class basic_string<char>;
2637 friend class basic_string<xtd::char16>;
2638 friend class basic_string<xtd::char32>;
2639 friend class basic_string<xtd::char8>;
2640 friend class basic_string<xtd::wchar>;
2641
2642 static const xtd::array<value_type> default_split_separators;
2643 static const xtd::array<value_type> default_trim_chars;
2644
2645 template<typename arg_t>
2646 [[nodiscard]] static auto convert_param(arg_t&& arg) noexcept {
2647 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();
2648 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();
2649 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();
2650 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();
2651 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();
2652 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();
2653 else return std::forward<arg_t>(arg);
2654 }
2655
2656 [[nodiscard]] static auto get_class_name(const basic_string& full_name) -> basic_string {
2657 auto length = full_name.last_index_of("<");
2658 if (length == npos) length = full_name.length();
2659 if (full_name.last_index_of("::", 0, length) == npos) return full_name;
2660 return full_name.substring(full_name.last_index_of("::", 0, length) + 2);
2661 }
2662
2663 base_type chars_;
2664 };
2665}
2666
2667#define __XTD_BASIC_STRING_INTERNAL__
2668#include "basic_string_.hpp"
2669#undef __XTD_BASIC_STRING_INTERNAL__
2670
2672namespace std {
2673 template<typename char_t>
2674 struct hash<xtd::basic_string<char_t>> {
2675 auto operator()(const xtd::basic_string<char_t>& s) const noexcept -> xtd::size {return s.get_hash_code();}
2676 };
2677}
Contains xtd::basic_string class.
Provides methods for creating, manipulating, searching, and sorting arrays, thereby serving as the ba...
Definition array.hpp:64
Represents text as a sequence of character units.
Definition basic_string.hpp:66
basic_string(const basic_string< xtd::char32 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:177
basic_string(const xtd::char8 *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:302
auto last_index_of(value_type value) const noexcept -> xtd::size
Reports the index of the last occurrence of the specified character in this tring.
Definition basic_string.hpp:598
std::basic_string< char_t, traits_t, allocator_t > base_type
Represents the basic string base type.
Definition basic_string.hpp:73
static auto parse(const basic_string &str) -> value_t
Converts a basic_string into a value_t type.
Definition basic_string.hpp:1304
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 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:714
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:682
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:1121
static auto class_name() -> basic_string
Gets the class name of the object_t.
Definition basic_string.hpp:2599
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:400
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:930
static const basic_string empty_string
Definition basic_string.hpp:111
auto chars() noexcept -> base_type &
Returns a reference to the underlying base type.
Definition basic_string.hpp:357
auto last_index_of_any(const xtd::array< value_type > &values) const noexcept -> xtd::size
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
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:1405
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:1199
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:2540
static auto join(const basic_string &separator, const collection_t &values, xtd::size index, xtd::size count) -> basic_string
Concatenates a specified separator basic_string between each element of a specified Object array,...
Definition basic_string.hpp:1280
basic_string(const xtd::char32 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:259
auto to_u16string() const noexcept -> basic_string< xtd::char16 >
Definition basic_string.hpp:923
typename base_type::allocator_type allocator_type
Represents the basic string allocator type.
Definition basic_string.hpp:79
auto remove(xtd::size start_index, xtd::size count) const -> basic_string
Deletes all the characters from this basic_string beginning at a specified position and continuing th...
Definition basic_string.hpp:697
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::...
basic_string(char character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:226
auto pad_left(xtd::size 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:651
auto last_index_of(const basic_string &value, xtd::size start_index) const -> xtd::size
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:583
auto to_upper() const noexcept -> basic_string
Returns a copy of the current xtd::basic_string converted to uppercase.
Definition basic_string.hpp:944
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:1018
static auto full_class_name() -> basic_string
Definition basic_string.hpp:2619
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:421
basic_string(const char *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:281
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:850
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:1886
basic_string(const std::basic_string_view< char_t > &str)
Initializes a new instance of xtd::basic_string with specified std::basic_string_view.
Definition basic_string.hpp:321
basic_string(xtd::wchar character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:242
typename xtd::collections::generic::enumerator< value_type > enumerator_type
Represents the basic string enumerator type.
Definition basic_string.hpp:103
auto quoted(value_type delimiter) const -> basic_string
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified...
Definition basic_string.hpp:676
auto index_of(value_type value, xtd::size start_index) const -> xtd::size
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:525
auto operator[](xtd::size index) const -> const_reference
Returns a reference to the character at specified location index.
Definition basic_string.hpp:1393
auto index_of_any(const xtd::array< value_type > &values) const noexcept -> xtd::size
Reports the index of the first occurrence in this instance of any character in a specified array of c...
basic_string(const basic_string< xtd::char8 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:183
static auto join(const basic_string &separator, const collection_t &values) noexcept -> basic_string
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:1255
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:437
auto index_of(const basic_string &value, xtd::size start_index, xtd::size count) const -> xtd::size
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:512
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:412
basic_string(input_iterator_t first, input_iterator_t last)
Initializes a new instance of xtd::basic_string with specified first and last iterators of substring.
Definition basic_string.hpp:318
auto starts_with(const basic_string &value, xtd::string_comparison comparison_type) const noexcept -> bool
Determines whether the end of this basic_string matches the specified basic_string when compared usin...
Definition basic_string.hpp:855
static auto compare(const basic_string &str_a, xtd::size index_a, const basic_string &str_b, xtd::size index_b, xtd::size length, xtd::string_comparison comparison_type) -> xtd::int32
Compares substrings of two specified basic_string objects using the specified rules,...
Definition basic_string.hpp:1081
typename base_type::const_pointer const_pointer
Represents the basic string const pointer type.
Definition basic_string.hpp:91
auto index_of(const basic_string &value, xtd::size start_index) const -> xtd::size
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:505
basic_string(std::initializer_list< xtd::wchar > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:336
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:2560
auto last_index_of(value_type value, xtd::size start_index, xtd::size count) const -> xtd::size
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:612
auto index_of(value_type value, xtd::size start_index, xtd::size count) const -> xtd::size
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.hpp:532
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 basic_string< xtd::char16 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:171
auto substring(xtd::size start_index) const -> basic_string
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.hpp:865
basic_string(const std::basic_string< char > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:195
virtual auto length() const noexcept -> size_type
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:380
typename base_type::traits_type traits_type
Represents the basic string traits type.
Definition basic_string.hpp:75
virtual auto get_base_type() const noexcept -> const base_type &
Returns the underlying base type.
Definition basic_string.hpp:474
typename base_type::pointer pointer
Represents the basic string pointer type.
Definition basic_string.hpp:89
typename base_type::const_reference const_reference
Represents the basic string const referecne type.
Definition basic_string.hpp:87
basic_string(std::initializer_list< xtd::char32 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:330
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:457
basic_string(const std::basic_string< xtd::char16 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:201
basic_string(const xtd::wchar *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:309
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:937
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:417
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:1097
auto to_lower() const noexcept -> basic_string
Returns a copy of the current xtd::basic_string converted to lowercase.
Definition basic_string.hpp:903
static auto join(const basic_string &separator, const collection_t &values, xtd::size index) -> basic_string
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.hpp:1270
auto index_of(const basic_string &value) const noexcept -> xtd::size
Reports the index of the first occurrence of the specified basic_string in this basic_string.
Definition basic_string.hpp:500
basic_string(const basic_string< xtd::wchar > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:189
static auto concat(const xtd::array< basic_string > &values) noexcept -> basic_string
Concatenates the elements of a specified basic_string array.
auto pad_right(xtd::size 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:665
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:2626
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:1040
typename xtd::collections::generic::ienumerable< char_t >::iterator iterator
Represents the basic string iterator type.
Definition basic_string.hpp:94
typename base_type::const_reverse_iterator const_reverse_iterator
Represents the basic string const reverse iterator type.
Definition basic_string.hpp:101
static auto concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c, const basic_string &str_d) noexcept -> basic_string
Concatenates four specified instances of basic_string.
Definition basic_string.hpp:1089
basic_string(const char *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:245
auto last_index_of(value_type value, xtd::size start_index) const -> xtd::size
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:604
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:952
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:350
basic_string(std::initializer_list< char > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:324
auto to_title_case() const noexcept -> basic_string
Converts the current basic_string to title case (except for words that are entirely in uppercase,...
auto index_of_any(const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const -> xtd::size
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, const basic_string &str_c) noexcept -> basic_string
Concatenates three specified instances of basic_string.
Definition basic_string.hpp:1103
auto index_of(value_type value) const noexcept -> xtd::size
Reports the index of the first occurrence of the specified character in this basic_string.
Definition basic_string.hpp:520
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:836
typename base_type::size_type size_type
Represents the basic string size type.
Definition basic_string.hpp:81
auto index_of_any(const xtd::array< value_type > &values, xtd::size start_index) const -> xtd::size
Reports the index of the first occurrence in this instance of any character in a specified array of c...
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:462
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:1376
basic_string(xtd::char8 character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:238
basic_string(const xtd::wchar *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:273
auto insert(xtd::size 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:567
static constexpr xtd::size epos
Definition basic_string.hpp:149
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:708
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:993
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:426
basic_string(basic_string &&)=default
Initializes a new instance of xtd::basic_string with specified string to move.
static constexpr size_type npos
Definition basic_string.hpp:121
auto trim_start(value_type trim_char) const noexcept -> basic_string
Removes all leading occurrences of a character specified from the specified xtd::basic_string .
auto get_hash_code() const noexcept -> xtd::size override
Returns the hash code for this basic_string.
Definition basic_string.hpp:478
virtual auto empty() const noexcept -> bool
Checks whether the container is empty.
Definition basic_string.hpp:375
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:1222
basic_string(const basic_string< char > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:165
static auto concat(const xtd::array< object_t > &args) noexcept -> basic_string
Concatenates the basic_string representations of the elements in a specified object array.
static auto full_class_name(const std::type_info &info) -> basic_string
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition basic_string.hpp:2632
auto operator+=(const basic_string< char > &str) -> basic_string &
Addition assignment operator. Appends additional characters to the string.
Definition basic_string.hpp:1692
static auto class_name(const std::type_info &info) -> basic_string
Gets the class name of the specified object.
Definition basic_string.hpp:2612
basic_string(xtd::char16 character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:230
static auto concat(value_t value) noexcept -> basic_string
Creates the basic_string representation of a specified object.
Definition basic_string.hpp:1165
static auto compare(const basic_string &str_a, xtd::size index_a, const basic_string &str_b, xtd::size index_b, xtd::size length, bool ignore_case) -> xtd::int32
Compares substrings of two specified basic_string objects, ignoring or honoring their case,...
Definition basic_string.hpp:1067
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:961
auto last_index_of_any(const xtd::array< value_type > &values, xtd::size start_index) const -> xtd::size
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
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:450
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:671
basic_string(const xtd::char16 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:252
typename base_type::value_type value_type
Represents the basic string value type.
Definition basic_string.hpp:77
typename base_type::reverse_iterator reverse_iterator
Represents the basic string reverse iterator type.
Definition basic_string.hpp:99
basic_string(const xtd::char16 *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:288
auto last_index_of(const basic_string &value) const noexcept -> xtd::size
Reports the index of the last occurrence of the specified basic_string in this basic_string.
Definition basic_string.hpp:577
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:445
basic_string(std::initializer_list< xtd::char16 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:327
auto to_char_array() const noexcept -> xtd::array< value_type >
basic_string(std::initializer_list< xtd::char8 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.hpp:333
static auto demangle(const basic_string &name) -> basic_string
Gets demangled basic_string of name,.
Definition basic_string.hpp:1189
static constexpr xtd::size bpos
Definition basic_string.hpp:131
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:431
auto last_index_of(const basic_string &value, xtd::size start_index, xtd::size count) const -> xtd::size
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.hpp:590
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:977
basic_string()=default
Initializes a new instance of xtd::basic_string.
bool starts_with(value_type value) const noexcept
Definition basic_string.hpp:830
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:1110
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:1029
basic_string(const xtd::char8 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:266
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:1115
basic_string(xtd::char32 character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.hpp:234
auto is_empty() const noexcept -> bool
Name Public Deprecated Methods.
Definition basic_string.hpp:2588
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:371
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:844
auto split() const noexcept -> xtd::array< basic_string >
Splits this basic_string into substrings that are based on the default white-space characters....
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:912
auto get_enumerator() const noexcept -> enumerator_type override
Returns an enumerator that iterates through a collection.
Definition basic_string.hpp:480
typename base_type::reference reference
Represents the basic string referecne type.
Definition basic_string.hpp:85
static auto equals(const char_a_t *a, const char_b_t *b) noexcept -> bool
Determines whether two specified xtd::basic_string objects have the same value.
Definition basic_string.hpp:1206
basic_string(const std::basic_string< xtd::wchar > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:219
virtual auto count() const noexcept -> size_type
Definition basic_string.hpp:362
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:467
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:1214
typename xtd::collections::generic::ienumerable< char_t >::const_iterator const_iterator
Represents the basic string const iterator type.
Definition basic_string.hpp:97
typename base_type::difference_type difference_type
Represents the basic string difference type.
Definition basic_string.hpp:83
auto pad_left(xtd::size 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:644
static auto compare(const basic_string &str_a, xtd::size index_a, const basic_string &str_b, xtd::size index_b, xtd::size length) -> xtd::int32
Compares substrings of two specified basic_string objects and returns an integer that indicates their...
Definition basic_string.hpp:1053
basic_string(const std::basic_string< xtd::char32 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:207
basic_string(const xtd::char32 *str, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring and count characters.
Definition basic_string.hpp:295
auto substring(xtd::size start_index, xtd::size length) const -> basic_string
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.hpp:874
basic_string(const std::basic_string< xtd::char8 > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.hpp:213
auto chars() const noexcept -> const base_type &
Returns a reference to the underlying base type.
Definition basic_string.hpp:354
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:1246
basic_string(std::basic_string< char_t > &&str)
Initializes a new instance of xtd::basic_string with specified string to move.
Definition basic_string.hpp:162
static auto class_name(const object_t &object) -> basic_string
Gets the class name of the specified object.
Definition basic_string.hpp:2606
virtual auto size() const noexcept -> size_type
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.hpp:385
auto remove(xtd::size 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:692
auto last_index_of_any(const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const -> xtd::size
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
auto pad_right(xtd::size 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:658
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 xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.hpp:70
static auto throws(xtd::helpers::exception_case exception_case, const source_location &location=source_location::current()) -> void
Throws an exption with specified exception case.
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.hpp:22
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:1369
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
size_t size
Represents a size of any object in bytes.
Definition size.hpp:23
char8_t char8
Represents a 8-bit unicode character.
Definition char8.hpp:26
null_ptr null
Represents a null pointer value.
wchar_t wchar
Represents a wide character.
Definition wchar.hpp:24
char16_t char16
Represents a 16-bit unicode character.
Definition char16.hpp:26
std::int32_t int32
Represents a 32-bit signed integer.
Definition int32.hpp:25
char32_t char32
Represents a 32-bit unicode character.
Definition char32.hpp:23
string_comparison
Specifies the culture, case, and sort rules to be used by certain overloads of the xtd::string::compa...
Definition string_comparison.hpp:14
string_split_options
Specifies whether applicable xtd::string::split method overloads include or omit empty substrings fro...
Definition string_split_options.hpp:14
ptr< type_t > new_ptr(args_t &&... args)
The xtd::new_ptr operator creates a xtd::ptr object.
Definition new_ptr.hpp:24
value_t parse(const std::string &str)
Convert a string into a type.
Definition parse.hpp:34
@ ordinal
Compare strings using ordinal (binary) sort rules.
Definition string_comparison.hpp:24
@ ordinal_ignore_case
Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared...
Definition string_comparison.hpp:26
@ s
The S key.
Definition console_key.hpp:124
@ a
The A key.
Definition console_key.hpp:88
@ c
The C key.
Definition console_key.hpp:92
@ i
The I key.
Definition console_key.hpp:104
@ b
The B key.
Definition console_key.hpp:90
@ separator
The Separator key.
Definition console_key.hpp:172
@ escape
The ESC (ESCAPE) key.
Definition console_key.hpp:34
Contains xtd::hash_code class.
Contains xtd::icomparable interface.
Contains xtd::iequatable interface.
The xtd namespace contains all fundamental classes to access Hardware, Os, System,...
Definition abstract_object.hpp:8
read_only_span< type_t, count > first() const
Obtains a subspan consisting of the first count elements of the sequence.
Definition read_only_span.hpp:282
read_only_span< type_t, count > last() const
Obtains a subspan consisting of the last N elements of the sequence.
Definition read_only_span.hpp:307
Contains xtd::null pointer valiue.
Contains xtd::object class.
Contains xtd::parse methods.
Contains xtd::string_comparison enum class.
Contains xtd::string_split_options enum class.
Supports a simple iteration over a generic collection.
Definition enumerator.hpp:38
Contains xtd fundamental types.