3template <plUInt16 Size>
10template <plUInt16 Size>
17template <plUInt16 Size>
24template <plUInt16 Size>
31template <plUInt16 Size>
38template <plUInt16 Size>
45template <plUInt16 Size>
48template <plUInt16 Size>
51 m_Data.SetCountUninitialized(1);
55template <plUInt16 Size>
58 PL_ASSERT_DEBUG(!m_Data.IsEmpty(),
"plHybridString has been corrupted, the array can never be empty. This can happen when you access a "
59 "string that was previously std::move'd into another string.");
64template <plUInt16 Size>
67 return m_Data.GetCount() - 1;
70template <plUInt16 Size>
76template <plUInt16 Size>
81 if (szString + uiElementCount < m_Data.GetData() || szString >= m_Data.GetData() + m_Data.GetCount())
88 PL_ASSERT_DEBUG(uiElementCount < m_Data.GetCount(),
"Invalid copy of overlapping string data.");
91 m_Data.SetCountUninitialized(uiElementCount + 1);
95template <plUInt16 Size>
104template <plUInt16 Size>
110 m_Data = std::move(rhs.m_Data);
113template <plUInt16 Size>
116 plStringUtf8 sConversion(szString, m_Data.GetAllocator());
117 *
this = sConversion.GetData();
120template <plUInt16 Size>
124 "Can't assign string a value that points to ourself!");
130template <plUInt16 Size>
133 const char* szStart = GetData();
137 const char* szEnd = szStart;
143template <plUInt16 Size>
146 return GetSubString(0, uiNumCharacters);
149template <plUInt16 Size>
152 const plUInt32 uiMaxCharacterCount = GetCharacterCount();
153 PL_ASSERT_DEV(uiNumCharacters < uiMaxCharacterCount,
"The string only contains {0} characters, cannot return the last {1} characters.",
154 uiMaxCharacterCount, uiNumCharacters);
155 return GetSubString(uiMaxCharacterCount - uiNumCharacters, uiNumCharacters);
159template <plUInt16 Size,
typename A>
165template <plUInt16 Size,
typename A>
171template <plUInt16 Size,
typename A>
177template <plUInt16 Size,
typename A>
183template <plUInt16 Size,
typename A>
189template <plUInt16 Size,
typename A>
195template <plUInt16 Size,
typename A>
201template <plUInt16 Size,
typename A>
207template <plUInt16 Size,
typename A>
213template <plUInt16 Size,
typename A>
219template <plUInt16 Size,
typename A>
225template <plUInt16 Size,
typename A>
231template <plUInt16 Size,
typename A>
237template <plUInt16 Size,
typename A>
243template <plUInt16 Size,
typename A>
249template <plUInt16 Size,
typename A>
255#if PL_ENABLED(PL_INTEROP_STL_STRINGS)
257template <plUInt16 Size>
263template <plUInt16 Size>
269template <plUInt16 Size>
278 m_Data.SetCountUninitialized(((plUInt32)rhs.size() + 1));
283template <plUInt16 Size>
286 *
this = std::string_view(rhs);
289template <plUInt16 Size,
typename A>
295template <plUInt16 Size,
typename A>
301template <plUInt16 Size,
typename A>
307template <plUInt16 Size,
typename A>
315#include <Foundation/Strings/Implementation/AllStrings_inl.h>
Base class for all memory allocators.
Definition Allocator.h:23
A small string class that converts any other encoding to Utf8.
Definition StringConversion.h:47
static constexpr plUInt32 GetStringElementCount(const T *pString)
Returns the number of elements of type T that the string contains, until it hits an element that is z...
Definition StringUtils_inl.h:45
static plUInt32 GetCharacterCount(const char *szUtf8, const char *pStringEnd=plUnicodeUtils::GetMaxStringEnd< char >())
Returns the number of characters (not Bytes!) in a Utf8 string (excluding the zero terminator),...
Definition StringUtils_inl.h:81
static plUInt32 Copy(char *szDest, plUInt32 uiDstSize, const char *szSource, const char *pSourceEnd=plUnicodeUtils::GetMaxStringEnd< char >())
Copies the string from szSource into the given buffer, which can hold at least uiDstSize bytes.
Definition StringUtils.cpp:362
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
plUInt32 GetElementCount() const
Returns the number of bytes from the start position up to its end.
Definition StringView.h:93
const char * GetEndPointer() const
Returns the end of the view range. This will point to the byte AFTER the last character.
Definition StringView.h:108
const char * GetStartPointer() const
Returns the start of the view range.
Definition StringView.h:102
static plResult MoveToNextUtf8(const char *&ref_szUtf8, plUInt32 uiNumCharacters=1)
Moves the given string pointer ahead to the next Utf8 character sequence.
Definition UnicodeUtils_inl.h:201
A string class for storing and passing around strings.
Definition String.h:28
plHybridStringBase(plAllocator *pAllocator)
Creates an empty string.
Definition String_inl.h:4
const char * GetData() const
Returns a pointer to the internal Utf8 string.
Definition String_inl.h:56
plUInt32 GetElementCount() const
Returns the amount of bytes that this string takes (excluding the '\0' terminator).
Definition String_inl.h:65
plStringView GetFirst(plUInt32 uiNumCharacters) const
Returns a view to the sub-string containing the first uiNumCharacters characters of this string.
Definition String_inl.h:144
plUInt32 GetCharacterCount() const
Returns the number of characters in this string. Might be less than GetElementCount,...
Definition String_inl.h:71
~plHybridStringBase()
Destructor.
plStringView GetSubString(plUInt32 uiFirstCharacter, plUInt32 uiNumCharacters) const
Returns a view to a sub-string of this string, starting at character uiFirstCharacter,...
Definition String_inl.h:131
void Clear()
Resets this string to an empty string.
Definition String_inl.h:49
void operator=(const plHybridStringBase &rhs)
Copies the data from rhs.
Definition String_inl.h:96
plStringView GetLast(plUInt32 uiNumCharacters) const
Returns a view to the sub-string containing the last uiNumCharacters characters of this string.
Definition String_inl.h:150
PL_ALWAYS_INLINE void IgnoreResult()
Used to silence compiler warnings, when success or failure doesn't matter.
Definition Types.h:69