203 using inherited = Iterable<Character>;
242 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
243 String (
const CHAR_T* cString);
244 template <Memory::ISpan SPAN_OF_CHAR_T>
247 template <IStdBasicStringCompatibleCharacter CHAR_T>
248 String (
const basic_string<CHAR_T>& s);
249 template <IStdBasicStringCompatibleCharacter CHAR_T>
250 String (
const basic_string_view<CHAR_T>& s);
251 template <IStdBasicStringCompatibleCharacter CHAR_T>
252 explicit String (basic_string<CHAR_T>&& s);
253 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
254 String (
const Iterable<CHAR_T>& src)
256 template <IStdPathLike2UNICODEString PATHLIKE_TOSTRINGABLE>
257 explicit String (PATHLIKE_TOSTRINGABLE&& s);
262 template <IStdPathLike2UNICODEString PATHLIKE_TOSTRINGABLE>
263 static String mkSTR_ (PATHLIKE_TOSTRINGABLE&& s);
266 static shared_ptr<_IRep> CTORFromBasicStringView_ (
const basic_string_view<ASCII>& str);
267 static shared_ptr<_IRep> CTORFromBasicStringView_ (
const basic_string_view<char8_t>& str);
268 static shared_ptr<_IRep> CTORFromBasicStringView_ (
const basic_string_view<char16_t>& str);
269 static shared_ptr<_IRep> CTORFromBasicStringView_ (
const basic_string_view<char32_t>& str);
270 static shared_ptr<_IRep> CTORFromBasicStringView_ (
const basic_string_view<wchar_t>& str);
278 using _SafeReadRepAccessor = Iterable<Character>::_SafeReadRepAccessor<
_IRep>;
285 String (
const shared_ptr<_IRep>& rep)
noexcept;
286 String (shared_ptr<_IRep>&& rep)
noexcept;
289 nonvirtual
String& operator= (
String&& rhs)
noexcept =
default;
290 nonvirtual
String& operator= (
const String& rhs)
noexcept =
default;
306 template <
typename CHAR_T>
307 static String FromUTF8 (span<CHAR_T> from)
308 requires (same_as<remove_cv_t<CHAR_T>,
char8_t> or same_as<remove_cv_t<CHAR_T>,
char>);
309 template <
typename CHAR_T>
310 static String FromUTF8 (basic_string<CHAR_T> from)
311 requires (same_as<remove_cv_t<CHAR_T>,
char8_t> or same_as<remove_cv_t<CHAR_T>,
char>);
312 template <
typename CHAR_T>
313 static String FromUTF8 (
const CHAR_T* from)
314 requires (same_as<remove_cv_t<CHAR_T>,
char8_t> or same_as<remove_cv_t<CHAR_T>,
char>);
325 static String FromSDKString (span<const SDKChar> s);
334 static String FromNarrowSDKString (
const char* from);
335 static String FromNarrowSDKString (span<const char> s);
336 static String FromNarrowSDKString (
const string& from);
345 static String FromNarrowString (
const char* from,
const locale& l);
346 static String FromNarrowString (span<const char> s,
const locale& l);
347 static String FromNarrowString (
const string& from,
const locale& l);
377 template <
size_t SIZE, IUNICODECanUnambiguouslyConvertFrom CHAR_T>
378 static String FromStringConstant (
const CHAR_T (&cString)[SIZE]);
379 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
380 static String FromStringConstant (
const basic_string_view<CHAR_T>& str);
381 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
382 static String FromStringConstant (span<const CHAR_T> str);
383 static String FromStringConstant (span<const ASCII> s);
384 static String FromStringConstant (span<const char16_t> s);
385 static String FromStringConstant (span<const wchar_t> s);
386 static String FromStringConstant (span<const char32_t> s);
398 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
399 static String FromLatin1 (
const CHAR_T* cString);
400 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
401 static String FromLatin1 (span<const CHAR_T> s);
402 template <IStdBasicStringCompatibleCharacter CHAR_T>
403 static String FromLatin1 (
const basic_string<CHAR_T>& s);
411 template <
typename T>
413 requires (is_convertible_v<T, String>);
416 nonvirtual
String Concatenate_ (
const String& rhs)
const;
426 nonvirtual
size_t size () const noexcept;
431 nonvirtual
bool empty () const noexcept;
436 nonvirtual const
Character GetCharAt (
size_t i) const noexcept;
446 nonvirtual const
Character operator[] (
size_t i) const noexcept;
459 nonvirtual
String InsertAt (const
String& s,
size_t at) const;
483 nonvirtual
String RemoveAt (
size_t charAt) const;
484 nonvirtual
String RemoveAt (
size_t from,
size_t to) const;
485 nonvirtual
String RemoveAt (pair<
size_t,
size_t> fromTo) const;
495 nonvirtual
String RemoveFirstIf (const
String& subString) const;
504 nonvirtual
String RemoveAll (const
String& subString) const;
571 template <typename SZ>
572 nonvirtual
String SubString (SZ from) const;
573 template <typename SZ1, typename SZ2>
574 nonvirtual
String SubString (SZ1 from, SZ2 to) const;
587 template <typename SZ>
588 nonvirtual
String SafeSubString (SZ from) const;
589 template <typename SZ1, typename SZ2>
590 nonvirtual
String SafeSubString (SZ1 from, SZ2 to) const;
596 nonvirtual
String Repeat (
unsigned int count) const;
607 nonvirtual
bool Contains (
Character c, CompareOptions co = eWithCase) const;
608 nonvirtual
bool Contains (const
String& subString, CompareOptions co = eWithCase) const;
614 nonvirtual
bool ContainsAny (Iterable<
Character> cs, CompareOptions co = eWithCase) const;
629 nonvirtual
bool StartsWith (const
Character& c, CompareOptions co = eWithCase) const;
630 nonvirtual
bool StartsWith (const
String& subString, CompareOptions co = eWithCase) const;
645 nonvirtual
bool EndsWith (const
Character& c, CompareOptions co = eWithCase) const;
646 nonvirtual
bool EndsWith (const
String& subString, CompareOptions co = eWithCase) const;
654 nonvirtual
String AssureEndsWith (const
Character& c, CompareOptions co = eWithCase) const;
722 template <Common::IAnyOf<optional<
String>*,
String*, nullptr_t>... OPTIONAL_STRINGS>
723 nonvirtual
bool Matches (const
RegularExpression& regEx, OPTIONAL_STRINGS&&... subMatches) const;
759 nonvirtual optional<
size_t> Find (
Character c, CompareOptions co = eWithCase) const;
760 nonvirtual optional<
size_t> Find (
Character c,
size_t startAt, CompareOptions co = eWithCase) const;
761 nonvirtual optional<
size_t> Find (const
String& subString, CompareOptions co = eWithCase) const;
762 nonvirtual optional<
size_t> Find (const
String& subString,
size_t startAt, CompareOptions co = eWithCase) const;
763 nonvirtual optional<pair<
size_t,
size_t>> Find (const
RegularExpression& regEx,
size_t startAt = 0) const;
764 nonvirtual Traversal::Iterator<
Character> Find (const function<
bool (
Character item)>& that) const;
789 nonvirtual Containers::Sequence<pair<
size_t,
size_t>> FindEach (const
RegularExpression& regEx) const;
790 nonvirtual Containers::Sequence<
size_t> FindEach (const
String& string2SearchFor, CompareOptions co = eWithCase) const;
833 nonvirtual optional<
size_t> RFind (
Character c) const noexcept;
834 nonvirtual optional<
size_t> RFind (const
String& subString) const;
840 nonvirtual
String Replace (
size_t from,
size_t to, const
String& replacement) const;
841 nonvirtual
String Replace (pair<
size_t,
size_t> fromTo, const
String& replacement) const;
874 nonvirtual
String ReplaceAll (const
String& string2SearchFor, const
String& with, CompareOptions co = eWithCase) const;
875 nonvirtual
String ReplaceAll (const function<
bool (
Character)>& replaceCharP, const
String& with) const;
882 nonvirtual
String NormalizeTextToNL () const;
891 nonvirtual
String NormalizeSpace (
Character useSpaceCharacter = ' ') const;
944 nonvirtual Containers::Sequence<
String> Tokenize () const;
945 nonvirtual Containers::Sequence<
String> Tokenize (const function<
bool (
Character)>& isTokenSeperator) const;
947 nonvirtual Containers::Sequence<
String> Tokenize (const Containers::Set<
Character>& delimiters) const;
957 nonvirtual Containers::Sequence<
String> AsLines () const;
971 nonvirtual Containers::Sequence<
String> Grep (const
String& fgrepArg) const;
986 nonvirtual optional<
String> Col (
size_t i) const;
993 nonvirtual
String ColValue (
size_t i, const
String& valueIfMissing = {})
const;
1002 nonvirtual
String LTrim (
bool (*shouldBeTrimmed) (
Character) = Character::IsWhitespace)
const;
1016 nonvirtual
String RTrim (
bool (*shouldBeTrimmed) (
Character) = Character::IsWhitespace)
const;
1022 nonvirtual
String Trim (
bool (*shouldBeTrimmed) (
Character) = Character::IsWhitespace)
const;
1042 static String Join (
const Iterable<String>& list,
const String& separator =
", "sv);
1049 nonvirtual
String ToLowerCase ()
const;
1056 nonvirtual
String ToUpperCase ()
const;
1062 nonvirtual
bool IsWhitespace ()
const;
1088 template <IUNICODECanAlwaysConvertTo CHAR_T>
1089 nonvirtual span<CHAR_T>
CopyTo (span<CHAR_T> s)
const
1090 requires (not is_const_v<CHAR_T>);
1119 template <
typename T>
1129 nonvirtual
string AsNarrowString (const locale& l) const;
1141 template <typename T = u8string>
1142 nonvirtual T AsUTF8 () const
1143 requires (same_as<T,
string> or same_as<T, u8string>);
1159 template <typename T = u16string>
1160 nonvirtual T AsUTF16 () const
1161 requires (same_as<T, u16string> or (sizeof (
wchar_t) == sizeof (
char16_t) and same_as<T, wstring>));
1177 template <typename T = u32string>
1178 nonvirtual T AsUTF32 () const
1179 requires (same_as<T, u32string> or (sizeof (
wchar_t) == sizeof (
char32_t) and same_as<T, wstring>));
1188 nonvirtual
SDKString AsSDKString () const;
1199 nonvirtual
string AsNarrowSDKString () const;
1221 template <typename T =
string>
1222 nonvirtual T AsASCII () const
1223 requires requires (T* into) {
1224 { into->empty () } -> same_as<bool>;
1225 { into->push_back (
ASCII{0}) };
1239 template <
typename T =
string>
1241 requires requires (T* into) {
1242 { into->empty () } -> same_as<bool>;
1243 { into->push_back (
ASCII{0}) };
1276 StorageCodePointType fInCP;
1278 span<const ASCII> fAscii;
1279 span<const Latin1> fSingleByteLatin1;
1280 span<const char16_t> fChar16;
1281 span<const char32_t> fChar32;
1299 template <IUNICODECanUnambiguouslyConvertFrom CHAR_TYPE = ASCII>
1315 template <IUNICODECanUnambiguouslyConvertFrom CHAR_TYPE>
1316 static optional<span<const CHAR_TYPE>> PeekData (
const PeekSpanData& pds);
1317 template <IUNICODECanUnambiguouslyConvertFrom CHAR_TYPE>
1318 nonvirtual optional<span<const CHAR_TYPE>> PeekData ()
const;
1345 template <IUNICODECanAlwaysConvertTo CHAR_TYPE,
size_t STACK_BUFFER_SZ>
1347 template <IUNICODECanAlwaysConvertTo CHAR_TYPE,
size_t STACK_BUFFER_SZ>
1357 struct ThreeWayComparer;
1367 nonvirtual
bool operator== (
const String& rhs)
const;
1368 template <IConvertibleToString T>
1369 nonvirtual
bool operator== (T&& rhs)
const
1370 requires (not same_as<remove_cvref_t<T>,
String>);
1379 nonvirtual strong_ordering operator<=> (
const String& rhs)
const;
1380 template <IConvertibleToString T>
1381 nonvirtual strong_ordering operator<=> (T&& rhs)
const
1382 requires (not same_as<remove_cvref_t<T>,
String>);
1390 static constexpr size_t npos =
static_cast<size_t> (-1);
1396 nonvirtual
size_t length () const noexcept;
1423 nonvirtual tuple<const
wchar_t*, wstring_view> c_str (Memory::StackBuffer<
wchar_t>* possibleBackingStore) const;
1433 nonvirtual
size_t find (
Character c,
size_t startAt = 0) const;
1434 nonvirtual
size_t find (const
String& s,
size_t startAt = 0) const;
1444 nonvirtual
size_t rfind (
Character c) const;
1474 nonvirtual
String substr (
size_t from,
size_t count = npos) const;
1478 [[deprecated ("Since Stroika v3.0d13 - if you must use c_str() - use the overload taking StackBuffer arg), or use As<wstring> "
1479 "().c_str ()")]] const
wchar_t*
1481 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder::SetAt")]]
void SetCharAt (
Character c,
size_t i);
1482 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void erase (
size_t from = 0);
1483 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void erase (
size_t from,
size_t count);
1484 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void push_back (
wchar_t c);
1488 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void Append (const
wchar_t* s);
1489 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void Append (const
wchar_t* from, const
wchar_t* to);
1491 template <typename CHAR_T>
1492 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void Append (span<const CHAR_T> s)
1493 requires (same_as<CHAR_T,
Character> or same_as<CHAR_T,
char32_t>);
1496 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
String& operator+= (const
wchar_t* appendageCStr);
1497 [[deprecated ("Since Stroika v3.0d12 - just use a b
String{}
")]] void clear ()
1501 template <typename T>
1502 [[deprecated ("Since Stroika v3.0d2, just use 0 arg version)
")]] void As (T* into) const
1503 requires (IBasicUNICODEStdString<T> or same_as<T, String>)
1505 *into = this->As<T> ();
1507 [[deprecated ("Since Stroika v3.0d2, just use 1 arg version)
")]] void AsNarrowString (const locale& l, string* into) const
1509 *into = this->AsNarrowString (l);
1511 template <typename T = u8string>
1512 [[deprecated ("Since Stroika v3.0d2 - use AsUTF8/0
")]] void AsUTF8 (T* into) const
1513 requires (same_as<T, string> or same_as<T, u8string>)
1515 *into = this->AsUTF8 ();
1517 template <typename T = u16string>
1518 [[deprecated ("Since Stroika v3.0d2 - use AsUTF16/0
")]] void AsUTF16 (T* into) const
1519 requires (same_as<T, u16string> or (sizeof (wchar_t) == sizeof (char16_t) and same_as<T, wstring>))
1523 template <typename T = u32string>
1524 [[deprecated ("Since Stroika v3.0d2 - use AsUTF32/0
")]] void AsUTF32 (T* into) const
1525 requires (same_as<T, u32string> or (sizeof (wchar_t) == sizeof (char32_t) and same_as<T, wstring>))
1529 [[deprecated ("Since Stroika v3.0d2 - just use /0
")]] void AsSDKString (SDKString* into) const
1531 *into = AsSDKString ();
1533 [[deprecated ("Since Stroika v3.0d2 - just use /0
")]] void AsNarrowSDKString (string* into) const
1535 *into = SDK2Narrow (AsSDKString ());
1537 template <typename T = string>
1538 [[deprecated ("Since v3.0d2 use /0
")]] void AsASCII (T* into) const
1539 requires (same_as<T, string> or same_as<T, Memory::StackBuffer<char>>)
1541 if (not AsASCIIQuietly (into)) {
1542 ThrowInvalidAsciiException_ ();
1545 template <typename T = string>
1546 [[deprecated ("Since v3.0d2 use /0 overload
")]] bool AsASCIIQuietly (T* into) const
1547 requires (same_as<T, string> or same_as<T, Memory::StackBuffer<char>>)
1549 auto r = this->AsASCIIQuietly ();
1558 [[deprecated ("Since Stroika v3.0d5 use
StringShorteningPreference argument
")]] String LimitLength (size_t maxLen, bool keepLeft) const
1560 return LimitLength (maxLen, keepLeft ? StringShorteningPreference::ePreferKeepLeft : StringShorteningPreference::ePreferKeepRight);
1562 [[deprecated ("Since Stroika v3.0d5 use
StringShorteningPreference argument
")]] String LimitLength (size_t maxLen, bool keepLeft,
1563 const String& ellipsis) const
1565 return LimitLength (maxLen, keepLeft ? StringShorteningPreference::ePreferKeepLeft : StringShorteningPreference::ePreferKeepRight, ellipsis);
1567 template <typename CHAR_T>
1568 [[deprecated ("Since Stroika v3.0d1,
String{}
")]] static String FromASCII (span<const CHAR_T> s)
1572 template <typename CHAR_T>
1573 [[deprecated ("Since Stroika v3.0d1, String{}
")]] static String FromASCII (const CHAR_T* cString)
1575 return String{cString};
1577 template <IStdBasicStringCompatibleCharacter CHAR_T>
1578 [[deprecated ("Since Stroika v3.0d1, String{}
")]] static String FromASCII (const basic_string<CHAR_T>& str)
1582 [[deprecated ("Since Stroika v3.0d1, use span{} overload
for this")]] static String FromASCII (const char* from, const char* to)
1584 return String{span{from, to}};
1586 [[deprecated ("Since Stroika v3.0d1, use span{} overload
for this")]] static String FromASCII (const wchar_t* from, const wchar_t* to)
1588 return String{span{from, to}};
1590 [[deprecated ("Since Stroika v3.0d1, use span overloads
")]] String InsertAt (const wchar_t* from, const wchar_t* to, size_t at) const
1592 Memory::StackBuffer<Character> buf{Memory::eUninitialized, UTFConvert::ComputeTargetBufferSize<Character> (span{from, to})};
1593 return InsertAt (UTFConvert::kThe.ConvertSpan (span{from, to}, span{buf}), at);
1595 [[deprecated ("Since Stroika v3.0d1, use span overloads
")]] String InsertAt (const Character* from, const Character* to, size_t at) const
1597 return InsertAt (span{from, to}, at);
1599 [[deprecated ("Since Stroika v3.0d1, use span{} overload
for this")]] static String FromLatin1 (const char* start, const char* end)
1601 return FromLatin1 (span{start, end});
1603 [[deprecated ("Since Stroika v3.0d1, use span{} constructor
for this")]] static String FromNarrowString (const char* from,
1604 const char* to, const locale& l)
1606 return FromNarrowString (span{from, to}, l);
1608 [[deprecated ("Since Stroika v3.0d1, use span{} constructor
for this")]] static String FromNarrowSDKString (const char* from, const char* to)
1610 return FromNarrowSDKString (span{from, to});
1612 template <IUNICODECanAlwaysConvertTo CHAR_T>
1613 [[deprecated ("Since Stroika v3.0d1, use span{} constructor
for this")]] String (const CHAR_T* from, const CHAR_T* to)
1614 : String{span<const CHAR_T>{from, to}}
1618 "Since Stroika v3.0d1 - use As<wstring> ().
c_str () or other c_str() overload (*UNSAFE TO USE*)")]] nonvirtual const
wchar_t*
1619 c_str () const noexcept;
1620 [[deprecated ("Since Stroika v3.0 - use span{} overloads
")]] inline static String FromSDKString (const SDKChar* from, const SDKChar* to)
1622 return FromSDKString (span{from, to});
1624 [[deprecated ("Since Stroika v3.0 - use span{} overloads
")]] static String FromUTF8 (const char* from, const char* to)
1626 return FromUTF8 (span{from, to});
1628 [[deprecated ("Since Stroika v3.0 - use span{} overloads
")]] static String FromUTF8 (const char8_t* from, const char8_t* to)
1630 return FromUTF8 (span{from, to});
1632 template <typename T = string>
1633 [[deprecated ("Since Stroika v3.0d1 - use Character::AsAsciiQuietly
")]] static bool AsASCIIQuietly (const wchar_t* fromStart,
1634 const wchar_t* fromEnd, T* into)
1636 return Character::AsASCIIQuietly (span<const wchar_t>{fromStart, fromEnd}, into);
1639 "Since Stroika v3.0d1 due to http:
1641 [[deprecated (
"Since Stroika v3.0d8 - use RemoveFirstIf")]] String Remove (Character c)
const
1643 return RemoveFirstIf (c);
1645 [[deprecated (
"Since Stroika v3.0d8 - use RemoveFirstIf")]] String Remove (
const String& subString)
const
1647 return RemoveFirstIf (subString);
1651 static shared_ptr<_IRep> mkEmpty_ ();
1663 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
1664 static shared_ptr<_IRep> mk_ (span<const CHAR_T> s);
1665 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
1666 static shared_ptr<_IRep> mk_ (Iterable<CHAR_T> it);
1667 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
1668 static shared_ptr<_IRep> mk_ (span<CHAR_T> s);
1669 template <IStdBasicStringCompatibleCharacter CHAR_T>
1670 static shared_ptr<_IRep> mk_ (basic_string<CHAR_T>&& s);
1679 template <
typename CHAR_T>
1680 static shared_ptr<_IRep> mk_nocheck_ (span<const CHAR_T> s)
1681 requires (same_as<CHAR_T, ASCII> or same_as<CHAR_T, Latin1> or same_as<CHAR_T, char16_t> or same_as<CHAR_T, char32_t>);
1684 template <
unsigned_
integral T>
1685 nonvirtual
size_t SubString_adjust_ (T fromOrTo,
size_t myLength)
const;
1686 template <
signed_
integral T>
1687 nonvirtual
size_t SubString_adjust_ (T fromOrTo,
size_t myLength)
const;
1690 nonvirtual String SubString_ (
const _SafeReadRepAccessor& thisAccessor,
size_t from,
size_t to)
const;
1693 nonvirtual
void _AssertRepValidType ()
const;
1696 [[noreturn]]
static void ThrowInvalidAsciiException_ ();