CryStringT

#include

Inherited by CryStringLocalT< T >.

Public Types

enum _npos_type : size_type { npos = (size_type) ~0 }
typedef CryStringT< T > _Self
typedef size_t size_type
typedef T value_type
typedef const value_type * const_str
typedef value_type * pointer
typedef const value_type * const_pointer
typedef value_type & reference
typedef const value_type & const_reference
typedef pointer iterator
typedef const_pointer const_iterator
typedef std::reverse_iterator< iterator > reverse_iterator
typedef std::reverse_iterator< const_iterator > const_reverse_iterator

Public Member Functions

CryStringT (const _Self &str)
CryStringT (const _Self &str, size_type nOff, size_type nCount)
CryStringT (size_type nRepeat, value_type ch)
CryStringT (const_str str)
CryStringT (const_str str, size_type nLength)
CryStringT (const_iterator _First, const_iterator _Last)
size_type length () const
Operators.
size_type size () const
bool empty () const
void clear ()
Frees the data.
size_type capacity () const
Returns the storage currently allocated to hold the string, a value at least as large as length().
void reserve (size_type nCount=0)
void shrink_to_fit ()
_Self & append (const value_type *_Ptr)
_Self & append (const value_type *_Ptr, size_type nCount)
_Self & append (const _Self &_Str, size_type nOff, size_type nCount)
_Self & append (const _Self &_Str)
_Self & append (size_type nCount, value_type _Ch)
_Self & append (const_iterator _First, const_iterator _Last)
_Self & assign (const_str _Ptr)
_Self & assign (const_str _Ptr, size_type nCount)
_Self & assign (const _Self &_Str, size_type off, size_type nCount)
_Self & assign (const _Self &_Str)
_Self & assign (size_type nCount, value_type _Ch)
_Self & assign (const_iterator _First, const_iterator _Last)
value_type at (size_type index) const
const_reference front () const
const_reference back () const
const_iterator begin () const
const_iterator cbegin () const
const_iterator end () const
const_iterator cend () const
const_reverse_iterator rbegin () const
const_reverse_iterator crbegin () const
const_reverse_iterator rend () const
const_reverse_iterator crend () const
operator const_str () const
cast to C string operator.
const value_type * c_str () const
cast to C string.
const value_type * data () const
int compare (const _Self &_Str) const
int compare (size_type _Pos1, size_type _Num1, const _Self &_Str) const
int compare (size_type _Pos1, size_type _Num1, const _Self &_Str, size_type nOff, size_type nCount) const
int compare (const char *_Ptr) const
int compare (const wchar_t *_Ptr) const
int compare (size_type _Pos1, size_type _Num1, const value_type *_Ptr, size_type _Num2=npos) const
int compareNoCase (const _Self &_Str) const
int compareNoCase (size_type _Pos1, size_type _Num1, const _Self &_Str) const
int compareNoCase (size_type _Pos1, size_type _Num1, const _Self &_Str, size_type nOff, size_type nCount) const
int compareNoCase (const value_type *_Ptr) const
int compareNoCase (size_type _Pos1, size_type _Num1, const value_type *_Ptr, size_type _Num2=npos) const
size_type copy (value_type *_Ptr, size_type nCount, size_type nOff=0) const
Copies at most a specified number of characters from an indexed position in a source string to a target character array.
void push_back (value_type _Ch)
void pop_back ()
void resize (size_type nCount, value_type _Ch=' ')
_Self substr (size_type pos, size_type count=npos) const
Simple sub-string extraction.
_Self & replace (value_type chOld, value_type chNew)
_Self & replace (const_str strOld, const_str strNew)
_Self & replace (size_type pos, size_type count, const_str strNew)
_Self & replace (size_type pos, size_type count, const_str strNew, size_type count2)
_Self & replace (size_type pos, size_type count, size_type nNumChars, value_type chNew)
_Self & insert (size_type nIndex, value_type ch)
_Self & insert (size_type nIndex, size_type nCount, value_type ch)
_Self & insert (size_type nIndex, const_str pstr)
_Self & insert (size_type nIndex, const_str pstr, size_type nCount)
_Self & erase (size_type nIndex, size_type count=npos)
Delete count characters starting at zero-based index.
size_type find (value_type ch, size_type pos=0) const
Find first single character. More...
size_type find (const_str subs, size_type pos=0) const
size_type rfind (value_type ch, size_type pos=npos) const
Find last single character.
size_type rfind (const _Self &subs, size_type pos=0) const
size_type find_first_of (value_type _Ch, size_type nOff=0) const
size_type find_first_of (const_str charSet, size_type nOff=0) const
size_type find_first_of (const _Self &_Str, size_type _Off=0) const
size_type find_first_not_of (value_type _Ch, size_type _Off=0) const
size_type find_first_not_of (const value_type *_Ptr, size_type _Off=0) const
size_type find_first_not_of (const value_type *_Ptr, size_type _Off, size_type _Count) const
size_type find_first_not_of (const _Self &_Str, size_type _Off=0) const
size_type find_last_of (value_type _Ch, size_type _Off=npos) const
size_type find_last_of (const value_type *_Ptr, size_type _Off=npos) const
This function is actually a convenience alias.
size_type find_last_of (const value_type *_Ptr, size_type _Off, size_type _Count) const
size_type find_last_of (const _Self &_Str, size_type _Off=npos) const
size_type find_last_not_of (value_type _Ch, size_type _Off=npos) const
size_type find_last_not_of (const value_type *_Ptr, size_type _Off=npos) const
This function is actually a convenience alias.
size_type find_last_not_of (const value_type *_Ptr, size_type _Off, size_type _Count) const
size_type find_last_not_of (const _Self &_Str, size_type _Off=npos) const
void swap (_Self &_Str)
_Self & operator= (const _Self &str)
_Self & operator= (value_type ch)
_Self & operator= (const_str str)
template
CryStringT (const CryStackStringT< T, AnySize > &str)
_Self & operator+= (const _Self &str)
_Self & operator+= (value_type ch)
_Self & operator+= (const_str str)
size_t GetAllocatedMemory () const
_Self & Format (const value_type *format,...)
_Self & FormatV (const value_type *format, va_list args)
_Self & MakeLower ()
_Self & MakeUpper ()
_Self & Trim ()
_Self & Trim (value_type ch)
_Self & Trim (const_str sCharSet)
_Self & TrimLeft ()
_Self & TrimLeft (value_type ch)
_Self & TrimLeft (const_str sCharSet)
_Self & TrimRight ()
_Self & TrimRight (value_type ch)
_Self & TrimRight (const_str sCharSet)
void Truncate (size_type nNewLength)
_Self SpanIncluding (const_str charSet) const
strspn equivalent.
_Self SpanExcluding (const_str charSet) const
strcspn equivalent.
_Self Tokenize (const_str charSet, int &nStart) const
_Self Mid (size_type nFirst, size_type nCount=npos) const
const_str GetString () const
const_str GetBuffer () const
int GetLength () const
bool IsEmpty () const
void Empty ()
_Self & Insert (size_type nIndex, value_type ch)
_Self & Insert (size_type nIndex, const_str charSet)
_Self & Insert (size_type nIndex, const _Self &charSet)
int Find (value_type ch, size_type pos=0) const
int Find (const_str subs, size_type pos=0) const
int ReverseFind (value_type ch, size_type pos=npos) const
int ReverseFind (const _Self &subs, size_type pos=0) const
int FindOneOf (const_str chars) const
_Self & Replace (value_type chOld, value_type chNew)
_Self & Replace (const_str strOld, const_str strNew)
int CompareNoCase (const _Self &_Str) const
int CompareNoCase (const value_type *_Ptr) const
int Compare (const _Self &_Str) const
int Compare (const char *_Ptr) const
_Self & Append (const value_type *_Ptr)
_Self & Append (const _Self &_Str)
_Self & Append (const value_type *_Ptr, size_type nCount)
_Self & AppendFormat (const value_type *pszFormat,...)
void Preallocate (size_type nLength)
_Self Delete (size_type nIndex, size_type nCount=1)
value_type GetAt (size_type pos) const
void SetAt (size_type pos, value_type ch)
_Self Left (size_type count) const
_Self Right (size_type count) const

Static Public Member Functions

static size_type _strlen (const_str str)
static size_type _strnlen (const_str str, size_type maxLen)
static const_str _strchr (const_str str, value_type c)
static const_str _strrchr (const_str str, value_type c)
static value_type * _strstr (value_type *str, const_str strSearch)
static bool _IsValidString (const_str str)
static size_t _usedMemory (ptrdiff_t size)
Only used for debugging statistics.

Protected Member Functions

CryStringT (const CConstCharWrapper &str)
Constructor for strings without memory allocations.
template
_Self & operator= (const CryStackStringT< T, AnySize > &str)
StrHeader * _header () const
void _AllocData (size_type nLen)
void _Free ()
void _Initialize ()
void _Concatenate (const_str sStr1, size_type nLen1, const_str sStr2, size_type nLen2)
void _ConcatenateInPlace (const_str sStr, size_type nLen)
void _Assign (const_str sStr, size_type nLen)
void _MakeUnique ()

Static Protected Member Functions

static StrHeader * _emptyHeader ()
static void _FreeData (StrHeader *pData)
static void _copy (value_type *dest, const value_type *src, size_type count)
static void _move (value_type *dest, const value_type *src, size_type count)
static void _set (value_type *dest, value_type ch, size_type count)

Protected Attributes

value_type * m_str
Pointer to ref counted string data.

Friends

class CConstCharWrapper

Detailed Description

template class CryStringT< T >

Reference-tracked string implementation, historically used to avoid string duplication across memory Enforced for use in the engine codebase as opposed to std::string

See also
string and wstring

Member Function Documentation

◆ _AllocData()

template
void CryStringT< T >::_AllocData ( size_type nLen)
inline
protected

Always allocate one extra character for '\0' termination. Assumes [optimistically] that data length will equal allocation length.

◆ _emptyHeader()

template
static StrHeader* CryStringT< T >::_emptyHeader ( )
inline
static
protected

String header. Actual string data starts immediately after this header in memory.

◆ find()

template
CryStringT< T >::size_type CryStringT< T >::find ( value_type ch,
size_type pos = 0
) const
inline

Find first single character.

Find a sub-string (like strstr).

Searching (return starting index, or -1 if not found). Look for a single character match (like "C" strchr).

◆ Format()

template
CryStringT< T > & CryStringT< T >::Format ( const value_type * format,
...
)
inline

Format string printf-like. This function exists in 'char' version of the class only: it's almost impossible to implement it robustly for wchar_t - different compilers handle wchar_t formatting differently.

◆ FormatV()

template
CryStringT< T > & CryStringT< T >::FormatV ( const value_type * format,
va_list args
)
inline

Format string printf-like. va_list version. This function exists in 'char' version of the class only: it's almost impossible to implement it robustly for wchar_t - different compilers handle wchar_t formatting differently.

◆ MakeLower()

template
CryStringT< T > & CryStringT< T >::MakeLower ( )
inline

Converts the string to lower-case. This function uses the "C" locale for case-conversion (ie, A-Z only).

◆ MakeUpper()

template
CryStringT< T > & CryStringT< T >::MakeUpper ( )
inline

Converts the string to upper-case. This function uses the "C" locale for case-conversion (ie, A-Z only).

◆ operator=()

template
template
_Self& CryStringT< T >::operator= ( const CryStackStringT< T, AnySize > & str)
inline
protected

We prohibit an implicit conversion from CryStackString to make user aware of allocation! -> use string(stackedString) instead.

◆ reserve()

template
void CryStringT< T >::reserve ( size_type nCount = 0)
inline

Sets the capacity of the string to a number at least as great as a specified number. nCount = 0 is shrinking string to fit number of characters in it (equivalent to shrink_to_fit()).