![]() |
ezEngine
Release 25.03
|
ezStringBuilder is a class that is meant for creating and modifying strings. More...
#include <StringBuilder.h>
Public Member Functions | |
ezStringBuilder (ezAllocator *pAllocator=ezFoundation::GetDefaultAllocator()) | |
Initializes the string to be empty. No data is allocated, but the ezStringBuilder ALWAYS creates an array on the stack. | |
ezStringBuilder (const ezStringBuilder &rhs) | |
Copies the given string into this one. | |
ezStringBuilder (ezStringBuilder &&rhs) noexcept | |
Moves the given string into this one. | |
template<ezUInt16 Size> | |
ezStringBuilder (const ezHybridStringBase< Size > &rhs) | |
Copies the given string into this one. | |
template<ezUInt16 Size, typename A > | |
ezStringBuilder (const ezHybridString< Size, A > &rhs) | |
Copies the given string into this one. | |
template<ezUInt16 Size> | |
ezStringBuilder (ezHybridStringBase< Size > &&rhs) | |
Moves the given string into this one. | |
template<ezUInt16 Size, typename A > | |
ezStringBuilder (ezHybridString< Size, A > &&rhs) | |
Moves the given string into this one. | |
ezStringBuilder (ezStringView sData1, ezStringView sData2, ezStringView sData3={}, ezStringView sData4={}, ezStringView sData5={}, ezStringView sData6={}) | |
Constructor that appends all the given strings. | |
ezStringBuilder (const char *szUTF8, ezAllocator *pAllocator=ezFoundation::GetDefaultAllocator()) | |
Copies the given Utf8 string into this one. | |
ezStringBuilder (const wchar_t *pWChar, ezAllocator *pAllocator=ezFoundation::GetDefaultAllocator()) | |
Copies the given wchar_t string into this one. | |
ezStringBuilder (ezStringView rhs, ezAllocator *pAllocator=ezFoundation::GetDefaultAllocator()) | |
Copies the given substring into this one. The ezStringView might actually be a substring of this very string. | |
void | operator= (const ezStringBuilder &rhs) |
Copies the given string into this one. | |
void | operator= (ezStringBuilder &&rhs) noexcept |
Moves the given string into this one. | |
void | operator= (const char *szUTF8) |
Copies the given Utf8 string into this one. | |
void | operator= (const wchar_t *pWChar) |
Copies the given wchar_t string into this one. | |
void | operator= (ezStringView rhs) |
Copies the given substring into this one. The ezStringView might actually be a substring of this very string. | |
template<ezUInt16 Size> | |
void | operator= (const ezHybridStringBase< Size > &rhs) |
Copies the given string into this one. | |
template<ezUInt16 Size, typename A > | |
void | operator= (const ezHybridString< Size, A > &rhs) |
Copies the given string into this one. | |
template<ezUInt16 Size> | |
void | operator= (ezHybridStringBase< Size > &&rhs) |
Moves the given string into this one. | |
template<ezUInt16 Size, typename A > | |
void | operator= (ezHybridString< Size, A > &&rhs) noexcept |
Moves the given string into this one. | |
ezAllocator * | GetAllocator () const |
Returns the allocator that is used by this object. | |
void | Clear () |
Resets this string to be empty. Does not deallocate any previously allocated data, as it might be reused later again. | |
const char * | GetData () const |
Returns a char pointer to the internal Utf8 data. | |
ezUInt32 | GetElementCount () const |
Returns the number of bytes that this string takes up. | |
ezUInt32 | GetCharacterCount () const |
Returns the number of characters of which this string consists. Might be less than GetElementCount, if it contains Utf8 multi-byte characters. More... | |
void | ToUpper () |
Converts all characters to upper case. Might move the string data around, so all iterators to the data will be invalid afterwards. | |
void | ToLower () |
Converts all characters to lower case. Might move the string data around, so all iterators to the data will be invalid afterwards. | |
void | ChangeCharacter (iterator &ref_it, ezUInt32 uiCharacter) |
Changes the single character in this string, to which the iterator currently points. More... | |
void | Set (ezStringView sData1) |
Sets the string to the given string. | |
void | Set (ezStringView sData1, ezStringView sData2) |
Sets the string by concatenating all given strings. | |
void | Set (ezStringView sData1, ezStringView sData2, ezStringView sData3) |
Sets the string by concatenating all given strings. | |
void | Set (ezStringView sData1, ezStringView sData2, ezStringView sData3, ezStringView sData4) |
Sets the string by concatenating all given strings. | |
void | Set (ezStringView sData1, ezStringView sData2, ezStringView sData3, ezStringView sData4, ezStringView sData5, ezStringView sData6={}) |
Sets the string by concatenating all given strings. | |
void | SetPath (ezStringView sData1, ezStringView sData2, ezStringView sData3={}, ezStringView sData4={}) |
Sets several path pieces. Makes sure they are always properly separated by a slash. | |
void | SetSubString_FromTo (const char *pStart, const char *pEnd) |
Copies the string starting at pStart up to pEnd (exclusive). | |
void | SetSubString_ElementCount (const char *pStart, ezUInt32 uiElementCount) |
Copies the string starting at pStart with a length of uiElementCount bytes. | |
void | SetSubString_CharacterCount (const char *pStart, ezUInt32 uiCharacterCount) |
Copies the string starting at pStart with a length of uiCharacterCount characters. | |
void | Append (ezUInt32 uiChar) |
Appends a single Utf32 character. | |
void | Append (const wchar_t *pData1, const wchar_t *pData2=nullptr, const wchar_t *pData3=nullptr, const wchar_t *pData4=nullptr, const wchar_t *pData5=nullptr, const wchar_t *pData6=nullptr) |
Appends all the given strings at the back of this string in one operation. | |
void | Append (ezStringView sData1) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (ezStringView sData1, ezStringView sData2) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (ezStringView sData1, ezStringView sData2, ezStringView sData3) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (ezStringView sData1, ezStringView sData2, ezStringView sData3, ezStringView sData4) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (ezStringView sData1, ezStringView sData2, ezStringView sData3, ezStringView sData4, ezStringView sData5, ezStringView sData6={}) |
Appends all the given strings to the back of this string in one operation. | |
void | Prepend (ezUInt32 uiChar) |
Prepends a single Utf32 character. | |
void | Prepend (const wchar_t *pData1, const wchar_t *pData2=nullptr, const wchar_t *pData3=nullptr, const wchar_t *pData4=nullptr, const wchar_t *pData5=nullptr, const wchar_t *pData6=nullptr) |
Prepends all the given strings to the front of this string in one operation. | |
void | Prepend (ezStringView sData1, ezStringView sData2={}, ezStringView sData3={}, ezStringView sData4={}, ezStringView sData5={}, ezStringView sData6={}) |
Prepends all the given strings to the front of this string in one operation. | |
void | SetPrintf (const char *szUtf8Format,...) |
Sets this string to the formatted string, uses printf-style formatting. | |
void | SetPrintfArgs (const char *szUtf8Format, va_list szArgs) |
Sets this string to the formatted string, uses printf-style formatting. | |
void | SetFormat (const ezFormatString &string) |
Replaces this with a formatted string. Uses '{}' formatting placeholders, see ezFormatString for details. | |
template<typename... ARGS> | |
void | SetFormat (const char *szFormat, ARGS &&... args) |
Replaces this with a formatted string. Uses '{}' formatting placeholders, see ezFormatString for details. | |
void | AppendFormat (const ezFormatString &string) |
Appends a formatted string. Uses '{}' formatting placeholders, see ezFormatString for details. | |
template<typename... ARGS> | |
void | AppendFormat (const char *szFormat, ARGS &&... args) |
Appends a formatted string. Uses '{}' formatting placeholders, see ezFormatString for details. | |
void | PrependFormat (const ezFormatString &string) |
Prepends a formatted string. Uses '{}' formatting placeholders, see ezFormatString for details. | |
template<typename... ARGS> | |
void | PrependFormat (const char *szFormat, ARGS &&... args) |
Prepends a formatted string. Uses '{}' formatting placeholders, see ezFormatString for details. | |
void | Shrink (ezUInt32 uiShrinkCharsFront, ezUInt32 uiShrinkCharsBack) |
Removes the first n and last m characters from this string. More... | |
void | Reserve (ezUInt32 uiNumElements) |
Reserves uiNumElements bytes. | |
void | ReplaceSubString (const char *szStartPos, const char *szEndPos, ezStringView sReplaceWith) |
Replaces the string that starts at szStartPos and ends at szEndPos with the string szReplaceWith. | |
void | Insert (const char *szInsertAtPos, ezStringView sTextToInsert) |
A wrapper around ReplaceSubString. Will insert the given string at szInsertAtPos. | |
void | Remove (const char *szRemoveFromPos, const char *szRemoveToPos) |
A wrapper around ReplaceSubString. Will remove the substring which starts at szRemoveFromPos and ends at szRemoveToPos. | |
const char * | ReplaceFirst (ezStringView sSearchFor, ezStringView sReplacement, const char *szStartSearchAt=nullptr) |
Replaces the first occurrence of szSearchFor by szReplacement. Optionally starts searching at szStartSearchAt (or the beginning). More... | |
const char * | ReplaceFirst_NoCase (ezStringView sSearchFor, ezStringView sReplacement, const char *szStartSearchAt=nullptr) |
Case-insensitive version of ReplaceFirst. | |
const char * | ReplaceLast (ezStringView sSearchFor, ezStringView sReplacement, const char *szStartSearchAt=nullptr) |
Replaces the last occurrence of szSearchFor by szReplacement. Optionally starts searching at szStartSearchAt (or the end). More... | |
const char * | ReplaceLast_NoCase (ezStringView sSearchFor, ezStringView sReplacement, const char *szStartSearchAt=nullptr) |
Case-insensitive version of ReplaceLast. | |
ezUInt32 | ReplaceAll (ezStringView sSearchFor, ezStringView sReplacement) |
Replaces all occurrences of szSearchFor by szReplacement. Returns the number of replacements. | |
ezUInt32 | ReplaceAll_NoCase (ezStringView sSearchFor, ezStringView sReplacement) |
Case-insensitive version of ReplaceAll. | |
const char * | ReplaceWholeWord (const char *szSearchFor, ezStringView sReplaceWith, ezStringUtils::EZ_CHARACTER_FILTER isDelimiterCB) |
Replaces the first occurrence of szSearchFor by szReplaceWith, if szSearchFor was found to be a 'whole word', as indicated by the delimiter function IsDelimiterCB. More... | |
const char * | ReplaceWholeWord_NoCase (const char *szSearchFor, ezStringView sReplaceWith, ezStringUtils::EZ_CHARACTER_FILTER isDelimiterCB) |
Case-insensitive version of ReplaceWholeWord. More... | |
ezUInt32 | ReplaceWholeWordAll (const char *szSearchFor, ezStringView sReplaceWith, ezStringUtils::EZ_CHARACTER_FILTER isDelimiterCB) |
Replaces all occurrences of szSearchFor by szReplaceWith, if szSearchFor was found to be a 'whole word', as indicated by the delimiter function IsDelimiterCB. More... | |
ezUInt32 | ReplaceWholeWordAll_NoCase (const char *szSearchFor, ezStringView sReplaceWith, ezStringUtils::EZ_CHARACTER_FILTER isDelimiterCB) |
Case-insensitive version of ReplaceWholeWordAll. More... | |
void | ReadAll (ezStreamReader &inout_stream) |
Replaces the current string with the content from the stream. Reads the stream to its end. | |
void | MakeCleanPath () |
Removes "../" where possible, replaces all path separators with /, removes double slashes. More... | |
void | PathParentDirectory (ezUInt32 uiLevelsUp=1) |
Modifies this string to point to the parent directory. More... | |
void | AppendPath (ezStringView sPath1, ezStringView sPath2={}, ezStringView sPath3={}, ezStringView sPath4={}) |
Appends several path pieces. Makes sure they are always properly separated by a slash. | |
void | AppendWithSeparator (ezStringView sSeparator, ezStringView sText1, ezStringView sText2=ezStringView(), ezStringView sText3=ezStringView(), ezStringView sText4=ezStringView(), ezStringView sText5=ezStringView(), ezStringView sText6=ezStringView()) |
Similar to Append() but the very first argument is a separator that is only appended (once) if the existing string is not empty and does not already end with the separator. More... | |
void | ChangeFileName (ezStringView sNewFileName) |
Changes the file name part of the path, keeps the extension intact (if there is any). | |
void | ChangeFileNameAndExtension (ezStringView sNewFileNameWithExtension) |
Changes the file name and the extension part of the path. | |
void | ChangeFileExtension (ezStringView sNewExtension, bool bFullExtension=false) |
Only changes the file extension of the path. If there is no extension yet, one is appended (including a dot). More... | |
void | RemoveFileExtension (bool bFullExtension=false) |
If any extension exists, it is removed, including the dot before it. More... | |
ezResult | MakeRelativeTo (ezStringView sAbsolutePathToMakeThisRelativeTo) |
Converts this path into a relative path to the path with the awesome variable name 'szAbsolutePathToMakeThisRelativeTo'. More... | |
void | MakePathSeparatorsNative () |
Cleans this path up and replaces all path separators by the OS specific separator. More... | |
bool | IsPathBelowFolder (const char *szPathToFolder) |
Checks whether this path is a sub-path of the given path. More... | |
ezUInt64 | GetHeapMemoryUsage () const |
Returns the amount of bytes that are currently allocated on the heap. | |
void | Trim (const char *szTrimChars=" \f\n\r\t\v") |
Removes all characters from the start and end that appear in the given strings. More... | |
void | Trim (const char *szTrimCharsStart, const char *szTrimCharsEnd) |
Removes all characters from the start and/or end that appear in the given strings. | |
void | TrimLeft (const char *szTrimChars=" \f\n\r\t\v") |
Removes all characters from the start that appear in the given strings. More... | |
void | TrimRight (const char *szTrimChars=" \f\n\r\t\v") |
Removes all characters from the end that appear in the given strings. More... | |
bool | TrimWordStart (ezStringView sWord) |
If the string starts with the given word (case insensitive), it is removed and the function returns true. | |
bool | TrimWordEnd (ezStringView sWord) |
If the string ends with the given word (case insensitive), it is removed and the function returns true. | |
![]() | |
bool | IsEmpty () const |
Returns whether the string is an empty string. | |
bool | StartsWith (ezStringView sStartsWith) const |
Returns true, if this string starts with the given string. | |
bool | StartsWith_NoCase (ezStringView sStartsWith) const |
Returns true, if this string starts with the given string. Case insensitive. | |
bool | EndsWith (ezStringView sEndsWith) const |
Returns true, if this string ends with the given string. | |
bool | EndsWith_NoCase (ezStringView sEndsWith) const |
Returns true, if this string ends with the given string. Case insensitive. | |
const char * | FindSubString (ezStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindSubString_NoCase (ezStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindLastSubString (ezStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindLastSubString_NoCase (ezStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindWholeWord (const char *szSearchFor, ezStringUtils::EZ_CHARACTER_FILTER isDelimiterCB, const char *szStartSearchAt=nullptr) const |
const char * | FindWholeWord_NoCase (const char *szSearchFor, ezStringUtils::EZ_CHARACTER_FILTER isDelimiterCB, const char *szStartSearchAt=nullptr) const |
ezInt32 | Compare (ezStringView sOther) const |
Compares this string with the other one. Returns 0 for equality, -1 if this string is 'smaller', 1 otherwise. | |
ezInt32 | CompareN (ezStringView sOther, ezUInt32 uiCharsToCompare) const |
ezInt32 | Compare_NoCase (ezStringView sOther) const |
Compares this string with the other one. Returns 0 for equality, -1 if this string is 'smaller', 1 otherwise. Case insensitive. | |
ezInt32 | CompareN_NoCase (ezStringView sOther, ezUInt32 uiCharsToCompare) const |
bool | IsEqual (ezStringView sOther) const |
Compares this string with the other string for equality. | |
bool | IsEqualN (ezStringView sOther, ezUInt32 uiCharsToCompare) const |
Compares up to a given number of characters of this string with the other string for equality. Case insensitive. | |
bool | IsEqual_NoCase (ezStringView sOther) const |
Compares this string with the other string for equality. | |
bool | IsEqualN_NoCase (ezStringView sOther, ezUInt32 uiCharsToCompare) const |
Compares up to a given number of characters of this string with the other string for equality. Case insensitive. | |
const char * | ComputeCharacterPosition (ezUInt32 uiCharacterIndex) const |
Computes the pointer to the n-th character in the string. This is a linear search from the start. | |
iterator | GetIteratorFront () const |
Returns an iterator to this string, which points to the very first character. More... | |
reverse_iterator | GetIteratorBack () const |
Returns an iterator to this string, which points to the very last character (NOT the end). More... | |
operator ezStringView () const | |
Returns a string view to this string's data. | |
ezStringView | GetView () const |
Returns a string view to this string's data. | |
EZ_ALWAYS_INLINE | operator const char * () const |
Returns a pointer to the internal Utf8 string. | |
void | Split (bool bReturnEmptyStrings, Container &ref_output, const char *szSeparator1, const char *szSeparator2=nullptr, const char *szSeparator3=nullptr, const char *szSeparator4=nullptr, const char *szSeparator5=nullptr, const char *szSeparator6=nullptr) const |
Fills the given container with ezStringView's which represent each found substring. If bReturnEmptyStrings is true, even empty strings between separators are returned. Output must be a container that stores ezStringView's and provides the functions 'Clear' and 'Append'. szSeparator1 to szSeparator6 are strings which act as separators and indicate where to split the string. This string itself will not be modified. | |
bool | HasAnyExtension () const |
Checks whether the given path has any file extension. | |
bool | HasExtension (ezStringView sExtension) const |
Checks whether the given path ends with the given extension. szExtension should start with a '.' for performance reasons, but it will work without a '.' too. | |
ezStringView | GetFileExtension (bool bFullExtension=false) const |
Returns the file extension of the given path. Will be empty, if the path does not end with a proper extension. | |
ezStringView | GetFileName () const |
Returns the file name of a path, excluding the path and extension. More... | |
ezStringView | GetFileNameAndExtension () const |
Returns the substring that represents the file name including the file extension. More... | |
ezStringView | GetFileDirectory () const |
Returns the directory of the given file, which is the substring up to the last path separator. More... | |
bool | IsAbsolutePath () const |
Returns true, if the given path represents an absolute path on the current OS. | |
bool | IsRelativePath () const |
Returns true, if the given path represents a relative path on the current OS. | |
bool | IsRootedPath () const |
Returns true, if the given path represents a 'rooted' path. See ezFileSystem for details. | |
ezStringView | GetRootedPathRootName () const |
Extracts the root name from a rooted path. More... | |
Friends | |
template<ezUInt16 T> | |
struct | ezHybridStringBase |
Additional Inherited Members | |
![]() | |
using | iterator = ezStringIterator |
using | const_iterator = ezStringIterator |
using | reverse_iterator = ezStringReverseIterator |
using | const_reverse_iterator = ezStringReverseIterator |
ezStringBuilder is a class that is meant for creating and modifying strings.
It is not meant to store strings for a longer duration. Each ezStringBuilder uses an ezHybridArray to allocate a large buffer on the stack, such that string manipulations are possible without memory allocations, unless the string is too large. No sharing of data happens between ezStringBuilder instances, as it is expected that they will be modified anyway. Instead all data is always copied, therefore instances should not be passed by copy. All string data is stored Utf8 encoded, just as all other string classes, too. That makes it difficult to modify individual characters. Instead you should prefer high-level functions such as 'ReplaceSubString'. If individual characters must be modified, it might make more sense to create a second ezStringBuilder, and iterate over the first while rebuilding the desired result in the second. Once a string is built and should only be stored for read access, it should be stored in an ezString instance.
void ezStringBuilder::AppendWithSeparator | ( | ezStringView | sSeparator, |
ezStringView | sText1, | ||
ezStringView | sText2 = ezStringView() , |
||
ezStringView | sText3 = ezStringView() , |
||
ezStringView | sText4 = ezStringView() , |
||
ezStringView | sText5 = ezStringView() , |
||
ezStringView | sText6 = ezStringView() |
||
) |
Similar to Append() but the very first argument is a separator that is only appended (once) if the existing string is not empty and does not already end with the separator.
This is useful when one wants to append entries that require a separator like a comma in between items. E.g. calling AppendWithSeparator(", ", "a", "b"); AppendWithSeparator(", ", "c", "d"); results in the string "ab, cd"
|
inline |
Changes the single character in this string, to which the iterator currently points.
The string might need to be moved around, if its encoding size changes, however the given iterator will be adjusted so that it will always stay valid.
void ezStringBuilder::ChangeFileExtension | ( | ezStringView | sNewExtension, |
bool | bFullExtension = false |
||
) |
Only changes the file extension of the path. If there is no extension yet, one is appended (including a dot).
sNewExtension may or may not start with a dot. If sNewExtension is empty, the file extension is removed, but the dot remains. E.g. "file.txt" -> "file." If you also want to remove the dot, use RemoveFileExtension() instead.
If bFullExtension is false, a file named "file.a.b.c" will replace only "c". If bFullExtension is true, a file named "file.a.b.c" will replace all of "a.b.c".
EZ_ALWAYS_INLINE ezUInt32 ezStringBuilder::GetCharacterCount | ( | ) | const |
Returns the number of characters of which this string consists. Might be less than GetElementCount, if it contains Utf8 multi-byte characters.
bool ezStringBuilder::IsPathBelowFolder | ( | const char * | szPathToFolder | ) |
Checks whether this path is a sub-path of the given path.
This function will call 'MakeCleanPath' to be able to compare both paths, thus it might modify the data of this instance.
An empty folder (zero length) does not contain ANY files.
A non-existing file-name (zero length) is never in any folder.
Example:
IsFileBelowFolder ("", "XYZ") -> always false
IsFileBelowFolder ("XYZ", "") -> always false
IsFileBelowFolder ("", "") -> always false
void ezStringBuilder::MakeCleanPath | ( | ) |
Removes "../" where possible, replaces all path separators with /, removes double slashes.
All paths use slashes on all platforms. If you need to convert a path to the OS specific representation, use 'MakePathSeparatorsNative' 'MakeCleanPath' will in rare circumstances grow the string by one character. That means it is quite safe to assume that it will not waste time on memory allocations. If it is repeatedly called on the same string, it has a minor overhead for computing the same string over and over, but no memory allocations will be done (everything is in-place).
Removes all double path separators (slashes and backslashes) in a path, except if the path starts with two (back-)slashes, those are kept, as they might indicate a UNC path.
void ezStringBuilder::MakePathSeparatorsNative | ( | ) |
Cleans this path up and replaces all path separators by the OS specific separator.
This can be used, if you want to present paths in the OS specific form to the user in the UI. In all other cases the internal representation uses slashes, no matter on which operating system.
ezResult ezStringBuilder::MakeRelativeTo | ( | ezStringView | sAbsolutePathToMakeThisRelativeTo | ) |
Converts this path into a relative path to the path with the awesome variable name 'szAbsolutePathToMakeThisRelativeTo'.
If the method succeeds the StringBuilder's contents are modified in place.
void ezStringBuilder::PathParentDirectory | ( | ezUInt32 | uiLevelsUp = 1 | ) |
Modifies this string to point to the parent directory.
'uiLevelsUp' can be used to go several folders upwards. It has to be at least one. If there are no more folders to go up, "../" is appended as much as needed.
void ezStringBuilder::RemoveFileExtension | ( | bool | bFullExtension = false | ) |
If any extension exists, it is removed, including the dot before it.
If bFullExtension is false, a file named "file.a.b.c" will end up as "file.a.b" If bFullExtension is true, a file named "file.a.b.c" will end up as "file"
const char * ezStringBuilder::ReplaceFirst | ( | ezStringView | sSearchFor, |
ezStringView | sReplacement, | ||
const char * | szStartSearchAt = nullptr |
||
) |
Replaces the first occurrence of szSearchFor by szReplacement. Optionally starts searching at szStartSearchAt (or the beginning).
Returns the first position where szSearchFor was found, or nullptr if nothing was found (and replaced).
const char * ezStringBuilder::ReplaceLast | ( | ezStringView | sSearchFor, |
ezStringView | sReplacement, | ||
const char * | szStartSearchAt = nullptr |
||
) |
Replaces the last occurrence of szSearchFor by szReplacement. Optionally starts searching at szStartSearchAt (or the end).
Returns the last position where szSearchFor was found, or nullptr if nothing was found (and replaced).
const char * ezStringBuilder::ReplaceWholeWord | ( | const char * | szSearchFor, |
ezStringView | sReplaceWith, | ||
ezStringUtils::EZ_CHARACTER_FILTER | isDelimiterCB | ||
) |
Replaces the first occurrence of szSearchFor by szReplaceWith, if szSearchFor was found to be a 'whole word', as indicated by the delimiter function IsDelimiterCB.
Returns the start position of where the word was replaced or nullptr if nothing got replaced.
const char * ezStringBuilder::ReplaceWholeWord_NoCase | ( | const char * | szSearchFor, |
ezStringView | sReplaceWith, | ||
ezStringUtils::EZ_CHARACTER_FILTER | isDelimiterCB | ||
) |
Case-insensitive version of ReplaceWholeWord.
Returns the start position of where the word was replaced or nullptr if nothing got replaced.
ezUInt32 ezStringBuilder::ReplaceWholeWordAll | ( | const char * | szSearchFor, |
ezStringView | sReplaceWith, | ||
ezStringUtils::EZ_CHARACTER_FILTER | isDelimiterCB | ||
) |
Replaces all occurrences of szSearchFor by szReplaceWith, if szSearchFor was found to be a 'whole word', as indicated by the delimiter function IsDelimiterCB.
Returns how many words got replaced.
ezUInt32 ezStringBuilder::ReplaceWholeWordAll_NoCase | ( | const char * | szSearchFor, |
ezStringView | sReplaceWith, | ||
ezStringUtils::EZ_CHARACTER_FILTER | isDelimiterCB | ||
) |
Case-insensitive version of ReplaceWholeWordAll.
Returns how many words got replaced.
void ezStringBuilder::Shrink | ( | ezUInt32 | uiShrinkCharsFront, |
ezUInt32 | uiShrinkCharsBack | ||
) |
Removes the first n and last m characters from this string.
This function will never reallocate data. Removing characters at the back is very cheap. Removing characters at the front needs to move data around, so can be quite costly.
void ezStringBuilder::Trim | ( | const char * | szTrimChars = " \f\n\r\t\v" | ) |
Removes all characters from the start and end that appear in the given strings.
The default string removes all standard whitespace characters.
void ezStringBuilder::TrimLeft | ( | const char * | szTrimChars = " \f\n\r\t\v" | ) |
Removes all characters from the start that appear in the given strings.
The default string removes all standard whitespace characters.
void ezStringBuilder::TrimRight | ( | const char * | szTrimChars = " \f\n\r\t\v" | ) |
Removes all characters from the end that appear in the given strings.
The default string removes all standard whitespace characters.