xtd 0.2.0
Loading...
Searching...
No Matches
ustring.h
Go to the documentation of this file.
1
3#pragma once
5#define __XTD_CORE_INTERNAL__
6#include "internal/__generic_stream_output.h"
7#include "internal/__format_information.h"
8#include "internal/__format_stringer.h"
9#include "internal/__sprintf.h"
10#undef __XTD_CORE_INTERNAL__
12#include "icomparable.h"
13#include "iequatable.h"
14#include "string_comparison.h"
16#include "types.h"
17#include "object.h"
18#include "parse.h"
19#include "to_string.h"
20#include "types.h"
21#include "unused.h"
22#include <ostream>
23#include <string>
24
26namespace xtd {
27 class ustring;
28}
29template<typename ...args_t>
30void __ustring_extract_format_arg(xtd::ustring& fmt, std::vector<__format_information<char>>& format, args_t&& ... args);
31void __throw_ustring_format_exception(const char* file, xtd::uint32 line, const char* func);
32void __throw_ustring_format_exception_close_bracket(const char* file, xtd::uint32 line, const char* func);
33void __throw_ustring_format_exception_open_bracket(const char* file, xtd::uint32 line, const char* func);
34void __throw_ustring_format_exception_start_colon(const char* file, xtd::uint32 line, const char* func);
36
37namespace xtd {
47 class ustring : public object, public xtd::icomparable<ustring>, public std::basic_string<char> {
48 public:
50
54 static const ustring empty_string;
56
58
61 ustring() noexcept;
64 explicit ustring(const allocator_type& allocator) noexcept;
65
70 ustring(size_t count, value_type character);
76 ustring(size_t count, value_type character, const allocator_type& allocator);
77#if defined(__cpp_lib_char8_t)
82 ustring(size_t count, char8 character);
88 ustring(size_t count, char8 character, const allocator_type& allocator);
89#endif
94 ustring(size_t count, char16 character);
100 ustring(size_t count, char16 character, const allocator_type& allocator);
105 ustring(size_t count, char32 character);
111 ustring(size_t count, char32 character, const allocator_type& allocator);
116 ustring(size_t count, wchar character);
122 ustring(size_t count, wchar character, const allocator_type& allocator);
123
128 ustring(const ustring& str, size_t index, size_t count);
134 ustring(const ustring& str, size_t index, size_t count, const allocator_type& allocator);
138 ustring(const ustring& str, size_t index);
143 ustring(const ustring& str, size_t index, const allocator_type& allocator);
144
147 ustring(const value_type* str, size_t count);
152 ustring(const value_type* str, size_t count, const allocator_type& allocator);
153
155 ustring(const value_type* str); // Can't be explicit by design.
159 ustring(const value_type* str, const allocator_type& allocator);
160
162 ustring(value_type* str); // Can't be explicit by design.
166 ustring(value_type* str, const allocator_type& allocator);
167
170 ustring(const ustring& str) noexcept;
174 ustring(const ustring& str, const allocator_type& allocator) noexcept;
175
178 ustring(const std::string& str) noexcept; // Can't be explicit by design.
182 ustring(const std::string& str, const allocator_type& allocator) noexcept;
183
184#if defined(__cpp_lib_char8_t)
187 ustring(const std::u8string& str) noexcept; // Can't be explicit by design.
191 ustring(const std::u8string& str, const allocator_type& allocator) noexcept;
192
194 ustring(const char8* str); // Can't be explicit by design.
198 ustring(const char8* str, const allocator_type& allocator);
199
201 ustring(char8* str); // Can't be explicit by design.
205 ustring(char8* str, const allocator_type& allocator);
206#endif
207
210 ustring(const std::u16string& str) noexcept; // Can't be explicit by design.
214 ustring(const std::u16string& str, const allocator_type& allocator) noexcept;
215
217 ustring(const char16* str); // Can't be explicit by design.
221 ustring(const char16* str, const allocator_type& allocator);
222
224 ustring(char16* str); // Can't be explicit by design.
228 ustring(char16* str, const allocator_type& allocator);
229
232 ustring(const std::u32string& str) noexcept; // Can't be explicit by design.
236 ustring(const std::u32string& str, const allocator_type& allocator) noexcept;
237
239 ustring(const char32* str); // Can't be explicit by design.
243 ustring(const char32* str, const allocator_type& allocator);
244
246 ustring(char32* str); // Can't be explicit by design.
250 ustring(char32* str, const allocator_type& allocator);
251
254 ustring(const std::wstring& str) noexcept; // Can't be explicit by design.
258 ustring(const std::wstring& str, const allocator_type& allocator) noexcept;
259
261 ustring(const wchar* str); // Can't be explicit by design.
265 ustring(const wchar* str, const allocator_type& allocator);
266
268 ustring(wchar* str); // Can't be explicit by design.
272 ustring(wchar* str, const allocator_type& allocator);
273
276 ustring(ustring&& str) noexcept;
280 ustring(ustring&& str, const allocator_type& allocator) noexcept;
281
285 template<typename input_iterator_t>
286 ustring(input_iterator_t first, input_iterator_t last) : std::basic_string<value_type>(first, last) {}
291 template<typename input_iterator_t>
292 ustring(input_iterator_t first, input_iterator_t last, const allocator_type& allocator) : std::basic_string<value_type>(first, last, allocator) {}
293
297 template<typename string_view_like_t>
298 explicit constexpr ustring(const string_view_like_t& string_view, const allocator_type& allocator = allocator_type()) : std::basic_string<value_type>(string_view, allocator) {}
299
305 template<typename string_view_like_t>
306 constexpr ustring(const string_view_like_t& string_view, size_type index, size_type count, const allocator_type& allocator = allocator_type()) : std::basic_string<value_type>(string_view, index, count, allocator) {}
307
310 ustring(std::initializer_list<value_type> il);
314 ustring(std::initializer_list<value_type> il, const allocator_type& allocator);
315
316#if defined(__cpp_lib_char8_t)
319 ustring(std::initializer_list<char8> il);
323 ustring(std::initializer_list<char8> il, const allocator_type& allocator);
324#endif
325
328 ustring(std::initializer_list<char16> il);
332 ustring(std::initializer_list<char16> il, const allocator_type& allocator);
333
336 ustring(std::initializer_list<char32> il);
340 ustring(std::initializer_list<char32> il, const allocator_type& allocator);
341
344 ustring(std::initializer_list<wchar> il);
348 ustring(std::initializer_list<wchar> il, const allocator_type& allocator);
350
352 /*
353 template<typename type_t>
354 ustring(const type_t& object) : std::basic_string<value_type>(object) {}
355 template<typename type_t>
356 ustring(const type_t& object, const allocator_type& allocator) : std::basic_string<value_type>(object, allocator) {}
357 template<typename type_t>
358 ustring(const type_t& object, size_t index, size_t count) : std::basic_string<value_type>(object, index, count) {}
359 template<typename type_t>
360 ustring(const type_t& object, size_t index, size_t count, const allocator_type& allocator) : std::basic_string<value_type>(object, index, count, allocator) {}
361 template<typename type_t>
362 ustring(const type_t& object, size_t count) : std::basic_string<value_type>(object, 0, count) {}
363 template<typename type_t>
364 ustring(const type_t& object, size_t count, const allocator_type& allocator) : std::basic_string<value_type>(object, 0, count, allocator) {}
365 */
366
367 ustring& operator =(const ustring& str) noexcept;
368 ustring& operator =(const std::string& str) noexcept;
369 ustring& operator =(const value_type* str);
370#if defined(__cpp_lib_char8_t)
371 ustring& operator =(const std::u8string& str) noexcept;
372 ustring& operator =(const char8* str);
373#endif
374 ustring& operator =(const std::u16string& str) noexcept;
375 ustring& operator =(const char16* str);
376 ustring& operator =(const std::u32string& str) noexcept;
377 ustring& operator =(const char32* str);
378 ustring& operator =(const std::wstring& str) noexcept;
379 ustring& operator =(const wchar* str);
380 ustring& operator =(ustring&& str) noexcept;
381
382 ustring& operator =(value_type character);
383#if defined(__cpp_lib_char8_t)
384 ustring& operator =(char8 character);
385#endif
386 ustring& operator =(char16 character);
387 ustring& operator =(char32 character);
388 ustring& operator =(wchar character);
389 ustring& operator =(const std::initializer_list<value_type>& il);
390#if defined(__cpp_lib_char8_t)
391 ustring& operator =(const std::initializer_list<char8>& il);
392#endif
393 ustring& operator =(const std::initializer_list<char16>& il);
394 ustring& operator =(const std::initializer_list<char32>& il);
395 ustring& operator =(const std::initializer_list<wchar>& il);
396 //template<typename type_t>
397 //ustring& operator =(const type_t& object) {return std::basic_string<value_type>::assign(object);}
398
399 template<typename type_t>
400 ustring operator +(const type_t& object) const {
401 ustring result(*this);
402 result.append(object);
403 return result;
404 }
405
406 template<typename type_t>
407 ustring operator +(const type_t* object) const {
408 ustring result(*this);
409 result.append(ustring(object));
410 return result;
411 }
412
413 template<typename type_t>
414 ustring operator +(type_t* object) const {
415 ustring result(*this);
416 result.append(ustring(object));
417 return result;
418 }
419
420 ustring& operator +=(const ustring& str);
421 ustring& operator +=(const std::string& str);
422 ustring& operator +=(const value_type* str);
423#if defined(__cpp_lib_char8_t)
424 ustring& operator +=(const std::u8string& str);
425 ustring& operator +=(const char8* str);
426#endif
427 ustring& operator +=(const std::u16string& str);
428 ustring& operator +=(const char16* str);
429 ustring& operator +=(const std::u32string& str);
430 ustring& operator +=(const char32* str);
431 ustring& operator +=(const std::wstring& str);
432 ustring& operator +=(const wchar* str);
433 ustring& operator +=(value_type character);
434#if defined(__cpp_lib_char8_t)
435 ustring& operator +=(char8 character);
436#endif
437 ustring& operator +=(char16 character);
438 ustring& operator +=(char32 character);
439 ustring& operator +=(wchar character);
440 ustring& operator +=(const std::initializer_list<value_type>& il);
441#if defined(__cpp_lib_char8_t)
442 ustring& operator +=(const std::initializer_list<char8>& il);
443#endif
444 ustring& operator +=(const std::initializer_list<char16>& il);
445 ustring& operator +=(const std::initializer_list<char32>& il);
446 ustring& operator +=(const std::initializer_list<wchar>& il);
447 template<typename type_t>
448 ustring& operator +=(const type_t& object) {
449 *this = *this + ustring(object);
450 return *this;
451 }
452
453 bool operator ==(const ustring& other) const;
454 bool operator !=(const ustring& other) const;
455 bool operator ==(const std::string& other) const;
456 bool operator !=(const std::string& other) const;
457 bool operator ==(const value_type* other) const;
458 bool operator !=(const value_type* other) const;
459#if defined(__cpp_lib_char8_t)
460 bool operator ==(const std::u8string& other) const;
461 bool operator !=(const std::u8string& other) const;
462 bool operator ==(const char8* other) const;
463 bool operator !=(const char8* other) const;
464#endif
465 bool operator ==(const std::u16string& other) const;
466 bool operator !=(const std::u16string& other) const;
467 bool operator ==(const char16* other) const;
468 bool operator !=(const char16* other) const;
469 bool operator ==(const std::u32string& other) const;
470 bool operator !=(const std::u32string& other) const;
471 bool operator ==(const char32* other) const;
472 bool operator !=(const char32* other) const;
473 bool operator ==(const std::wstring& other) const;
474 bool operator !=(const std::wstring& other) const;
475 bool operator ==(const wchar* other) const;
476 bool operator !=(const wchar* other) const;
477 const value_type& operator [](size_t index);
478 const value_type& operator [](size_t index) const;
479 ustring substr(size_type index = 0, size_type count = npos) const;
481
483
485 int32 compare_to(const ustring& tzi) const noexcept override;
486
490 bool contains(const ustring& value) const noexcept;
491
492 bool equals(const ustring& tzi) const noexcept;
493
497 bool ends_with(value_type value) const noexcept;
498
499#if defined(__cpp_lib_char8_t)
503 bool ends_with(char8 value) const noexcept;
504#endif
505
509 bool ends_with(const ustring& value) const noexcept;
510
514 bool ends_with(const ustring& value, bool ignore_case) const noexcept;
515
519 bool ends_with(const ustring& value, xtd::string_comparison comparison_type) const noexcept;
520
523 size_t get_hash_code() const noexcept override;
524
528 size_t index_of(value_type value) const noexcept;
529
533 size_t index_of(const ustring& value) const noexcept;
534
539 size_t index_of(value_type value, size_t start_index) const noexcept;
540
545 size_t index_of(const ustring& value, size_t start_index) const noexcept;
546
552 size_t index_of(value_type value, size_t start_index, size_t count) const noexcept;
553
559 size_t index_of(const ustring& value, size_t start_index, size_t count) const noexcept;
560
564 size_t index_of_any(const std::vector<value_type>& values) const noexcept;
565
570 size_t index_of_any(const std::vector<value_type>& values, size_t start_index) const noexcept;
571
577 size_t index_of_any(const std::vector<value_type>& values, size_t start_index, size_t count) const noexcept;
578
580 size_t index_of_any(const std::initializer_list<value_type>& values) const noexcept;
581 size_t index_of_any(const std::initializer_list<value_type>& values, size_t start_index) const noexcept;
582 size_t index_of_any(const std::initializer_list<value_type>& values, size_t start_index, size_t count) const noexcept;
584
591 ustring insert(size_t start_index, const ustring& value) const noexcept;
592
596 [[deprecated("Replaced by xtd::ustring::is_empty(const xtd::ustring&) - Will be removed in version 0.4.0")]]
597 bool is_empty() const noexcept {return is_empty(*this);}
598
602 size_t last_index_of(value_type value) const noexcept;
603
607 size_t last_index_of(const ustring& value) const noexcept;
608
613 size_t last_index_of(value_type value, size_t start_index) const noexcept;
614
619 size_t last_index_of(const ustring& value, size_t start_index) const noexcept;
620
627 size_t last_index_of(value_type value, size_t start_index, size_t count) const noexcept;
628
634 size_t last_index_of(const ustring& value, size_t start_index, size_t count) const noexcept;
635
639 size_t last_index_of_any(const std::vector<value_type>& values) const noexcept;
640
645 size_t last_index_of_any(const std::vector<value_type>& values, size_t start_index) const noexcept;
646
652 size_t last_index_of_any(const std::vector<value_type>& values, size_t start_index, size_t count) const noexcept;
653
655 size_t last_index_of_any(const std::initializer_list<value_type>& values) const noexcept;
656 size_t last_index_of_any(const std::initializer_list<value_type>& values, size_t start_index) const noexcept;
657 size_t last_index_of_any(const std::initializer_list<value_type>& values, size_t start_index, size_t count) const noexcept;
659
665 ustring pad_left(size_t total_width) const noexcept;
666
673 ustring pad_left(size_t total_width, value_type padding_char) const noexcept;
674
680 ustring pad_right(size_t total_width) const noexcept;
681
688 ustring pad_right(size_t total_width, value_type padding_char) const noexcept;
689
700 ustring quoted(value_type delimiter, value_type escape) const;
701
705 ustring remove(size_t start_index) const noexcept;
706
711 ustring remove(size_t start_index, size_t count) const noexcept;
712
717 ustring replace(value_type old_char, value_type new_char) const noexcept;
718
724 ustring replace(const ustring& old_string, const ustring& new_string) const noexcept;
725
737 std::vector<ustring> split(const std::vector<value_type>& separators, size_t count, string_split_options options) const noexcept;
738
743 std::vector<ustring> split() const noexcept;
744
750 std::vector<ustring> split(const std::vector<value_type>& separators) const noexcept;
751
768 std::vector<ustring> split(const std::vector<value_type>& separators, string_split_options options) const noexcept;
769
778 std::vector<ustring> split(const std::vector<value_type>& separators, size_t count) const noexcept;
779
784 bool starts_with(value_type value) const noexcept;
785
791 bool starts_with(value_type value, bool ignore_case) const noexcept;
792
797 bool starts_with(const ustring& value) const noexcept;
798
804 bool starts_with(const ustring& value, bool ignore_case) const noexcept;
805
810 ustring substring(size_t start_index) const noexcept;
811
816 ustring substring(size_t start_index, size_t length) const noexcept;
817
820 std::vector<value_type> to_array() const noexcept;
821
825 std::vector<value_type> to_array(size_t start_index) const noexcept;
826
831 std::vector<value_type> to_array(size_t start_index, size_t length) const noexcept;
832
835 ustring to_lower() const noexcept;
836
837 //ustring to_string() const noexcept override;
838 ustring to_string() const noexcept override;
839
842 ustring to_title_case() const noexcept;
843
846 ustring to_upper() const noexcept;
847
852 ustring trim() const noexcept;
853
858 ustring trim(value_type trim_char) const noexcept;
859
864 ustring trim(const std::vector<value_type>& trim_chars) const noexcept;
865
870 ustring trim_end() const noexcept;
871
876 ustring trim_end(value_type trim_char) const noexcept;
877
882 ustring trim_end(const std::vector<value_type>& trim_chars) const noexcept;
883
888 ustring trim_start() const noexcept;
889
894 ustring trim_start(value_type trim_char) const noexcept;
895
900 ustring trim_start(const std::vector<value_type>& trim_chars) const noexcept;
902
904
910 template<typename object_t>
911 [[deprecated("Replaced by typeof_<object_t>().name() - Will be removed in version 0.4.0")]]
912 static ustring class_name() {return get_class_name(full_class_name<object_t>());}
913
918 template<typename object_t>
919 [[deprecated("Replaced by typeof_(object).name() - Will be removed in version 0.4.0")]]
920 static ustring class_name(const object_t& object) {return get_class_name(full_class_name(object));}
921
926 [[deprecated("Replaced by typeof_(info).name() - Will be removed in version 0.4.0")]]
927 static ustring class_name(const std::type_info& info);
928
929 using std::basic_string<value_type>::compare;
939 static int32 compare(const ustring& str_a, const ustring& str_b) noexcept;
950 static int32 compare(const ustring& str_a, const ustring& str_b, bool ignore_case) noexcept;
951
962 static int32 compare(const ustring& str_a, const ustring& str_b, xtd::string_comparison comparison_type) noexcept;
975 static int32 compare(const ustring& str_a, size_t index_a, const ustring& str_b, size_t index_b, size_t length) noexcept;
989 static int32 compare(const ustring& str_a, size_t index_a, const ustring& str_b, size_t index_b, size_t length, bool ignore_case) noexcept;
1003 static int32 compare(const ustring& str_a, size_t index_a, const ustring& str_b, size_t index_b, size_t length, xtd::string_comparison comparison_type) noexcept;
1004
1011 static ustring concat(const ustring& str_a, const ustring& str_b, const ustring& str_c, const ustring& str_d) noexcept;
1012
1019 template<typename object_a_t, typename object_b_t, typename object_c_t, typename object_d_t>
1020 static ustring concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c, object_d_t obj_d) noexcept {
1021 return format("{}{}{}{}", obj_a, obj_b, obj_c, obj_d);
1022 }
1023
1029 static ustring concat(const ustring& str_a, const ustring& str_b, const ustring& str_c) noexcept;
1030
1036 template<typename object_a_t, typename object_b_t, typename object_c_t>
1037 static ustring concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept {
1038 return format("{}{}{}", obj_a, obj_b, obj_c);
1039 }
1040
1045 static ustring concat(const ustring& str_a, const ustring& str_b) noexcept;
1046
1051 template<typename object_a_t, typename object_b_t>
1052 static ustring concat(object_a_t obj_a, object_b_t obj_b) noexcept {
1053 return format("{}{}", obj_a, obj_b);
1054 }
1055
1059 static ustring concat(const std::vector<ustring>& values) noexcept;
1060
1062 static ustring concat(const std::vector<const value_type*>& values) noexcept;
1063#if defined(__cpp_lib_char8_t)
1064 static ustring concat(const std::vector<const char8*>& values) noexcept;
1065#endif
1066 static ustring concat(const std::initializer_list<ustring>& values) noexcept;
1067 static ustring concat(const std::initializer_list<const value_type*>& values) noexcept;
1068#if defined(__cpp_lib_char8_t)
1069 static ustring concat(const std::initializer_list<const char8*>& values) noexcept;
1070#endif
1072
1076 template<typename object_t>
1077 static ustring concat(const std::vector<object_t>& args) noexcept {
1078 ustring result;
1079 for (const auto& arg : args)
1080 result += format("{}", arg);
1081 return result;
1082 }
1083
1085 template<typename object_t>
1086 static ustring concat(const std::initializer_list<object_t>& args) noexcept {
1087 ustring result;
1088 for (const auto& arg : args)
1089 result += format("{}", arg);
1090 return result;
1091 }
1093
1097 template<typename value_t>
1098 static ustring concat(value_t value) noexcept {
1099 return format("{}", value);
1100 }
1101
1122 static ustring demangle(const ustring& name);
1123
1130 template<typename ...args_t>
1131 static ustring format(const ustring& fmt, args_t&& ... args) {
1132 ustring result;
1133 size_t index = 0;
1134 std::vector<__format_information<char>> formats;
1135 auto begin_format_iterator = fmt.end();
1136 auto end_format_iterator = fmt.end();
1137 for (auto iterator = fmt.begin(); iterator != fmt.end(); ++iterator) {
1138 if (*iterator == '{') {
1139 if (++iterator == fmt.end())
1140 __throw_ustring_format_exception_open_bracket(__FILE__, __LINE__, __func__);
1141 if (*iterator == '{')
1142 result += *iterator;
1143 else {
1144 begin_format_iterator = iterator;
1145 while (iterator != fmt.end() && *iterator != '}') ++iterator;
1146 if (iterator == fmt.end())
1147 __throw_ustring_format_exception_open_bracket(__FILE__, __LINE__, __func__);
1148 end_format_iterator = iterator;
1149 __format_information<char> fi;
1150 fi.location = result.size();
1151 std::string format_str {begin_format_iterator, end_format_iterator};
1152 if (format_str.size() == 0)
1153 fi.index = index++;
1154 else {
1155 size_t index_alignment_separator = ustring(format_str).index_of(',');
1156 size_t index_format_separator = ustring(format_str).index_of(u':');
1157
1158 if (index_alignment_separator != std::string::npos && index_format_separator != std::string::npos && index_alignment_separator > index_format_separator)
1159 index_alignment_separator = std::string::npos;
1160
1161 if (index_alignment_separator != std::string::npos)
1162 fi.alignment = format_str.substr(index_alignment_separator + 1, index_format_separator != std::string::npos ? index_format_separator - index_alignment_separator - 1 : std::string::npos);
1163
1164 if (index_format_separator != std::string::npos)
1165 fi.format = format_str.substr(index_format_separator + 1);
1166
1167 if (index_alignment_separator == 0 || index_format_separator == 0)
1168 fi.index = index++;
1169 else {
1170 std::string index_str;
1171 if (index_alignment_separator != std::string::npos)
1172 index_str = format_str.substr(0, index_alignment_separator);
1173 else if (index_format_separator != std::string::npos)
1174 index_str = format_str.substr(0, index_format_separator);
1175 else
1176 index_str = std::move(format_str);
1177 try {
1178 for (auto c : index_str)
1179 if (!std::isdigit(c)) __throw_ustring_format_exception_start_colon(__FILE__, __LINE__, __func__);
1180 fi.index = std::stoi(index_str);
1181 } catch (...) {
1182 __throw_ustring_format_exception_start_colon(__FILE__, __LINE__, __func__);
1183 }
1184 }
1185 }
1186 formats.push_back(fi);
1187 }
1188 } else if (*iterator == '}') {
1189 if (++iterator == fmt.end()) {
1190 __throw_ustring_format_exception_close_bracket(__FILE__, __LINE__, __func__);
1191 break;
1192 }
1193 if (*iterator != '}') {
1194 __throw_ustring_format_exception_close_bracket(__FILE__, __LINE__, __func__);
1195 break;
1196 }
1197 result += *iterator;
1198 } else
1199 result += *iterator;
1200 }
1201
1202 __ustring_extract_format_arg(result, formats, std::forward<args_t>(args)...);
1203 return result.c_str();
1204 }
1205
1210 template<typename object_t>
1211 [[deprecated("Replaced by typeof_<object_t>().full_name() - Will be removed in version 0.4.0")]]
1212 static ustring full_class_name() {return demangle(typeid(object_t).name());}
1213
1218 template<typename object_t>
1219 [[deprecated("Replaced by typeof_(object).full_name() - Will be removed in version 0.4.0")]]
1220 static ustring full_class_name(const object_t& object) {return demangle(typeid(object).name());}
1221
1226 [[deprecated("Replaced by typeof_(info).full_name() - Will be removed in version 0.4.0")]]
1227 static ustring full_class_name(const std::type_info& info);
1228
1232 static bool is_empty(const xtd::ustring& string) noexcept;
1233
1240 template<typename collection_t>
1241 static ustring join(const ustring separator, const collection_t& values) noexcept {return join(separator, values, 0, values.size());}
1242
1250 template<typename collection_t>
1251 static ustring join(const ustring& separator, const collection_t& values, size_t index) noexcept {return join(separator, values, index, values.size() - index);}
1252
1261 template<typename collection_t>
1262 static ustring join(const ustring& separator, const collection_t& values, size_t index, size_t count) noexcept {
1263 size_t i = 0;
1264 ustring result;
1265 for (const auto& item : values) {
1266 if (i >= index) {
1267 if (i != index) result += separator;
1268 result += format("{}", item);
1269 }
1270 if (++i >= index + count) break;
1271 }
1272 return result;
1273 }
1274
1276 template<typename value_t>
1277 static ustring join(const ustring& separator, const std::initializer_list<value_t>& values) noexcept {return join(separator, std::vector<value_t>(values));}
1278 template<typename value_t>
1279 static ustring join(const ustring& separator, const std::initializer_list<value_t>& values, size_t index) noexcept {return join(separator, std::vector<value_t>(values), index);}
1280 template<typename value_t>
1281 static ustring join(const ustring& separator, const std::initializer_list<value_t>& values, size_t index, size_t count) noexcept {return join(separator, std::vector<value_t>(values), index, count);}
1283
1287 template<typename value_t>
1288 static value_t parse(const ustring& str) {
1289 return xtd::parse<value_t>(str);
1290 }
1291
1351 template<typename ... args_t>
1352 static ustring sprintf(const ustring& fmt, args_t&& ... args) noexcept {return __sprintf(fmt.c_str(), convert_param(std::forward<args_t>(args)) ...);}
1353
1358 template<typename value_t>
1359 static bool try_parse(const ustring& str, value_t& value) noexcept {
1360 try {
1361 value = parse<value_t>(str);
1362 return true;
1363 } catch (...) {
1364 return false;
1365 }
1366 }
1368
1370 friend std::ostream& operator <<(std::ostream& stream, const ustring& str) {return stream << str.c_str();}
1371 friend std::istream& operator >>(std::istream& stream, ustring& str) {
1372 std::string s;
1373 stream >> s;
1374 str = s;
1375 return stream;
1376 }
1377
1378 friend ustring operator +(const ustring& str_a, const ustring& str_b) {
1379 ustring result = str_a;
1380 result.append(str_b);
1381 return result;
1382 }
1383
1384 friend ustring operator +(const ustring& str_a, const std::string& str_b) {
1385 ustring result = str_a;
1386 result.append(ustring(str_b));
1387 return result;
1388 }
1389
1390 friend ustring operator +(const ustring& str_a, const value_type* str_b) {
1391 ustring result = str_a;
1392 result.append(ustring(str_b));
1393 return result;
1394 }
1395
1396#if defined(__cpp_lib_char8_t)
1397 friend ustring operator +(const ustring& str_a, const std::u8string& str_b) {
1398 ustring result = str_a;
1399 result.append(ustring(str_b));
1400 return result;
1401 }
1402
1403 friend ustring operator +(const ustring& str_a, const char8* str_b) {
1404 ustring result = str_a;
1405 result.append(ustring(str_b));
1406 return result;
1407 }
1408#endif
1409
1410 friend ustring operator +(const ustring& str_a, const std::u16string& str_b) {
1411 ustring result = str_a;
1412 result.append(ustring(str_b));
1413 return result;
1414 }
1415
1416 friend ustring operator +(const ustring& str_a, const char16* str_b) {
1417 ustring result = str_a;
1418 result.append(ustring(str_b));
1419 return result;
1420 }
1421
1422 friend ustring operator +(const ustring& str_a, const std::u32string& str_b) {
1423 ustring result = str_a;
1424 result.append(ustring(str_b));
1425 return result;
1426 }
1427
1428 friend ustring operator +(const ustring& str_a, const char32* str_b) {
1429 ustring result = str_a;
1430 result.append(ustring(str_b));
1431 return result;
1432 }
1433
1434 friend ustring operator +(const ustring& str_a, const std::wstring& str_b) {
1435 ustring result = str_a;
1436 result.append(ustring(str_b));
1437 return result;
1438 }
1439
1440 friend ustring operator +(const ustring& str_a, const wchar* str_b) {
1441 ustring result = str_a;
1442 result.append(ustring(str_b));
1443 return result;
1444 }
1445
1446 friend ustring operator +(const ustring& str_a, value_type character) {
1447 ustring result = str_a;
1448 result.append(ustring(1, character));
1449 return result;
1450 }
1451
1452#if defined(__cpp_lib_char8_t)
1453 friend ustring operator +(const ustring& str_a, char8 character) {
1454 ustring result = str_a;
1455 result.append(ustring(1, character));
1456 return result;
1457 }
1458#endif
1459
1460 friend ustring operator +(const ustring& str_a, char16 character) {
1461 ustring result = str_a;
1462 result.append(ustring(1, character));
1463 return result;
1464 }
1465
1466 friend ustring operator +(const ustring& str_a, char32 character) {
1467 ustring result = str_a;
1468 result.append(ustring(1, character));
1469 return result;
1470 }
1471
1472 friend ustring operator +(const ustring& str_a, wchar character) {
1473 ustring result = str_a;
1474 result.append(ustring(1, character));
1475 return result;
1476 }
1477
1478 friend ustring operator +(const ustring& str_a, const std::initializer_list<value_type>& il) {
1479 ustring result = str_a;
1480 result.append(ustring(il));
1481 return result;
1482 }
1483
1484#if defined(__cpp_lib_char8_t)
1485 friend ustring operator +(const ustring& str_a, const std::initializer_list<char8>& il) {
1486 ustring result = str_a;
1487 result.append(ustring(il));
1488 return result;
1489 }
1490#endif
1491
1492 friend ustring operator +(const ustring& str_a, const std::initializer_list<char16>& il) {
1493 ustring result = str_a;
1494 result.append(ustring(il));
1495 return result;
1496 }
1497
1498 friend ustring operator +(const ustring& str_a, const std::initializer_list<char32>& il) {
1499 ustring result = str_a;
1500 result.append(ustring(il));
1501 return result;
1502 }
1503
1504 friend ustring operator +(const ustring& str_a, const std::initializer_list<wchar>& il) {
1505 ustring result = str_a;
1506 result.append(ustring(il));
1507 return result;
1508 }
1509
1510 friend ustring operator +(const std::string& str_a, const ustring& str_b) {
1511 ustring result(str_a);
1512 result.append(str_b);
1513 return result;
1514 }
1515
1516 friend ustring operator +(const value_type* str_a, const ustring& str_b) {
1517 ustring result(str_a);
1518 result.append(str_b);
1519 return result;
1520 }
1521
1522#if defined(__cpp_lib_char8_t)
1523 friend ustring operator +(const std::u8string& str_a, const ustring& str_b) {
1524 ustring result(str_a);
1525 result.append(str_b);
1526 return result;
1527 }
1528
1529 friend ustring operator +(const char8* str_a, const ustring& str_b) {
1530 ustring result(str_a);
1531 result.append(str_b);
1532 return result;
1533 }
1534#endif
1535
1536 friend ustring operator +(const std::u16string& str_a, const ustring& str_b) {
1537 ustring result(str_a);
1538 result.append(str_b);
1539 return result;
1540 }
1541
1542 friend ustring operator +(const char16* str_a, const ustring& str_b) {
1543 ustring result(str_a);
1544 result.append(str_b);
1545 return result;
1546 }
1547
1548 friend ustring operator +(const std::u32string& str_a, const ustring& str_b) {
1549 ustring result(str_a);
1550 result.append(str_b);
1551 return result;
1552 }
1553
1554 friend ustring operator +(const char32* str_a, const ustring& str_b) {
1555 ustring result(str_a);
1556 result.append(str_b);
1557 return result;
1558 }
1559
1560 friend ustring operator +(const std::wstring& str_a, const ustring& str_b) {
1561 ustring result(str_a);
1562 result.append(str_b);
1563 return result;
1564 }
1565
1566 friend ustring operator +(const wchar* str_a, const ustring& str_b) {
1567 ustring result(str_a);
1568 result.append(str_b);
1569 return result;
1570 }
1571
1572 friend ustring operator +(value_type character, const ustring& str_b) {
1573 ustring result(1, character);
1574 result.append(str_b);
1575 return result;
1576 }
1577
1578#if defined(__cpp_lib_char8_t)
1579 friend ustring operator +(char8 character, const ustring& str_b) {
1580 ustring result(1, character);
1581 result.append(str_b);
1582 return result;
1583 }
1584#endif
1585
1586 friend ustring operator +(char16 character, const ustring& str_b) {
1587 ustring result(1, character);
1588 result.append(str_b);
1589 return result;
1590 }
1591
1592 friend ustring operator +(char32 character, const ustring& str_b) {
1593 ustring result(1, character);
1594 result.append(str_b);
1595 return result;
1596 }
1597
1598 friend ustring operator +(wchar character, const ustring& str_b) {
1599 ustring result(1, character);
1600 result.append(str_b);
1601 return result;
1602 }
1603
1604 friend ustring operator +(const std::initializer_list<value_type>& il, const ustring& str_b) {
1605 ustring result(il);
1606 result.append(str_b);
1607 return result;
1608 }
1609
1610#if defined(__cpp_lib_char8_t)
1611 friend ustring operator +(const std::initializer_list<char8>& il, const ustring& str_b) {
1612 ustring result(il);
1613 result.append(str_b);
1614 return result;
1615 }
1616#endif
1617
1618 friend ustring operator +(const std::initializer_list<char16>& il, const ustring& str_b) {
1619 ustring result(il);
1620 result.append(str_b);
1621 return result;
1622 }
1623
1624 friend ustring operator +(const std::initializer_list<char32>& il, const ustring& str_b) {
1625 ustring result(il);
1626 result.append(str_b);
1627 return result;
1628 }
1629
1630 friend ustring operator +(const std::initializer_list<wchar>& il, const ustring& str_b) {
1631 ustring result(il);
1632 result.append(str_b);
1633 return result;
1634 }
1636
1637 private:
1638 template<typename arg_t>
1639 static auto convert_param(arg_t&& arg) noexcept {
1640 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();
1641 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();
1642 else if constexpr(std::is_same<std::remove_cv_t<std::remove_reference_t<arg_t>>, xtd::ustring>::value) return std::forward<arg_t>(arg).c_str();
1643 else return std::forward<arg_t>(arg);
1644 }
1645
1646 static ustring get_class_name(const ustring& full_name);
1647
1648 using std::basic_string<value_type>::assign;
1649 using std::basic_string<value_type>::reserve;
1650 using std::basic_string<value_type>::shrink_to_fit;
1651 using std::basic_string<value_type>::clear;
1652 using std::basic_string<value_type>::erase;
1653 using std::basic_string<value_type>::push_back;
1654 using std::basic_string<value_type>::pop_back;
1655 using std::basic_string<value_type>::append;
1656 using std::basic_string<value_type>::replace;
1657 using std::basic_string<value_type>::resize;
1658 };
1659
1667 ustring to_ustring(unsigned val);
1675 ustring to_ustring(unsigned long val);
1679 ustring to_ustring(long long val);
1683 ustring to_ustring(unsigned long long val);
1691 ustring to_ustring(double val);
1695 ustring to_ustring(long double val);
1699 template <typename type_t>
1700 ustring to_ustring(type_t val) {
1701 return ustring::format("{}", val);
1702 }
1703}
1704
1706template<typename arg_t>
1707void __ustring_extract_format_arg(std::string& fmt, size_t& index, std::vector<__format_information<char>>& formats, arg_t&& arg) {
1708 size_t offset = 0;
1709 for (auto& format : formats) {
1710 format.location += offset;
1711 if (format.index == index) {
1712 xtd::ustring arg_str = format.format.empty() ? __format_stringer<char, arg_t>(arg) : xtd::to_string(arg, format.format);
1713
1714 if (!format.alignment.empty()) {
1715 xtd::int32 alignment = 0;
1716 try {
1717 alignment = std::stoi(format.alignment);
1718 } catch (...) {
1719 __throw_ustring_format_exception(__FILE__, __LINE__, __func__);
1720 }
1721 if (alignment > 0) arg_str = arg_str.pad_left(alignment);
1722 else if (alignment < 0) arg_str = arg_str.pad_right(-alignment);
1723 }
1724 fmt.insert(format.location, arg_str);
1725 offset += arg_str.size();
1726 }
1727 }
1728 ++index;
1729}
1730
1731template<typename ...args_t>
1732void __ustring_extract_format_arg(xtd::ustring& fmt, std::vector<__format_information<char>>& formats, args_t&& ... args) {
1733 size_t index = 0;
1734 (__ustring_extract_format_arg(fmt, index, formats, args), ...);
1735 unused_(index); // workaround to mute gcc warning: unused-but-set-variable
1736}
Defines a generalized comparison method that a value type or class implements to create a type-specif...
Definition icomparable.h:17
Supports all classes in the xtd class hierarchy and provides low-level services to derived classes....
Definition object.h:32
Represents text as a sequence of UTF-8 code units.
Definition ustring.h:47
ustring(std::initializer_list< value_type > il, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified initializer list and allocator.
ustring remove(size_t start_index, size_t count) const noexcept
Deletes all the characters from this string beginning at a specified position and continuing through ...
static ustring concat(object_a_t obj_a, object_b_t obj_b, object_c_t obj_c) noexcept
Concatenates three specified instances of object.
Definition ustring.h:1037
constexpr ustring(const string_view_like_t &string_view, size_type index, size_type count, const allocator_type &allocator=allocator_type())
Initializes a new instance of xtd::ustring with specified string view of substring and allocator.
Definition ustring.h:306
size_t last_index_of_any(const std::vector< value_type > &values) const noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
ustring(const ustring &str, size_t index, size_t count)
Initializes a new instance of xtd::ustring with specified substring at index and count characters.
ustring(size_t count, char32 character, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified count copies of character and specified all...
ustring(std::initializer_list< char16 > il)
Initializes a new instance of xtd::ustring with specified initializer list.
size_t last_index_of(const ustring &value, size_t start_index) const noexcept
Reports the index of the last occurrence of the specified character in this string....
size_t last_index_of(const ustring &value, size_t start_index, size_t count) const noexcept
Reports the index of the last occurrence of the specified character in this string....
ustring(char32 *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(const char8 *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
ustring(const value_type *str, size_t count)
Initializes a new instance of xtd::ustring with specified substring and count characters.
int32 compare_to(const ustring &tzi) const noexcept override
Compares the current instance with another object of the same type.
ustring(const char16 *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
size_t last_index_of(value_type value) const noexcept
Reports the index of the last occurrence of the specified character in this tring.
ustring(const std::u8string &str) noexcept
Initializes a new instance of xtd::ustring with specified string to copy.
bool is_empty() const noexcept
Indicates whether this string is an empty string ("").
Definition ustring.h:597
ustring(const value_type *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(input_iterator_t first, input_iterator_t last, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified first and last iterators of substring and a...
Definition ustring.h:292
bool ends_with(char8 value) const noexcept
Determines whether the end of this string matches the specified character.
static ustring demangle(const ustring &name)
Gets demangled string of name,.
ustring(std::initializer_list< value_type > il)
Initializes a new instance of xtd::ustring with specified initializer list.
ustring(const std::wstring &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::ustring with specified string to copy and allocator.
size_t last_index_of(value_type value, size_t start_index) const noexcept
Reports the index of the last occurrence of the specified character in this string....
ustring(size_t count, char16 character)
Initializes a new instance of xtd::ustring with specified count copies of character.
ustring quoted() const
Allows insertion and extraction of quoted strings, such as the ones found in CSV or XML.
ustring(std::initializer_list< wchar > il, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified initializer list and allocator.
ustring(char16 *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(const std::u8string &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::ustring with specified string to copy and allocator.
ustring(std::initializer_list< char32 > il)
Initializes a new instance of xtd::ustring with specified initializer list.
static ustring concat(value_t value) noexcept
Creates the string representation of a specified object.
Definition ustring.h:1098
ustring replace(const ustring &old_string, const ustring &new_string) const noexcept
Replaces all occurrences of a specified string in this string with another specified string.
ustring(const ustring &str, size_t index, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified substring at index and allocator.
static int32 compare(const ustring &str_a, const ustring &str_b, xtd::string_comparison comparison_type) noexcept
Compares two specified string objects using the specified rules, and returns an integer that indicate...
ustring pad_left(size_t total_width, value_type padding_char) const noexcept
Right-aligns the characters in this string, padding with spaces on the left for a specified total len...
ustring(const char16 *str)
Initializes a new instance of xtd::ustring with specified string to copy.
constexpr ustring(const string_view_like_t &string_view, const allocator_type &allocator=allocator_type())
Initializes a new instance of xtd::ustring with specified string view of substring and allocator.
Definition ustring.h:298
static int32 compare(const ustring &str_a, const ustring &str_b) noexcept
Compares two specified string objects and returns an integer that indicates their relative position i...
ustring(value_type *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(size_t count, wchar character)
Initializes a new instance of xtd::ustring with specified count copies of character.
ustring to_upper() const noexcept
Returns a copy of the current string converted to uppercase.
static bool is_empty(const xtd::ustring &string) noexcept
Indicates whether the specifeid string is an empty string ("").
ustring(const wchar *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring pad_right(size_t total_width, value_type padding_char) const noexcept
Left-aligns the characters in this string, padding with spaces on the right for a specified total len...
ustring insert(size_t start_index, const ustring &value) const noexcept
Inserts a specified instance of string at a specified index position in this instance.
static ustring join(const ustring &separator, const collection_t &values, size_t index, size_t count) noexcept
Concatenates a specified separator string between each element of a specified Object array,...
Definition ustring.h:1262
ustring(ustring &&str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::ustring with specified string to move and allocator.
size_t index_of_any(const std::vector< value_type > &values) const noexcept
Reports the index of the first occurrence in this instance of any character in a specified array of c...
ustring(std::initializer_list< char32 > il, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified initializer list and allocator.
std::vector< value_type > to_array() const noexcept
Copies the characters in this instance to a Unicode character array.
ustring(const char32 *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(char32 *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
static ustring class_name(const object_t &object)
Gets the class name of the specified object.
Definition ustring.h:920
ustring(size_t count, char8 character)
Initializes a new instance of xtd::ustring with specified count copies of character.
ustring trim() const noexcept
Removes all leading and trailing occurrences of white-space characters from the specified xtd::ustrin...
std::vector< ustring > split(const std::vector< value_type > &separators, size_t count, string_split_options options) const noexcept
Splits this string into a maximum number of substrings based on the characters in an array.
std::vector< ustring > split() const noexcept
Splits this string into substrings that are based on the default white-space characters....
ustring(size_t count, char16 character, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified count copies of character and specified all...
ustring trim_end() const noexcept
Removes all trailing occurrences of white-space characters from the specified xtd::ustring.
static bool try_parse(const ustring &str, value_t &value) noexcept
Try to convert a string into a value_t type.
Definition ustring.h:1359
ustring(char8 *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
static ustring 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 ustring.h:1020
size_t index_of(value_type value) const noexcept
Reports the index of the first occurrence of the specified character in this string.
ustring pad_right(size_t total_width) const noexcept
Left-aligns the characters in this string, padding with spaces on the right for a specified total len...
static ustring class_name(const std::type_info &info)
Gets the class name of the specified object.
static ustring concat(const std::vector< object_t > &args) noexcept
Concatenates the string representations of the elements in a specified object array.
Definition ustring.h:1077
static ustring full_class_name(const object_t &object)
Gets the fully qualified class name of the specified object, including the namespace of the specified...
Definition ustring.h:1220
ustring(const value_type *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
ustring to_title_case() const noexcept
Converts the current string to title case (except for words that are entirely in uppercase,...
ustring trim_start() const noexcept
Removes all leading occurrences of white-space characters from the specified xtd::ustring.
size_t last_index_of(const ustring &value) const noexcept
Reports the index of the last occurrence of the specified string in this string.
ustring replace(value_type old_char, value_type new_char) const noexcept
Replaces all occurrences of a specified char_t in this string with another specified char_t.
bool ends_with(const ustring &value, xtd::string_comparison comparison_type) const noexcept
Determines whether the end of this string matches the specified string when compared using the specif...
static value_t parse(const ustring &str)
Converts a string into a value_t type.
Definition ustring.h:1288
size_t last_index_of_any(const std::vector< value_type > &values, size_t start_index, size_t count) const noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
ustring(const value_type *str, size_t count, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified substring, count characters and allocator.
static ustring join(const ustring separator, const collection_t &values) noexcept
Concatenates a specified separator string between each element of a specified object array,...
Definition ustring.h:1241
ustring(const ustring &str, size_t index, size_t count, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified substring at index, count characters and al...
ustring(const ustring &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::ustring with specified string to copy and allocator.
ustring(const std::string &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::ustring with specified string to copy and allocator.
static ustring concat(const ustring &str_a, const ustring &str_b, const ustring &str_c, const ustring &str_d) noexcept
Concatenates four specified instances of string.
ustring(wchar *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
ustring(const std::string &str) noexcept
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(value_type *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
static ustring full_class_name()
Gets the fully qualified class name of the objec_t, including the namespace of the objec_t.
Definition ustring.h:1212
static ustring concat(object_a_t obj_a, object_b_t obj_b) noexcept
Concatenates two specified instances of object.
Definition ustring.h:1052
ustring pad_left(size_t total_width) const noexcept
Right-aligns the characters in this string, padding with spaces on the left for a specified total len...
static ustring class_name()
Gets the class name of the object_t.
Definition ustring.h:912
size_t last_index_of(value_type value, size_t start_index, size_t count) const noexcept
Reports the index of the last occurrence of the specified character in this string....
bool ends_with(value_type value) const noexcept
Determines whether the end of this string matches the specified character.
static int32 compare(const ustring &str_a, size_t index_a, const ustring &str_b, size_t index_b, size_t length) noexcept
Compares substrings of two specified string objects and returns an integer that indicates their relat...
ustring(char8 *str)
Initializes a new instance of xtd::ustring with specified string to copy.
size_t get_hash_code() const noexcept override
Returns the hash code for this string.
ustring(const std::u32string &str) noexcept
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(const char32 *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
ustring(const wchar *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
ustring(const std::u16string &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::ustring with specified string to copy and allocator.
ustring(const ustring &str, size_t index)
Initializes a new instance of xtd::ustring with specified substring at index.
ustring(const std::wstring &str) noexcept
Initializes a new instance of xtd::ustring with specified string to copy.
ustring remove(size_t start_index) const noexcept
Deletes all the characters from this string beginning at a specified position and continuing through ...
ustring(const ustring &str) noexcept
Initializes a new instance of xtd::ustring with specified string to copy.
static ustring concat(const std::vector< ustring > &values) noexcept
Concatenates the elements of a specified string array.
ustring(ustring &&str) noexcept
Initializes a new instance of xtd::ustring with specified string to move.
static ustring concat(const ustring &str_a, const ustring &str_b, const ustring &str_c) noexcept
Concatenates three specified instances of string.
ustring(size_t count, wchar character, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified count copies of character and specified all...
bool ends_with(const ustring &value) const noexcept
Determines whether the end of this string matches the specified string.
ustring substring(size_t start_index) const noexcept
Retrieves a substring from this instance. The substring starts at a specified character position and ...
static const ustring empty_string
Represents the empty string.
Definition ustring.h:54
ustring(size_t count, char32 character)
Initializes a new instance of xtd::ustring with specified count copies of character.
ustring(std::initializer_list< char8 > il, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified initializer list and allocator.
ustring(char16 *str, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified string to copy, and allocator.
ustring(wchar *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(const std::u32string &str, const allocator_type &allocator) noexcept
Initializes a new instance of xtd::ustring with specified string to copy and allocator.
ustring() noexcept
Initializes a new instance of xtd::ustring.
static int32 compare(const ustring &str_a, const ustring &str_b, bool ignore_case) noexcept
Compares two specified string objects, ignoring or honoring their case, and returns an integer that i...
bool starts_with(value_type value) const noexcept
Determines whether the beginning of this instance of xtd::ustring matches a specified xtd::ustring.
ustring 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...
ustring to_string() const noexcept override
Returns a sxd::ustring that represents the current object.
static ustring join(const ustring &separator, const collection_t &values, size_t index) noexcept
Concatenates a specified separator string between each element of a specified object array,...
Definition ustring.h:1251
ustring(size_t count, char8 character, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified count copies of character and specified all...
ustring(input_iterator_t first, input_iterator_t last)
Initializes a new instance of xtd::ustring with specified first and last iterators of substring.
Definition ustring.h:286
ustring(const std::u16string &str) noexcept
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(std::initializer_list< wchar > il)
Initializes a new instance of xtd::ustring with specified initializer list.
static ustring concat(const ustring &str_a, const ustring &str_b) noexcept
Concatenates two specified instances of string.
bool ends_with(const ustring &value, bool ignore_case) const noexcept
Determines whether the end of this string instance matches the specified string when compared using t...
bool contains(const ustring &value) const noexcept
Returns a value indicating whether a specified substring occurs within this string.
size_t last_index_of_any(const std::vector< value_type > &values, size_t start_index) const noexcept
Reports the index of the last occurrence in this instance of any character in a specified array of ch...
ustring to_lower() const noexcept
Returns a copy of the current string converted to lowercase.
ustring(const char8 *str)
Initializes a new instance of xtd::ustring with specified string to copy.
ustring(std::initializer_list< char8 > il)
Initializes a new instance of xtd::ustring with specified initializer list.
ustring(std::initializer_list< char16 > il, const allocator_type &allocator)
Initializes a new instance of xtd::ustring with specified initializer list and allocator.
static ustring full_class_name(const std::type_info &info)
Gets the fully qualified class name of the specified object, including the namespace of the specified...
static int32 compare(const ustring &str_a, size_t index_a, const ustring &str_b, size_t index_b, size_t length, bool ignore_case) noexcept
Compares substrings of two specified string objects, ignoring or honoring their case,...
static int32 compare(const ustring &str_a, size_t index_a, const ustring &str_b, size_t index_b, size_t length, xtd::string_comparison comparison_type) noexcept
Compares substrings of two specified string objects using the specified rules, and returns an integer...
Represents the version number of an assembly, operating system, or the xtd. This class cannot be inhe...
Definition version.h:110
static ustring sprintf(const ustring &fmt, args_t &&... args) noexcept
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition ustring.h:1352
static ustring format(const ustring &fmt, args_t &&... args)
Writes the text representation of the specified arguments list, to string using the specified format ...
Definition ustring.h:1131
#define unused_
It may be used to suppress the "unused variable" or "unused local typedefs" compiler warnings when th...
Definition unused.h:30
#define typeof_
Used to obtain the type object of a specified type or object.
Definition typeof.h:45
char8_t char8
Represents a 8-bit unicode character.
Definition types.h:64
wchar_t wchar
Represents a wide character.
Definition types.h:286
char16_t char16
Represents a 16-bit unicode character.
Definition types.h:76
int_least32_t int32
Represents a 32-bit signed integer.
Definition types.h:131
char32_t char32
Represents a 32-bit unicode character.
Definition types.h:87
uint_least32_t uint32
Represents a 32-bit unsigned integer.
Definition types.h:241
string_comparison
Specifies the culture, case, and sort rules to be used by certain overloads of the xtd::ustring::comp...
Definition string_comparison.h:14
string_split_options
Specifies whether applicable xtd::ustring::split method overloads include or omit empty substrings fr...
Definition string_split_options.h:14
std::string to_string(const date_time &value, const std::string &fmt, const std::locale &loc)
Convert a specified value into a string with specified format and locale.
Definition date_time.h:1080
@ other
The operating system is other.
@ clear
The CLEAR key.
@ s
The S key.
@ c
The C key.
@ u
The U key.
@ i
The I key.
@ separator
The Separator key.
@ insert
The INS (INSERT) key.
@ escape
The ESC (ESCAPE) key.
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
ustring to_ustring(int val)
Converts a signed integer to xtd::ustring.
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 xtd fundamental types.
Contains unused_ keyword.