xtd 0.2.0
Loading...
Searching...
No Matches
basic_string.h
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.h"
18#include "icomparable.h"
19#include "iequatable.h"
20#include "null.h"
21#include "string_comparison.h"
23#include "types.h"
24#include "object.h"
25#include "parse.h"
26#include "to_string.h"
27#include "types.h"
28#include "unused.h"
29#include <cctype>
30#if defined(__xtd__cpp_lib_format)
31#include <format>
32#endif
33#include <iomanip>
34#include <ostream>
35#include <sstream>
36#include <string>
37
39template<typename ...args_t>
40void __basic_string_extract_format_arg(xtd::basic_string<char>& fmt, xtd::array<__format_information<char>>& formats, args_t&&... args);
41template<typename target_t, typename source_t>
42std::basic_string<target_t> __xtd_convert_to_string(std::basic_string<source_t>&& str) noexcept;
43template<typename target_t, typename source_t>
44std::basic_string<target_t> __xtd_convert_to_string(const std::basic_string<source_t>& str) noexcept;
45std::basic_string<char> __xtd_demangle(const std::basic_string<char>& value) noexcept;
46std::basic_string<char> __xtd_get_class_name(const std::type_info& value) noexcept;
47std::basic_string<char> __xtd_get_full_class_name(const std::type_info& value) noexcept;
48void __throw_basic_string_argument_exception(const char* file, xtd::uint32 line, const char* func);
49void __throw_basic_string_argument_out_of_range_exception(const char* file, xtd::uint32 line, const char* func);
50void __throw_basic_string_format_exception(const char* file, xtd::uint32 line, const char* func);
51void __throw_basic_string_format_exception_close_bracket(const char* file, xtd::uint32 line, const char* func);
52void __throw_basic_string_format_exception_open_bracket(const char* file, xtd::uint32 line, const char* func);
53void __throw_basic_string_format_exception_start_colon(const char* file, xtd::uint32 line, const char* func);
54void __throw_basic_string_index_out_of_range_exception(const char* file, xtd::uint32 line, const char* func);
55void __throw_basic_string_null_pointer_exception(const char* file, xtd::uint32 line, const char* func);
57
59namespace xtd {
78 template<typename char_t, typename traits_t, typename allocator_t>
79 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> {
80 public:
82
86 using base_type = std::basic_string<char_t, traits_t, allocator_t>;
88 using traits_type = typename base_type::traits_type;
90 using value_type = typename base_type::value_type;
92 using allocator_type = typename base_type::allocator_type;
94 using size_type = typename base_type::size_type;
96 using difference_type = typename base_type::difference_type;
98 using reference = typename base_type::reference;
100 using const_reference = typename base_type::const_reference;
102 using pointer = typename base_type::pointer;
104 using const_pointer = typename base_type::const_pointer;
112 using reverse_iterator = typename base_type::reverse_iterator;
114 using const_reverse_iterator = typename base_type::const_reverse_iterator;
118
120
125
127 inline static constexpr size_type npos = base_type::npos;
129
131
134 basic_string() = default;
137 explicit basic_string(const allocator_type& allocator) noexcept;
138
141 basic_string(const basic_string<char>& str) noexcept {
142 if constexpr (std::is_same_v<char, char_t>) chars_ = str.chars_;
143 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
144 }
145
149 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = str.chars_;
150 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
151 }
155 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = str.chars_;
156 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
157 }
158#if defined(__xtd__cpp_lib_char8_t)
162 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = str.chars_;
163 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
164 }
165#endif
169 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = str.chars_;
170 else chars_ = __xtd_convert_to_string<value_type>(str.chars_);
171 }
172
176 basic_string(const basic_string<char>& str, const allocator_type& allocator) noexcept {
177 if constexpr (std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, allocator);
178 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
179 }
183 basic_string(const basic_string<xtd::char16>& str, const allocator_type& allocator) noexcept {
184 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, allocator);
185 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
186 }
190 basic_string(const basic_string<xtd::char32>& str, const allocator_type& allocator) noexcept {
191 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, allocator);
192 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
193 }
194#if defined(__xtd__cpp_lib_char8_t)
198 basic_string(const basic_string<xtd::char8>& str, const allocator_type& allocator) noexcept {
199 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, allocator);
200 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
201 }
202#endif
206 basic_string(const basic_string<xtd::wchar>& str, const allocator_type& allocator) noexcept {
207 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, allocator);
208 else chars_ = base_type(__xtd_convert_to_string<value_type>(str.chars_), allocator);
209 }
210
216 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
217 if constexpr (std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index);
218 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index)));
219 }
225 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
226 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index);
227 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index)));
228 }
234 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
235 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index);
236 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index)));
237 }
238#if defined(__xtd__cpp_lib_char8_t)
244 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
245 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index);
246 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index)));
247 }
248#endif
254 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
255 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index);
256 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index)));
257 }
258
264 basic_string(const basic_string<char>& str, xtd::size index, const allocator_type& allocator) {
265 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
266 if constexpr (std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index, allocator);
267 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index)), allocator);
268 }
274 basic_string(const basic_string<xtd::char16>& str, xtd::size index, const allocator_type& allocator) {
275 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
276 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index, allocator);
277 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index)), allocator);
278 }
284 basic_string(const basic_string<xtd::char32>& str, xtd::size index, const allocator_type& allocator) {
285 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
286 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index, allocator);
287 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index)), allocator);
288 }
289#if defined(__xtd__cpp_lib_char8_t)
295 basic_string(const basic_string<xtd::char8>& str, xtd::size index, const allocator_type& allocator) {
296 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
297 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index, allocator);
298 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index)), allocator);
299 }
300#endif
306 basic_string(const basic_string<xtd::wchar>& str, xtd::size index, const allocator_type& allocator) {
307 if (index > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
308 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index, allocator);
309 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index)), allocator);
310 }
311
318 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
319 if constexpr (std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index, count);
320 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index, count)));
321 }
328 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
329 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index, count);
330 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index, count)));
331 }
338 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
339 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index, count);
340 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index, count)));
341 }
342#if defined(__xtd__cpp_lib_char8_t)
349 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
350 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index, count);
351 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index, count)));
352 }
353#endif
360 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
361 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index, count);
362 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index, count)));
363 }
364
371 basic_string(const basic_string<char>& str, xtd::size index, xtd::size count, const allocator_type& allocator) {
372 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
373 if constexpr (std::is_same_v<char, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
374 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<char>(str.chars_, index, count)), allocator);
375 }
382 basic_string(const basic_string<xtd::char16>& str, xtd::size index, xtd::size count, const allocator_type& allocator) {
383 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
384 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
385 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str.chars_, index, count)), allocator);
386 }
393 basic_string(const basic_string<xtd::char32>& str, xtd::size index, xtd::size count, const allocator_type& allocator) {
394 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
395 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
396 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str.chars_, index, count)), allocator);
397 }
398#if defined(__xtd__cpp_lib_char8_t)
405 basic_string(const basic_string<xtd::char8>& str, xtd::size index, xtd::size count, const allocator_type& allocator) {
406 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
407 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
408 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str.chars_, index, count)), allocator);
409 }
410#endif
417 basic_string(const basic_string<xtd::wchar>& str, xtd::size index, xtd::size count, const allocator_type& allocator) {
418 if (index + count > str.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
419 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str.chars_, index, count, allocator);
420 else chars_ = base_type(__xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str.chars_, index, count)), allocator);
421 }
422
426
430 basic_string(basic_string&& str, const allocator_type& allocator) noexcept : chars_(std::move(str.chars_)) {}
431
436 basic_string(xtd::size count, char character) : basic_string(std::basic_string<char>(count, character)) {}
441 basic_string(xtd::size count, char character, const allocator_type& allocator) : basic_string(std::basic_string<char>(count, character), allocator) {}
445 basic_string(xtd::size count, xtd::char16 character) : basic_string(std::basic_string<xtd::char16>(count, character)) {}
450 basic_string(xtd::size count, xtd::char16 character, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char16>(count, character), allocator) {}
454 basic_string(xtd::size count, xtd::char32 character) : basic_string(std::basic_string<xtd::char32>(count, character)) {}
459 basic_string(xtd::size count, xtd::char32 character, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char32>(count, character), allocator) {}
460#if defined(__xtd__cpp_lib_char8_t)
464 basic_string(xtd::size count, xtd::char8 character) : basic_string(std::basic_string<xtd::char8>(count, character)) {}
469 basic_string(xtd::size count, xtd::char8 character, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char8>(count, character), allocator) {}
470#endif
474 basic_string(xtd::size count, xtd::wchar character) : basic_string(std::basic_string<xtd::wchar>(count, character)) {}
480 basic_string(xtd::size count, xtd::wchar character, const allocator_type& allocator) : basic_string(std::basic_string<xtd::wchar>(count, character), allocator) {}
481
485 basic_string(char character, xtd::size count) : basic_string(std::basic_string<char>(count, character)) {}
490 basic_string(char character, xtd::size count, const allocator_type& allocator) : basic_string(std::basic_string<char>(count, character), allocator) {}
494 basic_string(xtd::char16 character, xtd::size count) : basic_string(std::basic_string<xtd::char16>(count, character)) {}
499 basic_string(xtd::char16 character, xtd::size count, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char16>(count, character), allocator) {}
503 basic_string(xtd::char32 character, xtd::size count) : basic_string(std::basic_string<xtd::char32>(count, character)) {}
508 basic_string(xtd::char32 character, xtd::size count, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char32>(count, character), allocator) {}
509#if defined(__xtd__cpp_lib_char8_t)
513 basic_string(xtd::char8 character, xtd::size count) : basic_string(std::basic_string<xtd::char8>(count, character)) {}
518 basic_string(xtd::char8 character, xtd::size count, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char8>(count, character), allocator) {}
519#endif
523 basic_string(xtd::wchar character, xtd::size count) : basic_string(std::basic_string<xtd::wchar>(count, character)) {}
528 basic_string(xtd::wchar character, xtd::size count, const allocator_type& allocator) : basic_string(std::basic_string<xtd::wchar>(count, character), allocator) {}
529
532 basic_string(const char* str) { // Can't be explicit by design.
533 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
534 if constexpr (std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
535 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
536 }
539 basic_string(const xtd::char16* str) { // Can't be explicit by design.
540 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
541 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
542 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
543 }
546 basic_string(const xtd::char32* str) { // Can't be explicit by design.
547 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
548 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
549 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
550 }
551#if defined(__xtd__cpp_lib_char8_t)
554 basic_string(const xtd::char8* str) { // Can't be explicit by design.
555 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
556 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
557 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
558 }
559#endif
562 basic_string(const xtd::wchar* str) { // Can't be explicit by design.
563 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
564 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
565 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
566 }
567
571 basic_string(const char* str, const allocator_type& allocator) {
572 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
573 if constexpr (std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, allocator);
574 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str), allocator);
575 }
579 basic_string(const xtd::char16* str, const allocator_type& allocator) {
580 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
581 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, allocator);
582 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str), allocator);
583 }
587 basic_string(const xtd::char32* str, const allocator_type& allocator) {
588 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
589 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, allocator);
590 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str), allocator);
591 }
592#if defined(__xtd__cpp_lib_char8_t)
596 basic_string(const xtd::char8* str, const allocator_type& allocator) {
597 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
598 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, allocator);
599 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str), allocator);
600 }
601#endif
605 basic_string(const xtd::wchar* str, const allocator_type& allocator) : chars_(allocator) {
606 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
607 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
608 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
609 }
610
613 basic_string(const char* str, xtd::size count) {
614 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
615 if constexpr (std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count);
616 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count));
617 }
620 basic_string(const xtd::char16* str, xtd::size count) {
621 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
622 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count);
623 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count));
624 }
627 basic_string(const xtd::char32* str, xtd::size count) {
628 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
629 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count);
630 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count));
631 }
632#if defined(__xtd__cpp_lib_char8_t)
635 basic_string(const xtd::char8* str, xtd::size count) {
636 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
637 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count);
638 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count));
639 }
640#endif
643 basic_string(const xtd::wchar* str, xtd::size count) {
644 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
645 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count);
646 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count));
647 }
648
653 basic_string(const char* str, xtd::size count, const allocator_type& allocator) {
654 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
655 if constexpr (std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str, count, allocator);
656 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str, count), allocator);
657 }
662 basic_string(const xtd::char16* str, xtd::size count, const allocator_type& allocator) : chars_(allocator) {
663 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
664 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str, count, allocator);
665 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str, count), allocator);
666 }
671 basic_string(const xtd::char32* str, xtd::size count, const allocator_type& allocator) : chars_(allocator) {
672 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
673 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str, count, allocator);
674 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str, count), allocator);
675 }
676#if defined(__xtd__cpp_lib_char8_t)
681 basic_string(const xtd::char8* str, xtd::size count, const allocator_type& allocator) : chars_(allocator) {
682 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
683 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str, count, allocator);
684 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str, count), allocator);
685 }
686#endif
691 basic_string(const xtd::wchar* str, xtd::size count, const allocator_type& allocator) : chars_(allocator) {
692 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
693 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str, count, allocator);
694 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str, count), allocator);
695 }
696
699 basic_string(const std::basic_string<char>& str) noexcept { // Can't be explicit by design.
700 if constexpr (std::is_same_v<char, char_t>) chars_ = str;
701 else chars_ = __xtd_convert_to_string<value_type>(str);
702 }
705 basic_string(const std::basic_string<xtd::char16>& str) noexcept { // Can't be explicit by design.
706 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = str;
707 else chars_ = __xtd_convert_to_string<value_type>(str);
708 }
711 basic_string(const std::basic_string<xtd::char32>& str) noexcept { // Can't be explicit by design.
712 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = str;
713 else chars_ = __xtd_convert_to_string<value_type>(str);
714 }
715#if defined(__xtd__cpp_lib_char8_t)
718 basic_string(const std::basic_string<xtd::char8>& str) noexcept { // Can't be explicit by design.
719 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = str;
720 else chars_ = __xtd_convert_to_string<value_type>(str);
721 }
722#endif
725 basic_string(const std::basic_string<xtd::wchar>& str) noexcept { // Can't be explicit by design.
726 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = str;
727 else chars_ = __xtd_convert_to_string<value_type>(str);
728 }
729
733 basic_string(const std::basic_string<char>& str, const allocator_type& allocator) noexcept {
734 if constexpr (std::is_same_v<char, char_t>) chars_ = base_type(str, allocator);
735 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
736 }
740 basic_string(const std::basic_string<xtd::char16>& str, const allocator_type& allocator) noexcept {
741 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = base_type(str, allocator);
742 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
743 }
747 basic_string(const std::basic_string<xtd::char32>& str, const allocator_type& allocator) noexcept {
748 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = base_type(str, allocator);
749 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
750 }
751#if defined(__xtd__cpp_lib_char8_t)
755 basic_string(const std::basic_string<xtd::char8>& str, const allocator_type& allocator) noexcept {
756 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = base_type(str, allocator);
757 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
758 }
759#endif
763 basic_string(const std::basic_string<xtd::wchar>& str, const allocator_type& allocator) noexcept {
764 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = base_type(str, allocator);
765 else chars_ = base_type(__xtd_convert_to_string<value_type>(str), allocator);
766 }
767
771 template<typename input_iterator_t>
772 basic_string(input_iterator_t first, input_iterator_t last) : chars_(first, last) {}
777 template<typename input_iterator_t>
778 basic_string(input_iterator_t first, input_iterator_t last, const allocator_type& allocator) : chars_(first, last, allocator) {}
779
783 template<typename string_view_like_t>
784 explicit constexpr basic_string(const string_view_like_t& string_view) : chars_(string_view) {}
788 template<typename string_view_like_t>
789 explicit constexpr basic_string(const string_view_like_t& string_view, const allocator_type& allocator) : chars_(string_view, allocator) {}
795 template<typename string_view_like_t>
796 constexpr basic_string(const string_view_like_t& string_view, size_type index, size_type count) : chars_(string_view, index, count) {}
802 template<typename string_view_like_t>
803 constexpr basic_string(const string_view_like_t& string_view, size_type index, size_type count, const allocator_type& allocator) : chars_(string_view, index, count, allocator) {}
804
807 basic_string(std::initializer_list<char> il) : basic_string(std::basic_string<char>(il)) {}
810 basic_string(std::initializer_list<xtd::char16> il) : basic_string(std::basic_string<xtd::char16>(il)) {}
813 basic_string(std::initializer_list<xtd::char32> il) : basic_string(std::basic_string<xtd::char32>(il)) {}
814#if defined(__xtd__cpp_lib_char8_t)
817 basic_string(std::initializer_list<xtd::char8> il) : basic_string(std::basic_string<xtd::char8>(il)) {}
818#endif
821 basic_string(std::initializer_list<xtd::wchar> il) : basic_string(std::basic_string<xtd::wchar>(il)) {}
822
826 basic_string(std::initializer_list<char> il, const allocator_type& allocator) : basic_string(std::basic_string<char>(il), allocator) {}
830 basic_string(std::initializer_list<xtd::char16> il, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char16>(il), allocator) {}
834 basic_string(std::initializer_list<xtd::char32> il, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char32>(il), allocator) {}
835#if defined(__xtd__cpp_lib_char8_t)
839 basic_string(std::initializer_list<xtd::char8> il, const allocator_type& allocator) : basic_string(std::basic_string<xtd::char8>(il), allocator) {}
840#endif
844 basic_string(std::initializer_list<xtd::wchar> il, const allocator_type& allocator) : basic_string(std::basic_string<xtd::wchar>(il), allocator) {}
846
848
853 const_reference back() const {return operator[](size() - 1);}
854
858
867 const_pointer c_str() const noexcept {return chars_.c_str();}
868
871 size_type capacity() const noexcept {return chars_.capacity();}
872
876
879 const_reverse_iterator crbegin() const {return chars_.crbegin();}
880
883 const base_type& chars() const noexcept {return chars_;}
884
888
891 const_reverse_iterator crend() const {return chars_.crend();}
892
900 const_pointer data() const noexcept {return chars_.data();}
901
904 bool empty() const noexcept {return chars_.empty();}
905
909
913 const_reference front() const {return operator[](0);}
914
918 size_type length() const noexcept {return chars_.size();}
919
922 size_type max_size() const noexcept {return chars_.max_size();}
923
926 const_reverse_iterator rbegin() const {return chars_.crbegin();}
927
930 const_reverse_iterator rend() const {return chars_.crend();}
931
934 size_type size() const noexcept {return chars_.size();}
936
938
943 const_reference at(size_type pos) const {return operator [](pos);}
944
963 int32 compare(const basic_string& str) const {return chars_.compare(str);}
985 int32 compare(size_type pos1, size_type count1, const basic_string& str) const {return chars_.compare(pos1, count1, str);}
1009 int32 compare(size_type pos1, size_type count1, const basic_string& str, size_type pos2) const {return chars_.compare(pos1, count1, str, pos2);}
1034 int32 compare(size_type pos1, size_type count1, const basic_string& str, size_type pos2, size_type count2) const {return chars_.compare(pos1, count1, str, pos2, count2);}
1053 int32 compare(const_pointer s) const {return chars_.compare(s);}
1075 int32 compare(size_type pos1, size_type count1, const_pointer s) const {return chars_.compare(pos1, count1, s);}
1098 int32 compare(size_type pos1, size_type count1, const_pointer s, size_type count2) const {return chars_.compare(pos1, count1, s, count2);}
1099
1109 int32 compare_to(const object& value) const {
1110 if (!dynamic_cast<const basic_string*>(&value)) __throw_basic_string_argument_exception(__FILE__, __LINE__, __func__);
1111 return compare_to(static_cast<const basic_string&>(value));
1112 }
1121 int32 compare_to(const basic_string& value) const noexcept override {return chars_.compare(value.chars_);}
1122
1126 virtual bool contains(value_type value) const noexcept {return find(value) != npos;}
1130 virtual bool contains(const basic_string& value) const noexcept {return find(value) != npos;}
1131
1135 bool equals(const object& obj) const noexcept override {return dynamic_cast<const basic_string*>(&obj) && equals(static_cast<const basic_string&>(obj));}
1140 bool equals(const basic_string& value) const noexcept override {return equals(value, false);}
1146 bool equals(const basic_string& value, bool ignore_case) const noexcept {
1147 if (ignore_case) return to_upper().chars_ == value.to_upper().chars_;
1148 return chars_ == value.chars_;
1149 }
1150
1154 bool ends_with(value_type value) const noexcept {return ends_with(value, false);}
1159 bool ends_with(value_type value, bool ignore_case) const noexcept {
1160 if (ignore_case) return to_lower().rfind(static_cast<value_type>(tolower(value))) == size() - 1;
1161 return rfind(value) == size() - 1;
1162 }
1166 bool ends_with(const basic_string& value) const noexcept {return ends_with(value, xtd::string_comparison::ordinal);}
1171 bool ends_with(const basic_string& value, bool ignore_case) const noexcept {return ends_with(value, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
1176 bool ends_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept {
1177 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().rfind(value.to_lower()) + value.to_lower().size() == size();
1178 return rfind(value) + value.size() == size();
1179 }
1180
1184 size_type find(const basic_string& str) const {return chars_.find(str);}
1190 size_type find(const basic_string& str, size_type pos) const {return chars_.find(str, pos);}
1198 size_type find(const_pointer s, size_type pos, size_type count) const {return chars_.find(s, pos, count);}
1204 size_type find(const_pointer s) const {return chars_.find(s);}
1211 size_type find(const_pointer s, size_type pos) const {return chars_.find(s, pos);}
1216 size_type find(value_type ch) const {return chars_.find(ch);}
1222 size_type find(value_type ch, size_type pos) const {return chars_.find(ch, pos);}
1223
1228 size_type find_first_of(const basic_string& str) const {return chars_.find_first_of(str);}
1234 size_type find_first_of(const basic_string& str, size_type pos) const {return chars_.find_first_of(str, pos);}
1242 size_type find_first_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_first_of(s, pos, count);}
1248 size_type find_first_of(const_pointer s) const {return chars_.find_first_of(s);}
1255 size_type find_first_of(const_pointer s, size_type pos) const {return chars_.find_first_of(s, pos);}
1260 size_type find_first_of(char_t ch) const {return chars_.find_first_of(ch);}
1266 size_type find_first_of(char_t ch, size_type pos) const {return chars_.find_first_of(ch, pos);}
1267
1272 size_type find_first_not_of(const basic_string& str) const {return chars_.find_first_not_of(str);}
1278 size_type find_first_not_of(const basic_string& str, size_type pos) const {return chars_.find_first_not_of(str, pos);}
1286 size_type find_first_not_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_first_not_of(s, pos, count);}
1292 size_type find_first_not_of(const_pointer s) const {return chars_.find_first_not_of(s);}
1299 size_type find_first_not_of(const_pointer s, size_type pos) const {return chars_.find_first_not_of(s, pos);}
1304 size_type find_first_not_of(char_t ch) const {return chars_.find_first_not_of(ch);}
1310 size_type find_first_not_of(char_t ch, size_type pos) const {return chars_.find_first_not_of(ch, pos);}
1311
1316 size_type find_last_of(const basic_string& str) const {return chars_.find_last_of(str);}
1322 size_type find_last_of(const basic_string& str, size_type pos) const {return chars_.find_last_of(str, pos);}
1330 size_type find_last_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_last_of(s, pos, count);}
1336 size_type find_last_of(const_pointer s) const {return chars_.find_last_of(s);}
1343 size_type find_last_of(const_pointer s, size_type pos) const {return chars_.find_last_of(s, pos);}
1348 size_type find_last_of(char_t ch) const {return chars_.find_last_of(ch);}
1354 size_type find_last_of(char_t ch, size_type pos) const {return chars_.find_last_of(ch, pos);}
1355
1360 size_type find_last_not_of(const basic_string& str) const {return chars_.find_last_not_of(str);}
1366 size_type find_last_not_of(const basic_string& str, size_type pos) const {return chars_.find_last_not_of(str, pos);}
1374 size_type find_last_not_of(const_pointer s, size_type pos, size_type count) const {return chars_.find_last_not_of(s, pos, count);}
1380 size_type find_last_not_of(const_pointer s) const {return chars_.find_last_not_of(s);}
1387 size_type find_last_not_of(const_pointer s, size_type pos) const {return chars_.find_last_not_of(s, pos);}
1392 size_type find_last_not_of(char_t ch) const {return chars_.find_last_not_of(ch);}
1398 size_type find_last_not_of(char_t ch, size_type pos) const {return chars_.find_last_not_of(ch, pos);}
1399
1402 allocator_type get_allocator() const {return chars_.get_allocator();}
1403
1406 virtual const base_type& get_base_type() const noexcept {return chars_;}
1407
1410 xtd::size get_hash_code() const noexcept override {return xtd::hash_code::combine(chars_);}
1411
1412 enumerator_type get_enumerator() const noexcept override {
1413 class basic_string_enumerator : public xtd::collections::generic::ienumerator<value_type> {
1414 public:
1415 explicit basic_string_enumerator(const basic_string& chars) : chars_(chars) {}
1416
1417 const value_type& current() const override {return chars_[index_];}
1418
1419 bool move_next() override {return ++index_ < chars_.size();}
1420
1421 void reset() override {index_ = basic_string::npos;}
1422
1423 protected:
1424 const basic_string& chars_;
1425 xtd::size index_ = basic_string::npos;
1426 };
1427 return {new_ptr<basic_string_enumerator>(*this)};
1428 }
1429
1433 xtd::size index_of(const basic_string& value) const noexcept {return index_of(value, 0, size());}
1438 xtd::size index_of(const basic_string& value, xtd::size start_index) const {return index_of(value, start_index, size() - start_index);}
1445 xtd::size index_of(const basic_string& value, xtd::size start_index, xtd::size count) const {
1446 if (start_index > size() || start_index + count > size()) __throw_basic_string_index_out_of_range_exception(__FILE__, __LINE__, __func__);
1447 auto result = find(value, start_index);
1448 return result > start_index + count ? npos : result;
1449 }
1453 xtd::size index_of(value_type value) const noexcept {return index_of(value, 0, size());}
1458 xtd::size index_of(value_type value, xtd::size start_index) const {return index_of(value, start_index, size() - start_index);}
1465 xtd::size index_of(value_type value, xtd::size start_index, xtd::size count) const {
1466 if (start_index > size() || start_index + count > size()) __throw_basic_string_index_out_of_range_exception(__FILE__, __LINE__, __func__);
1467 auto result = find(value, start_index);
1468 return result > start_index + count ? npos : result;
1469 }
1470
1474 xtd::size index_of_any(const xtd::array<value_type>& values) const noexcept;
1480 xtd::size index_of_any(const xtd::array<value_type>& values, xtd::size start_index) const;
1487 xtd::size index_of_any(const xtd::array<value_type>& values, xtd::size start_index, xtd::size count) const;
1489 xtd::size index_of_any(const std::initializer_list<value_type>& values) const noexcept;
1490 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
1491 xtd::size index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
1493
1500 basic_string insert(xtd::size start_index, const basic_string& value) const {
1501 if (start_index > size()) __throw_basic_string_index_out_of_range_exception(__FILE__, __LINE__, __func__);
1502 auto result = *this;
1503 result.chars_.insert(start_index, value);
1504 return result;
1505 }
1506
1510 [[deprecated("Replaced by xtd::basic_string::is_empty(const xtd::basic_string&) - Will be removed in version 0.4.0.")]]
1511 bool is_empty() const noexcept {return is_empty(*this);}
1512
1516 xtd::size last_index_of(const basic_string& value) const noexcept {return last_index_of(value, 0, size());}
1522 xtd::size last_index_of(const basic_string& value, xtd::size start_index) const {return last_index_of(value, start_index, size() - start_index);}
1529 xtd::size last_index_of(const basic_string& value, xtd::size start_index, xtd::size count) const {
1530 if (start_index > size() || start_index + count > size()) __throw_basic_string_index_out_of_range_exception(__FILE__, __LINE__, __func__);
1531 auto result = rfind(value, start_index + count - value.size());
1532 return result < start_index ? npos : result;
1533 }
1537 xtd::size last_index_of(value_type value) const noexcept {return last_index_of(value, 0, size());}
1543 xtd::size last_index_of(value_type value, xtd::size start_index) const {return last_index_of(value, start_index, size() - start_index);}
1551 xtd::size last_index_of(value_type value, xtd::size start_index, xtd::size count) const {
1552 if (start_index > size() || start_index + count > size()) __throw_basic_string_index_out_of_range_exception(__FILE__, __LINE__, __func__);
1553 auto result = rfind(value, start_index + count - 1);
1554 return result < start_index ? npos : result;
1555 }
1556
1573 xtd::size last_index_of_any(const std::initializer_list<value_type>& values) const noexcept;
1574 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index) const;
1575 xtd::size last_index_of_any(const std::initializer_list<value_type>& values, xtd::size start_index, xtd::size count) const;
1577
1583 basic_string pad_left(xtd::size total_width) const noexcept {return pad_left(total_width, ' ');}
1590 basic_string pad_left(xtd::size total_width, char32 padding_char) const noexcept {return total_width < size() ? *this : basic_string(total_width - size(), padding_char) + *this;}
1591
1597 basic_string pad_right(xtd::size total_width) const noexcept {return pad_right(total_width, ' ');}
1604 basic_string pad_right(xtd::size total_width, char32 padding_char) const noexcept {return total_width < size() ? *this : *this + basic_string(total_width - size(), padding_char);}
1605
1610 basic_string quoted() const {return quoted('"', '\\');}
1615 basic_string quoted(value_type delimiter) const {return quoted(delimiter, '\\');}
1622 std::wstringstream ss;
1623 if constexpr (std::is_same_v<xtd::wchar, value_type>) ss << std::quoted(chars_, delimiter, escape);
1624 else ss << std::quoted(__xtd_convert_to_string<xtd::wchar>(chars_), static_cast<xtd::wchar>(delimiter), static_cast<xtd::wchar>(escape));
1625 return ss.str();
1626 }
1627
1631 basic_string remove(xtd::size start_index) const {return remove(start_index, size() - start_index);}
1636 basic_string remove(xtd::size start_index, xtd::size count) const {
1637 if (start_index > size() || start_index + count > size()) __throw_basic_string_index_out_of_range_exception(__FILE__, __LINE__, __func__);
1638 auto result = *this;
1639 result.chars_.erase(start_index, count);
1640 return result;
1641 }
1642
1647 basic_string replace(value_type old_char, value_type new_char) const noexcept {return replace(string(1, old_char), string(1, new_char));}
1653 basic_string replace(const basic_string& old_string, const basic_string& new_string) const noexcept {
1654 auto result = *this;
1655 auto old_size = old_string.size();
1656 auto new_size = new_string.size();
1657 auto index = xtd::size {0};
1658 while (true) {
1659 index = result.find(old_string, index);
1660 if (index == npos) break;
1661 if (old_size == new_size) result.chars_.replace(index, old_size, new_string);
1662 else {
1663 result.chars_.erase(index, old_string.size());
1664 result.chars_.insert(index, new_string);
1665 }
1666 index += new_string.size();
1667 }
1668 return result;
1669 }
1670
1674 size_type rfind(const basic_string& str) const {return chars_.rfind(str);}
1680 size_type rfind(const basic_string& str, size_type pos) const {return chars_.rfind(str, pos);}
1688 size_type rfind(const_pointer s, size_type pos, size_type count) const {return chars_.rfind(s, pos, count);}
1694 size_type rfind(const_pointer s) const {return chars_.rfind(s);}
1701 size_type rfind(const_pointer s, size_type pos) const {return chars_.rfind(s, pos);}
1706 size_type rfind(value_type ch) const {return chars_.rfind(ch);}
1712 size_type rfind(value_type ch, size_type pos) const {return chars_.rfind(ch, pos);}
1713
1768 xtd::array<basic_string> split(const xtd::array<value_type>& separators) const noexcept;
1785 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::string_split_options options) const noexcept;
1794 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count) const noexcept;
1806 xtd::array<basic_string> split(const xtd::array<value_type>& separators, xtd::size count, xtd::string_split_options options) const noexcept;
1807
1812 bool starts_with(value_type value) const noexcept {return starts_with(value, false);}
1818 bool starts_with(value_type value, bool ignore_case) const noexcept {
1819 if (ignore_case) return to_lower().find(static_cast<value_type>(tolower(value))) == 0;
1820 return find(value) == 0;
1821 }
1826 bool starts_with(const basic_string& value) const noexcept {return starts_with(value, string_comparison::ordinal);}
1832 bool starts_with(const basic_string& value, bool ignore_case) const noexcept {return starts_with(value, ignore_case ? string_comparison::ordinal_ignore_case : string_comparison::ordinal);}
1837 bool starts_with(const basic_string& value, xtd::string_comparison comparison_type) const noexcept {
1838 if (comparison_type == xtd::string_comparison::ordinal_ignore_case) return to_lower().find(value.to_lower()) == 0;
1839 return find(value) == 0;
1840 }
1841
1846 basic_string substr() const {return chars_.substr();}
1853 if (pos > size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
1854 return chars_.substr(pos);
1855 }
1863 if (pos > size() || pos + count > size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
1864 return chars_.substr(pos, count);
1865 }
1866
1872 basic_string substring(xtd::size start_index) const {
1873 if (start_index > size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
1874 return substr(start_index);
1875 }
1882 if (start_index > size() || start_index + length > size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
1883 return substr(start_index, length);
1884 }
1885
1892 xtd::array<value_type> to_array(xtd::size start_index) const;
1897 xtd::array<value_type> to_array(xtd::size start_index, xtd::size length) const;
1898
1901 xtd::array<value_type> to_char_array() const noexcept;
1907
1910 basic_string to_lower() const noexcept {
1911 auto result = basic_string::empty_string;
1912 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::tolower(c));});
1913 return result;
1914 }
1915
1919 basic_string<char> to_string() const noexcept override {
1920 if constexpr (std::is_same_v<char, char_t>) return chars_;
1921 else return __xtd_convert_to_string<char>(chars_);
1922 }
1923
1926 basic_string to_title_case() const noexcept;
1927
1931 if constexpr (std::is_same_v<xtd::char16, char_t>) return chars_;
1932 else return __xtd_convert_to_string<xtd::char16>(chars_);
1933 }
1934
1938 if constexpr (std::is_same_v<xtd::char32, char_t>) return chars_;
1939 else return __xtd_convert_to_string<xtd::char32>(chars_);
1940 }
1941
1942#if defined(__xtd__cpp_lib_char8_t)
1946 if constexpr (std::is_same_v<xtd::char8, char_t>) return chars_;
1947 else return __xtd_convert_to_string<xtd::char8>(chars_);
1948 }
1949#endif
1950
1953 basic_string to_upper() const noexcept {
1954 auto result = basic_string::empty_string;
1955 std::for_each(chars_.begin(), chars_.end(), [&](auto c) {result += static_cast<value_type>(std::toupper(c));});
1956 return result;
1957 }
1958
1962 if constexpr (std::is_same_v<xtd::wchar, char_t>) return chars_;
1963 else return __xtd_convert_to_string<xtd::wchar>(chars_);
1964 }
1965
1970 basic_string trim() const noexcept {return trim(default_trim_chars);}
1975 basic_string trim(value_type trim_char) const noexcept;
1980 basic_string trim(const xtd::array<value_type>& trim_chars) const noexcept;
1981
1986 basic_string trim_end() const noexcept {return trim_end(default_trim_chars);}
1991 basic_string trim_end(value_type trim_char) const noexcept;
1996 basic_string trim_end(const xtd::array<value_type>& trim_chars) const noexcept;
1997
2002 basic_string trim_start() const noexcept {return trim_start(default_trim_chars);}
2007 basic_string trim_start(value_type trim_char) const noexcept;
2012 basic_string trim_start(const xtd::array<value_type>& trim_chars) const noexcept;
2014
2016
2022 template<typename object_t>
2023 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 0.4.0.")]]
2024 static basic_string class_name() {return get_class_name(full_class_name<object_t>());}
2029 template<typename object_t>
2030 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 0.4.0.")]]
2031 static basic_string class_name(const object_t& object) {return get_class_name(full_class_name(object));}
2036 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 0.4.0.")]]
2037 static basic_string class_name(const std::type_info& info) {return __xtd_get_class_name(info);}
2038
2048 static int32 compare(const basic_string& str_a, const basic_string& str_b) noexcept {return compare(str_a, str_b, false);}
2059 static int32 compare(const basic_string& str_a, const basic_string& str_b, bool ignore_case) noexcept {return compare(str_a, str_b, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
2070 static int32 compare(const basic_string& str_a, const basic_string& str_b, xtd::string_comparison comparison_type) noexcept {return comparison_type == xtd::string_comparison::ordinal_ignore_case ? str_a.to_lower().compare(str_b.to_lower()) : str_a.compare(str_b);}
2083 static int32 compare(const basic_string& str_a, xtd::size index_a, const basic_string& str_b, xtd::size index_b, xtd::size length) {return compare(str_a, index_a, str_b, index_b, length, false);}
2097 static int32 compare(const basic_string& str_a, xtd::size index_a, const basic_string& str_b, xtd::size index_b, xtd::size length, bool ignore_case) {return compare(str_a, index_a, str_b, index_b, length, ignore_case ? xtd::string_comparison::ordinal_ignore_case : xtd::string_comparison::ordinal);}
2111 static int32 compare(const basic_string& str_a, xtd::size index_a, const basic_string& str_b, xtd::size index_b, xtd::size length, xtd::string_comparison comparison_type) {return comparison_type == xtd::string_comparison::ordinal_ignore_case ? str_a.substr(index_a, length).to_lower().compare(str_b.substr(index_b, length).to_lower()) : str_a.substr(index_a, length).compare(str_b.substr(index_b, length));}
2112
2119 static basic_string concat(const basic_string& str_a, const basic_string& str_b, const basic_string& str_c, const basic_string& str_d) noexcept {return str_a + str_b + str_c + str_d;}
2126 template<typename object_a_t, typename object_b_t, typename object_c_t, typename object_d_t>
2127 static basic_string concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c, object_d_t obj_d) noexcept {return format("{}{}{}{}", obj_a, obj_b, obj_c, obj_d);}
2133 static basic_string concat(const basic_string& str_a, const basic_string& str_b, const basic_string& str_c) noexcept {return str_a + str_b + str_c;}
2139 template<typename object_a_t, typename object_b_t, typename object_c_t>
2140 static basic_string concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept {return format("{}{}{}", obj_a, obj_b, obj_c);}
2145 static basic_string concat(const basic_string& str_a, const basic_string& str_b) noexcept {return str_a + str_b;}
2150 template<typename object_a_t, typename object_b_t>
2151 static basic_string concat(object_a_t obj_a, object_b_t obj_b) noexcept {return format("{}{}", obj_a, obj_b);}
2155 static basic_string concat(const xtd::array<basic_string>& values) noexcept;
2157 static basic_string concat(const xtd::array<const_pointer>& values) noexcept;
2158 template<typename other_char_t>
2159 static basic_string concat(const xtd::array<const other_char_t*>& values) noexcept;
2160 static basic_string concat(const std::initializer_list<basic_string>& values) noexcept {
2161 auto result = basic_string::empty_string;
2162 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
2163 return result;
2164 }
2165 static basic_string concat(const std::initializer_list<const_pointer>& values) noexcept {
2166 auto result = basic_string::empty_string;
2167 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
2168 return result;
2169 }
2170 template<typename other_char_t>
2171 static basic_string concat(const std::initializer_list<const other_char_t*>& values) noexcept {
2172 auto result = basic_string::empty_string;
2173 std::for_each(values.begin(), values.end(), [&](const auto & item) {result += item;});
2174 return result;
2175 }
2180 template<typename object_t>
2181 static basic_string concat(const xtd::array<object_t>& args) noexcept;
2183 template<typename object_t>
2184 static basic_string concat(const std::initializer_list<object_t>& args) noexcept {
2185 basic_string result;
2186 for (const auto& arg : args)
2187 result += format("{}", arg);
2188 return result;
2189 }
2194 template<typename value_t>
2195 static basic_string concat(value_t value) noexcept {
2196 return format("{}", value);
2197 }
2198
2219 static basic_string demangle(const basic_string& name) {
2220 if constexpr (std::is_same_v<char, char_t>) return __xtd_demangle(name.chars());
2221 else return __xtd_demangle(__xtd_convert_to_string<char>(name.chars()));
2222 }
2223
2229 static bool equals(const basic_string& a, const basic_string& b) noexcept{return a.equals(b);}
2235 template<typename char_a_t, typename char_b_t>
2236 static bool equals(const char_a_t* a, const char_b_t* b) noexcept{return basic_string {a}.equals(basic_string {b});}
2237
2244 static bool equals(const basic_string& a, const basic_string& b, bool ignore_case) noexcept {return a.equals(b, ignore_case);}
2251 template<typename char_a_t, typename char_b_t>
2252 static bool equals(const char_a_t* a, const char_b_t* b, bool ignore_case) noexcept{return basic_string {a}.equals(basic_string {b}, ignore_case);}
2253
2260 template<typename ...args_t>
2261 static basic_string format(const basic_string<char>& fmt, args_t&& ... args);
2262
2267 template<typename object_t>
2268 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 0.4.0.")]]
2269 static basic_string full_class_name() {return demangle(typeid(object_t).name());}
2274 template<typename object_t>
2275 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 0.4.0.")]]
2276 static basic_string full_class_name(const object_t& object) {return demangle(typeid(object).name());}
2281 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 0.4.0.")]]
2282 static basic_string full_class_name(const std::type_info& info) {return __xtd_get_full_class_name(info);}
2283
2287 static bool is_empty(const xtd::basic_string<value_type, traits_type, allocator_type>& string) noexcept {return !string.length();}
2288
2295 template<typename collection_t>
2296 static basic_string join(const basic_string separator, const collection_t& values) noexcept {return join(separator, values, 0, values.size());}
2304 template<typename collection_t>
2305 static basic_string join(const basic_string& separator, const collection_t& values, xtd::size index) {return join(separator, values, index, values.size() - index);}
2314 template<typename collection_t>
2315 static basic_string join(const basic_string& separator, const collection_t& values, xtd::size index, xtd::size count) {
2316 if (index > values.size() || index + count > values.size()) __throw_basic_string_argument_out_of_range_exception(__FILE__, __LINE__, __func__);
2317 xtd::size i = 0;
2318 basic_string result;
2319 for (const auto& item : values) {
2320 if (i >= index) {
2321 if (i != index) result += separator;
2322 result += format("{}", item);
2323 }
2324 if (++i >= index + count) break;
2325 }
2326 return result;
2327 }
2329 template<typename value_t>
2330 static basic_string join(const basic_string& separator, const std::initializer_list<value_t>& values) noexcept;
2331 template<typename value_t>
2332 static basic_string join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::size index);
2333 template<typename value_t>
2334 static basic_string join(const basic_string& separator, const std::initializer_list<value_t>& values, xtd::size index, xtd::size count);
2336
2340 template<typename value_t>
2341 static value_t parse(const basic_string& str) {
2342 if constexpr (std::is_same_v<char, char_t>) return xtd::parse<value_t>(str.chars());
2343 else return xtd::parse<value_t>(__xtd_convert_to_string<char>(str.chars()));
2344 }
2345
2405 template<typename ... args_t>
2406 static basic_string sprintf(const basic_string& fmt, args_t&& ... args) noexcept {return __sprintf(fmt.c_str(), convert_param(std::forward<args_t>(args)) ...);}
2407
2412 template<typename value_t>
2413 static bool try_parse(const basic_string& str, value_t& value) noexcept {
2414 try {
2415 value = parse<value_t>(str);
2416 return true;
2417 } catch (...) {
2418 return false;
2419 }
2420 }
2422
2424
2431 if (index >= length()) __throw_basic_string_index_out_of_range_exception(__FILE__, __LINE__, __func__);
2432 return chars_[index];
2433 }
2434
2437 operator const base_type&() const noexcept {return chars_;}
2438
2443 if constexpr(std::is_same<char_t, char>::value) chars_ = str.chars_;
2444 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2445 return *this;
2446 }
2451 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str.chars_;
2452 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2453 return *this;
2454 }
2459 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str.chars_;
2460 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2461 return *this;
2462 }
2463#if defined(__xtd__cpp_lib_char8_t)
2468 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str.chars_;
2469 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2470 return *this;
2471 }
2472#endif
2477 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str.chars_;
2478 else chars_ = __xtd_convert_to_string<value_type>(str.chars());
2479 return *this;
2480 }
2481
2486 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str.chars_);
2487 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2488 return *this;
2489 }
2494 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str.chars_);
2495 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2496 return *this;
2497 }
2502 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str.chars_);
2503 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2504 return *this;
2505 }
2506#if defined(__xtd__cpp_lib_char8_t)
2511 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str.chars_);
2512 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2513 return *this;
2514 }
2515#endif
2520 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str.chars_);
2521 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str.chars_)));
2522 return *this;
2523 }
2524
2528 basic_string& operator =(const std::basic_string<char>& str) noexcept {
2529 if constexpr(std::is_same<char_t, char>::value) chars_ = str;
2530 else chars_ = __xtd_convert_to_string<value_type>(str);
2531 return *this;
2532 }
2536 basic_string& operator =(const std::basic_string<xtd::char16>& str) noexcept {
2537 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = str;
2538 else chars_ = __xtd_convert_to_string<value_type>(str);
2539 return *this;
2540 }
2544 basic_string& operator =(const std::basic_string<xtd::char32>& str) noexcept {
2545 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = str;
2546 else chars_ = __xtd_convert_to_string<value_type>(str);
2547 return *this;
2548 }
2549#if defined(__xtd__cpp_lib_char8_t)
2553 basic_string& operator =(const std::basic_string<xtd::char8>& str) noexcept {
2554 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = str;
2555 else chars_ = __xtd_convert_to_string<value_type>(str);
2556 return *this;
2557 }
2558#endif
2562 basic_string& operator =(const std::basic_string<xtd::wchar>& str) noexcept {
2563 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = str;
2564 else chars_ = __xtd_convert_to_string<value_type>(str);
2565 return *this;
2566 }
2567
2571 basic_string& operator =(std::basic_string<char>&& str) noexcept {
2572 if constexpr(std::is_same<char_t, char>::value) chars_ = std::move(str);
2573 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2574 return *this;
2575 }
2579 basic_string& operator =(std::basic_string<xtd::char16>&& str) noexcept {
2580 if constexpr(std::is_same<char_t, xtd::char16>::value) chars_ = std::move(str);
2581 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2582 return *this;
2583 }
2587 basic_string& operator =(std::basic_string<xtd::char32>&& str) noexcept {
2588 if constexpr(std::is_same<char_t, xtd::char32>::value) chars_ = std::move(str);
2589 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2590 return *this;
2591 }
2592#if defined(__xtd__cpp_lib_char8_t)
2596 basic_string& operator =(std::basic_string<xtd::char8>&& str) noexcept {
2597 if constexpr(std::is_same<char_t, xtd::char8>::value) chars_ = std::move(str);
2598 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2599 return *this;
2600 }
2601#endif
2605 basic_string& operator =(std::basic_string<xtd::wchar>&& str) noexcept {
2606 if constexpr(std::is_same<char_t, xtd::wchar>::value) chars_ = std::move(str);
2607 else chars_ = std::move(__xtd_convert_to_string<value_type>(std::move(str)));
2608 return *this;
2609 }
2610
2615 basic_string& operator =(const char* str) {
2616 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
2617 if constexpr (std::is_same_v<char, char_t>) chars_ = std::basic_string<char>(str);
2618 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<char>(str));
2619 return *this;
2620 }
2626 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
2627 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ = std::basic_string<xtd::char16>(str);
2628 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char16>(str));
2629 return *this;
2630 }
2636 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
2637 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ = std::basic_string<xtd::char32>(str);
2638 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char32>(str));
2639 return *this;
2640 }
2641#if defined(__xtd__cpp_lib_char8_t)
2647 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
2648 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ = std::basic_string<xtd::char8>(str);
2649 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::char8>(str));
2650 return *this;
2651 }
2652#endif
2658 if (str == null) __throw_basic_string_null_pointer_exception(__FILE__, __LINE__, __func__);
2659 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ = std::basic_string<xtd::wchar>(str);
2660 else chars_ = __xtd_convert_to_string<value_type>(std::basic_string<xtd::wchar>(str));
2661 return *this;
2662 }
2663
2667 basic_string& operator =(char character) {
2668 *this = basic_string(1, character);
2669 return *this;
2670 }
2675 *this = basic_string(1, character);
2676 return *this;
2677 }
2682 *this = basic_string(1, character);
2683 return *this;
2684 }
2685#if defined(__xtd__cpp_lib_char8_t)
2690 *this = basic_string(1, character);
2691 return *this;
2692 }
2693#endif
2698 *this = basic_string(1, character);
2699 return *this;
2700 }
2701
2705 basic_string& operator =(const std::initializer_list<char>& il) {
2706 *this = basic_string(il);
2707 return *this;
2708 }
2712 basic_string& operator =(const std::initializer_list<xtd::char16>& il) {
2713 *this = basic_string(il);
2714 return *this;
2715 }
2719 basic_string& operator =(const std::initializer_list<xtd::char32>& il) {
2720 *this = basic_string(il);
2721 return *this;
2722 }
2723#if defined(__xtd__cpp_lib_char8_t)
2727 basic_string& operator =(const std::initializer_list<xtd::char8>& il) {
2728 *this = basic_string(il);
2729 return *this;
2730 }
2731#endif
2735 basic_string& operator =(const std::initializer_list<xtd::wchar>& il) {
2736 *this = basic_string(il);
2737 return *this;
2738 }
2739
2744 if constexpr (std::is_same_v<char, char_t>) chars_ += str.chars_;
2745 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2746 return *this;
2747 }
2752 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ += str.chars_;
2753 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2754 return *this;
2755 }
2760 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ += str.chars_;
2761 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2762 return *this;
2763 }
2764#if defined(__xtd__cpp_lib_char8_t)
2769 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ += str.chars_;
2770 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2771 return *this;
2772 }
2773#endif
2778 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ += str.chars_;
2779 else chars_ += __xtd_convert_to_string<value_type>(str.chars_);
2780 return *this;
2781 }
2782
2787 if constexpr (std::is_same_v<char, char_t>) chars_ += std::move(str.chars_);
2788 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2789 return *this;
2790 }
2795 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ += std::move(str.chars_);
2796 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2797 return *this;
2798 }
2803 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ += std::move(str.chars_);
2804 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2805 return *this;
2806 }
2807#if defined(__xtd__cpp_lib_char8_t)
2812 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ += std::move(str.chars_);
2813 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2814 return *this;
2815 }
2816#endif
2821 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ += std::move(str.chars_);
2822 else chars_ += __xtd_convert_to_string<value_type>(std::move(str.chars_));
2823 return *this;
2824 }
2825
2829 basic_string& operator +=(const std::basic_string<char>& str) {
2830 if constexpr (std::is_same_v<char, char_t>) chars_ += str;
2831 else chars_ += __xtd_convert_to_string<value_type>(str);
2832 return *this;
2833 }
2837 basic_string& operator +=(const std::basic_string<xtd::char16>& str) {
2838 if constexpr (std::is_same_v<xtd::char16, char_t>) chars_ += str;
2839 else chars_ += __xtd_convert_to_string<value_type>(str);
2840 return *this;
2841 }
2845 basic_string& operator +=(const std::basic_string<xtd::char32>& str) {
2846 if constexpr (std::is_same_v<xtd::char32, char_t>) chars_ += str;
2847 else chars_ += __xtd_convert_to_string<value_type>(str);
2848 return *this;
2849 }
2850#if defined(__xtd__cpp_lib_char8_t)
2854 basic_string& operator +=(const std::basic_string<xtd::char8>& str) {
2855 if constexpr (std::is_same_v<xtd::char8, char_t>) chars_ += str;
2856 else chars_ += __xtd_convert_to_string<value_type>(str);
2857 return *this;
2858 }
2859#endif
2863 basic_string& operator +=(const std::basic_string<xtd::wchar>& str) {
2864 if constexpr (std::is_same_v<xtd::wchar, char_t>) chars_ += str;
2865 else chars_ += __xtd_convert_to_string<value_type>(str);
2866 return *this;
2867 }
2868
2872 basic_string& operator +=(const char* str) {
2873 chars_ += basic_string(str).chars_;
2874 return *this;
2875 }
2880 chars_.append(basic_string(str).chars_); return *this;
2881 }
2886 chars_ += basic_string(str).chars_;
2887 return *this;
2888 }
2889#if defined(__xtd__cpp_lib_char8_t)
2894 chars_ += basic_string(str).chars_;
2895 return *this;
2896 }
2897#endif
2902 chars_ += basic_string(str).chars_;
2903 return *this;
2904 }
2909 chars_ += basic_string(1, ch).chars_;
2910 return *this;
2911 }
2916 chars_ += basic_string(1, ch).chars_;
2917 return *this;
2918 }
2923 chars_ += basic_string(1, ch).chars_;
2924 return *this;
2925 }
2926#if defined(__xtd__cpp_lib_char8_t)
2931 chars_ += basic_string(1, ch).chars_;
2932 return *this;
2933 }
2934#endif
2939 chars_ += basic_string(1, ch).chars_;
2940 return *this;
2941 }
2942
2948 auto result = lhs;
2949 result += rhs;
2950 return result;
2951 }
2957 auto result = lhs;
2958 result += rhs;
2959 return result;
2960 }
2966 auto result = lhs;
2967 result += rhs;
2968 return result;
2969 }
2970#if defined(__xtd__cpp_lib_char8_t)
2976 auto result = lhs;
2977 result += rhs;
2978 return result;
2979 }
2980#endif
2986 auto result = lhs;
2987 result += rhs;
2988 return result;
2989 }
2990
2996 auto result = std::move(lhs);
2997 result += std::move(rhs);
2998 return result;
2999 }
3005 auto result = std::move(lhs);
3006 result += std::move(rhs);
3007 return result;
3008 }
3014 auto result = std::move(lhs);
3015 result += std::move(rhs);
3016 return result;
3017 }
3018#if defined(__xtd__cpp_lib_char8_t)
3024 auto result = std::move(lhs);
3025 result += std::move(rhs);
3026 return result;
3027 }
3028#endif
3034 auto result = std::move(lhs);
3035 result += std::move(rhs);
3036 return result;
3037 }
3038
3044 auto result = std::move(lhs);
3045 result += rhs;
3046 return result;
3047 }
3053 auto result = std::move(lhs);
3054 result += rhs;
3055 return result;
3056 }
3062 auto result = std::move(lhs);
3063 result += rhs;
3064 return result;
3065 }
3066#if defined(__xtd__cpp_lib_char8_t)
3072 auto result = std::move(lhs);
3073 result += rhs;
3074 return result;
3075 }
3076#endif
3082 auto result = std::move(lhs);
3083 result += rhs;
3084 return result;
3085 }
3086
3092 auto result = lhs;
3093 result += std::move(rhs);
3094 return result;
3095 }
3101 auto result = lhs;
3102 result += std::move(rhs);
3103 return result;
3104 }
3110 auto result = lhs;
3111 result += std::move(rhs);
3112 return result;
3113 }
3114#if defined(__xtd__cpp_lib_char8_t)
3120 auto result = lhs;
3121 result += std::move(rhs);
3122 return result;
3123 }
3124#endif
3130 auto result = lhs;
3131 result += std::move(rhs);
3132 return result;
3133 }
3134
3139 friend basic_string operator +(const basic_string& lhs, const std::basic_string<char>& rhs) {
3140 auto result = lhs;
3141 result += rhs;
3142 return result;
3143 }
3148 friend basic_string operator +(const basic_string& lhs, const std::basic_string<xtd::char16>& rhs) {
3149 auto result = lhs;
3150 result += rhs;
3151 return result;
3152 }
3157 friend basic_string operator +(const basic_string& lhs, const std::basic_string<xtd::char32>& rhs) {
3158 auto result = lhs;
3159 result += rhs;
3160 return result;
3161 }
3162#if defined(__xtd__cpp_lib_char8_t)
3167 friend basic_string operator +(const basic_string& lhs, const std::basic_string<xtd::char8>& rhs) {
3168 auto result = lhs;
3169 result += rhs;
3170 return result;
3171 }
3172#endif
3177 friend basic_string operator +(const basic_string& lhs, const std::basic_string<xtd::wchar>& rhs) {
3178 auto result = lhs;
3179 result += rhs;
3180 return result;
3181 }
3182
3187 friend basic_string operator +(const std::basic_string<char>& lhs, const basic_string& rhs) {
3188 auto result = lhs;
3189 if constexpr (std::is_same_v<char, char_t>) result += rhs.chars();
3190 else result += __xtd_convert_to_string<char>(rhs.chars());
3191 return result;
3192 }
3197 friend basic_string operator +(const std::basic_string<xtd::char16>& lhs, const basic_string& rhs) {
3198 auto result = lhs;
3199 if constexpr (std::is_same_v<xtd::char16, char_t>) result += rhs.chars();
3200 else result += __xtd_convert_to_string<xtd::char16>(rhs.chars());
3201 return result;
3202 }
3207 friend basic_string operator +(const std::basic_string<xtd::char32>& lhs, const basic_string& rhs) {
3208 auto result = lhs;
3209 if constexpr (std::is_same_v<xtd::char32, char_t>) result += rhs.chars();
3210 else result += __xtd_convert_to_string<xtd::char32>(rhs.chars());
3211 return result;
3212 }
3213#if defined(__xtd__cpp_lib_char8_t)
3218 friend basic_string operator +(const std::basic_string<xtd::char8>& lhs, const basic_string& rhs) {
3219 auto result = lhs;
3220 if constexpr (std::is_same_v<xtd::char8, char_t>) result += rhs.chars();
3221 else result += __xtd_convert_to_string<xtd::char8>(rhs.chars());
3222 return result;
3223 }
3224#endif
3229 friend basic_string operator +(const std::basic_string<xtd::wchar>& lhs, const basic_string& rhs) {
3230 auto result = lhs;
3231 if constexpr (std::is_same_v<xtd::wchar, char_t>) result += rhs.chars();
3232 else result += __xtd_convert_to_string<xtd::wchar>(rhs.chars());
3233 return result;
3234 }
3235
3240 friend basic_string operator +(const basic_string& lhs, const char* rhs) {
3241 auto result = lhs;
3242 result += rhs;
3243 return result;
3244 }
3249 friend basic_string operator +(const basic_string& lhs, const xtd::char16* rhs) {
3250 auto result = lhs;
3251 result += rhs;
3252 return result;
3253 }
3258 friend basic_string operator +(const basic_string& lhs, const xtd::char32* rhs) {
3259 auto result = lhs;
3260 result += rhs;
3261 return result;
3262 }
3263#if defined(__xtd__cpp_lib_char8_t)
3268 friend basic_string operator +(const basic_string& lhs, const xtd::char8* rhs) {
3269 auto result = lhs;
3270 result += rhs;
3271 return result;
3272 }
3273#endif
3278 friend basic_string operator +(const basic_string& lhs, const xtd::wchar* rhs) {
3279 auto result = lhs;
3280 result += rhs;
3281 return result;
3282 }
3283
3288 friend basic_string operator +(basic_string&& lhs, const char* rhs) {
3289 auto result = std::move(lhs);
3290 result += rhs;
3291 return result;
3292 }
3298 auto result = std::move(lhs);
3299 result += rhs;
3300 return result;
3301 }
3307 auto result = std::move(lhs);
3308 result += rhs;
3309 return result;
3310 }
3311#if defined(__xtd__cpp_lib_char8_t)
3317 auto result = std::move(lhs);
3318 result += rhs;
3319 return result;
3320 }
3321#endif
3327 auto result = std::move(lhs);
3328 result += rhs;
3329 return result;
3330 }
3331
3336 friend basic_string operator +(const char* lhs, const basic_string& rhs) {
3337 auto result = basic_string(lhs);
3338 result += rhs;
3339 return result;
3340 }
3345 friend basic_string operator +(const xtd::char16* lhs, const basic_string& rhs) {
3346 auto result = basic_string(lhs);
3347 result += rhs;
3348 return result;
3349 }
3354 friend basic_string operator +(const xtd::char32* lhs, const basic_string& rhs) {
3355 auto result = basic_string(lhs);
3356 result += rhs;
3357 return result;
3358 }
3359#if defined(__xtd__cpp_lib_char8_t)
3364 friend basic_string operator +(const xtd::char8* lhs, const basic_string& rhs) {
3365 auto result = basic_string(lhs);
3366 result += rhs;
3367 return result;
3368 }
3369#endif
3374 friend basic_string operator +(const xtd::wchar* lhs, const basic_string& rhs) {
3375 auto result = basic_string(lhs);
3376 result += rhs;
3377 return result;
3378 }
3379
3384 friend basic_string operator +(const char* lhs, basic_string&& rhs) {
3385 auto result = basic_string(lhs);
3386 result += std::move(rhs);
3387 return result;
3388 }
3394 auto result = basic_string(lhs);
3395 result += std::move(rhs);
3396 return result;
3397 }
3403 auto result = basic_string(lhs);
3404 result += std::move(rhs);
3405 return result;
3406 }
3407
3408#if defined(__xtd__cpp_lib_char8_t)
3414 auto result = basic_string(lhs);
3415 result += std::move(rhs);
3416 return result;
3417 }
3418#endif
3424 auto result = basic_string(lhs);
3425 result += std::move(rhs);
3426 return result;
3427 }
3428
3433 friend basic_string operator +(const basic_string& lhs, const char rhs) {
3434 auto result = lhs;
3435 result += rhs;
3436 return result;
3437 }
3442 friend basic_string operator +(const basic_string& lhs, const xtd::char16 rhs) {
3443 auto result = lhs;
3444 result += rhs;
3445 return result;
3446 }
3451 friend basic_string operator +(const basic_string& lhs, const xtd::char32 rhs) {
3452 auto result = lhs;
3453 result += rhs;
3454 return result;
3455 }
3456#if defined(__xtd__cpp_lib_char8_t)
3461 friend basic_string operator +(const basic_string& lhs, const xtd::char8 rhs) {
3462 auto result = lhs;
3463 result += rhs;
3464 return result;
3465 }
3466#endif
3471 friend basic_string operator +(const basic_string& lhs, const xtd::wchar rhs) {
3472 auto result = lhs;
3473 result += rhs;
3474 return result;
3475 }
3476
3481 friend basic_string operator +(basic_string&& lhs, const char rhs) {
3482 auto result = std::move(lhs);
3483 result += rhs;
3484 return result;
3485 }
3491 auto result = std::move(lhs);
3492 result += rhs;
3493 return result;
3494 }
3500 auto result = std::move(lhs);
3501 result += rhs;
3502 return result;
3503 }
3504#if defined(__xtd__cpp_lib_char8_t)
3510 auto result = std::move(lhs);
3511 result += rhs;
3512 return result;
3513 }
3514#endif
3520 auto result = std::move(lhs);
3521 result += rhs;
3522 return result;
3523 }
3524
3529 friend basic_string operator +(char lhs, const basic_string& rhs) {
3530 auto result = basic_string(1, lhs);
3531 result += rhs;
3532 return result;
3533 }
3539 auto result = basic_string(1, lhs);
3540 result += rhs;
3541 return result;
3542 }
3548 auto result = basic_string(1, lhs);
3549 result += rhs;
3550 return result;
3551 }
3552#if defined(__xtd__cpp_lib_char8_t)
3558 auto result = basic_string(1, lhs);
3559 result += rhs;
3560 return result;
3561 }
3562#endif
3568 auto result = basic_string(1, lhs);
3569 result += rhs;
3570 return result;
3571 }
3572
3577 friend basic_string operator +(char lhs, basic_string&& rhs) {
3578 auto result = basic_string(1, lhs);
3579 result += std::move(rhs);
3580 return result;
3581 }
3587 auto result = basic_string(1, lhs);
3588 result += std::move(rhs);
3589 return result;
3590 }
3596 auto result = basic_string(1, lhs);
3597 result += std::move(rhs);
3598 return result;
3599 }
3600#if defined(__xtd__cpp_lib_char8_t)
3606 auto result = basic_string(1, lhs);
3607 result += std::move(rhs);
3608 return result;
3609 }
3610#endif
3616 auto result = basic_string(1, lhs);
3617 result += std::move(rhs);
3618 return result;
3619 }
3620
3629 //friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {return stream << str.to_string().chars_;}
3630 friend std::basic_ostream<char>& operator <<(std::basic_ostream<char>& stream, const basic_string& str) {
3631 if constexpr (std::is_same_v<char, char_t>) return stream << str.chars();
3632 else return stream << __xtd_convert_to_string<char>(str.chars());
3633 }
3640 friend std::basic_ostream<xtd::wchar>& operator <<(std::basic_ostream<xtd::wchar>& stream, const basic_string& str) {return stream << str.to_wstring().chars();}
3641
3650 friend std::basic_istream<char>& operator >>(std::basic_istream<char>& stream, basic_string& str) {
3651 auto s = std::basic_string<char> {};
3652 stream >> s;
3653 str = s;
3654 return stream;
3655 }
3664 friend std::basic_istream<xtd::wchar>& operator >>(std::basic_istream<xtd::wchar>& stream, basic_string& str) {
3665 auto s = std::basic_string<xtd::wchar> {};
3666 stream >> s;
3667 str = s;
3668 return stream;
3669 }
3671
3672 private:
3673 friend class basic_string<char>;
3674 friend class basic_string<xtd::char16>;
3675 friend class basic_string<xtd::char32>;
3676#if defined(__xtd__cpp_lib_char8_t)
3677 friend class basic_string<xtd::char8>;
3678#endif
3679 friend class basic_string<xtd::wchar>;
3680
3681 static const xtd::array<value_type> default_split_separators;
3682 static const xtd::array<value_type> default_trim_chars;
3683
3684 template<typename arg_t>
3685 static auto convert_param(arg_t&& arg) noexcept {
3686 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();
3687 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();
3688 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();
3689#if defined(__xtd__cpp_lib_char8_t)
3690 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();
3691#endif
3692 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();
3693 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();
3694 else return std::forward<arg_t>(arg);
3695 }
3696
3697 static basic_string get_class_name(const basic_string& full_name) {
3698 auto length = full_name.last_index_of("<");
3699 if (length == npos) length = full_name.length();
3700 if (full_name.last_index_of("::", 0, length) == npos) return full_name;
3701 return full_name.substring(full_name.last_index_of("::", 0, length) + 2);
3702 }
3703
3704 typename base_type::iterator to_base_type_iterator(iterator value) const noexcept {
3705 if (value == begin()) return chars_.begin();
3706 if (value == end()) return chars_.end();
3707 return chars_.begin() + (value - begin());
3708 }
3709
3710 iterator to_iterator(typename base_type::iterator value) const noexcept {
3711 if (value == chars_.begin()) return begin();
3712 if (value == chars_.end()) return end();
3713 return begin() + (value - chars_.begin());
3714 }
3715
3716 base_type chars_;
3717 };
3718}
3719
3720#define __XTD_BASIC_STRING_INTERNAL__
3721#include "basic_string.hpp"
3722#undef __XTD_BASIC_STRING_INTERNAL__
Contains array definitions.
Contains __format_information struct.
Contains __format method.
Contains string definitions.
Contains __xtd_std_version definitions.
Represents text as a sequence of character units.
Definition basic_string.h:79
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.h:154
basic_string trim(value_type trim_char) const noexcept
Removes all leading and trailing occurrences of a character specified from the specified xtd::basic_s...
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.h:635
basic_string(const basic_string< xtd::char32 > &str, xtd::size index, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring at index and count character...
Definition basic_string.h:337
std::basic_string< char_t, traits_t, allocator_t > base_type
Represents the basic string base type.
Definition basic_string.h:86
static basic_string concat(object_a_t obj_a, object_b_t obj_b) noexcept
Concatenates two specified instances of object.
Definition basic_string.h:2151
xtd::size index_of(value_type value) const noexcept
Reports the index of the first occurrence of the specified character in this basic_string.
Definition basic_string.h:1453
static int32 compare(const basic_string &str_a, const basic_string &str_b, xtd::string_comparison comparison_type) noexcept
Compares two specified basic_string objects using the specified rules, and returns an integer that in...
Definition basic_string.h:2070
basic_string trim_end(const xtd::array< value_type > &trim_chars) const noexcept
Removes all trailing occurrences of a set of characters specified in an array from the specified xtd:...
basic_string to_lower() const noexcept
Returns a copy of the current xtd::basic_string converted to lowercase.
Definition basic_string.h:1910
static value_t parse(const basic_string &str)
Converts a basic_string into a value_t type.
Definition basic_string.h:2341
basic_string pad_left(xtd::size total_width) const noexcept
Right-aligns the characters in this basic_string, padding with spaces on the left for a specified tot...
Definition basic_string.h:1583
basic_string(const basic_string< char > &str, xtd::size index)
Initializes a new instance of xtd::basic_string with specified substring at index.
Definition basic_string.h:215
static const basic_string empty_string
Represents the empty basic_string.
Definition basic_string.h:124
basic_string(xtd::size count, xtd::char16 character, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:450
basic_string(const basic_string< xtd::char8 > &str, xtd::size index)
Initializes a new instance of xtd::basic_string with specified substring at index.
Definition basic_string.h:243
bool ends_with(const basic_string &value, xtd::string_comparison comparison_type) const noexcept
Determines whether the end of this basic_string matches the specified basic_string when compared usin...
Definition basic_string.h:1176
static basic_string class_name(const object_t &object)
Gets the class name of the specified object.
Definition basic_string.h:2031
size_type find_last_not_of(const_pointer s, size_type pos, size_type count) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.h:1374
basic_string(const xtd::char32 *str, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified string to copy, and allocator.
Definition basic_string.h:587
constexpr basic_string(const string_view_like_t &string_view)
Initializes a new instance of xtd::basic_string with specified string view of substring and allocator...
Definition basic_string.h:784
allocator_type get_allocator() const
Returns the allocator associated with the string.
Definition basic_string.h:1402
xtd::size index_of(value_type value, xtd::size start_index, xtd::size count) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.h:1465
basic_string(xtd::char16 character, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:499
basic_string(const xtd::char16 *str, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring, count characters and alloca...
Definition basic_string.h:662
xtd::size index_of(value_type value, xtd::size start_index) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.h:1458
basic_string trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified xtd::basic_...
Definition basic_string.h:1970
xtd::array< basic_string > split() const noexcept
Splits this basic_string into substrings that are based on the default white-space characters....
const_reverse_iterator rbegin() const
Returns a reverse iterator to the first character of the string.
Definition basic_string.h:926
basic_string(xtd::size count, xtd::char8 character)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.h:464
basic_string(std::initializer_list< xtd::char16 > il, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified initializer list and allocator.
Definition basic_string.h:830
basic_string(const xtd::char8 *str, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified string to copy, and allocator.
Definition basic_string.h:596
basic_string(const xtd::char32 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.h:546
size_type find_first_of(const basic_string &str) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.h:1228
xtd::size index_of_any(const xtd::array< value_type > &values, xtd::size start_index) const
Reports the index of the first occurrence in this instance of any character in a specified array of c...
typename base_type::allocator_type allocator_type
Represents the basic string allocator type.
Definition basic_string.h:92
basic_string substring(xtd::size start_index, xtd::size length) const
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.h:1881
basic_string(char character, xtd::size count)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.h:485
basic_string(const xtd::char16 *str, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified string to copy, and allocator.
Definition basic_string.h:579
size_type find_last_of(char_t ch, size_type pos) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.h:1354
bool ends_with(value_type value, bool ignore_case) const noexcept
Determines whether the end of this basic_string matches the specified character, ignoring or honoring...
Definition basic_string.h:1159
basic_string(std::initializer_list< char > il, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified initializer list and allocator.
Definition basic_string.h:826
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.h:613
enumerator_type get_enumerator() const noexcept override
Returns an enumerator that iterates through a collection.
Definition basic_string.h:1412
static basic_string demangle(const basic_string &name)
Gets demangled basic_string of name,.
Definition basic_string.h:2219
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.h:523
basic_string(input_iterator_t first, input_iterator_t last, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified first and last iterators of substring ...
Definition basic_string.h:778
basic_string(xtd::size count, xtd::char8 character, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:469
int32 compare(size_type pos1, size_type count1, const basic_string &str) const
Compares two character sequences.
Definition basic_string.h:985
typename xtd::collections::generic::enumerator< value_type > enumerator_type
Represents the basic string enumerator type.
Definition basic_string.h:116
size_type rfind(const_pointer s, size_type pos, size_type count) const
Finds the last substring that is equal to the given character sequence. The search begins at pos and ...
Definition basic_string.h:1688
size_type find_last_not_of(char_t ch, size_type pos) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.h:1398
size_type rfind(const_pointer s) const
Finds the last substring that is equal to the given character sequence. The search begins at xtd::bas...
Definition basic_string.h:1694
size_type rfind(const basic_string &str) const
Finds the last substring that is equal to the given character sequence. The search begins at xtd::bas...
Definition basic_string.h:1674
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.h:161
basic_string(xtd::wchar character, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:528
basic_string(const basic_string< xtd::char8 > &str, xtd::size index, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring at index and count character...
Definition basic_string.h:348
basic_string(const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified allocator.
static bool try_parse(const basic_string &str, value_t &value) noexcept
Try to convert a basic_string into a value_t type.
Definition basic_string.h:2413
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.h:772
virtual const base_type & get_base_type() const noexcept
Returns the underlying base type.
Definition basic_string.h:1406
size_type find_first_not_of(const_pointer s, size_type pos) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.h:1299
xtd::size last_index_of(const basic_string &value, xtd::size start_index) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.h:1522
size_type find_last_of(const_pointer s) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.h:1336
basic_string(const basic_string< xtd::wchar > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:206
static basic_string full_class_name(const std::type_info &info)
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition basic_string.h:2282
typename base_type::const_pointer const_pointer
Represents the basic string const pointer type.
Definition basic_string.h:104
friend std::basic_istream< char > & operator>>(std::basic_istream< char > &stream, basic_string &str)
Input stream operator. Behaves as a FormattedInputFunction. After constructing and checking the sentr...
Definition basic_string.h:3650
basic_string(std::initializer_list< xtd::wchar > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.h:821
int32 compare(size_type pos1, size_type count1, const_pointer s) const
Compares two character sequences.
Definition basic_string.h:1075
size_type find_last_of(const_pointer s, size_type pos) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.h:1343
size_type find_first_not_of(const basic_string &str) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.h:1272
static basic_string concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c, object_d_t obj_d) noexcept
Concatenates four specified instances of object.
Definition basic_string.h:2127
bool starts_with(const basic_string &value) const noexcept
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.h:1826
basic_string(xtd::char8 character, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:518
virtual bool contains(const basic_string &value) const noexcept
Returns a value indicating whether a specified substring occurs within this basic_string.
Definition basic_string.h:1130
size_type find_first_of(const basic_string &str, size_type pos) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.h:1234
static bool equals(const basic_string &a, const basic_string &b, bool ignore_case) noexcept
Determines whether two specified xtd::basic_string objects have the same value, ignoring or honoring ...
Definition basic_string.h:2244
basic_string insert(xtd::size start_index, const basic_string &value) const
Inserts a specified instance of basic_string at a specified index position in this instance.
Definition basic_string.h:1500
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.h:148
basic_string(basic_string &&str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to move and allocator.
Definition basic_string.h:430
size_type find_first_of(const_pointer s, size_type pos) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.h:1255
basic_string to_upper() const noexcept
Returns a copy of the current xtd::basic_string converted to uppercase.
Definition basic_string.h:1953
int32 compare(size_type pos1, size_type count1, const_pointer s, size_type count2) const
Compares two character sequences.
Definition basic_string.h:1098
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.h:699
typename base_type::traits_type traits_type
Represents the basic string traits type.
Definition basic_string.h:88
const base_type & chars() const noexcept
Returns a reference to the underlying base type.
Definition basic_string.h:883
basic_string trim_start(value_type trim_char) const noexcept
Removes all leading occurrences of a character specified from the specified xtd::basic_string .
xtd::size last_index_of(const basic_string &value, xtd::size start_index, xtd::size count) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.h:1529
basic_string(const std::basic_string< xtd::char16 > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:740
static basic_string join(const basic_string &separator, const collection_t &values, xtd::size index, xtd::size count)
Concatenates a specified separator basic_string between each element of a specified Object array,...
Definition basic_string.h:2315
basic_string substring(xtd::size start_index) const
Retrieves a substring from this instance. The substring starts at a specified character position and ...
Definition basic_string.h:1872
typename base_type::pointer pointer
Represents the basic string pointer type.
Definition basic_string.h:102
xtd::size index_of_any(const xtd::array< value_type > &values) const noexcept
Reports the index of the first occurrence in this instance of any character in a specified array of c...
basic_string(char character, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:490
size_type find_first_not_of(char_t ch) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.h:1304
basic_string substr(size_type pos, size_type count) const
Returns a substring [pos, pos + count). If the requested substring extends past the end of the string...
Definition basic_string.h:1862
int32 compare_to(const basic_string &value) const noexcept override
Compares this instance with a specified xtd::basic_string object and indicates whether this instance ...
Definition basic_string.h:1121
xtd::array< value_type > to_char_array() const noexcept
Copies the characters in this instance to a Unicode character array.
basic_string quoted() const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML.
Definition basic_string.h:1610
static int32 compare(const basic_string &str_a, xtd::size index_a, const basic_string &str_b, xtd::size index_b, xtd::size length, xtd::string_comparison comparison_type)
Compares substrings of two specified basic_string objects using the specified rules,...
Definition basic_string.h:2111
basic_string< char > to_string() const noexcept override
Converts the value of this instance to a xtd::basic_string <char>.
Definition basic_string.h:1919
typename base_type::const_reference const_reference
Represents the basic string const referecne type.
Definition basic_string.h:100
basic_string(std::initializer_list< xtd::char32 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.h:813
static basic_string join(const basic_string &separator, const collection_t &values, xtd::size index)
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.h:2305
size_type find(const_pointer s) const
Finds the first substring equal to the given character sequence. Search begins at 0,...
Definition basic_string.h:1204
basic_string< xtd::wchar > to_wstring() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::wchar>.
Definition basic_string.h:1961
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.h:705
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.h:643
basic_string(const basic_string< xtd::char8 > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:198
basic_string remove(xtd::size start_index) const
Deletes all the characters from this basic_string beginning at a specified position and continuing th...
Definition basic_string.h:1631
basic_string(const basic_string< xtd::wchar > &str, xtd::size index)
Initializes a new instance of xtd::basic_string with specified substring at index.
Definition basic_string.h:253
const_iterator begin() const override
Returns an iterator to the first character of the string.
Definition basic_string.h:857
friend std::basic_ostream< char > & operator<<(std::basic_ostream< char > &stream, const basic_string &str)
Output stream operator. Behaves as a FormattedOutputFunction. After constructing and checking the sen...
Definition basic_string.h:3630
basic_string(const basic_string< xtd::wchar > &str, xtd::size index, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring at index and count character...
Definition basic_string.h:359
size_type find_last_not_of(char_t ch) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.h:1392
const_iterator end() const override
Returns an iterator to the character following the last character of the string. This character acts ...
Definition basic_string.h:908
constexpr basic_string(const string_view_like_t &string_view, size_type index, size_type count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified string view of substring and allocator...
Definition basic_string.h:803
basic_string(std::initializer_list< xtd::char32 > il, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified initializer list and allocator.
Definition basic_string.h:834
basic_string(const basic_string< xtd::char32 > &str, xtd::size index, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index,...
Definition basic_string.h:393
basic_string remove(xtd::size start_index, xtd::size count) const
Deletes all the characters from this basic_string beginning at a specified position and continuing th...
Definition basic_string.h:1636
xtd::size last_index_of(value_type value) const noexcept
Reports the index of the last occurrence of the specified character in this tring.
Definition basic_string.h:1537
static basic_string class_name()
Gets the class name of the object_t.
Definition basic_string.h:2024
static basic_string class_name(const std::type_info &info)
Gets the class name of the specified object.
Definition basic_string.h:2037
const_iterator cend() const override
Returns an iterator to the character following the last character of the string. This character acts ...
Definition basic_string.h:887
basic_string(xtd::size count, xtd::wchar character)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.h:474
size_type find_last_not_of(const_pointer s) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.h:1380
basic_string trim_start(const xtd::array< value_type > &trim_chars) const noexcept
Removes all leading occurrences of a set of characters specified in an array from the specified xtd::...
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.h:168
static bool equals(const basic_string &a, const basic_string &b) noexcept
Determines whether two specified xtd::basic_string objects have the same value.
Definition basic_string.h:2229
bool is_empty() const noexcept
Indicates whether this basic_string is an empty basic_string ("").
Definition basic_string.h:1511
basic_string(const std::basic_string< char > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:733
size_type find(value_type ch) const
Finds the first substring equal to the given character sequence. Search begins at 0,...
Definition basic_string.h:1216
size_type rfind(value_type ch, size_type pos) const
Finds the last substring that is equal to the given character sequence. The search begins at pos and ...
Definition basic_string.h:1712
static int32 compare(const basic_string &str_a, const basic_string &str_b, bool ignore_case) noexcept
Compares two specified basic_string objects, ignoring or honoring their case, and returns an integer ...
Definition basic_string.h:2059
static int32 compare(const basic_string &str_a, const basic_string &str_b) noexcept
Compares two specified basic_string objects and returns an integer that indicates their relative posi...
Definition basic_string.h:2048
typename xtd::collections::generic::ienumerable< char_t >::iterator iterator
Represents the basic string iterator type.
Definition basic_string.h:107
basic_string(const basic_string< xtd::char32 > &str, xtd::size index)
Initializes a new instance of xtd::basic_string with specified substring at index.
Definition basic_string.h:233
typename base_type::const_reverse_iterator const_reverse_iterator
Represents the basic string const reverse iterator type.
Definition basic_string.h:114
static basic_string concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c) noexcept
Concatenates three specified instances of basic_string.
Definition basic_string.h:2133
basic_string(const basic_string< xtd::char16 > &str, xtd::size index, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring at index and count character...
Definition basic_string.h:327
basic_string(const char *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.h:532
basic_string(const basic_string< xtd::char16 > &str, xtd::size index, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index and allocator.
Definition basic_string.h:274
size_type max_size() const noexcept
Returns the maximum number of elements the string is able to hold due to system or library implementa...
Definition basic_string.h:922
basic_string quoted(value_type delimiter) const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified...
Definition basic_string.h:1615
int32 compare_to(const object &value) const
Compares this instance with a specified xtd::object and indicates whether this instance precedes,...
Definition basic_string.h:1109
basic_string(const basic_string< xtd::char16 > &str, xtd::size index)
Initializes a new instance of xtd::basic_string with specified substring at index.
Definition basic_string.h:224
basic_string pad_right(xtd::size total_width, char32 padding_char) const noexcept
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.h:1604
basic_string(xtd::char32 character, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:508
basic_string(const xtd::char8 *str, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring, count characters and alloca...
Definition basic_string.h:681
int32 compare(size_type pos1, size_type count1, const basic_string &str, size_type pos2, size_type count2) const
Compares two character sequences.
Definition basic_string.h:1034
basic_string(std::initializer_list< char > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.h:807
static bool equals(const char_a_t *a, const char_b_t *b, bool ignore_case) noexcept
Determines whether two specified xtd::basic_string objects have the same value, ignoring or honoring ...
Definition basic_string.h:2252
static basic_string concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept
Concatenates three specified instances of object.
Definition basic_string.h:2140
basic_string(const basic_string< char > &str, xtd::size index, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index and allocator.
Definition basic_string.h:264
basic_string replace(const basic_string &old_string, const basic_string &new_string) const noexcept
Replaces all occurrences of a specified basic_string in this basic_string with another specified basi...
Definition basic_string.h:1653
basic_string(const basic_string< xtd::char16 > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:183
xtd::size get_hash_code() const noexcept override
Returns the hash code for this basic_string.
Definition basic_string.h:1410
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.h:1818
typename base_type::size_type size_type
Represents the basic string size type.
Definition basic_string.h:94
virtual bool contains(value_type value) const noexcept
Returns a value indicating whether a specified char occurs within this basic_string.
Definition basic_string.h:1126
size_type find_last_not_of(const basic_string &str) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.h:1360
size_type find_first_not_of(const basic_string &str, size_type pos) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.h:1278
bool ends_with(value_type value) const noexcept
Determines whether the end of this basic_string matches the specified character.
Definition basic_string.h:1154
basic_string(const basic_string< xtd::wchar > &str, xtd::size index, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index and allocator.
Definition basic_string.h:306
size_type rfind(value_type ch) const
Finds the last substring that is equal to the given character sequence. The search begins at xtd::bas...
Definition basic_string.h:1706
static basic_string concat(const basic_string &str_a, const basic_string &str_b, const basic_string &str_c, const basic_string &str_d) noexcept
Concatenates four specified instances of basic_string.
Definition basic_string.h:2119
static basic_string join(const basic_string separator, const collection_t &values) noexcept
Concatenates a specified separator basic_string between each element of a specified object array,...
Definition basic_string.h:2296
const_reverse_iterator crend() const
Returns a reverse iterator to the character following the last character of the string....
Definition basic_string.h:891
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.h:513
basic_string(const xtd::wchar *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.h:562
xtd::size last_index_of(value_type value, xtd::size start_index, xtd::size count) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.h:1551
basic_string(const char *str, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified string to copy, and allocator.
Definition basic_string.h:571
basic_string & operator=(const basic_string< char > &str) noexcept
Copy assignment operator. Replaces the contents with a copy of the contents of str.
Definition basic_string.h:2442
const_reverse_iterator crbegin() const
Returns a reverse iterator to the first character of the string.
Definition basic_string.h:879
size_type find_first_of(const_pointer s, size_type pos, size_type count) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.h:1242
basic_string(const basic_string< xtd::char8 > &str, xtd::size index, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index and allocator.
Definition basic_string.h:295
xtd::size index_of(const basic_string &value, xtd::size start_index, xtd::size count) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.h:1445
basic_string(const basic_string< xtd::char32 > &str, xtd::size index, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index and allocator.
Definition basic_string.h:284
const_pointer data() const noexcept
Returns a pointer to the underlying array serving as character storage. The pointer is such that the ...
Definition basic_string.h:900
basic_string(basic_string &&)=default
Initializes a new instance of xtd::basic_string with specified string to move.
static constexpr size_type npos
This is a special value equal to the maximum value representable by the type xtd::size.
Definition basic_string.h:127
static basic_string concat(const basic_string &str_a, const basic_string &str_b) noexcept
Concatenates two specified instances of basic_string.
Definition basic_string.h:2145
size_type find(const basic_string &str) const
Finds the first substring equal to the given character sequence. Search begins at 0,...
Definition basic_string.h:1184
basic_string trim_end() const noexcept
Removes all trailing occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.h:1986
xtd::size last_index_of_any(const xtd::array< value_type > &values) const noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
static bool equals(const char_a_t *a, const char_b_t *b) noexcept
Determines whether two specified xtd::basic_string objects have the same value.
Definition basic_string.h:2236
static int32 compare(const basic_string &str_a, xtd::size index_a, const basic_string &str_b, xtd::size index_b, xtd::size length)
Compares substrings of two specified basic_string objects and returns an integer that indicates their...
Definition basic_string.h:2083
const_reverse_iterator rend() const
Returns a reverse iterator to the character following the last character of the string....
Definition basic_string.h:930
basic_string(const basic_string< char > &str) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.h:141
xtd::size index_of(const basic_string &value) const noexcept
Reports the index of the first occurrence of the specified basic_string in this basic_string.
Definition basic_string.h:1433
size_type find_first_not_of(char_t ch, size_type pos) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.h:1310
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.h:494
int32 compare(const_pointer s) const
Compares two character sequences.
Definition basic_string.h:1053
bool equals(const object &obj) const noexcept override
Determines whether this instance and a specified object, which must also be a xtd::basic_string objec...
Definition basic_string.h:1135
size_type find_first_of(char_t ch) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.h:1260
size_type find_first_not_of(const_pointer s) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.h:1292
size_type size() const noexcept
Returns the number of char_t elements in the string, i.e. std::distance(begin(), end()).
Definition basic_string.h:934
const_reference at(size_type pos) const
Returns a reference to the character at specified location pos.
Definition basic_string.h:943
size_type find_first_not_of(const_pointer s, size_type pos, size_type count) const
Finds the first character equal to none of the characters in the given character sequence....
Definition basic_string.h:1286
basic_string(const basic_string< char > &str, xtd::size index, xtd::size count)
Initializes a new instance of xtd::basic_string with specified substring at index and count character...
Definition basic_string.h:317
basic_string substr(size_type pos) const
Returns a substring [pos, pos + count). If the requested substring extends past the end of the string...
Definition basic_string.h:1852
basic_string to_title_case() const noexcept
Converts the current basic_string to title case (except for words that are entirely in uppercase,...
basic_string replace(value_type old_char, value_type new_char) const noexcept
Replaces all occurrences of a specified char_t in this basic_string with another specified char_t.
Definition basic_string.h:1647
size_type length() const noexcept
Gets the number of characters in the current xtd::basic_string object.
Definition basic_string.h:918
xtd::size index_of_any(const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const
Reports the index of the first occurrence in this instance of any character in a specified array of c...
bool ends_with(const basic_string &value, bool ignore_case) const noexcept
Determines whether the end of this basic_string instance matches the specified basic_string,...
Definition basic_string.h:1171
basic_string(xtd::size count, xtd::char32 character)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.h:454
basic_string(xtd::size count, xtd::wchar character, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:480
basic_string(const std::basic_string< xtd::char32 > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:747
static basic_string concat(const xtd::array< object_t > &args) noexcept
Concatenates the basic_string representations of the elements in a specified object array.
basic_string(const char *str, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring, count characters and alloca...
Definition basic_string.h:653
static bool is_empty(const xtd::basic_string< value_type, traits_type, allocator_type > &string) noexcept
Indicates whether the specifeid basic_string is an empty basic_string ("").
Definition basic_string.h:2287
constexpr basic_string(const string_view_like_t &string_view, size_type index, size_type count)
Initializes a new instance of xtd::basic_string with specified string view of substring and allocator...
Definition basic_string.h:796
basic_string(xtd::size count, char character, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:441
basic_string(const xtd::char16 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.h:539
basic_string & operator+=(const basic_string< char > &str)
Addition assignment operator. Appends additional characters to the string.
Definition basic_string.h:2743
typename base_type::value_type value_type
Represents the basic string value type.
Definition basic_string.h:90
typename base_type::reverse_iterator reverse_iterator
Represents the basic string reverse iterator type.
Definition basic_string.h:112
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.h:620
bool equals(const basic_string &value, bool ignore_case) const noexcept
Determines whether this instance and another specified xtd::basic_string object have the same value,...
Definition basic_string.h:1146
basic_string pad_right(xtd::size total_width) const noexcept
Left-aligns the characters in this basic_string, padding with spaces on the right for a specified tot...
Definition basic_string.h:1597
size_type find_last_of(const basic_string &str, size_type pos) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.h:1322
static basic_string full_class_name()
Gets the fully qualified class name of the objec_t, including the namespace of the objec_t.
Definition basic_string.h:2269
basic_string(std::initializer_list< xtd::char16 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.h:810
basic_string trim_end(value_type trim_char) const noexcept
Removes all trailing occurrences of a character specified from the specified xtd::basic_string .
basic_string(xtd::size count, xtd::char16 character)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.h:445
int32 compare(size_type pos1, size_type count1, const basic_string &str, size_type pos2) const
Compares two character sequences.
Definition basic_string.h:1009
static basic_string concat(value_t value) noexcept
Creates the basic_string representation of a specified object.
Definition basic_string.h:2195
xtd::size last_index_of_any(const xtd::array< value_type > &values, xtd::size start_index, xtd::size count) const
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
basic_string(std::initializer_list< xtd::char8 > il)
Initializes a new instance of xtd::basic_string with specified initializer list.
Definition basic_string.h:817
static basic_string concat(const xtd::array< basic_string > &values) noexcept
Concatenates the elements of a specified basic_string array.
const_reference front() const
Returns reference to the first character in the string. The behavior is undefined if empty() is true.
Definition basic_string.h:913
basic_string trim_start() const noexcept
Removes all leading occurrences of white-space characters from the specified xtd::basic_string.
Definition basic_string.h:2002
bool ends_with(const basic_string &value) const noexcept
Determines whether the end of this basic_string matches the specified basic_string.
Definition basic_string.h:1166
size_type find_first_of(const_pointer s) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.h:1248
basic_string()=default
Initializes a new instance of xtd::basic_string.
basic_string(const basic_string< xtd::char32 > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:190
static basic_string full_class_name(const object_t &object)
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition basic_string.h:2276
xtd::size last_index_of(const basic_string &value) const noexcept
Reports the index of the last occurrence of the specified basic_string in this basic_string.
Definition basic_string.h:1516
basic_string pad_left(xtd::size total_width, char32 padding_char) const noexcept
Right-aligns the characters in this basic_string, padding with spaces on the left for a specified tot...
Definition basic_string.h:1590
basic_string(const xtd::char32 *str, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring, count characters and alloca...
Definition basic_string.h:671
bool equals(const basic_string &value) const noexcept override
Determines whether this instance and another specified xtd::basic_string object have the same value.
Definition basic_string.h:1140
bool starts_with(value_type value) const noexcept
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.h:1812
const_iterator cbegin() const override
Returns an iterator to the first character of the string.
Definition basic_string.h:875
basic_string(xtd::size count, char character)
Initializes a new instance of xtd::basic_string with specified count copies of character.
Definition basic_string.h:436
size_type find_last_of(char_t ch) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.h:1348
basic_string(const xtd::char8 *str)
Initializes a new instance of xtd::basic_string with specified string to copy.
Definition basic_string.h:554
basic_string(std::initializer_list< xtd::char8 > il, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified initializer list and allocator.
Definition basic_string.h:839
size_type rfind(const basic_string &str, size_type pos) const
Finds the last substring that is equal to the given character sequence. The search begins at pos and ...
Definition basic_string.h:1680
static int32 compare(const basic_string &str_a, xtd::size index_a, const basic_string &str_b, xtd::size index_b, xtd::size length, bool ignore_case)
Compares substrings of two specified basic_string objects, ignoring or honoring their case,...
Definition basic_string.h:2097
basic_string(const basic_string< xtd::wchar > &str, xtd::size index, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index,...
Definition basic_string.h:417
basic_string trim(const xtd::array< value_type > &trim_chars) const noexcept
Removes all leading and trailing occurrences of a set of characters specified in an array from the sp...
size_type find_last_not_of(const_pointer s, size_type pos) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.h:1387
basic_string< xtd::char8 > to_u8string() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::char8>.
Definition basic_string.h:1945
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.h:503
basic_string(const basic_string< xtd::char8 > &str, xtd::size index, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index,...
Definition basic_string.h:405
xtd::size last_index_of_any(const xtd::array< value_type > &values, xtd::size start_index) const
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
size_type find(value_type ch, size_type pos) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.h:1222
size_type find_last_of(const basic_string &str) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.h:1316
int32 compare(const basic_string &str) const
Compares two character sequences.
Definition basic_string.h:963
const_pointer c_str() const noexcept
Returns a pointer to a null-terminated character array with data equivalent to those stored in the st...
Definition basic_string.h:867
bool empty() const noexcept
Checks if the string has no characters, i.e. whether begin() == end().
Definition basic_string.h:904
basic_string(const xtd::wchar *str, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring, count characters and alloca...
Definition basic_string.h:691
typename base_type::reference reference
Represents the basic string referecne type.
Definition basic_string.h:98
basic_string(std::initializer_list< xtd::wchar > il, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified initializer list and allocator.
Definition basic_string.h:844
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.h:725
basic_string(const xtd::wchar *str, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified string to copy, and allocator.
Definition basic_string.h:605
size_type find_last_of(const_pointer s, size_type pos, size_type count) const
Finds the last character equal to one of characters in the given character sequence....
Definition basic_string.h:1330
basic_string(const std::basic_string< xtd::char8 > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:755
typename xtd::collections::generic::ienumerable< char_t >::const_iterator const_iterator
Represents the basic string const iterator type.
Definition basic_string.h:110
constexpr basic_string(const string_view_like_t &string_view, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified string view of substring and allocator...
Definition basic_string.h:789
basic_string substr() const
Returns a substring [pos, pos + count). If the requested substring extends past the end of the string...
Definition basic_string.h:1846
typename base_type::difference_type difference_type
Represents the basic string difference type.
Definition basic_string.h:96
size_type find_last_not_of(const basic_string &str, size_type pos) const
Finds the last character equal to none of the characters in the given character sequence....
Definition basic_string.h:1366
size_type find(const basic_string &str, size_type pos) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.h:1190
xtd::size index_of(const basic_string &value, xtd::size start_index) const
Reports the index of the first occurrence of the specified character in this basic_string....
Definition basic_string.h:1438
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.h:711
friend basic_string operator+(const basic_string &lhs, const basic_string< char > &rhs)
Addition operator. Returns a string containing characters from lhs followed by the characters from rh...
Definition basic_string.h:2947
size_type find_first_of(char_t ch, size_type pos) const
Finds the first character equal to one of the characters in the given character sequence....
Definition basic_string.h:1266
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.h:627
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.h:718
basic_string(const basic_string< char > &str, xtd::size index, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index,...
Definition basic_string.h:371
bool starts_with(const basic_string &value, bool ignore_case) const noexcept
Determines whether the beginning of this instance of xtd::basic_string matches a specified xtd::basic...
Definition basic_string.h:1832
basic_string(const basic_string< xtd::char16 > &str, xtd::size index, xtd::size count, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified substring at index,...
Definition basic_string.h:382
basic_string(const std::basic_string< xtd::wchar > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:763
basic_string quoted(value_type delimiter, value_type escape) const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML ith specified...
Definition basic_string.h:1621
basic_string(const basic_string< char > &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::basic_string with specified string to copy and allocator.
Definition basic_string.h:176
basic_string< xtd::char16 > to_u16string() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::char16>.
Definition basic_string.h:1930
basic_string(xtd::size count, xtd::char32 character, const allocator_type &allocator)
Initializes a new instance of xtd::basic_string with specified count copies of character and specifie...
Definition basic_string.h:459
xtd::array< value_type > to_array() const noexcept
Copies the characters in this instance to a Unicode character array.
basic_string< xtd::char32 > to_u32string() const noexcept
Converts the value of this instance to a xtd::basic_string <xtd::char32>.
Definition basic_string.h:1937
const_reference operator[](xtd::size index) const
Returns a reference to the character at specified location index.
Definition basic_string.h:2430
xtd::size last_index_of(value_type value, xtd::size start_index) const
Reports the index of the last occurrence of the specified character in this basic_string....
Definition basic_string.h:1543
bool starts_with(const basic_string &value, xtd::string_comparison comparison_type) const noexcept
Determines whether the end of this basic_string matches the specified basic_string when compared usin...
Definition basic_string.h:1837
size_type find(const_pointer s, size_type pos, size_type count) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.h:1198
size_type capacity() const noexcept
Returns the number of characters that the string has currently allocated space for.
Definition basic_string.h:871
const_reference back() const
Returns reference to the last character in the string.
Definition basic_string.h:853
size_type find(const_pointer s, size_type pos) const
Finds the first substring equal to the given character sequence. Search begins at pos,...
Definition basic_string.h:1211
size_type rfind(const_pointer s, size_type pos) const
Finds the last substring that is equal to the given character sequence. The search begins at pos and ...
Definition basic_string.h:1701
virtual const_iterator cend() const
Returns an iterator to the element following the last element of the enumarable.
Definition enumerable_iterators.h:209
virtual iterator begin()
Returns an iterator to the first element of the enumarable.
Definition enumerable_iterators.h:201
virtual iterator end()
Returns an iterator to the element following the last element of the enumarable.
Definition enumerable_iterators.h:216
virtual const_iterator cbegin() const
Returns an iterator to the first element of the enumarable.
Definition enumerable_iterators.h:205
virtual const_iterator end() const
Returns an iterator to the element following the last element of the enumarable.
Definition enumerable_iterators.h:213
virtual const_iterator begin() const
Returns an iterator to the first element of the enumarable.
Definition enumerable_iterators.h:198
Supports a simple iteration over a generic collection.
Definition enumerator.h:31
Exposes the enumerator, which supports a simple iteration over a collection of a specified type.
Definition ienumerable.h:35
typename enumerable_iterators< type_t, ienumerable< type_t > >::const_iterator const_iterator
Represents the const iterator of xtd::collections::generic::ienumerable value type.
Definition ienumerable.h:43
typename enumerable_iterators< type_t, ienumerable< type_t > >::iterator iterator
Represents the iterator of xtd::collections::generic::ienumerable value type.
Definition ienumerable.h:41
Supports a simple iteration over a generic collection.
Definition ienumerator.h:58
static xtd::size combine(args_t... values) noexcept
Combines values into a hash code.
Definition hash_code.h:65
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:21
Defines a generalized method that a value type or class implements to create a type-specific method f...
Definition iequatable.h:22
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:42
Contains xtd::collections::generic::ienumarable <type_t> interface.
static basic_string sprintf(const basic_string &fmt, args_t &&... args) noexcept
Writes the text representation of the specified arguments list, to basic_string using the specified f...
Definition basic_string.h:2406
static basic_string format(const basic_string< char > &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
char8_t char8
Represents a 8-bit unicode character.
Definition char8.h:27
wchar_t wchar
Represents a wide character.
Definition wchar.h:24
int32_t int32
Represents a 32-bit signed integer.
Definition int32.h:23
null_ptr null
Represents a null pointer value.
char16_t char16
Represents a 16-bit unicode character.
Definition char16.h:26
uint32_t uint32
Represents a 32-bit unsigned integer.
Definition uint32.h:23
size_t size
Represents a size of any object in bytes.
Definition size.h:23
char32_t char32
Represents a 32-bit unicode character.
Definition char32.h:26
string_comparison
Specifies the culture, case, and sort rules to be used by certain overloads of the xtd::string::compa...
Definition string_comparison.h:14
string_split_options
Specifies whether applicable xtd::string::split method overloads include or omit empty substrings fro...
Definition string_split_options.h:14
@ ordinal
Compare strings using ordinal (binary) sort rules.
@ ordinal_ignore_case
Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared...
@ s
The S key.
@ a
The A key.
@ c
The C key.
@ i
The I key.
@ b
The B key.
@ separator
The Separator key.
@ escape
The ESC (ESCAPE) key.
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 xtd_about_box.h:10
std::vector< type_t > array
Definition __array_definition.h:18
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.
Contains xtd::to_string methods.
Contains unused_ keyword.
Contains xtd fundamental types.