3#include <Foundation/Strings/StringConversion.h>
12 : m_Data(rhs.GetAllocator())
20 : m_Data(rhs.GetAllocator())
24 *
this = std::move(rhs);
75 m_Data = std::move(rhs.m_Data);
96 char szChar[6] = {0, 0, 0, 0, 0, 0};
97 char* pChar = &szChar[0];
100 plUInt32 uiCharLen = (plUInt32)(pChar - szChar);
101 plUInt32 uiOldCount = m_Data.
GetCount();
104 for (plUInt32 i = 0; i < uiCharLen; i++)
106 m_Data[uiOldCount + i] = szChar[i];
108 m_Data[uiOldCount + uiCharLen] =
'\0';
113 char szChar[6] = {0, 0, 0, 0, 0, 0};
114 char* pChar = &szChar[0];
120inline void plStringBuilder::Append(
const wchar_t* pData1,
const wchar_t* pData2,
const wchar_t* pData3,
const wchar_t* pData4,
const wchar_t* pData5,
const wchar_t* pData6)
131 Append(s1.GetView(), s2.GetView(), s3.GetView(), s4.GetView(), s5.GetView(), s6.GetView());
134inline void plStringBuilder::Prepend(
const wchar_t* pData1,
const wchar_t* pData2,
const wchar_t* pData3,
const wchar_t* pData4,
const wchar_t* pData5,
const wchar_t* pData6)
145 Prepend(s1.GetView(), s2.GetView(), s3.GetView(), s4.GetView(), s5.GetView(), s6.GetView());
150 PL_ASSERT_DEBUG(!m_Data.
IsEmpty(),
"plStringBuilder has been corrupted, the array can never be empty.");
155inline void plStringBuilder::AppendTerminator()
180 PL_ASSERT_DEV(ref_it.IsValid(),
"The given character iterator does not point to a valid character.");
182 "The given character iterator does not point into this string. It was either created from another string, or this string "
183 "has been reallocated in the mean time.");
189 char* pPos =
const_cast<char*
>(ref_it.GetData());
190 *pPos = uiCharacter & 0xFF;
194 ChangeCharacterNonASCII(ref_it, uiCharacter);
212template <
typename Container>
226 while (pStartData < pEndData)
238#include <Foundation/Strings/Implementation/AllStrings_inl.h>
Base class for all memory allocators.
Definition Allocator.h:23
void PushBack(const T &value)
Pushes value at the end of the array.
Definition ArrayBase_inl.h:333
T * GetData()
Returns a pointer to the array data, or nullptr if the array is empty.
Definition ArrayBase_inl.h:423
void SetCountUninitialized(plUInt32 uiCount)
Resizes the array to have exactly uiCount elements. Extra elements might be uninitialized.
Definition ArrayBase_inl.h:155
T & PeekBack()
Returns the last element of the array.
Definition ArrayBase_inl.h:388
bool IsEmpty() const
Returns true, if the array does not contain any elements.
Definition ArrayBase_inl.h:178
plUInt32 GetCount() const
Returns the number of active elements in the array.
Definition ArrayBase_inl.h:172
plAllocator * GetAllocator() const
Returns the allocator that is used by this instance.
Definition DynamicArray.h:53
void Reserve(plUInt32 uiCapacity)
Expands the array so it can at least store the given capacity.
Definition DynamicArray_inl.h:179
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
void Clear()
Resets this string to be empty. Does not deallocate any previously allocated data,...
Definition StringBuilder_inl.h:88
plAllocator * GetAllocator() const
Returns the allocator that is used by this object.
Definition StringBuilder_inl.h:51
plStringBuilder(plAllocator *pAllocator=plFoundation::GetDefaultAllocator())
Initializes the string to be empty. No data is allocated, but the plStringBuilder ALWAYS creates an a...
Definition StringBuilder_inl.h:5
const char * GetData() const
Returns a char pointer to the internal Utf8 data.
Definition StringBuilder_inl.h:148
plUInt32 GetElementCount() const
Returns the number of bytes that this string takes up.
Definition StringBuilder_inl.h:78
void Append(plUInt32 uiChar)
Appends a single Utf32 character.
Definition StringBuilder_inl.h:94
void Insert(const char *szInsertAtPos, plStringView sTextToInsert)
A wrapper around ReplaceSubString. Will insert the given string at szInsertAtPos.
Definition StringBuilder_inl.h:202
void ToUpper()
Converts all characters to upper case. Might move the string data around, so all iterators to the dat...
Definition StringBuilder_inl.h:162
void Prepend(plUInt32 uiChar)
Prepends a single Utf32 character.
Definition StringBuilder_inl.h:111
void operator=(const plStringBuilder &rhs)
Copies the given string into this one.
Definition StringBuilder_inl.h:68
void Set(plStringView sData1)
Sets the string to the given string.
Definition StringBuilder.cpp:16
plUInt32 GetCharacterCount() const
Returns the number of characters of which this string consists. Might be less than GetElementCount,...
Definition StringBuilder_inl.h:83
void ReplaceSubString(const char *szStartPos, const char *szEndPos, plStringView sReplaceWith)
Replaces the string that starts at szStartPos and ends at szEndPos with the string szReplaceWith.
Definition StringBuilder.cpp:427
void Reserve(plUInt32 uiNumElements)
Reserves uiNumElements bytes.
Definition StringBuilder_inl.h:197
void Remove(const char *szRemoveFromPos, const char *szRemoveToPos)
A wrapper around ReplaceSubString. Will remove the substring which starts at szRemoveFromPos and ends...
Definition StringBuilder_inl.h:207
void ChangeCharacter(iterator &ref_it, plUInt32 uiCharacter)
Changes the single character in this string, to which the iterator currently points.
Definition StringBuilder_inl.h:178
void ToLower()
Converts all characters to lower case. Might move the string data around, so all iterators to the dat...
Definition StringBuilder_inl.h:170
A small string class that converts any other encoding to Utf8.
Definition StringConversion.h:47
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 ToLowerString(char *szString, const char *pStringEnd=plUnicodeUtils::GetMaxStringEnd< char >())
Converts a (UTF-8) string in-place to lower case.
Definition StringUtils.cpp:176
static plUInt32 ToUpperString(char *szString, const char *pStringEnd=plUnicodeUtils::GetMaxStringEnd< char >())
Converts a (UTF-8) string in-place to upper case.
Definition StringUtils.cpp:158
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
static plUInt32 DecodeUtf8ToUtf32(ByteIterator &ref_szUtf8Iterator)
Decodes the next character from the given Utf8 sequence to Utf32 and increments the iterator as far a...
Definition UnicodeUtils_inl.h:51
static bool IsASCII(plUInt32 uiChar)
Returns whether a character is a pure ASCII character (only the first 7 Bits are used)
Definition UnicodeUtils_inl.h:23
static void EncodeUtf32ToUtf8(plUInt32 uiUtf32, ByteIterator &ref_szUtf8Output)
Encodes the given Utf32 character to Utf8 and writes as many bytes to the output iterator,...
Definition UnicodeUtils_inl.h:92
static bool IsValidUtf8(const char *szString, const char *szStringEnd=GetMaxStringEnd< char >())
Returns false if the given string does not contain a completely valid Utf8 string.
Definition UnicodeUtils_inl.h:150
static bool RepairNonUtf8Text(const char *pStartData, const char *pEndData, Container &out_result)
Checks an array of char's, whether it is a valid Utf8 string. If not, it repairs the string,...
Definition StringBuilder_inl.h:213
[internal] Small helper class to append bytes to some arbitrary container. Used for Utf8 string build...
Definition UnicodeUtils.h:111