3#ifndef PL_INCLUDING_BASICS_H
4# error "Please don't include StringView.h directly, but instead include Foundation/Basics.h"
7#include <Foundation/Strings/StringUtils.h>
9#include <Foundation/Strings/Implementation/StringIterator.h>
13#if PL_ENABLED(PL_INTEROP_STL_STRINGS)
14# include <string_view>
36 PL_DECLARE_POD_TYPE();
51 constexpr plStringView(T pStart,
typename std::enable_if<std::is_same<T, const char*>::value,
int>::type* = 0);
55 constexpr PL_ALWAYS_INLINE
plStringView(
const T&& str,
typename std::enable_if<std::is_same<T, const char*>::value ==
false && std::is_convertible<T, const char*>::value,
int>::type* = 0);
58 constexpr plStringView(
const char* pStart,
const char* pEnd);
61 constexpr plStringView(
const char* pStart, plUInt32 uiLength);
75 void operator+=(plUInt32 d);
78 plUInt32 GetCharacter()
const;
98 void SetStartPosition(
const char* szCurPos);
111 bool IsEmpty()
const;
120 bool IsEqualN(
plStringView sOther, plUInt32 uiCharsToCompare)
const;
123 bool IsEqualN_NoCase(
plStringView sOther, plUInt32 uiCharsToCompare)
const;
130 plInt32 CompareN(
plStringView sOther, plUInt32 uiCharsToCompare)
const;
137 plInt32 CompareN_NoCase(
plStringView sOther, plUInt32 uiCharsToCompare)
const;
152 const char* ComputeCharacterPosition(plUInt32 uiCharacterIndex)
const;
156 const char* FindSubString(
plStringView sStringToFind,
const char* szStartSearchAt =
nullptr)
const;
160 const char* FindSubString_NoCase(
plStringView sStringToFind,
const char* szStartSearchAt =
nullptr)
const;
164 const char* FindLastSubString(
plStringView sStringToFind,
const char* szStartSearchAt =
nullptr)
const;
168 const char* FindLastSubString_NoCase(
plStringView sStringToFind,
const char* szStartSearchAt =
nullptr)
const;
186 void Shrink(plUInt32 uiShrinkCharsFront, plUInt32 uiShrinkCharsBack);
189 plStringView GetShrunk(plUInt32 uiShrinkCharsFront, plUInt32 uiShrinkCharsBack = 0)
const;
196 plStringView GetSubString(plUInt32 uiFirstCharacter, plUInt32 uiNumCharacters)
const;
199 void ChopAwayFirstCharacterUtf8();
204 void ChopAwayFirstCharacterAscii();
207 void Trim(
const char* szTrimChars);
210 void Trim(
const char* szTrimCharsStart,
const char* szTrimCharsEnd);
223 template <
typename Container>
224 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;
230 iterator GetIteratorFront()
const;
236 reverse_iterator GetIteratorBack()
const;
241 bool HasAnyExtension()
const;
252 plStringView GetFileExtension(
bool bFullExtension =
false)
const;
274 bool IsAbsolutePath()
const;
277 bool IsRelativePath()
const;
280 bool IsRootedPath()
const;
291#if PL_ENABLED(PL_INTEROP_STL_STRINGS)
299 operator std::string_view()
const;
302 std::string_view GetAsStdView()
const;
306 const char* m_pStart =
nullptr;
307 plUInt32 m_uiElementCount = 0;
314constexpr plStringView operator"" _plsv(
const char* pString,
size_t uiLen);
357#include <Foundation/Strings/Implementation/StringView_inl.h>
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
bool(*)(plUInt32 uiChar) PL_CHARACTER_FILTER
Function Definition for a function that determines whether a (Utf32) character belongs to a certain c...
Definition StringUtils.h:209
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
constexpr plStringView(T pStart, typename std::enable_if< std::is_same< T, const char * >::value, int >::type *=0)
Creates a string view starting at the given position, ending at the next '\0' terminator.
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
constexpr plStringView(char(&str)[N])
Construct a string view from a fixed size buffer.
const char * GetStartPointer() const
Returns the start of the view range.
Definition StringView.h:102
constexpr plStringView()
Default constructor creates an invalid view.
constexpr plStringView(const char(&str)[N])
Construct a string view from a string literal.
STL forward iterator used by all string classes. Iterates over unicode characters....
Definition StringIterator.h:10
STL reverse iterator used by all string classes. Iterates over unicode characters....
Definition StringIterator.h:163
Base class which marks a class as containing string data.
Definition StringView.h:19