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
14#include <istream>
15#include <ostream>
16#include <string>
17#include <sstream>
18#include <system/diagnostics/debug.h>
19#include <iterator>
20#include <cstdint>
21
22#include <fwd.h>
23
24#ifdef ASPOSECPPLIB_BEING_BUILT
25#include <unicode/unistr.h>
26#endif
28ASPOSECPP_3RD_PARTY_ICU_NAMESPACE_START {
30 ASPOSECPP_3RD_PARTY_CLASS(UnicodeString);
31}
32
34ASPOSECPP_3RD_PARTY_TYPEDEF(UChar, char16_t);
35
36namespace System { namespace Text { class StringBuilder; } }
37namespace System { namespace Text { namespace RegularExpressions { class Regex; } } }
38namespace System { namespace Text { namespace RegularExpressions { namespace Detail { class Formatter; } } } }
39namespace System { namespace Globalization { class CompareInfo; } }
40namespace System { namespace Globalization { class TextElementEnumerator; } }
41namespace System { namespace Globalization { class TextInfo; } }
42namespace System { namespace Collections { namespace Generic { template <typename T> class IEnumerable; } } }
43namespace System { template<typename T> class ReadOnlySpan; }
44
45namespace System { namespace Details { template<typename T> class ArrayView; } }
46
47namespace System
48{
49
50namespace Detail {
52 ASPOSECPP_3RD_PARTY_TYPE_HOLDER(codeporting_icu::UnicodeString, UnicodeString, 64, size_t, UnicodeStringHolder);
53}
54
57{
59 None = 0,
62};
63
64using codeporting_icu::UnicodeString;
65
69template <typename T, typename CharT>
71 : 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> {};
72
76template <typename T, typename CharT>
78 public std::integral_constant<bool, IsStringByteSequence<T, CharT>::value && std::is_pointer<T>::value> {};
79
83template <typename T, typename CharT>
85 public std::integral_constant<bool, IsStringByteSequence<T, CharT>::value && std::is_array<T>::value> {};
86
124class ASPOSECPP_SHARED_CLASS String
125{
126 static const uintptr_t state_literal = 0;
127 static const uintptr_t state_null = 1;
128
132 friend class System::Text::RegularExpressions::Regex; // Uses private method Append for efficient string construction.
133 friend class System::Text::RegularExpressions::Detail::Formatter; // Uses private method Append for efficient string construction.
135 friend class System::Object;
136
137 using ThisType = String;
138
140 RTTI_INFO_VALUE_TYPE(System::String);
141public:
143 using reverse_iterator = std::reverse_iterator<const char16_t*>;
144
147
149 ASPOSECPP_SHARED_API String();
150
153 template<typename T>
154 String(T& value, typename std::enable_if<IsStringLiteral<T, char16_t>::value>::type* = nullptr)
155 : String(value, std::extent<T>::value - 1, state_literal)
156 {}
157
160 template<typename T>
161 String(const T& value, typename std::enable_if<IsStringPointer<T, char16_t>::value>::type* = nullptr)
162 : String(value, -1)
163 {
164 m_state = state_literal;
165 }
166
169 template<typename T>
170 explicit String(T& value, typename std::enable_if<IsStringLiteral<T, char>::value>::type* = nullptr)
171 : String(value, std::extent<T>::value - 1)
172 {
173 m_state = state_literal;
174 }
175
178 template<typename T>
179 explicit String(const T& value, typename std::enable_if<IsStringPointer<T, char>::value>::type* = nullptr)
180 : String(value, -1)
181 {
182 m_state = state_literal;
183 }
184
188 ASPOSECPP_SHARED_API String(const char16_t* str, int length);
189
193 ASPOSECPP_SHARED_API String(const ReadOnlySpan<char16_t>& value);
194
198 ASPOSECPP_SHARED_API String(const char* str, int length);
199
204 ASPOSECPP_SHARED_API String(const char16_t* str, int start, int length);
205
209 ASPOSECPP_SHARED_API explicit String(const char16_t ch, int count);
210
214 template<typename T>
215 String(const T& value, typename std::enable_if<std::is_same<T, std::nullptr_t>::value>::type* = nullptr) : String()
216 {
217 ASPOSE_UNUSED(value);
218 }
219
223 template<typename T>
224 explicit String(T& value, typename std::enable_if<IsStringLiteral<T, wchar_t>::value>::type* = nullptr)
225 : String(value, std::extent<T>::value - 1)
226 {}
227
231 template<typename T>
232 explicit String(const T& value, typename std::enable_if<IsStringPointer<T, wchar_t>::value>::type* = nullptr)
233 : String(value, -1)
234 {}
235
240 ASPOSECPP_SHARED_API explicit String(const wchar_t* str, int length);
245 ASPOSECPP_SHARED_API explicit String(const wchar_t ch, int count = 1);
246
249 ASPOSECPP_SHARED_API String(const String& str);
252 ASPOSECPP_SHARED_API String(String&& str) noexcept;
253
256 ASPOSECPP_SHARED_API String(const ArrayPtr<char16_t>& arr);
261 ASPOSECPP_SHARED_API String(const ArrayPtr<char16_t>& arr, int offset, int len);
262
264 ASPOSECPP_SHARED_API ~String();
265
268 ASPOSECPP_SHARED_API const UChar* u_str() const;
269
272 ASPOSECPP_SHARED_API const UChar* begin() const;
275 ASPOSECPP_SHARED_API const UChar* end() const;
276
279 ASPOSECPP_SHARED_API reverse_iterator rbegin() const;
282 ASPOSECPP_SHARED_API reverse_iterator rend() const;
283
286 ASPOSECPP_SHARED_API bool IsNullOrEmpty() const;
287
291 inline bool IsNull() const { return m_state == state_null; }
292
295 ASPOSECPP_SHARED_API bool IsEmpty() const;
296
299 ASPOSECPP_SHARED_API std::string ToUtf8String() const;
302 ASPOSECPP_SHARED_API std::wstring ToWCS() const;
305 ASPOSECPP_SHARED_API std::u16string ToU16Str() const;
308 ASPOSECPP_SHARED_API std::u32string ToU32Str() const;
312 ASPOSECPP_SHARED_API std::string ToAsciiString() const;
313
316 ASPOSECPP_SHARED_API String& reset();
317
320 ASPOSECPP_SHARED_API int get_Length() const;
324 ASPOSECPP_SHARED_API char_t operator[](int index) const;
329 ASPOSECPP_SHARED_API String& SetCharAt(int index, char_t ch);
330
334 ASPOSECPP_SHARED_API String& operator=(const String& str);
338 ASPOSECPP_SHARED_API String& operator=(String&& str) noexcept;
339
343 ASPOSECPP_SHARED_API String operator+(const String& str) const;
348 template <typename T, std::enable_if_t<IsStringLiteral<T, char_t>::value>* = nullptr>
349 String operator+(const T& arg) const
350 {
351 return *this + String(arg, std::extent<T>::value - 1);
352 }
353
357 ASPOSECPP_SHARED_API String operator+(char_t x) const;
361 ASPOSECPP_SHARED_API String operator+(int i) const;
365 ASPOSECPP_SHARED_API String operator+(uint32_t i) const;
369 ASPOSECPP_SHARED_API String operator+(double d) const;
373 ASPOSECPP_SHARED_API String operator+(int64_t v) const;
378 template <typename T, std::enable_if_t<IsSmartPtr<T>::value>* = nullptr>
379 String operator+(const T& value) const
380 {
381 return value == nullptr ? *this : *this + value->ToString();
382 }
387 template <typename T, std::enable_if_t<!IsSmartPtr<T>::value && !std::is_scalar<T>::value && !std::is_array<T>::value>* = nullptr>
388 String operator+(const T& value) const
389 {
390 return *this + value.ToString();
391 }
396 template <typename T, std::enable_if_t<std::is_same<T, bool>::value>* = nullptr>
397 String operator+(T arg) const
398 {
399 return String(*this).AddBoolImpl(arg);
400 }
401
405 ASPOSECPP_SHARED_API String& operator+=(char_t c);
409 ASPOSECPP_SHARED_API String& operator+=(const String& str);
413 ASPOSECPP_SHARED_API String& operator+=(double value);
417 ASPOSECPP_SHARED_API String& operator+=(uint8_t value);
421 ASPOSECPP_SHARED_API String& operator+=(int16_t value);
425 ASPOSECPP_SHARED_API String& operator+=(uint16_t value);
429 ASPOSECPP_SHARED_API String& operator+=(int32_t value);
433 ASPOSECPP_SHARED_API String& operator+=(uint32_t value);
437 ASPOSECPP_SHARED_API String& operator+=(int64_t value);
441 ASPOSECPP_SHARED_API String& operator+=(uint64_t value);
446 template <typename T, std::enable_if_t<std::is_same<T, bool>::value>* = nullptr>
448 {
449 return AddBoolImpl(value);
450 }
451
455 ASPOSECPP_SHARED_API bool operator==(const String& str) const;
458 ASPOSECPP_SHARED_API bool operator==(std::nullptr_t) const;
459
460
464 ASPOSECPP_SHARED_API bool operator!=(const String& str) const;
467 ASPOSECPP_SHARED_API bool operator!=(std::nullptr_t) const;
468
472 ASPOSECPP_SHARED_API bool operator<(const String& str) const;
473
477 ASPOSECPP_SHARED_API bool operator>(const String& str) const;
478
481 explicit operator std::string() const
482 {
483 return ToUtf8String();
484 }
487 explicit operator std::wstring() const
488 {
489 return ToWCS();
490 }
493 explicit operator std::u16string() const
494 {
495 return ToU16Str();
496 }
499 explicit operator std::u32string() const
500 {
501 return ToU32Str();
502 }
503
506 ASPOSECPP_SHARED_API String Clone() const;
507
510 String ToString() const { ThrowIfNull(); return *this; }
513 String ToString(const SharedPtr<IFormatProvider>&) const { ThrowIfNull(); return *this; }
514
517 ASPOSECPP_SHARED_API int GetHashCode() const;
522 ASPOSECPP_SHARED_API bool Equals(const String& str, System::StringComparison comparison_type) const;
526 ASPOSECPP_SHARED_API bool Equals(const String& str) const;
527
531 ASPOSECPP_SHARED_API bool Contains(const String& str) const;
535 ASPOSECPP_SHARED_API bool Contains(char16_t value) const;
539 ASPOSECPP_SHARED_API int CompareTo(const String& str) const;
545 ASPOSECPP_SHARED_API void CopyTo(int sourceIndex, const ArrayPtr<char_t>& destination, int destinationIndex, int count) const;
548 ASPOSECPP_SHARED_API String Normalize() const;
552 ASPOSECPP_SHARED_API String Normalize(System::Text::NormalizationForm form) const;
556 ASPOSECPP_SHARED_API bool IsNormalized(System::Text::NormalizationForm form) const;
557
561 ASPOSECPP_SHARED_API bool StartsWith(const String& value) const;
566 ASPOSECPP_SHARED_API bool StartsWith(const String& value, System::StringComparison comparisonType) const;
572 ASPOSECPP_SHARED_API bool StartsWith(const String& value, bool ignoreCase, const SharedPtr<System::Globalization::CultureInfo>& culture = nullptr) const;
573
577 ASPOSECPP_SHARED_API bool EndsWith(const String& value) const;
582 ASPOSECPP_SHARED_API bool EndsWith(const String& value, System::StringComparison comparisonType) const;
588 ASPOSECPP_SHARED_API bool EndsWith(const String& value, bool ignoreCase, const SharedPtr<System::Globalization::CultureInfo>& culture = nullptr) const;
589
594 ASPOSECPP_SHARED_API ArrayPtr<char_t> ToCharArray(int32_t startIndex = 0, int32_t length = INT32_MAX) const;
600 ASPOSECPP_SHARED_API ArrayPtr<uint8_t> ToByteArray(int32_t startIndex = 0, int32_t length = INT32_MAX, bool LE = true) const;
601
604 ASPOSECPP_SHARED_API operator ReadOnlySpan<char16_t>() const;
605
608 ASPOSECPP_SHARED_API String ToUpper() const;
611 ASPOSECPP_SHARED_API String ToLower() const;
612
616 ASPOSECPP_SHARED_API String ToLower(const SharedPtr<System::Globalization::CultureInfo>& cultureInfo) const;
620 ASPOSECPP_SHARED_API String ToUpper(const SharedPtr<System::Globalization::CultureInfo>& cultureInfo) const;
621
624 ASPOSECPP_SHARED_API String ToUpperInvariant() const;
627 ASPOSECPP_SHARED_API String ToLowerInvariant() const;
628
632 ASPOSECPP_SHARED_API String Substring(int32_t startIndex) const;
637 ASPOSECPP_SHARED_API String Substring(int32_t startIndex, int32_t length) const;
642 ASPOSECPP_SHARED_API String Remove(int32_t startIndex, int32_t count = INT32_MAX) const;
643
647 bool Is(const System::TypeInfo &target) const
648 {
649 return GetType() == target;
650 }
651
652 // Finds
653
658 ASPOSECPP_SHARED_API int IndexOf(const String& str, System::StringComparison comparison_type) const;
663 ASPOSECPP_SHARED_API int IndexOf(char_t c, int startIndex = 0) const;
669 ASPOSECPP_SHARED_API int IndexOf(char_t c, int startIndex, int count) const;
674 ASPOSECPP_SHARED_API int IndexOf(const String& str, int startIndex = 0) const;
680 ASPOSECPP_SHARED_API int IndexOf(const String& str, int startIndex, System::StringComparison comparison_type) const;
687 ASPOSECPP_SHARED_API int IndexOf(const String& value, int startIndex, int count, System::StringComparison comparisonType) const;
693 ASPOSECPP_SHARED_API int IndexOf(const String& str, int startIndex, int count) const;
694
699 ASPOSECPP_SHARED_API int IndexOfAny(char_t c, int startIndex = 0) const;
704 ASPOSECPP_SHARED_API int IndexOfAny(const String& str, int startIndex = 0) const;
709 ASPOSECPP_SHARED_API int IndexOfAny(const ArrayPtr<char_t>& anyOf) const;
715 ASPOSECPP_SHARED_API int IndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex) const;
722 ASPOSECPP_SHARED_API int IndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex, int32_t count) const;
723
728 ASPOSECPP_SHARED_API int LastIndexOf(const String& str, int startIndex = INT32_MAX) const;
733 ASPOSECPP_SHARED_API int LastIndexOf(const String& str, System::StringComparison comparison_type) const;
739 ASPOSECPP_SHARED_API int LastIndexOf(const String& str, int startIndex, System::StringComparison comparison_type) const;
746 ASPOSECPP_SHARED_API int LastIndexOf(const String& value, int startIndex, int count, StringComparison comparisonType) const;
747
751 ASPOSECPP_SHARED_API int LastIndexOf(char_t value) const;
756 ASPOSECPP_SHARED_API int LastIndexOf(char_t value, int32_t startIndex) const;
762 ASPOSECPP_SHARED_API int LastIndexOf(char_t value, int32_t startIndex, int32_t count) const;
763
768 ASPOSECPP_SHARED_API int LastIndexOfAny(const ArrayPtr<char_t>& anyOf) const;
774 ASPOSECPP_SHARED_API int LastIndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex) const;
781 ASPOSECPP_SHARED_API int LastIndexOfAny(const ArrayPtr<char_t>& anyOf, int32_t startindex, int32_t count) const;
782
783 // Trim
784
787 ASPOSECPP_SHARED_API String Trim() const;
791 ASPOSECPP_SHARED_API String Trim(char_t ch) const;
795 ASPOSECPP_SHARED_API String Trim(const String& anyOf) const;
799 ASPOSECPP_SHARED_API String Trim(const ArrayPtr<char_t>& anyOf) const;
800
803 ASPOSECPP_SHARED_API String TrimStart() const;
807 ASPOSECPP_SHARED_API String TrimStart(char_t ch) const;
811 ASPOSECPP_SHARED_API String TrimStart(const String& anyOf) const;
815 ASPOSECPP_SHARED_API String TrimStart(const ArrayPtr<char_t>& anyOf) const;
816
819 ASPOSECPP_SHARED_API String TrimEnd() const;
823 ASPOSECPP_SHARED_API String TrimEnd(char_t ch) const;
827 ASPOSECPP_SHARED_API String TrimEnd(const String& anyOf) const;
831 ASPOSECPP_SHARED_API String TrimEnd(const ArrayPtr<char_t>& anyOf) const;
832
837 ASPOSECPP_SHARED_API String PadLeft(int totalWidth, char_t c = u' ') const;
842 ASPOSECPP_SHARED_API String PadRight(int totalWidth, char_t c = u' ') const;
843
844 // Replace
845
850 ASPOSECPP_SHARED_API String Replace(char_t oldValue, char_t newValue) const;
855 ASPOSECPP_SHARED_API String Replace(const String& oldValue, const String& newValue) const;
856
857 // Insert
858
863 ASPOSECPP_SHARED_API String Insert(int startIndex, const String& value) const;
864
865 // Split
870 ASPOSECPP_SHARED_API ArrayPtr<String> Split(char_t separator = u' ', StringSplitOptions opt = StringSplitOptions::None) const;
876 ASPOSECPP_SHARED_API ArrayPtr<String> Split(char_t separator, int32_t count, StringSplitOptions opt = StringSplitOptions::None) const;
882 ASPOSECPP_SHARED_API ArrayPtr<String> Split(char_t separatorA, char_t separatorB, StringSplitOptions opt = StringSplitOptions::None) const;
887 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<char_t>& separators, StringSplitOptions opt = StringSplitOptions::None) const;
893 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<char_t>& separators, int32_t count, StringSplitOptions opt = StringSplitOptions::None) const;
894
899 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const String& separator, StringSplitOptions opt = StringSplitOptions::None) const;
905 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const String& separator, int count, StringSplitOptions opt = StringSplitOptions::None) const;
910 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<String>& separators, StringSplitOptions opt = StringSplitOptions::None) const;
916 ASPOSECPP_SHARED_API ArrayPtr<String> Split(const ArrayPtr<String>& separators, int count, StringSplitOptions opt = StringSplitOptions::None) const;
917
918 // static members
919
921 static const ASPOSECPP_SHARED_API String Empty;
923 static const ASPOSECPP_SHARED_API String Null;
924
928 static ASPOSECPP_SHARED_API bool IsNullOrEmpty(const String& str);
932 static ASPOSECPP_SHARED_API bool IsNullOrWhiteSpace(const String& str);
937 static ASPOSECPP_SHARED_API bool Equals(const String& strA, const String& strB);
943 static ASPOSECPP_SHARED_API bool Equals(const String& strA, const String& strB, System::StringComparison comparison_type);
944
953 static ASPOSECPP_SHARED_API int Compare(const String& strA, int indexA, const String& strB, int indexB,
954 int length, bool ignoreCase = false);
955
965 static ASPOSECPP_SHARED_API int Compare(const String& strA, int indexA, const String& strB, int indexB,
966 int length, bool ignoreCase,
968
974 static ASPOSECPP_SHARED_API int Compare(const String& strA, const String& strB, System::StringComparison comparison_type);
983 static ASPOSECPP_SHARED_API int Compare(const String& strA, int indexA, const String& strB, int indexB,
984 int length, System::StringComparison comparison_type);
985
991 static ASPOSECPP_SHARED_API int Compare(const String& strA, const String& strB, bool ignoreCase = false);
998 static ASPOSECPP_SHARED_API int Compare(const String& strA, const String& strB, bool ignoreCase,
1000
1005 static ASPOSECPP_SHARED_API int CompareOrdinal(const String& strA, const String& strB);
1013 static ASPOSECPP_SHARED_API int CompareOrdinal(const String& strA, int indexA, const String& strB, int indexB, int length);
1014
1021 static ASPOSECPP_SHARED_API String Join(const String& separator, const ArrayPtr<String>& parts, int startIndex = 0, int count = -1);
1022
1029 static ASPOSECPP_SHARED_API String Join(const String& separator, const System::Details::ArrayView<String>& parts, int startIndex = 0, int count = -1);
1030
1035 static ASPOSECPP_SHARED_API String Join(const String& separator, const SharedPtr<System::Collections::Generic::IEnumerable<String> >& parts);
1036
1041 static ASPOSECPP_SHARED_API String Join(const String& separator, const ArrayPtr<SharedPtr<Object>>& parts);
1042
1046 static ASPOSECPP_SHARED_API String Concat(const ArrayPtr<String>& parts);
1051 static ASPOSECPP_SHARED_API String Concat(const String & str0, const String & str1);
1057 static ASPOSECPP_SHARED_API String Concat(const String & str0, const String & str1, const String & str2);
1058
1065 static ASPOSECPP_SHARED_API String Concat(const String& str0, const String& str1, const String& str2, const String& str3);
1066
1070 static String Copy(const String& str) { return str; }
1071
1077 template<class... Args>
1078 static String Format(const SharedPtr<IFormatProvider>& fp, const String& format, const Args&... args);
1079
1084 template<class... Args>
1085 static String Format(std::nullptr_t, const String& format, const Args&... args);
1086
1091 template<std::size_t N, class... Args>
1092 static String Format(std::nullptr_t, const char16_t(&format)[N], const Args&... args);
1093
1098 template<class... Args>
1099 static String Format(const String& format, const Args&... args);
1100
1105 template<class T>
1106 static String Format(const String& format, const System::ArrayPtr<T>& args);
1107
1111 static ASPOSECPP_SHARED_API String FromUtf8(const char* utf8);
1116 static ASPOSECPP_SHARED_API String FromUtf8(const char* utf8, int len);
1120 static ASPOSECPP_SHARED_API String FromUtf8(const uint8_t* utf8);
1124 static ASPOSECPP_SHARED_API String FromUtf8(const std::string& utf8);
1128 static ASPOSECPP_SHARED_API String FromWCS(const std::wstring& wcs);
1133 static ASPOSECPP_SHARED_API String FromUtf32(const uint32_t *utf32, int32_t length);
1137 static ASPOSECPP_SHARED_API String FromUtf16(const std::u16string& u16str);
1141 static ASPOSECPP_SHARED_API String FromAscii(const char* asciiStr);
1146 static ASPOSECPP_SHARED_API String FromAscii(const char* asciiStr, int len);
1150 static ASPOSECPP_SHARED_API String FromAscii(const std::string& asciiStr);
1151
1154 explicit ASPOSECPP_SHARED_API String(const codeporting_icu::UnicodeString& str);
1157 explicit ASPOSECPP_SHARED_API String(codeporting_icu::UnicodeString&& str) noexcept;
1160 explicit String(const std::wstring& str) : String(str.data(), ASPOSECPP_CHECKED_CAST(int, str.length())) {};
1163 explicit String(const std::u16string& str) : String(str.data(), ASPOSECPP_CHECKED_CAST(int, str.length())) {};
1166 explicit ASPOSECPP_SHARED_API String(const std::string& utf8str);
1169 explicit ASPOSECPP_SHARED_API String(const std::u32string& u32str);
1170
1173 bool ASPOSECPP_SHARED_API IsAsciiString() const;
1174
1179 int ASPOSECPP_SHARED_API FastToAscii(char buffer[], int buffer_size) const;
1180
1181protected:
1186 ASPOSECPP_SHARED_API String& Append(const char16_t *src,
1187 int32_t startIndex,
1188 int32_t count);
1189
1191 mutable Detail::UnicodeStringHolder m_str; // mutable because of u_str
1192
1196 uintptr_t m_state;
1197
1198#if defined(_DEBUG) && (defined(_MSC_VER) || defined(__GNUC__))
1199 union IcuDebugHelper
1200 {
1201 struct
1202 {
1203 int16_t fLengthAndFlags;
1204 char16_t fBuffer[(int32_t)(64 - sizeof(void *) - 2) / 2];
1205 } fStackFields;
1206 struct
1207 {
1208 int16_t fLengthAndFlags;
1209 int32_t fLength;
1210 int32_t fCapacity;
1211 char16_t *fArray;
1212 } fFields;
1213 } static icuDebugHelper;
1214#endif
1215
1216private:
1217 static bool StartsWithImpl(const String& that, const String& other, System::StringComparison comparisonType,
1219
1220 static bool EndsWithImpl(const String& that, const String& other, System::StringComparison comparisonType,
1222
1223 static int32_t CompareImpl(const String& strA, int32_t indexA, const String& strB, int32_t indexB,
1224 int32_t length, StringComparison comparisonType,
1226
1227 static int LastIndexOfOrdinalIgnoreCaseImpl(const String& source, const String& value, int startIndex, int count);
1228 static int IndexOfOrdinalIgnoreCaseImpl(const String& source, const String& value, int startIndex, int count);
1229
1230 ASPOSECPP_SHARED_API String& AddBoolImpl(bool value);
1231
1237 ASPOSECPP_SHARED_API void ThrowIfNull() const;
1238
1239 static SharedPtr<Text::StringBuilder> GetBuilder();
1240
1241 // Special ctor for literals
1242 ASPOSECPP_SHARED_API String(const char16_t* str, int length, uintptr_t state);
1243
1244 inline void SetState()
1245 {
1246 m_state = reinterpret_cast<uintptr_t>(this);
1247 }
1248
1249}; // class String
1250
1256template<typename T>
1257typename std::enable_if<IsStringLiteral<T, char_t>::value, String>::type inline operator+(T& left, const String& right)
1258{
1259 return String(left, std::extent<T>::value - 1) + right;
1260}
1261
1267template<typename T>
1268typename std::enable_if<IsStringPointer<T, char_t>::value, String>::type inline operator+(T& left, const String& right)
1269{
1270 return String(left) + right;
1271}
1272
1273
1278String inline operator+(const char_t left, const String& right)
1279{
1280 return String(left, 1) + right;
1281}
1282
1288template<class Chars, typename std::enable_if<IsStringLiteral<Chars, char_t>::value>::type* = nullptr>
1289bool inline operator==(Chars& left, const String& right)
1290{
1291 return String(left, std::extent<Chars>::value - 1) == right;
1292}
1293
1299template<class T, typename std::enable_if<IsStringPointer<T, char_t>::value>::type* = nullptr>
1300bool inline operator==(T& left, const String& right)
1301{
1302 return String(left) == right;
1303}
1304
1310template<class Chars, typename std::enable_if<IsStringLiteral<Chars, char_t>::value>::type* = nullptr>
1311bool inline operator!=(Chars& left, const String& right)
1312{
1313 return !(String(left, std::extent<Chars>::value - 1) == right);
1314}
1315
1321template<class T, typename std::enable_if<IsStringPointer<T, char_t>::value>::type* = nullptr>
1322bool inline operator!=(T& left, const String& right)
1323{
1324 return !(String(left) == right);
1325}
1326
1331ASPOSECPP_SHARED_API bool operator==(const SharedPtr<Object>& left, const String& right);
1336ASPOSECPP_SHARED_API bool operator!=(const SharedPtr<Object>& left, const String& right);
1337
1341ASPOSECPP_SHARED_API bool operator==(std::nullptr_t, const String& str);
1345ASPOSECPP_SHARED_API bool operator!=(std::nullptr_t, const String& str);
1346
1351ASPOSECPP_SHARED_API std::ostream& operator<<(std::ostream& os, const String& str);
1356ASPOSECPP_SHARED_API std::wostream& operator<<(std::wostream& os, const String& str);
1357
1362ASPOSECPP_SHARED_API std::istream& operator>>(std::istream &in, String &str);
1367ASPOSECPP_SHARED_API std::wistream& operator>>(std::wistream &in, String &str);
1368
1371template <>
1372struct CastResult<String>
1373{
1375 typedef String type;
1376};
1378
1382template <>
1383inline bool Object::ReferenceEquals(String const& str, std::nullptr_t)
1384{
1385 return str.IsNull();
1386}
1387
1392template <>
1393inline bool Object::ReferenceEquals(String const& str1, String const& str2)
1394{
1395 return str1.m_state == str2.m_state && (str1.m_state == String::state_null || str1 == str2);
1396}
1397
1398namespace BoxedValueDetail {
1400template<>
1401struct ImplementsInterface<String, IComparable<String>> : std::true_type {};
1402}
1403
1407ASPOSECPP_SHARED_API void PrintTo(const System::String& value, std::ostream* os);
1408
1409
1410} // namespace System
1411
1412// boost::hash specialization for System::String
1413
1414namespace std
1415{
1417 template <>
1418 struct hash<System::String>
1419 {
1423 std::size_t operator()(const System::String& str) const
1424 {
1425 return static_cast<std::size_t>(str.GetHashCode());
1426 }
1427 };
1428}
1429
1431typedef char16_t* system_char_array;
1433typedef char16_t const* const_system_char_array;
1434
1435#include <system/details/format_builder.h>
1436
1437namespace System {
1438
1444template<class... Args>
1445String String::Format(const SharedPtr<IFormatProvider>& fp, const String& format, const Args&... args)
1446{
1447 System::Details::FormatBuilder builder(format, fp);
1448 System::Details::FormatBuilder::AddArguments(builder, args...);
1449
1450 return builder.BuildResult();
1451}
1452
1457template<class... Args>
1458String String::Format(std::nullptr_t, const String& format, const Args&... args)
1459{
1460 System::Details::FormatBuilder builder(format);
1461 System::Details::FormatBuilder::AddArguments(builder, args...);
1462
1463 return builder.BuildResult();
1464}
1465
1470template<std::size_t N, class... Args>
1471String String::Format(std::nullptr_t, const char16_t (&format)[N], const Args&... args)
1472{
1473 System::Details::FormatBuilder builder(format);
1474 System::Details::FormatBuilder::AddArguments(builder, args...);
1475
1476 return builder.BuildResult();
1477}
1478
1479
1484template<class... Args>
1485String String::Format(const String& format, const Args&... args)
1486{
1487 System::Details::FormatBuilder builder(format);
1488 System::Details::FormatBuilder::AddArguments(builder, args...);
1489
1490 return builder.BuildResult();
1491}
1492
1497template<class T>
1499{
1500 System::Details::FormatBuilder builder(format);
1501 System::Details::FormatBuilder::AddArguments(builder, args);
1502
1503 return builder.BuildResult();
1504}
1505} // namespace System
1506
1507#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
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:125
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:1160
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:232
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:179
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:447
uintptr_t m_state
String state. Contains value 0 if string is null, 1 if string is constructed from string literal.
Definition: string.h:1196
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:1163
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:1445
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:1191
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:379
bool Is(const System::TypeInfo &target) const
Checks if string object is of type specified by TypeInfo passed.
Definition: string.h:647
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:921
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:215
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:1070
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:923
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:397
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:349
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:161
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:513
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:510
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:170
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:291
std::reverse_iterator< const char16_t * > reverse_iterator
Reverse iterator type.
Definition: string.h:143
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:224
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:154
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:57
@ 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:71
Template magic to check if a type is a string literal.
Definition: string.h:85
Template magic to check if a type is a pointer to character string.
Definition: string.h:78