CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
string.h
1
2#ifndef _aspose_system_string_h_
3#define _aspose_system_string_h_
4
5#include <system/text/normalization_form.h>
6#include <system/string_comparison.h>
7#include <system/shared_ptr.h>
8#include <system/details/icu_namespace.h>
9#include <system/details/stack_array.h>
10#include <system/object.h>
11#include <system/boxable_traits.h>
12#include <system/icomparable.h>
13#include <system/iequatable.h>
14
15#include <istream>
16#include <ostream>
17#include <string>
18#include <sstream>
19#include <system/diagnostics/debug.h>
20#include <iterator>
21#include <cstdint>
22
23#include <fwd.h>
24
25#ifdef ASPOSECPPLIB_BEING_BUILT
26#include <unicode/unistr.h>
27#endif
29ASPOSECPP_3RD_PARTY_ICU_NAMESPACE_START {
31 ASPOSECPP_3RD_PARTY_CLASS(UnicodeString);
32}
33
35ASPOSECPP_3RD_PARTY_TYPEDEF(UChar, char16_t);
36
37namespace System { namespace Text { class StringBuilder; } }
38namespace System { namespace Text { namespace RegularExpressions { class Regex; } } }
39namespace System { namespace Text { namespace RegularExpressions { namespace Detail { class Formatter; } } } }
40namespace System { namespace Globalization { class CompareInfo; } }
41namespace System { namespace Globalization { class TextElementEnumerator; } }
42namespace System { namespace Globalization { class TextInfo; } }
43namespace System { namespace Collections { namespace Generic { template <typename T> class IEnumerable; } } }
44namespace System { template<typename T> class ReadOnlySpan; }
45
46namespace System { namespace Details { template<typename T> class ArrayView; } }
47
48namespace System
49{
50
51namespace Detail {
53 ASPOSECPP_3RD_PARTY_TYPE_HOLDER(codeporting_icu::UnicodeString, UnicodeString, 64, size_t, UnicodeStringHolder);
54}
55
58{
60 None = 0,
63};
64
65using codeporting_icu::UnicodeString;
66
70template <typename T, typename CharT>
72 : public std::integral_constant<bool, std::is_same<typename std::remove_const<typename std::remove_pointer<typename std::decay<T>::type>::type>::type, CharT>::value> {};
73
77template <typename T, typename CharT>
79 public std::integral_constant<bool, IsStringByteSequence<T, CharT>::value && std::is_pointer<T>::value> {};
80
84template <typename T, typename CharT>
86 public std::integral_constant<bool, IsStringByteSequence<T, CharT>::value && std::is_array<T>::value> {};
87
125class ASPOSECPP_SHARED_CLASS String
126{
127 static const uintptr_t state_literal = 0;
128 static const uintptr_t state_null = 1;
129
133 friend class System::Text::RegularExpressions::Regex; // Uses private method Append for efficient string construction.
134 friend class System::Text::RegularExpressions::Detail::Formatter; // Uses private method Append for efficient string construction.
136 friend class System::Object;
137
138 using ThisType = String;
139
141 RTTI_INFO_VALUE_TYPE(System::String);
142public:
144 using reverse_iterator = std::reverse_iterator<const char16_t*>;
145
148
150 ASPOSECPP_SHARED_API String();
151
154 template<typename T>
155 String(T& value, typename std::enable_if<IsStringLiteral<T, char16_t>::value>::type* = nullptr)
156 : String(value, std::extent<T>::value - 1, state_literal)
157 {}
158
161 template<typename T>
162 String(const T& value, typename std::enable_if<IsStringPointer<T, char16_t>::value>::type* = nullptr)
163 : String(value, -1)
164 {
165 m_state = state_literal;
166 }
167
170 template<typename T>
171 explicit String(T& value, typename std::enable_if<IsStringLiteral<T, char>::value>::type* = nullptr)
172 : String(value, std::extent<T>::value - 1)
173 {
174 m_state = state_literal;
175 }
176
179 template<typename T>
180 explicit String(const T& value, typename std::enable_if<IsStringPointer<T, char>::value>::type* = nullptr)
181 : String(value, -1)
182 {
183 m_state = state_literal;
184 }
185
189 ASPOSECPP_SHARED_API String(const char16_t* str, int length);
190
194 ASPOSECPP_SHARED_API String(const ReadOnlySpan<char16_t>& value);
195
199 ASPOSECPP_SHARED_API String(const char* str, int length);
200
205 ASPOSECPP_SHARED_API String(const char16_t* str, int start, int length);
206
210 ASPOSECPP_SHARED_API explicit String(const char16_t ch, int count);
211
215 template<typename T>
216 String(const T& value, typename std::enable_if<std::is_same<T, std::nullptr_t>::value>::type* = nullptr) : String()
217 {
218 ASPOSE_UNUSED(value);
219 }
220
224 template<typename T>
225 explicit String(T& value, typename std::enable_if<IsStringLiteral<T, wchar_t>::value>::type* = nullptr)
226 : String(value, std::extent<T>::value - 1)
227 {}
228
232 template<typename T>
233 explicit String(const T& value, typename std::enable_if<IsStringPointer<T, wchar_t>::value>::type* = nullptr)
234 : String(value, -1)
235 {}
236
241 ASPOSECPP_SHARED_API explicit String(const wchar_t* str, int length);
246 ASPOSECPP_SHARED_API explicit String(const wchar_t ch, int count = 1);
247
250 ASPOSECPP_SHARED_API String(const String& str);
253 ASPOSECPP_SHARED_API String(String&& str) noexcept;
254
257 ASPOSECPP_SHARED_API String(const ArrayPtr<char16_t>& arr);
262 ASPOSECPP_SHARED_API String(const ArrayPtr<char16_t>& arr, int offset, int len);
263
265 ASPOSECPP_SHARED_API ~String();
266
269 ASPOSECPP_SHARED_API const UChar* u_str() const;
270
273 ASPOSECPP_SHARED_API const UChar* begin() const;
276 ASPOSECPP_SHARED_API const UChar* end() const;
277
280 ASPOSECPP_SHARED_API reverse_iterator rbegin() const;
283 ASPOSECPP_SHARED_API reverse_iterator rend() const;
284
287 ASPOSECPP_SHARED_API bool IsNullOrEmpty() const;
288
292 inline bool IsNull() const { return m_state == state_null; }
293
296 ASPOSECPP_SHARED_API bool IsEmpty() const;
297
300 ASPOSECPP_SHARED_API std::string ToUtf8String() const;
303 ASPOSECPP_SHARED_API std::wstring ToWCS() const;
306 ASPOSECPP_SHARED_API std::u16string ToU16Str() const;
309 ASPOSECPP_SHARED_API std::u32string ToU32Str() const;
313 ASPOSECPP_SHARED_API std::string ToAsciiString() const;
314
317 ASPOSECPP_SHARED_API String& reset();
318
321 ASPOSECPP_SHARED_API int get_Length() const;
325 ASPOSECPP_SHARED_API char_t operator[](int index) const;
330 ASPOSECPP_SHARED_API String& SetCharAt(int index, char_t ch);
331
335 ASPOSECPP_SHARED_API String& operator=(const String& str);
339 ASPOSECPP_SHARED_API String& operator=(String&& str) noexcept;
340
344 ASPOSECPP_SHARED_API String operator+(const String& str) const;
349 template <typename T, std::enable_if_t<IsStringLiteral<T, char_t>::value>* = nullptr>
350 String operator+(const T& arg) const
351 {
352 return *this + String(arg, std::extent<T>::value - 1);
353 }
354
358 ASPOSECPP_SHARED_API String operator+(char_t x) const;
362 ASPOSECPP_SHARED_API String operator+(int i) const;
366 ASPOSECPP_SHARED_API String operator+(uint32_t i) const;
370 ASPOSECPP_SHARED_API String operator+(double d) const;
374 ASPOSECPP_SHARED_API String operator+(int64_t v) const;
379 template <typename T, std::enable_if_t<IsSmartPtr<T>::value>* = nullptr>
380 String operator+(const T& value) const
381 {
382 return value == nullptr ? *this : *this + value->ToString();
383 }
388 template <typename T, std::enable_if_t<!IsSmartPtr<T>::value && !std::is_scalar<T>::value && !std::is_array<T>::value>* = nullptr>
389 String operator+(const T& value) const
390 {
391 return *this + value.ToString();
392 }
397 template <typename T, std::enable_if_t<std::is_same<T, bool>::value>* = nullptr>
398 String operator+(T arg) const
399 {
400 return String(*this).AddBoolImpl(arg);
401 }
402
406 ASPOSECPP_SHARED_API String& operator+=(char_t c);
410 ASPOSECPP_SHARED_API String& operator+=(const String& str);
414 ASPOSECPP_SHARED_API String& operator+=(double value);
418 ASPOSECPP_SHARED_API String& operator+=(uint8_t value);
422 ASPOSECPP_SHARED_API String& operator+=(int16_t value);
426 ASPOSECPP_SHARED_API String& operator+=(uint16_t value);
430 ASPOSECPP_SHARED_API String& operator+=(int32_t value);
434 ASPOSECPP_SHARED_API String& operator+=(uint32_t value);
438 ASPOSECPP_SHARED_API String& operator+=(int64_t value);
442 ASPOSECPP_SHARED_API String& operator+=(uint64_t value);
447 template <typename T, std::enable_if_t<std::is_same<T, bool>::value>* = nullptr>
449 {
450 return AddBoolImpl(value);
451 }
452
456 ASPOSECPP_SHARED_API bool operator==(const String& str) const;
459 ASPOSECPP_SHARED_API bool operator==(std::nullptr_t) const;
460
461
465 ASPOSECPP_SHARED_API bool operator!=(const String& str) const;
468 ASPOSECPP_SHARED_API bool operator!=(std::nullptr_t) const;
469
473 ASPOSECPP_SHARED_API bool operator<(const String& str) const;
474
478 ASPOSECPP_SHARED_API bool operator>(const String& str) const;
479
482 explicit operator std::string() const
483 {
484 return ToUtf8String();
485 }
488 explicit operator std::wstring() const
489 {
490 return ToWCS();
491 }
494 explicit operator std::u16string() const
495 {
496 return ToU16Str();
497 }
500 explicit operator std::u32string() const
501 {
502 return ToU32Str();
503 }
504
507 ASPOSECPP_SHARED_API String Clone() const;
508
511 String ToString() const { ThrowIfNull(); return *this; }
514 String ToString(const SharedPtr<IFormatProvider>&) const { ThrowIfNull(); return *this; }
515
518 ASPOSECPP_SHARED_API int GetHashCode() const;
523 ASPOSECPP_SHARED_API bool Equals(const String& str, System::StringComparison comparison_type) const;
527 ASPOSECPP_SHARED_API bool Equals(const String& str) const;
528
532 ASPOSECPP_SHARED_API bool Contains(const String& str) const;
536 ASPOSECPP_SHARED_API bool Contains(char16_t value) const;
540 ASPOSECPP_SHARED_API int CompareTo(const String& str) const;
546 ASPOSECPP_SHARED_API void CopyTo(int sourceIndex, const ArrayPtr<char_t>& destination, int destinationIndex, int count) const;
549 ASPOSECPP_SHARED_API String Normalize() const;
553 ASPOSECPP_SHARED_API String Normalize(System::Text::NormalizationForm form) const;
557 ASPOSECPP_SHARED_API bool IsNormalized(System::Text::NormalizationForm form) const;
558
562 ASPOSECPP_SHARED_API bool StartsWith(const String& value) const;
567 ASPOSECPP_SHARED_API bool StartsWith(const String& value, System::StringComparison comparisonType) const;
573 ASPOSECPP_SHARED_API bool StartsWith(const String& value, bool ignoreCase, const SharedPtr<System::Globalization::CultureInfo>& culture = nullptr) const;
574
578 ASPOSECPP_SHARED_API bool EndsWith(const String& value) const;
583 ASPOSECPP_SHARED_API bool EndsWith(const String& value, System::StringComparison comparisonType) const;
589 ASPOSECPP_SHARED_API bool EndsWith(const String& value, bool ignoreCase, const SharedPtr<System::Globalization::CultureInfo>& culture = nullptr) const;
590
595 ASPOSECPP_SHARED_API ArrayPtr<char_t> ToCharArray(int32_t startIndex = 0, int32_t length = INT32_MAX) const;
601 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ToByteArray(int32_t startIndex = 0, int32_t length = INT32_MAX, bool LE = true) const;
602
605 ASPOSECPP_SHARED_API operator ReadOnlySpan<char16_t>() const;
606
609 ASPOSECPP_SHARED_API String ToUpper() const;
612 ASPOSECPP_SHARED_API String ToLower() const;
613
617 ASPOSECPP_SHARED_API String ToLower(const SharedPtr<System::Globalization::CultureInfo>& cultureInfo) const;
621 ASPOSECPP_SHARED_API String ToUpper(const SharedPtr<System::Globalization::CultureInfo>& cultureInfo) const;
622
625 ASPOSECPP_SHARED_API String ToUpperInvariant() const;
628 ASPOSECPP_SHARED_API String ToLowerInvariant() const;
629
633 ASPOSECPP_SHARED_API String Substring(int32_t startIndex) const;
638 ASPOSECPP_SHARED_API String Substring(int32_t startIndex, int32_t length) const;
643 ASPOSECPP_SHARED_API String Remove(int32_t startIndex, int32_t count = INT32_MAX) const;
644
648 bool Is(const System::TypeInfo &target) const
649 {
650 return GetType() == target;
651 }
652
653 // Finds
654
659 ASPOSECPP_SHARED_API int IndexOf(const String& str, System::StringComparison comparison_type) const;
664 ASPOSECPP_SHARED_API int IndexOf(char_t c, int startIndex = 0) const;
670 ASPOSECPP_SHARED_API int IndexOf(char_t c, int startIndex, int count) const;
675 ASPOSECPP_SHARED_API int IndexOf(const String& str, int startIndex = 0) const;
681 ASPOSECPP_SHARED_API int IndexOf(const String& str, int startIndex, System::StringComparison comparison_type) const;
688 ASPOSECPP_SHARED_API int IndexOf(const String& value, int startIndex, int count, System::StringComparison comparisonType) const;
694 ASPOSECPP_SHARED_API int IndexOf(const String& str, int startIndex, int count) const;
695
700 ASPOSECPP_SHARED_API int IndexOfAny(char_t c, int startIndex = 0) const;
705 ASPOSECPP_SHARED_API int IndexOfAny(const String& str, int startIndex = 0) const;
710 ASPOSECPP_SHARED_API int IndexOfAny(const ArrayPtr<char_t>& anyOf) const;
716 ASPOSECPP_SHARED_API int IndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex) const;
723 ASPOSECPP_SHARED_API int IndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex, int32_t count) const;
724
729 ASPOSECPP_SHARED_API int LastIndexOf(const String& str, int startIndex = INT32_MAX) const;
734 ASPOSECPP_SHARED_API int LastIndexOf(const String& str, System::StringComparison comparison_type) const;
740 ASPOSECPP_SHARED_API int LastIndexOf(const String& str, int startIndex, System::StringComparison comparison_type) const;
747 ASPOSECPP_SHARED_API int LastIndexOf(const String& value, int startIndex, int count, StringComparison comparisonType) const;
748
752 ASPOSECPP_SHARED_API int LastIndexOf(char_t value) const;
757 ASPOSECPP_SHARED_API int LastIndexOf(char_t value, int32_t startIndex) const;
763 ASPOSECPP_SHARED_API int LastIndexOf(char_t value, int32_t startIndex, int32_t count) const;
764
769 ASPOSECPP_SHARED_API int LastIndexOfAny(const ArrayPtr<char_t>& anyOf) const;
775 ASPOSECPP_SHARED_API int LastIndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex) const;
782 ASPOSECPP_SHARED_API int LastIndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex, int32_t count) const;
783
784 // Trim
785
788 ASPOSECPP_SHARED_API String Trim() const;
792 ASPOSECPP_SHARED_API String Trim(char_t ch) const;
796 ASPOSECPP_SHARED_API String Trim(const String& anyOf) const;
800 ASPOSECPP_SHARED_API String Trim(const ArrayPtr<char_t>& anyOf) const;
801
804 ASPOSECPP_SHARED_API String TrimStart() const;
808 ASPOSECPP_SHARED_API String TrimStart(char_t ch) const;
812 ASPOSECPP_SHARED_API String TrimStart(const String& anyOf) const;
816 ASPOSECPP_SHARED_API String TrimStart(const ArrayPtr<char_t>& anyOf) const;
817
820 ASPOSECPP_SHARED_API String TrimEnd() const;
824 ASPOSECPP_SHARED_API String TrimEnd(char_t ch) const;
828 ASPOSECPP_SHARED_API String TrimEnd(const String& anyOf) const;
832 ASPOSECPP_SHARED_API String TrimEnd(const ArrayPtr<char_t>& anyOf) const;
833
838 ASPOSECPP_SHARED_API String PadLeft(int totalWidth, char_t c = u' ') const;
843 ASPOSECPP_SHARED_API String PadRight(int totalWidth, char_t c = u' ') const;
844
845 // Replace
846
851 ASPOSECPP_SHARED_API String Replace(char_t oldValue, char_t newValue) const;
856 ASPOSECPP_SHARED_API String Replace(const String& oldValue, const String& newValue) const;
857
858 // Insert
859
864 ASPOSECPP_SHARED_API String Insert(int startIndex, const String& value) const;
865
866 // Split
871 ASPOSECPP_SHARED_API ArrayPtr<String> Split(char_t separator = u' ', StringSplitOptions opt = StringSplitOptions::None) const;
877 ASPOSECPP_SHARED_API ArrayPtr<String> Split(char_t separator, int32_t count, StringSplitOptions opt = StringSplitOptions::None) const;
883 ASPOSECPP_SHARED_API ArrayPtr<String> Split(char_t separatorA, char_t separatorB, StringSplitOptions opt = StringSplitOptions::None) const;
888 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<char_t>& separators, StringSplitOptions opt = StringSplitOptions::None) const;
894 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<char_t>& separators, int32_t count, StringSplitOptions opt = StringSplitOptions::None) const;
895
900 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const String& separator, StringSplitOptions opt = StringSplitOptions::None) const;
906 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const String& separator, int count, StringSplitOptions opt = StringSplitOptions::None) const;
911 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<String>& separators, StringSplitOptions opt = StringSplitOptions::None) const;
917 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<String>& separators, int count, StringSplitOptions opt = StringSplitOptions::None) const;
918
919 // static members
920
922 static const ASPOSECPP_SHARED_API String Empty;
924 static const ASPOSECPP_SHARED_API String Null;
925
929 static ASPOSECPP_SHARED_API bool IsNullOrEmpty(const String& str);
933 static ASPOSECPP_SHARED_API bool IsNullOrWhiteSpace(const String& str);
938 static ASPOSECPP_SHARED_API bool Equals(const String& strA, const String& strB);
944 static ASPOSECPP_SHARED_API bool Equals(const String& strA, const String& strB, System::StringComparison comparison_type);
945
954 static ASPOSECPP_SHARED_API int Compare(const String& strA, int indexA, const String& strB, int indexB,
955 int length, bool ignoreCase = false);
956
966 static ASPOSECPP_SHARED_API int Compare(const String& strA, int indexA, const String& strB, int indexB,
967 int length, bool ignoreCase,
969
975 static ASPOSECPP_SHARED_API int Compare(const String& strA, const String& strB, System::StringComparison comparison_type);
984 static ASPOSECPP_SHARED_API int Compare(const String& strA, int indexA, const String& strB, int indexB,
985 int length, System::StringComparison comparison_type);
986
992 static ASPOSECPP_SHARED_API int Compare(const String& strA, const String& strB, bool ignoreCase = false);
999 static ASPOSECPP_SHARED_API int Compare(const String& strA, const String& strB, bool ignoreCase,
1001
1006 static ASPOSECPP_SHARED_API int CompareOrdinal(const String& strA, const String& strB);
1014 static ASPOSECPP_SHARED_API int CompareOrdinal(const String& strA, int indexA, const String& strB, int indexB, int length);
1015
1022 static ASPOSECPP_SHARED_API String Join(const String& separator, const ArrayPtr<String>& parts, int startIndex = 0, int count = -1);
1023
1030 static ASPOSECPP_SHARED_API String Join(const String& separator, const System::Details::ArrayView<String>& parts, int startIndex = 0, int count = -1);
1031
1036 static ASPOSECPP_SHARED_API String Join(const String& separator, const SharedPtr<System::Collections::Generic::IEnumerable<String> >& parts);
1037
1042 static ASPOSECPP_SHARED_API String Join(const String& separator, const ArrayPtr<SharedPtr<Object>>& parts);
1043
1047 static ASPOSECPP_SHARED_API String Concat(const ArrayPtr<String>& parts);
1052 static ASPOSECPP_SHARED_API String Concat(const String & str0, const String & str1);
1058 static ASPOSECPP_SHARED_API String Concat(const String & str0, const String & str1, const String & str2);
1059
1066 static ASPOSECPP_SHARED_API String Concat(const String& str0, const String& str1, const String& str2, const String& str3);
1067
1071 static String Copy(const String& str) { return str; }
1072
1078 template<class... Args>
1079 static String Format(const SharedPtr<IFormatProvider>& fp, const String& format, const Args&... args);
1080
1085 template<class... Args>
1086 static String Format(std::nullptr_t, const String& format, const Args&... args);
1087
1092 template<std::size_t N, class... Args>
1093 static String Format(std::nullptr_t, const char16_t(&format)[N], const Args&... args);
1094
1099 template<class... Args>
1100 static String Format(const String& format, const Args&... args);
1101
1106 template<class T>
1107 static String Format(const String& format, const System::ArrayPtr<T>& args);
1108
1112 static ASPOSECPP_SHARED_API String FromUtf8(const char* utf8);
1117 static ASPOSECPP_SHARED_API String FromUtf8(const char* utf8, int len);
1121 static ASPOSECPP_SHARED_API String FromUtf8(const uint8_t* utf8);
1125 static ASPOSECPP_SHARED_API String FromUtf8(const std::string& utf8);
1129 static ASPOSECPP_SHARED_API String FromWCS(const std::wstring& wcs);
1134 static ASPOSECPP_SHARED_API String FromUtf32(const uint32_t *utf32, int32_t length);
1138 static ASPOSECPP_SHARED_API String FromUtf16(const std::u16string& u16str);
1142 static ASPOSECPP_SHARED_API String FromAscii(const char* asciiStr);
1147 static ASPOSECPP_SHARED_API String FromAscii(const char* asciiStr, int len);
1151 static ASPOSECPP_SHARED_API String FromAscii(const std::string& asciiStr);
1152
1155 explicit ASPOSECPP_SHARED_API String(const codeporting_icu::UnicodeString& str);
1158 explicit ASPOSECPP_SHARED_API String(codeporting_icu::UnicodeString&& str) noexcept;
1161 explicit String(const std::wstring& str) : String(str.data(), ASPOSECPP_CHECKED_CAST(int, str.length())) {};
1164 explicit String(const std::u16string& str) : String(str.data(), ASPOSECPP_CHECKED_CAST(int, str.length())) {};
1167 explicit ASPOSECPP_SHARED_API String(const std::string& utf8str);
1170 explicit ASPOSECPP_SHARED_API String(const std::u32string& u32str);
1171
1174 bool ASPOSECPP_SHARED_API IsAsciiString() const;
1175
1180 int ASPOSECPP_SHARED_API FastToAscii(char buffer[], int buffer_size) const;
1181
1182protected:
1187 ASPOSECPP_SHARED_API String& Append(const char16_t *src,
1188 int32_t startIndex,
1189 int32_t count);
1190
1192 mutable Detail::UnicodeStringHolder m_str; // mutable because of u_str
1193
1197 uintptr_t m_state;
1198
1199#if defined(_DEBUG) && (defined(_MSC_VER) || defined(__GNUC__))
1200 union IcuDebugHelper
1201 {
1202 struct
1203 {
1204 int16_t fLengthAndFlags;
1205 char16_t fBuffer[(int32_t)(64 - sizeof(void *) - 2) / 2];
1206 } fStackFields;
1207 struct
1208 {
1209 int16_t fLengthAndFlags;
1210 int32_t fLength;
1211 int32_t fCapacity;
1212 char16_t *fArray;
1213 } fFields;
1214 } static icuDebugHelper;
1215#endif
1216
1217private:
1218 static bool StartsWithImpl(const String& that, const String& other, System::StringComparison comparisonType,
1220
1221 static bool EndsWithImpl(const String& that, const String& other, System::StringComparison comparisonType,
1223
1224 static int32_t CompareImpl(const String& strA, int32_t indexA, const String& strB, int32_t indexB,
1225 int32_t length, StringComparison comparisonType,
1227
1228 static int LastIndexOfOrdinalIgnoreCaseImpl(const String& source, const String& value, int startIndex, int count);
1229 static int IndexOfOrdinalIgnoreCaseImpl(const String& source, const String& value, int startIndex, int count);
1230
1231 ASPOSECPP_SHARED_API String& AddBoolImpl(bool value);
1232
1238 ASPOSECPP_SHARED_API void ThrowIfNull() const;
1239
1240 static SharedPtr<Text::StringBuilder> GetBuilder();
1241
1242 // Special ctor for literals
1243 ASPOSECPP_SHARED_API String(const char16_t* str, int length, uintptr_t state);
1244
1245 inline void SetState()
1246 {
1247 m_state = reinterpret_cast<uintptr_t>(this);
1248 }
1249
1250}; // class String
1251
1257template<typename T>
1258typename std::enable_if<IsStringLiteral<T, char_t>::value, String>::type inline operator+(T& left, const String& right)
1259{
1260 return String(left, std::extent<T>::value - 1) + right;
1261}
1262
1268template<typename T>
1269typename std::enable_if<IsStringPointer<T, char_t>::value, String>::type inline operator+(T& left, const String& right)
1270{
1271 return String(left) + right;
1272}
1273
1274
1279String inline operator+(const char_t left, const String& right)
1280{
1281 return String(left, 1) + right;
1282}
1283
1289template<class Chars, typename std::enable_if<IsStringLiteral<Chars, char_t>::value>::type* = nullptr>
1290bool inline operator==(Chars& left, const String& right)
1291{
1292 return String(left, std::extent<Chars>::value - 1) == right;
1293}
1294
1300template<class T, typename std::enable_if<IsStringPointer<T, char_t>::value>::type* = nullptr>
1301bool inline operator==(T& left, const String& right)
1302{
1303 return String(left) == right;
1304}
1305
1311template<class Chars, typename std::enable_if<IsStringLiteral<Chars, char_t>::value>::type* = nullptr>
1312bool inline operator!=(Chars& left, const String& right)
1313{
1314 return !(String(left, std::extent<Chars>::value - 1) == right);
1315}
1316
1322template<class T, typename std::enable_if<IsStringPointer<T, char_t>::value>::type* = nullptr>
1323bool inline operator!=(T& left, const String& right)
1324{
1325 return !(String(left) == right);
1326}
1327
1332ASPOSECPP_SHARED_API bool operator==(const SharedPtr<Object>& left, const String& right);
1337ASPOSECPP_SHARED_API bool operator!=(const SharedPtr<Object>& left, const String& right);
1338
1342ASPOSECPP_SHARED_API bool operator==(std::nullptr_t, const String& str);
1346ASPOSECPP_SHARED_API bool operator!=(std::nullptr_t, const String& str);
1347
1352ASPOSECPP_SHARED_API std::ostream& operator<<(std::ostream& os, const String& str);
1357ASPOSECPP_SHARED_API std::wostream& operator<<(std::wostream& os, const String& str);
1358
1363ASPOSECPP_SHARED_API std::istream& operator>>(std::istream &in, String &str);
1368ASPOSECPP_SHARED_API std::wistream& operator>>(std::wistream &in, String &str);
1369
1372template <>
1373struct CastResult<String>
1374{
1376 typedef String type;
1377};
1379
1383template <>
1384inline bool Object::ReferenceEquals(String const& str, std::nullptr_t)
1385{
1386 return str.IsNull();
1387}
1388
1393template <>
1394inline bool Object::ReferenceEquals(String const& str1, String const& str2)
1395{
1396 return str1.m_state == str2.m_state && (str1.m_state == String::state_null || str1 == str2);
1397}
1398
1399namespace BoxedValueDetail {
1401template<>
1402struct ImplementsInterface<String, IComparable<String>> : std::true_type {};
1404template <>
1405struct ImplementsInterface<String, IEquatable<String>> : std::true_type {};
1406} // namespace BoxedValueDetail
1407
1411ASPOSECPP_SHARED_API void PrintTo(const System::String& value, std::ostream* os);
1412
1413
1414} // namespace System
1415
1416// boost::hash specialization for System::String
1417
1418namespace std
1419{
1421 template <>
1422 struct hash<System::String>
1423 {
1427 std::size_t operator()(const System::String& str) const
1428 {
1429 return static_cast<std::size_t>(str.GetHashCode());
1430 }
1431 };
1432}
1433
1435typedef char16_t* system_char_array;
1437typedef char16_t const* const_system_char_array;
1438
1439#include <system/details/format_builder.h>
1440
1441namespace System {
1442
1448template<class... Args>
1449String String::Format(const SharedPtr<IFormatProvider>& fp, const String& format, const Args&... args)
1450{
1451 System::Details::FormatBuilder builder(format, fp);
1452 System::Details::FormatBuilder::AddArguments(builder, args...);
1453
1454 return builder.BuildResult();
1455}
1456
1461template<class... Args>
1462String String::Format(std::nullptr_t, const String& format, const Args&... args)
1463{
1464 System::Details::FormatBuilder builder(format);
1465 System::Details::FormatBuilder::AddArguments(builder, args...);
1466
1467 return builder.BuildResult();
1468}
1469
1474template<std::size_t N, class... Args>
1475String String::Format(std::nullptr_t, const char16_t (&format)[N], const Args&... args)
1476{
1477 System::Details::FormatBuilder builder(format);
1478 System::Details::FormatBuilder::AddArguments(builder, args...);
1479
1480 return builder.BuildResult();
1481}
1482
1483
1488template<class... Args>
1489String String::Format(const String& format, const Args&... args)
1490{
1491 System::Details::FormatBuilder builder(format);
1492 System::Details::FormatBuilder::AddArguments(builder, args...);
1493
1494 return builder.BuildResult();
1495}
1496
1501template<class T>
1503{
1504 System::Details::FormatBuilder builder(format);
1505 System::Details::FormatBuilder::AddArguments(builder, args);
1506
1507 return builder.BuildResult();
1508}
1509} // namespace System
1510
1511#endif // _aspose_system_string_h_
Makes culture-sensitive string comparison. Objects of this class should only be allocated using Syste...
Definition: compare_info.h:24
Enumerator to iterate through string elements (characters). Objects of this class should only be allo...
Definition: text_element_enumerator.h:28
Defines locale-specific text properties. Setter operations are only enabled on non-read-only objects....
Definition: text_info.h:23
Defines a method that compares two objects. Objects of this class should only be allocated using Syst...
Definition: icomparable.h:17
Defines a method that determines the equality of two objects. Objects of this class should only be al...
Definition: iequatable.h:18
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:51
virtual const TypeInfo & GetType() const
Gets actual type of object. Analog of C# System.Object.GetType() call.
static bool ReferenceEquals(ptr const &objA, ptr const &objB)
Compares objects by reference.
Definition: object.h:104
Forward to use within Span class.
Definition: span.h:415
Pointer class to wrap types being allocated on heap. Use it to manage memory for classes inheriting O...
Definition: smart_ptr.h:180
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:126
String & operator+=(uint8_t value)
Concatenation assignment operator.
String(const char *str, int length)
Constructs string from character string pointer and explicit length.
char_t operator[](int index) const
Gets character at specified position.
String(const std::wstring &str)
Creates String from widestring.
Definition: string.h:1161
ArrayPtr< char_t > ToCharArray(int32_t startIndex=0, int32_t length=INT32_MAX) const
Converts string or substring to array of characters.
int IndexOfAny(const ArrayPtr< char_t > &anyOf) const
Looks for any of passed characters through the whole string. Compares first string character to all c...
String(const String &str)
Copy constructor.
static String FromAscii(const char *asciiStr, int len)
Creates String from ASCII string.
int IndexOfAny(char_t c, int startIndex=0) const
Character forward lookup.
String PadRight(int totalWidth, char_t c=u' ') const
Adds padding on the right of original string.
String(const T &value, typename std::enable_if< IsStringPointer< T, wchar_t >::value >::type *=nullptr)
Constructs string based on widecharacter string pointer. Treats pointed string as null-terminated,...
Definition: string.h:233
bool EndsWith(const String &value, bool ignoreCase, const SharedPtr< System::Globalization::CultureInfo > &culture=nullptr) const
Checks if string ends with specified substring.
String(const T &value, typename std::enable_if< IsStringPointer< T, char >::value >::type *=nullptr)
Constructs string based on character string pointer. Treats pointed string as null-terminated in UTF8...
Definition: string.h:180
std::u16string ToU16Str() const
Converts string to std::u16string.
bool operator<(const String &str) const
Order-compares strings.
ArrayPtr< String > Split(char_t separatorA, char_t separatorB, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by one of two characters.
String Substring(int32_t startIndex, int32_t length) const
Extracts substring.
int IndexOf(const String &str, int startIndex=0) const
Substring forward lookup.
String TrimEnd(const String &anyOf) const
Removes all occurrences of passed characters from end of the string.
String & operator+=(int32_t value)
Concatenation assignment operator.
String & operator=(const String &str)
Assignment operator.
static String FromUtf8(const std::string &utf8)
Creates String from utf8 string.
int IndexOfAny(const String &str, int startIndex=0) const
Consequently looks for all characters of str in this. If first character is found,...
String ToLower() const
Converts all string's characters to lower case.
bool IsNormalized(System::Text::NormalizationForm form) const
Checks if unicode string is normalized using normalization form specified.
String Remove(int32_t startIndex, int32_t count=INT32_MAX) const
Extracts everything but substring from current string.
String(const std::u32string &u32str)
Creates String from std::u32string string.
String TrimStart(const String &anyOf) const
Removes all occurrences of passed characters from beginning of the string.
String & reset()
Sets string to null. Is analogous to 'string_variable_name = null' in C#.
String & Append(const char16_t *src, int32_t startIndex, int32_t count)
Puts some characters into string. Changes string size.
String Normalize() const
Normalizes unicode string using normalization form Unicode C.
String & operator+=(T value)
Concatenation assignment operator.
Definition: string.h:448
uintptr_t m_state
String state. Contains value 0 if string is null, 1 if string is constructed from string literal.
Definition: string.h:1197
String & operator+=(const String &str)
Concatenation assignment operator.
String Trim(const String &anyOf) const
Removes all occurrences of passed characters from both beginning and end of the string.
~String()
Destructor.
bool Equals(const String &str) const
String equality comparison. Uses System::StringComparison::Ordinal comparison mode.
bool operator>(const String &str) const
Order-compares strings.
String TrimStart() const
Removes all whitespace characters from beginning of the string.
String & operator+=(char_t c)
Concatenation assignment operator.
bool EndsWith(const String &value) const
Checks if string ends with specified substring.
int LastIndexOf(const String &str, System::StringComparison comparison_type) const
Substring backward lookup.
String Clone() const
Creates a copy of current string.
int get_Length() const
Gets string length.
static int Compare(const String &strA, int indexA, const String &strB, int indexB, int length, bool ignoreCase, const SharedPtr< System::Globalization::CultureInfo > &ci)
Less-equal-greater-compares two substrings.
bool operator==(const String &str) const
Equality comparison operator.
String & operator+=(int64_t value)
Concatenation assignment operator.
int IndexOf(const String &str, System::StringComparison comparison_type) const
Substring forward lookup.
int GetHashCode() const
Hashes contained string. Implemented in ICU, doesn't match hashes in C#.
reverse_iterator rbegin() const
Returns reverse iterator to the last character (if any) of actual string buffer.
String ToLower(const SharedPtr< System::Globalization::CultureInfo > &cultureInfo) const
Converts all string's characters to lower case using specific culture.
String Trim(char_t ch) const
Removes all occurrences of passed character from both beginning and end of the string.
String(codeporting_icu::UnicodeString &&str) noexcept
Move constructor.
String(const std::u16string &str)
Creates String from utf16 string.
Definition: string.h:1164
static String Join(const String &separator, const SharedPtr< System::Collections::Generic::IEnumerable< String > > &parts)
Joins array using string as separator.
int LastIndexOf(char_t value, int32_t startIndex, int32_t count) const
Character backward lookup.
static String FromAscii(const std::string &asciiStr)
Creates String from ASCII string.
bool Contains(char16_t value) const
Checks if string contains given character.
String & operator=(String &&str) noexcept
Move assignment operator.
static String Format(const SharedPtr< IFormatProvider > &fp, const String &format, const Args &... args)
Formats string in C# style.
Definition: string.h:1449
int LastIndexOfAny(const ArrayPtr< char_t > &anyOf) const
Looks for any of passed characters through whole string backwardly. Compares last string character to...
Detail::UnicodeStringHolder m_str
Actual string value.
Definition: string.h:1192
static String FromUtf16(const std::u16string &u16str)
Creates String from utf16 string.
int LastIndexOf(const String &str, int startIndex, System::StringComparison comparison_type) const
Substring backward lookup.
String operator+(const T &value) const
Adds reference type object string representation to the end of the string.
Definition: string.h:380
bool Is(const System::TypeInfo &target) const
Checks if string object is of type specified by TypeInfo passed.
Definition: string.h:648
String(String &&str) noexcept
Move constructor.
String ToLowerInvariant() const
Converts all string's characters to lower case using invariant culture.
bool StartsWith(const String &value) const
Checks if string begins with specified substring.
reverse_iterator rend() const
Returns reverse iterator to the before first character (if any) of actual string buffer.
String(const wchar_t *str, int length)
Constructs string from widecharacter string pointer and explicit length. Conversion from wchar_t is t...
int IndexOf(const String &str, int startIndex, int count) const
Substring forward lookup.
static String Join(const String &separator, const ArrayPtr< String > &parts, int startIndex=0, int count=-1)
Joins array using string as separator.
static bool Equals(const String &strA, const String &strB)
Equal-compares two strings using Ordial comparison mode.
int LastIndexOfAny(const ArrayPtr< char_t > &anyOf, int32_t startindex, int32_t count) const
Looks for any of passed characters through substring backwardly. Compares last string character to al...
String & operator+=(uint32_t value)
Concatenation assignment operator.
ArrayPtr< String > Split(const String &separator, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by substring.
String(const ArrayPtr< char16_t > &arr)
Converts whole character array to string.
static const String Empty
Empty string.
Definition: string.h:922
String & operator+=(int16_t value)
Concatenation assignment operator.
String(const ReadOnlySpan< char16_t > &value)
Initializes a new instance of the System.String class to the Unicode characters indicated in the spec...
ArrayPtr< String > Split(const String &separator, int count, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by substring.
String(const T &value, typename std::enable_if< std::is_same< T, std::nullptr_t >::value >::type *=nullptr)
Nullptr constructor. Declared as template to resolve priorities with other template constructors.
Definition: string.h:216
static String FromUtf8(const uint8_t *utf8)
Creates String from utf8 string.
String ToUpperInvariant() const
Converts all string's characters to upper case using invariant culture.
static String Copy(const String &str)
Creates string copy.
Definition: string.h:1071
ASPOSECPP_VALUE_TYPE_IMPLEMENTS_INTERFACES()
String is value type on C++ side which implicitly (without inheritance) implements some interfaces.
static const String Null
Null string.
Definition: string.h:924
String(const char16_t *str, int length)
Constructs string from character string pointer and explicit length.
bool operator==(std::nullptr_t) const
Checks if string is null. Applies same logic as IsNull() call.
String operator+(uint32_t i) const
Adds unsigned integer value string representation to the end of the string.
static bool Equals(const String &strA, const String &strB, System::StringComparison comparison_type)
Equal-compares two strings.
String(const wchar_t ch, int count=1)
Fill constructor. Conversion from wchar_t is time-consuming on some platforms, so no implicit convers...
String(const char16_t ch, int count)
Fill constructor.
String & operator+=(uint16_t value)
Concatenation assignment operator.
static int Compare(const String &strA, int indexA, const String &strB, int indexB, int length, bool ignoreCase=false)
Less-equal-greater-compares two substrings.
static bool IsNullOrEmpty(const String &str)
Checks if passed string is null or empty.
bool operator!=(std::nullptr_t) const
Checks if string is not null. Applies same logic as IsNull() call.
static int Compare(const String &strA, int indexA, const String &strB, int indexB, int length, System::StringComparison comparison_type)
Less-equal-greater-compares two strings.
String operator+(int i) const
Adds integer value string representation to the end of the string.
ArrayPtr< String > Split(char_t separator, int32_t count, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by character.
String operator+(T arg) const
Adds boolean value string representation to the end of the string.
Definition: string.h:398
static int Compare(const String &strA, const String &strB, System::StringComparison comparison_type)
Less-equal-greater-compares two strings.
bool EndsWith(const String &value, System::StringComparison comparisonType) const
Checks if string ends with specified substring.
String Substring(int32_t startIndex) const
Extracts substring.
String operator+(const T &arg) const
String concatenation with string literal or character string pointer.
Definition: string.h:350
String TrimEnd(char_t ch) const
Removes all occurrences of passed character from end of the string.
const UChar * begin() const
Returns pointer to the beginning of actual string buffer. Never reallocates anything....
ArrayPtr< String > Split(const ArrayPtr< String > &separators, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by substring.
int LastIndexOf(const String &str, int startIndex=INT32_MAX) const
Substring backward lookup.
std::wstring ToWCS() const
Converts string to std::wstring.
int FastToAscii(char buffer[], int buffer_size) const
Tries to convert a String to an ASCII string.
int IndexOf(const String &value, int startIndex, int count, System::StringComparison comparisonType) const
Substring forward lookup.
String TrimStart(char_t ch) const
Removes all occurrences of passed character from beginning of the string.
String Replace(char_t oldValue, char_t newValue) const
Replaces all occurrences of character in the string.
String ToUpper(const SharedPtr< System::Globalization::CultureInfo > &cultureInfo) const
Converts all string's characters to upper case using specific culture.
String(const T &value, typename std::enable_if< IsStringPointer< T, char16_t >::value >::type *=nullptr)
Constructs string based on character string pointer. Treats pointed string as null-terminated,...
Definition: string.h:162
String operator+(double d) const
Adds floating point value string representation to the end of the string.
String(const ArrayPtr< char16_t > &arr, int offset, int len)
Converts character array subrange to string. If parameters are out of array bounds,...
String ToUpper() const
Converts all string's characters to upper case.
int IndexOf(char_t c, int startIndex, int count) const
Character forward lookup in substring.
void CopyTo(int sourceIndex, const ArrayPtr< char_t > &destination, int destinationIndex, int count) const
Copies string characters into existing array elements. No resize is being done.
static int Compare(const String &strA, const String &strB, bool ignoreCase=false)
Less-equal-greater-compares two strings.
int LastIndexOfAny(const ArrayPtr< char_t > &anyOf, int32_t startindex) const
Looks for any of passed characters through substring backwardly. Compares last string character to al...
String(const char16_t *str, int start, int length)
Constructs string from character string pointer from starting position using length.
int CompareTo(const String &str) const
Compares two strings in 'less-equals-more' style. Uses current culture.
String PadLeft(int totalWidth, char_t c=u' ') const
Adds padding on the left of original string.
String TrimStart(const ArrayPtr< char_t > &anyOf) const
Removes all occurrences of passed characters from beginning of the string.
bool IsAsciiString() const
Indicates if a String contains ASCII symbols only.
ArrayPtr< String > Split(const ArrayPtr< char_t > &separators, int32_t count, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by one of characters specified.
static String Concat(const String &str0, const String &str1, const String &str2, const String &str3)
Concatenates strings.
String operator+(const String &str) const
String concatenation operator.
bool IsNullOrEmpty() const
Checks if string is empty or is considered null.
static String Concat(const String &str0, const String &str1, const String &str2)
Concatenates strings.
static String Join(const String &separator, const System::Details::ArrayView< String > &parts, int startIndex=0, int count=-1)
Joins array using string as separator.
String & operator+=(double value)
Concatenation assignment operator.
static int CompareOrdinal(const String &strA, const String &strB)
Less-equal-greater-compares two strings using ordinal mode.
String(const std::string &utf8str)
Creates String from std::string string presented in format UTF-8.
std::string ToUtf8String() const
Converts string to std::string. Uses UTF-8 encoding.
static String FromUtf8(const char *utf8, int len)
Creates String from utf8 string.
bool StartsWith(const String &value, System::StringComparison comparisonType) const
Checks if string begins with specified substring.
static bool IsNullOrWhiteSpace(const String &str)
Indicates whether a specified string is null, empty, or consists only of white-space characters.
bool operator!=(const String &str) const
Non-equality comparison operator.
static String Join(const String &separator, const ArrayPtr< SharedPtr< Object > > &parts)
Joins array using string as separator.
String operator+(char_t x) const
Adds character to the end of the string.
String TrimEnd() const
Removes all whitespace characters from end of the string.
ArrayPtr< String > Split(const ArrayPtr< char_t > &separators, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by one of characters specified.
bool Equals(const String &str, System::StringComparison comparison_type) const
String equality comparison. Several modes provided by StringComparison enumeration are supported.
const UChar * end() const
Returns pointer to the end of actual string buffer. Never reallocates anything. Doesn't guarantee buf...
String ToString(const SharedPtr< IFormatProvider > &) const
Wrapper for handling String class in contexts where ToString() is being called on value type objects.
Definition: string.h:514
const UChar * u_str() const
Returns ICU-styled null-terminated buffer. May reallocate the string.
ArrayPtr< String > Split(const ArrayPtr< String > &separators, int count, StringSplitOptions opt=StringSplitOptions::None) const
Splits string by substring. Currently, only supports separators array of zero or one elements.
static String Concat(const String &str0, const String &str1)
Concatenates strings.
String ToString() const
Wrapper for handling String class in contexts where ToString() is being called on value type objects.
Definition: string.h:511
String Trim() const
Removes all whitespace characters from both beginning and end of the string.
static int CompareOrdinal(const String &strA, int indexA, const String &strB, int indexB, int length)
Less-equal-greater-compares two strings using ordinal mode.
String operator+(int64_t v) const
Adds integer value string representation to the end of the string.
int IndexOf(char_t c, int startIndex=0) const
Character forward lookup.
ArrayPtr< uint8_t > ToByteArray(int32_t startIndex=0, int32_t length=INT32_MAX, bool LE=true) const
Converts string or substring to array of bytes.
std::u32string ToU32Str() const
Converts string to std::u32string.
int IndexOfAny(const ArrayPtr< char_t > &anyOf, int32_t startindex) const
Looks for any of passed characters through substring. Compares first string character to all characte...
String TrimEnd(const ArrayPtr< char_t > &anyOf) const
Removes all occurrences of passed characters from end of the string.
static String FromUtf32(const uint32_t *utf32, int32_t length)
Creates String from utf32 string.
String(T &value, typename std::enable_if< IsStringLiteral< T, char >::value >::type *=nullptr)
Constructs string based on string literal. Considers literal a null-terminated string in UTF8,...
Definition: string.h:171
int IndexOf(const String &str, int startIndex, System::StringComparison comparison_type) const
Substring forward lookup.
static String FromWCS(const std::wstring &wcs)
Creates String from widestring.
bool IsEmpty() const
Checks if string is both non-null and empty.
int IndexOfAny(const ArrayPtr< char_t > &anyOf, int32_t startindex, int32_t count) const
Looks for any of passed characters through substring. Compares first string character to all characte...
String & operator+=(uint64_t value)
Concatenation assignment operator.
String Insert(int startIndex, const String &value) const
Inserts substring at specified position.
bool Contains(const String &str) const
Checks if str is a substring of current string.
static String FromAscii(const char *asciiStr)
Creates String from ASCII string.
String & SetCharAt(int index, char_t ch)
Sets character at specified position.
int LastIndexOf(char_t value) const
Character backward lookup.
ArrayPtr< String > Split(char_t separator=u' ', StringSplitOptions opt=StringSplitOptions::None) const
Splits string by character.
bool StartsWith(const String &value, bool ignoreCase, const SharedPtr< System::Globalization::CultureInfo > &culture=nullptr) const
Checks if string begins with specified substring.
static String FromUtf8(const char *utf8)
Creates String from utf8 string.
bool IsNull() const
Checks if string is considered null. String is null and only if it is constructed via String() constr...
Definition: string.h:292
std::reverse_iterator< const char16_t * > reverse_iterator
Reverse iterator type.
Definition: string.h:144
String(T &value, typename std::enable_if< IsStringLiteral< T, wchar_t >::value >::type *=nullptr)
Constructs string based on widestring literal. Considers literal a null-terminated string,...
Definition: string.h:225
String Replace(const String &oldValue, const String &newValue) const
Replaces all occurrences of lookup in this string.
String()
Default constructor. Creates string object which is considered null.
String(const codeporting_icu::UnicodeString &str)
Wraps UnicodeString into String.
static String Concat(const ArrayPtr< String > &parts)
Concatenates strings.
String Normalize(System::Text::NormalizationForm form) const
Normalizes unicode string using normalization form specified.
String Trim(const ArrayPtr< char_t > &anyOf) const
Removes all occurrences of passed characters from both beginning and end of the string.
static int Compare(const String &strA, const String &strB, bool ignoreCase, const SharedPtr< System::Globalization::CultureInfo > &ci)
Less-equal-greater-compares two strings.
int LastIndexOf(const String &value, int startIndex, int count, StringComparison comparisonType) const
Substring backward lookup.
String(T &value, typename std::enable_if< IsStringLiteral< T, char16_t >::value >::type *=nullptr)
Constructs string based on string literal. Considers literal a null-terminated string,...
Definition: string.h:155
std::string ToAsciiString() const
Converts string to std::string. Uses ASCII encoding.
int LastIndexOf(char_t value, int32_t startIndex) const
Character backward lookup.
Regular expression that follows C#-like syntax. Objects of this class should only be allocated using ...
Definition: regex.h:30
Buffer to accumulate string part by part. This type can be allocated either in stack as value type or...
Definition: string_builder.h:17
Represents a particular type and provides information about it.
Definition: type_info.h:109
@ Text
Defines color adjustment information for text.
NormalizationForm
Defines how to normalize Unicode string.
Definition: normalization_form.h:9
Definition: db_command.h:9
void PrintTo(DateTime value, std::ostream *stream)
Prints value to ostream. Mostly used for debug.
bool operator!=(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:173
Decimal operator+(const T &x, const Decimal &d)
Returns a new instance of Decimal class that represents a value that is a sum of the specified value ...
Definition: decimal.h:542
std::istream & operator>>(std::istream &in, String &str)
Gets a string from the input streamusing UTF-8 encoding.
StringComparison
Defines string comparison style.
Definition: string_comparison.h:13
StringSplitOptions
Determines string splitting behavior.
Definition: string.h:58
@ None
Keep empty strings when splitting string.
@ RemoveEmptyEntries
Discard empty strings when splitting string.
std::ostream & operator<<(std::ostream &stream, DateTime date_time)
Insert data into the stream using UTF-8 encoding.
Definition: date_time.h:729
bool operator==(ArraySegment< T > a, ArraySegment< T > b)
Definition: array_segment.h:167
Template predicate that checks if boxed object should implement given interface by itself.
Definition: boxable_traits.h:33
Template magic to deduce cast results.
Definition: object.h:374
SmartPtr< TTo > type
An alias for a pointer to an instance of TTo.
Definition: object.h:376
Template magic to check if a type is a sequence of string characters.
Definition: string.h:72
Template magic to check if a type is a string literal.
Definition: string.h:86
Template magic to check if a type is a pointer to character string.
Definition: string.h:79