![]() |
Plasma Engine
2.0
|
plStringBuilder is a class that is meant for creating and modifying strings. More...
#include <StringBuilder.h>
Public Member Functions | |
plStringBuilder (plAllocator *pAllocator=plFoundation::GetDefaultAllocator()) | |
Initializes the string to be empty. No data is allocated, but the plStringBuilder ALWAYS creates an array on the stack. | |
plStringBuilder (const plStringBuilder &rhs) | |
Copies the given string into this one. | |
plStringBuilder (plStringBuilder &&rhs) noexcept | |
Moves the given string into this one. | |
template<plUInt16 Size> | |
plStringBuilder (const plHybridStringBase< Size > &rhs) | |
Copies the given string into this one. | |
template<plUInt16 Size, typename A > | |
plStringBuilder (const plHybridString< Size, A > &rhs) | |
Copies the given string into this one. | |
template<plUInt16 Size> | |
plStringBuilder (plHybridStringBase< Size > &&rhs) | |
Moves the given string into this one. | |
template<plUInt16 Size, typename A > | |
plStringBuilder (plHybridString< Size, A > &&rhs) | |
Moves the given string into this one. | |
plStringBuilder (plStringView sData1, plStringView sData2, plStringView sData3={}, plStringView sData4={}, plStringView sData5={}, plStringView sData6={}) | |
Constructor that appends all the given strings. | |
plStringBuilder (const char *szUTF8, plAllocator *pAllocator=plFoundation::GetDefaultAllocator()) | |
Copies the given Utf8 string into this one. | |
plStringBuilder (const wchar_t *pWChar, plAllocator *pAllocator=plFoundation::GetDefaultAllocator()) | |
Copies the given wchar_t string into this one. | |
plStringBuilder (plStringView rhs, plAllocator *pAllocator=plFoundation::GetDefaultAllocator()) | |
Copies the given substring into this one. The plStringView might actually be a substring of this very string. | |
void | operator= (const plStringBuilder &rhs) |
Copies the given string into this one. | |
void | operator= (plStringBuilder &&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= (plStringView rhs) |
Copies the given substring into this one. The plStringView might actually be a substring of this very string. | |
template<plUInt16 Size> | |
void | operator= (const plHybridStringBase< Size > &rhs) |
Copies the given string into this one. | |
template<plUInt16 Size, typename A > | |
void | operator= (const plHybridString< Size, A > &rhs) |
Copies the given string into this one. | |
template<plUInt16 Size> | |
void | operator= (plHybridStringBase< Size > &&rhs) |
Moves the given string into this one. | |
template<plUInt16 Size, typename A > | |
void | operator= (plHybridString< Size, A > &&rhs) noexcept |
Moves the given string into this one. | |
plAllocator * | 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. | |
plUInt32 | GetElementCount () const |
Returns the number of bytes that this string takes up. | |
plUInt32 | GetCharacterCount () const |
Returns the number of characters of which this string consists. Might be less than GetElementCount, if it contains Utf8 multi-byte characters. | |
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, plUInt32 uiCharacter) |
Changes the single character in this string, to which the iterator currently points. | |
void | Set (plStringView sData1) |
Sets the string to the given string. | |
void | Set (plStringView sData1, plStringView sData2) |
Sets the string by concatenating all given strings. | |
void | Set (plStringView sData1, plStringView sData2, plStringView sData3) |
Sets the string by concatenating all given strings. | |
void | Set (plStringView sData1, plStringView sData2, plStringView sData3, plStringView sData4) |
Sets the string by concatenating all given strings. | |
void | Set (plStringView sData1, plStringView sData2, plStringView sData3, plStringView sData4, plStringView sData5, plStringView sData6={}) |
Sets the string by concatenating all given strings. | |
void | SetPath (plStringView sData1, plStringView sData2, plStringView sData3={}, plStringView 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, plUInt32 uiElementCount) |
Copies the string starting at pStart with a length of uiElementCount bytes. | |
void | SetSubString_CharacterCount (const char *pStart, plUInt32 uiCharacterCount) |
Copies the string starting at pStart with a length of uiCharacterCount characters. | |
void | Append (plUInt32 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 (plStringView sData1) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (plStringView sData1, plStringView sData2) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (plStringView sData1, plStringView sData2, plStringView sData3) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (plStringView sData1, plStringView sData2, plStringView sData3, plStringView sData4) |
Appends all the given strings to the back of this string in one operation. | |
void | Append (plStringView sData1, plStringView sData2, plStringView sData3, plStringView sData4, plStringView sData5, plStringView sData6={}) |
Appends all the given strings to the back of this string in one operation. | |
void | Prepend (plUInt32 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 (plStringView sData1, plStringView sData2={}, plStringView sData3={}, plStringView sData4={}, plStringView sData5={}, plStringView 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 plFormatString &string) |
Replaces this with a formatted string. Uses '{}' formatting placeholders, see plFormatString for details. | |
template<typename... ARGS> | |
void | SetFormat (const char *szFormat, ARGS &&... args) |
Replaces this with a formatted string. Uses '{}' formatting placeholders, see plFormatString for details. | |
void | AppendFormat (const plFormatString &string) |
Appends a formatted string. Uses '{}' formatting placeholders, see plFormatString for details. | |
template<typename... ARGS> | |
void | AppendFormat (const char *szFormat, ARGS &&... args) |
Appends a formatted string. Uses '{}' formatting placeholders, see plFormatString for details. | |
void | PrependFormat (const plFormatString &string) |
Prepends a formatted string. Uses '{}' formatting placeholders, see plFormatString for details. | |
template<typename... ARGS> | |
void | PrependFormat (const char *szFormat, ARGS &&... args) |
Prepends a formatted string. Uses '{}' formatting placeholders, see plFormatString for details. | |
void | Shrink (plUInt32 uiShrinkCharsFront, plUInt32 uiShrinkCharsBack) |
Removes the first n and last m characters from this string. | |
void | Reserve (plUInt32 uiNumElements) |
Reserves uiNumElements bytes. | |
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. | |
void | Insert (const char *szInsertAtPos, plStringView 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 (plStringView sSearchFor, plStringView sReplacement, const char *szStartSearchAt=nullptr) |
Replaces the first occurrence of szSearchFor by szReplacement. Optionally starts searching at szStartSearchAt (or the beginning). | |
const char * | ReplaceFirst_NoCase (plStringView sSearchFor, plStringView sReplacement, const char *szStartSearchAt=nullptr) |
Case-insensitive version of ReplaceFirst. | |
const char * | ReplaceLast (plStringView sSearchFor, plStringView sReplacement, const char *szStartSearchAt=nullptr) |
Replaces the last occurrence of szSearchFor by szReplacement. Optionally starts searching at szStartSearchAt (or the end). | |
const char * | ReplaceLast_NoCase (plStringView sSearchFor, plStringView sReplacement, const char *szStartSearchAt=nullptr) |
Case-insensitive version of ReplaceLast. | |
plUInt32 | ReplaceAll (plStringView sSearchFor, plStringView sReplacement) |
Replaces all occurrences of szSearchFor by szReplacement. Returns the number of replacements. | |
plUInt32 | ReplaceAll_NoCase (plStringView sSearchFor, plStringView sReplacement) |
Case-insensitive version of ReplaceAll. | |
const char * | ReplaceWholeWord (const char *szSearchFor, plStringView sReplaceWith, plStringUtils::PL_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. | |
const char * | ReplaceWholeWord_NoCase (const char *szSearchFor, plStringView sReplaceWith, plStringUtils::PL_CHARACTER_FILTER isDelimiterCB) |
Case-insensitive version of ReplaceWholeWord. | |
plUInt32 | ReplaceWholeWordAll (const char *szSearchFor, plStringView sReplaceWith, plStringUtils::PL_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. | |
plUInt32 | ReplaceWholeWordAll_NoCase (const char *szSearchFor, plStringView sReplaceWith, plStringUtils::PL_CHARACTER_FILTER isDelimiterCB) |
Case-insensitive version of ReplaceWholeWordAll. | |
void | ReadAll (plStreamReader &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. | |
void | PathParentDirectory (plUInt32 uiLevelsUp=1) |
Modifies this string to point to the parent directory. | |
void | AppendPath (plStringView sPath1, plStringView sPath2={}, plStringView sPath3={}, plStringView sPath4={}) |
Appends several path pieces. Makes sure they are always properly separated by a slash. | |
void | AppendWithSeparator (plStringView sSeparator, plStringView sText1, plStringView sText2=plStringView(), plStringView sText3=plStringView(), plStringView sText4=plStringView(), plStringView sText5=plStringView(), plStringView sText6=plStringView()) |
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. | |
void | ChangeFileName (plStringView sNewFileName) |
Changes the file name part of the path, keeps the extension intact (if there is any). | |
void | ChangeFileNameAndExtension (plStringView sNewFileNameWithExtension) |
Changes the file name and the extension part of the path. | |
void | ChangeFileExtension (plStringView sNewExtension, bool bFullExtension=false) |
Only changes the file extension of the path. If there is no extension yet, one is appended (including a dot). | |
void | RemoveFileExtension (bool bFullExtension=false) |
If any extension exists, it is removed, including the dot before it. | |
plResult | MakeRelativeTo (plStringView sAbsolutePathToMakeThisRelativeTo) |
Converts this path into a relative path to the path with the awesome variable name 'szAbsolutePathToMakeThisRelativeTo'. | |
void | MakePathSeparatorsNative () |
Cleans this path up and replaces all path separators by the OS specific separator. | |
bool | IsPathBelowFolder (const char *szPathToFolder) |
Checks whether this path is a sub-path of the given path. | |
plUInt64 | 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. | |
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. | |
void | TrimRight (const char *szTrimChars=" \f\n\r\t\v") |
Removes all characters from the end that appear in the given strings. | |
bool | TrimWordStart (plStringView sWord) |
If the string starts with the given word (case insensitive), it is removed and the function returns true. | |
bool | TrimWordEnd (plStringView 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 (plStringView sStartsWith) const |
Returns true, if this string starts with the given string. | |
bool | StartsWith_NoCase (plStringView sStartsWith) const |
Returns true, if this string starts with the given string. Case insensitive. | |
bool | EndsWith (plStringView sEndsWith) const |
Returns true, if this string ends with the given string. | |
bool | EndsWith_NoCase (plStringView sEndsWith) const |
Returns true, if this string ends with the given string. Case insensitive. | |
const char * | FindSubString (plStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindSubString_NoCase (plStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindLastSubString (plStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindLastSubString_NoCase (plStringView sStringToFind, const char *szStartSearchAt=nullptr) const |
const char * | FindWholeWord (const char *szSearchFor, plStringUtils::PL_CHARACTER_FILTER isDelimiterCB, const char *szStartSearchAt=nullptr) const |
const char * | FindWholeWord_NoCase (const char *szSearchFor, plStringUtils::PL_CHARACTER_FILTER isDelimiterCB, const char *szStartSearchAt=nullptr) const |
plInt32 | Compare (plStringView sOther) const |
Compares this string with the other one. Returns 0 for equality, -1 if this string is 'smaller', 1 otherwise. | |
plInt32 | CompareN (plStringView sOther, plUInt32 uiCharsToCompare) const |
plInt32 | Compare_NoCase (plStringView sOther) const |
Compares this string with the other one. Returns 0 for equality, -1 if this string is 'smaller', 1 otherwise. Case insensitive. | |
plInt32 | CompareN_NoCase (plStringView sOther, plUInt32 uiCharsToCompare) const |
bool | IsEqual (plStringView sOther) const |
Compares this string with the other string for equality. | |
bool | IsEqualN (plStringView sOther, plUInt32 uiCharsToCompare) const |
Compares up to a given number of characters of this string with the other string for equality. Case insensitive. | |
bool | IsEqual_NoCase (plStringView sOther) const |
Compares this string with the other string for equality. | |
bool | IsEqualN_NoCase (plStringView sOther, plUInt32 uiCharsToCompare) const |
Compares up to a given number of characters of this string with the other string for equality. Case insensitive. | |
const char * | ComputeCharacterPosition (plUInt32 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. | |
reverse_iterator | GetIteratorBack () const |
Returns an iterator to this string, which points to the very last character (NOT the end). | |
operator plStringView () const | |
Returns a string view to this string's data. | |
plStringView | GetView () const |
Returns a string view to this string's data. | |
PL_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 plStringView's which represent each found substring. If bReturnEmptyStrings is true, even empty strings between separators are returned. Output must be a container that stores plStringView'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 (plStringView 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. | |
plStringView | GetFileExtension () const |
Returns the file extension of the given path. Will be empty, if the path does not end with a proper extension. | |
plStringView | GetFileName () const |
Returns the file name of a path, excluding the path and extension. | |
plStringView | GetFileNameAndExtension () const |
Returns the substring that represents the file name including the file extension. | |
plStringView | GetFileDirectory () const |
Returns the directory of the given file, which is the substring up to the last path separator. | |
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 plFileSystem for details. | |
plStringView | GetRootedPathRootName () const |
Extracts the root name from a rooted path. | |
Friends | |
template<plUInt16 T> | |
struct | plHybridStringBase |
Additional Inherited Members | |
![]() | |
using | iterator |
using | const_iterator |
using | reverse_iterator |
using | const_reverse_iterator |
plStringBuilder is a class that is meant for creating and modifying strings.
It is not meant to store strings for a longer duration. Each plStringBuilder uses an plHybridArray 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 plStringBuilder 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 plStringBuilder, 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 plString instance.
void plStringBuilder::AppendWithSeparator | ( | plStringView | sSeparator, |
plStringView | sText1, | ||
plStringView | sText2 = plStringView(), | ||
plStringView | sText3 = plStringView(), | ||
plStringView | sText4 = plStringView(), | ||
plStringView | sText5 = plStringView(), | ||
plStringView | sText6 = plStringView() ) |
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 plStringBuilder::ChangeFileExtension | ( | plStringView | 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".
PL_ALWAYS_INLINE plUInt32 plStringBuilder::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 plStringBuilder::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 plStringBuilder::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 plStringBuilder::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.
plResult plStringBuilder::MakeRelativeTo | ( | plStringView | 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 plStringBuilder::PathParentDirectory | ( | plUInt32 | 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 plStringBuilder::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 * plStringBuilder::ReplaceFirst | ( | plStringView | sSearchFor, |
plStringView | 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 * plStringBuilder::ReplaceLast | ( | plStringView | sSearchFor, |
plStringView | 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 * plStringBuilder::ReplaceWholeWord | ( | const char * | szSearchFor, |
plStringView | sReplaceWith, | ||
plStringUtils::PL_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 * plStringBuilder::ReplaceWholeWord_NoCase | ( | const char * | szSearchFor, |
plStringView | sReplaceWith, | ||
plStringUtils::PL_CHARACTER_FILTER | isDelimiterCB ) |
Case-insensitive version of ReplaceWholeWord.
Returns the start position of where the word was replaced or nullptr if nothing got replaced.
plUInt32 plStringBuilder::ReplaceWholeWordAll | ( | const char * | szSearchFor, |
plStringView | sReplaceWith, | ||
plStringUtils::PL_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.
plUInt32 plStringBuilder::ReplaceWholeWordAll_NoCase | ( | const char * | szSearchFor, |
plStringView | sReplaceWith, | ||
plStringUtils::PL_CHARACTER_FILTER | isDelimiterCB ) |
Case-insensitive version of ReplaceWholeWordAll.
Returns how many words got replaced.
void plStringBuilder::Shrink | ( | plUInt32 | uiShrinkCharsFront, |
plUInt32 | 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 plStringBuilder::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 plStringBuilder::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 plStringBuilder::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.