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>
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>
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>
314 requires (same_as<remove_cv_t<CHAR_T>,
char8_t> or same_as<remove_cv_t<CHAR_T>,
char>);
377 template <
size_t SIZE, IUNICODECanUnambiguouslyConvertFrom CHAR_T>
379 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
381 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
398 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
400 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
402 template <IStdBasicStringCompatibleCharacter CHAR_T>
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;
571 template <typename SZ>
573 template <typename SZ1, typename SZ2>
587 template <typename SZ>
589 template <typename SZ1, typename SZ2>
617 nonvirtual
bool Contains (const
String& subString, CompareOptions co = eWithCase) const;
623 nonvirtual
bool ContainsAny (
Iterable<
Character> cs, CompareOptions co = eWithCase) const;
639 nonvirtual
bool StartsWith (const
String& subString, CompareOptions co = eWithCase) const;
654 nonvirtual
bool EndsWith (const
Character& c, CompareOptions co = eWithCase) const;
655 nonvirtual
bool EndsWith (const
String& subString, CompareOptions co = eWithCase) const;
731 template <Common::IAnyOf<optional<
String>*,
String*, nullptr_t>... OPTIONAL_STRINGS>
768 nonvirtual optional<
size_t>
Find (
Character c, CompareOptions co = eWithCase) const;
769 nonvirtual optional<
size_t>
Find (
Character c,
size_t startAt, CompareOptions co = eWithCase) const;
770 nonvirtual optional<
size_t>
Find (const
String& subString, CompareOptions co = eWithCase) const;
771 nonvirtual optional<
size_t>
Find (const
String& subString,
size_t startAt, CompareOptions co = eWithCase) const;
772 nonvirtual optional<pair<
size_t,
size_t>>
Find (const
RegularExpression& regEx,
size_t startAt = 0) const;
799 nonvirtual Containers::Sequence<
size_t>
FindEach (const
String& string2SearchFor, CompareOptions co = eWithCase) const;
843 nonvirtual optional<
size_t>
RFind (const
String& subString) const;
980 nonvirtual Containers::Sequence<
String>
Grep (const
String& fgrepArg) const;
995 nonvirtual optional<
String>
Col (
size_t i) const;
1051 static String Join (
const Iterable<String>& list,
const String& separator =
", "sv);
1097 template <IUNICODECanAlwaysConvertTo CHAR_T>
1098 nonvirtual span<CHAR_T>
CopyTo (span<CHAR_T> s)
const
1099 requires (not is_const_v<CHAR_T>);
1128 template <
typename T>
1150 template <typename T = u8string>
1152 requires (same_as<T,
string> or same_as<T, u8string>);
1168 template <typename T = u16string>
1170 requires (same_as<T, u16string> or (sizeof (
wchar_t) == sizeof (
char16_t) and same_as<T, wstring>));
1186 template <typename T = u32string>
1188 requires (same_as<T, u32string> or (sizeof (
wchar_t) == sizeof (
char32_t) and same_as<T, wstring>));
1230 template <typename T =
string>
1232 requires requires (T* into) {
1233 { into->empty () } -> same_as<bool>;
1234 { into->push_back (
ASCII{0}) };
1248 template <
typename T =
string>
1250 requires requires (T* into) {
1251 { into->empty () } -> same_as<bool>;
1252 { into->push_back (
ASCII{0}) };
1287 span<const ASCII> fAscii;
1288 span<const Latin1> fSingleByteLatin1;
1289 span<const char16_t> fChar16;
1290 span<const char32_t> fChar32;
1308 template <IUNICODECanUnambiguouslyConvertFrom CHAR_TYPE = ASCII>
1324 template <IUNICODECanUnambiguouslyConvertFrom CHAR_TYPE>
1326 template <IUNICODECanUnambiguouslyConvertFrom CHAR_TYPE>
1327 nonvirtual optional<span<const CHAR_TYPE>>
PeekData ()
const;
1354 template <IUNICODECanAlwaysConvertTo CHAR_TYPE,
size_t STACK_BUFFER_SZ>
1356 template <IUNICODECanAlwaysConvertTo CHAR_TYPE,
size_t STACK_BUFFER_SZ>
1366 struct ThreeWayComparer;
1377 template <IConvertibleToString T>
1379 requires (not same_as<remove_cvref_t<T>,
String>);
1389 template <IConvertibleToString T>
1390 nonvirtual strong_ordering
operator<=> (T&& rhs)
const
1391 requires (not same_as<remove_cvref_t<T>,
String>);
1399 static constexpr size_t npos =
static_cast<size_t> (-1);
1405 nonvirtual
size_t length () const noexcept;
1432 nonvirtual tuple<const
wchar_t*, wstring_view> c_str (Memory::StackBuffer<
wchar_t>* possibleBackingStore) const;
1442 nonvirtual
size_t find (
Character c,
size_t startAt = 0) const;
1443 nonvirtual
size_t find (const
String& s,
size_t startAt = 0) const;
1487 [[deprecated ("Since Stroika v3.0d13 - if you must use c_str() - use the overload taking StackBuffer arg), or use
As<wstring> "
1488 "().c_str ()")]] const
wchar_t*
1490 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder::SetAt")]]
void SetCharAt (
Character c,
size_t i);
1491 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void erase (
size_t from = 0);
1492 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void erase (
size_t from,
size_t count);
1493 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void push_back (
wchar_t c);
1497 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void Append (const
wchar_t* s);
1498 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void Append (const
wchar_t* from, const
wchar_t* to);
1500 template <typename CHAR_T>
1501 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
void Append (span<const CHAR_T> s)
1502 requires (same_as<CHAR_T,
Character> or same_as<CHAR_T,
char32_t>);
1505 [[deprecated ("Since Stroika v3.0d12 use
StringBuilder")]]
String& operator+= (const
wchar_t* appendageCStr);
1506 [[deprecated ("Since Stroika v3.0d12 - just use a b
String{}
")]] void clear ()
1510 template <typename T>
1511 [[deprecated ("Since Stroika v3.0d2, just use 0 arg version)
")]] void As (T* into) const
1512 requires (IBasicUNICODEStdString<T> or same_as<T, String>)
1514 *into = this->As<T> ();
1516 [[deprecated ("Since Stroika v3.0d2, just use 1 arg version)
")]] void AsNarrowString (const locale& l, string* into) const
1518 *into = this->AsNarrowString (l);
1520 template <typename T = u8string>
1521 [[deprecated ("Since Stroika v3.0d2 - use
AsUTF8/0
")]] void AsUTF8 (T* into) const
1522 requires (same_as<T, string> or same_as<T, u8string>)
1524 *into = this->AsUTF8 ();
1526 template <typename T = u16string>
1527 [[deprecated ("Since Stroika v3.0d2 - use
AsUTF16/0
")]] void AsUTF16 (T* into) const
1528 requires (same_as<T, u16string> or (sizeof (wchar_t) == sizeof (char16_t) and same_as<T, wstring>))
1532 template <typename T = u32string>
1533 [[deprecated ("Since Stroika v3.0d2 - use
AsUTF32/0
")]] void AsUTF32 (T* into) const
1534 requires (same_as<T, u32string> or (sizeof (wchar_t) == sizeof (char32_t) and same_as<T, wstring>))
1538 [[deprecated ("Since Stroika v3.0d2 - just use /0
")]] void AsSDKString (SDKString* into) const
1540 *into = AsSDKString ();
1542 [[deprecated ("Since Stroika v3.0d2 - just use /0
")]] void AsNarrowSDKString (string* into) const
1544 *into = SDK2Narrow (AsSDKString ());
1546 template <typename T = string>
1547 [[deprecated ("Since v3.0d2 use /0
")]] void AsASCII (T* into) const
1548 requires (same_as<T, string> or same_as<T, Memory::StackBuffer<char>>)
1550 if (not AsASCIIQuietly (into)) {
1551 ThrowInvalidAsciiException_ ();
1554 template <typename T = string>
1555 [[deprecated ("Since v3.0d2 use /0 overload
")]] bool AsASCIIQuietly (T* into) const
1556 requires (same_as<T, string> or same_as<T, Memory::StackBuffer<char>>)
1558 auto r = this->AsASCIIQuietly ();
1567 [[deprecated ("Since Stroika v3.0d5 use
StringShorteningPreference argument
")]] String LimitLength (size_t maxLen, bool keepLeft) const
1569 return LimitLength (maxLen, keepLeft ? StringShorteningPreference::ePreferKeepLeft : StringShorteningPreference::ePreferKeepRight);
1571 [[deprecated ("Since Stroika v3.0d5 use
StringShorteningPreference argument
")]] String LimitLength (size_t maxLen, bool keepLeft,
1572 const String& ellipsis) const
1574 return LimitLength (maxLen, keepLeft ? StringShorteningPreference::ePreferKeepLeft : StringShorteningPreference::ePreferKeepRight, ellipsis);
1576 template <typename CHAR_T>
1577 [[deprecated ("Since Stroika v3.0d1,
String{}
")]] static String FromASCII (span<const CHAR_T> s)
1581 template <typename CHAR_T>
1582 [[deprecated ("Since Stroika v3.0d1,
String{}
")]] static String FromASCII (const CHAR_T* cString)
1584 return String{cString};
1586 template <IStdBasicStringCompatibleCharacter CHAR_T>
1587 [[deprecated ("Since Stroika v3.0d1,
String{}
")]] static String FromASCII (const basic_string<CHAR_T>& str)
1591 [[deprecated ("Since Stroika v3.0d1, use span{} overload
for this")]] static String FromASCII (const char* from, const char* to)
1593 return String{span{from, to}};
1595 [[deprecated ("Since Stroika v3.0d1, use span{} overload
for this")]] static String FromASCII (const wchar_t* from, const wchar_t* to)
1597 return String{span{from, to}};
1599 [[deprecated ("Since Stroika v3.0d1, use span overloads
")]] String InsertAt (const wchar_t* from, const wchar_t* to, size_t at) const
1601 Memory::StackBuffer<Character> buf{Memory::eUninitialized, UTFConvert::ComputeTargetBufferSize<Character> (span{from, to})};
1602 return InsertAt (UTFConvert::kThe.ConvertSpan (span{from, to}, span{buf}), at);
1604 [[deprecated ("Since Stroika v3.0d1, use span overloads
")]] String InsertAt (const Character* from, const Character* to, size_t at) const
1606 return InsertAt (span{from, to}, at);
1608 [[deprecated ("Since Stroika v3.0d1, use span{} overload
for this")]] static String FromLatin1 (const char* start, const char* end)
1610 return FromLatin1 (span{start, end});
1612 [[deprecated ("Since Stroika v3.0d1, use span{} constructor
for this")]] static String FromNarrowString (const char* from,
1613 const char* to, const locale& l)
1615 return FromNarrowString (span{from, to}, l);
1617 [[deprecated ("Since Stroika v3.0d1, use span{} constructor
for this")]] static String FromNarrowSDKString (const char* from, const char* to)
1619 return FromNarrowSDKString (span{from, to});
1621 template <IUNICODECanAlwaysConvertTo CHAR_T>
1622 [[deprecated ("Since Stroika v3.0d1, use span{} constructor
for this")]] String (const CHAR_T* from, const CHAR_T* to)
1623 : String{span<const CHAR_T>{from, to}}
1627 "Since Stroika v3.0d1 - use As<wstring> ().
c_str () or other
c_str() overload (*UNSAFE TO USE*)")]] nonvirtual const
wchar_t*
1628 c_str () const noexcept;
1629 [[deprecated ("Since Stroika v3.0 - use span{} overloads
")]] inline static String FromSDKString (const SDKChar* from, const SDKChar* to)
1631 return FromSDKString (span{from, to});
1633 [[deprecated ("Since Stroika v3.0 - use span{} overloads
")]] static String FromUTF8 (const char* from, const char* to)
1635 return FromUTF8 (span{from, to});
1637 [[deprecated ("Since Stroika v3.0 - use span{} overloads
")]] static String FromUTF8 (const char8_t* from, const char8_t* to)
1639 return FromUTF8 (span{from, to});
1641 template <typename T = string>
1642 [[deprecated ("Since Stroika v3.0d1 - use Character::AsAsciiQuietly
")]] static bool AsASCIIQuietly (const wchar_t* fromStart,
1643 const wchar_t* fromEnd, T* into)
1645 return Character::AsASCIIQuietly (span<const wchar_t>{fromStart, fromEnd}, into);
1648 "Since Stroika v3.0d1 due to http:
1650 [[deprecated (
"Since Stroika v3.0d8 - use RemoveFirstIf")]]
String Remove (Character c)
const
1654 [[deprecated (
"Since Stroika v3.0d8 - use RemoveFirstIf")]]
String Remove (
const String& subString)
const
1660 static shared_ptr<_IRep> mkEmpty_ ();
1672 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
1673 static shared_ptr<_IRep> mk_ (span<const CHAR_T> s);
1674 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
1675 static shared_ptr<_IRep> mk_ (Iterable<CHAR_T> it);
1676 template <IUNICODECanUnambiguouslyConvertFrom CHAR_T>
1677 static shared_ptr<_IRep> mk_ (span<CHAR_T> s);
1678 template <IStdBasicStringCompatibleCharacter CHAR_T>
1679 static shared_ptr<_IRep> mk_ (basic_string<CHAR_T>&& s);
1688 template <
typename CHAR_T>
1689 static shared_ptr<_IRep> mk_nocheck_ (span<const CHAR_T> s)
1690 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>);
1693 template <
unsigned_
integral T>
1694 nonvirtual
size_t SubString_adjust_ (T fromOrTo,
size_t myLength)
const;
1695 template <
signed_
integral T>
1696 nonvirtual
size_t SubString_adjust_ (T fromOrTo,
size_t myLength)
const;
1699 nonvirtual
String SubString_ (
const _SafeReadRepAccessor& thisAccessor,
size_t from,
size_t to)
const;
1702 nonvirtual
void _AssertRepValidType ()
const;
1705 [[noreturn]]
static void ThrowInvalidAsciiException_ ();