Plasma Engine  2.0
Loading...
Searching...
No Matches
plStringBase< Derived > Struct Template Reference

Base class for strings, which implements all read-only string functions. More...

#include <StringBase.h>

Inheritance diagram for plStringBase< Derived >:

Public Types

using iterator = plStringIterator
 
using const_iterator = plStringIterator
 
using reverse_iterator = plStringReverseIterator
 
using const_reverse_iterator = plStringReverseIterator
 

Public Member Functions

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.
 
template<typename Container >
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<typename Derived2 >
plStringBase< Derived2 >::iterator begin (const plStringBase< Derived2 > &container)
 
template<typename Derived2 >
plStringBase< Derived2 >::const_iterator cbegin (const plStringBase< Derived2 > &container)
 
template<typename Derived2 >
plStringBase< Derived2 >::iterator end (const plStringBase< Derived2 > &container)
 
template<typename Derived2 >
plStringBase< Derived2 >::const_iterator cend (const plStringBase< Derived2 > &container)
 
template<typename Derived2 >
plStringBase< Derived2 >::reverse_iterator rbegin (const plStringBase< Derived2 > &container)
 
template<typename Derived2 >
plStringBase< Derived2 >::const_reverse_iterator crbegin (const plStringBase< Derived2 > &container)
 
template<typename Derived2 >
plStringBase< Derived2 >::reverse_iterator rend (const plStringBase< Derived2 > &container)
 
template<typename Derived2 >
plStringBase< Derived2 >::const_reverse_iterator crend (const plStringBase< Derived2 > &container)
 

Detailed Description

template<typename Derived>
struct plStringBase< Derived >

Base class for strings, which implements all read-only string functions.

Member Function Documentation

◆ CompareN()

template<typename Derived >
plInt32 plStringBase< Derived >::CompareN ( plStringView sOther,
plUInt32 uiCharsToCompare ) const

Compares up to a given number of characters of this string with the other one. Returns 0 for equality, -1 if this string is 'smaller', 1 otherwise.

◆ CompareN_NoCase()

template<typename Derived >
plInt32 plStringBase< Derived >::CompareN_NoCase ( plStringView sOther,
plUInt32 uiCharsToCompare ) const

Compares up to a given number of characters of this string with the other one. Returns 0 for equality, -1 if this string is 'smaller', 1 otherwise. Case insensitive.

◆ FindLastSubString()

template<typename Derived >
const char * plStringBase< Derived >::FindLastSubString ( plStringView sStringToFind,
const char * szStartSearchAt = nullptr ) const
inline

Returns a pointer to the last occurrence of szStringToFind, or nullptr if none was found. szStartSearchAt allows to start searching at the end of the string (if it is nullptr) or at an earlier position.

◆ FindLastSubString_NoCase()

template<typename Derived >
const char * plStringBase< Derived >::FindLastSubString_NoCase ( plStringView sStringToFind,
const char * szStartSearchAt = nullptr ) const
inline

Returns a pointer to the last occurrence of szStringToFind, or nullptr if none was found. Case insensitive. szStartSearchAt allows to start searching at the end of the string (if it is nullptr) or at an earlier position.

◆ FindSubString()

template<typename Derived >
const char * plStringBase< Derived >::FindSubString ( plStringView sStringToFind,
const char * szStartSearchAt = nullptr ) const

Returns a pointer to the first occurrence of szStringToFind, or nullptr if none was found. To find the next occurrence, use an plStringView which points to the next position and call FindSubString again.

◆ FindSubString_NoCase()

template<typename Derived >
const char * plStringBase< Derived >::FindSubString_NoCase ( plStringView sStringToFind,
const char * szStartSearchAt = nullptr ) const

Returns a pointer to the first occurrence of szStringToFind, or nullptr if none was found. Case insensitive. To find the next occurrence, use an plStringView which points to the next position and call FindSubString again.

◆ FindWholeWord()

template<typename Derived >
const char * plStringBase< Derived >::FindWholeWord ( const char * szSearchFor,
plStringUtils::PL_CHARACTER_FILTER isDelimiterCB,
const char * szStartSearchAt = nullptr ) const
inline

Searches for the word szSearchFor. If IsDelimiterCB returns true for both characters in front and back of the word, the position is returned. Otherwise nullptr.

◆ FindWholeWord_NoCase()

template<typename Derived >
const char * plStringBase< Derived >::FindWholeWord_NoCase ( const char * szSearchFor,
plStringUtils::PL_CHARACTER_FILTER isDelimiterCB,
const char * szStartSearchAt = nullptr ) const
inline

Searches for the word szSearchFor. If IsDelimiterCB returns true for both characters in front and back of the word, the position is returned. Otherwise nullptr. Ignores case.

◆ GetFileDirectory()

template<typename Derived >
plStringView plStringBase< Derived >::GetFileDirectory ( ) const

Returns the directory of the given file, which is the substring up to the last path separator.

If the path already ends in a path separator, and thus points to a folder, instead of a file, the unchanged path is returned. "path/to/file" -> "path/to/" "path/to/folder/" -> "path/to/folder/" "filename" -> "" "/file_at_root_level" -> "/"

◆ GetFileName()

template<typename Derived >
plStringView plStringBase< Derived >::GetFileName ( ) const

Returns the file name of a path, excluding the path and extension.

If the path already ends with a path separator, the result will be empty.

◆ GetFileNameAndExtension()

template<typename Derived >
plStringView plStringBase< Derived >::GetFileNameAndExtension ( ) const

Returns the substring that represents the file name including the file extension.

Returns an empty string, if sPath already ends in a path separator, or is empty itself.

◆ GetIteratorBack()

template<typename Derived >
plStringBase< Derived >::reverse_iterator plStringBase< Derived >::GetIteratorBack ( ) const

Returns an iterator to this string, which points to the very last character (NOT the end).

Note that this iterator will only be valid as long as this string lives. Once the original string is destroyed, all iterators to them will point into invalid memory.

◆ GetIteratorFront()

template<typename Derived >
plStringBase< Derived >::iterator plStringBase< Derived >::GetIteratorFront ( ) const

Returns an iterator to this string, which points to the very first character.

Note that this iterator will only be valid as long as this string lives. Once the original string is destroyed, all iterators to them will point into invalid memory.

◆ GetRootedPathRootName()

template<typename Derived >
plStringView plStringBase< Derived >::GetRootedPathRootName ( ) const

Extracts the root name from a rooted path.

":MyRoot" -> "MyRoot" ":MyRoot\folder" -> "MyRoot" ":\MyRoot\folder" -> "MyRoot" ":/MyRoot\folder" -> "MyRoot" Returns an empty string, if the path is not rooted.


The documentation for this struct was generated from the following files: