Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::cStringT< _TYPE_CH > Class Template Reference

#include <cString.h>

Inheritance diagram for Gray::cStringT< _TYPE_CH >:
Gray::CStringT< char >

Public Types

typedef _TYPE_CH CharType_t
 ALA std::string::value_type. More...
 

Public Member Functions

 cStringT () noexcept
 
 cStringT (SUPER_t &str) noexcept
 
 cStringT (const char *pszText)
 
 cStringT (const char *pszText, StrLen_t iLenMax)
 
 cStringT (const wchar_t *pwText)
 
 cStringT (const wchar_t *pwText, StrLen_t iLenMax)
 
const _TYPE_CH * get_CPtr () const noexcept
 
bool isPrintableString () const
 
bool isValidString () const noexcept
 
bool isValidCheck () const noexcept
 
bool IsWhitespace () const
 
HRESULT ReadZ (cStreamInput &File, StrLen_t iLenMax)
 
bool WriteZ (cStreamOutput &File) const
 
HASHCODE_t get_HashCode () const noexcept
 
size_t GetHeapStats (OUT ITERATE_t &iAllocCount) const
 
int get_RefCount () const
 
void SetStringStatic ()
 
StrLen_t SetCodePage (const wchar_t *pwText, CODEPAGE_t uCodePage=CP_UTF8)
 
StrLen_t GetCodePage (OUT wchar_t *pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage=CP_UTF8) const
 
THIS_t GetTrimWhitespace () const
 
HRESULT SerializeInput (cStreamInput &File, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
HRESULT SerializeOutput (cStreamOutput &File) const
 
HRESULT SerializeOutput (cArchive &a) const
 
HRESULT Serialize (cArchive &a)
 
const THIS_toperator= (const THIS_t &s)
 
const THIS_toperator= (const char *pszStr)
 
const THIS_toperator= (const wchar_t *pwStr)
 
void SetErase ()
 
bool Contains (const _TYPE_CH *pSubStr)
 
bool ContainsI (const _TYPE_CH *pSubStr)
 
bool StartsWithI (const _TYPE_CH *pSubStr)
 
bool EndsWithI (const _TYPE_CH *pSubStr) const
 
const _TYPE_CH * c_str () const
 
StrLen_t size () const
 
StrLen_t length () const
 
bool empty () const
 
StrLen_t find (_TYPE_CH ch) const
 
void assign (const _TYPE_CH *pszStr, StrLen_t iLenCat)
 
void append (const _TYPE_CH *pszStr, StrLen_t iLenCat)
 
void push_back (_TYPE_CH ch)
 
void resize (StrLen_t iSize)
 
void reserve (StrLen_t iSize)
 
THIS_t substr (StrLen_t nFirst, StrLen_t nCount=StrT::k_LEN_MAX) const
 
StrLen_t SetCodePage (const wchar_t *pwStr, CODEPAGE_t uCodePage)
 
StrLen_t SetCodePage (const wchar_t *pwStr, CODEPAGE_t uCodePage)
 
StrLen_t GetCodePage (OUT wchar_t *pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage) const
 
StrLen_t GetCodePage (OUT wchar_t *pwText, StrLen_t iLenMax, CODEPAGE_t uCodePage) const
 
- Public Member Functions inherited from Gray::CStringT< char >
 CStringT () noexcept
 
 CStringT (const wchar_t *pwText)
 
 CStringT (const wchar_t *pwText, StrLen_t iLenMax)
 
 CStringT (const char *pszStr)
 
 CStringT (const char *pszStr, StrLen_t iLenMax)
 
 CStringT (const THIS_t &ref) noexcept
 
 CStringT (THIS_t &&ref) noexcept
 
 ~CStringT ()
 
CStringDataGetData () const noexcept
 
const char * GetString () const noexcept
 
bool isValidString () const noexcept
 
bool IsEmpty () const noexcept
 
StrLen_t GetLength () const noexcept
 
void Empty ()
 
const char & ReferenceAt (StrLen_t nIndex) const
 
char GetAt (StrLen_t nIndex) const
 
void SetAt (StrLen_t nIndex, char ch)
 
char * GetBuffer (StrLen_t iMinLength)
 
void ReleaseBuffer (StrLen_t nNewLength=k_StrLen_UNK)
 
const THIS_toperator= (const THIS_t &ref)
 
const THIS_toperator= (THIS_t &&ref)
 
const THIS_toperator= (const char *pStr)
 
const THIS_toperator= (const wchar_t *pStr)
 
void AssignLenT (const char *pszStr, StrLen_t iLenMax)
 
void AssignLen (const char *pszStr, StrLen_t iSizeMax=StrT::k_LEN_MAX)
 
void AssignLen (const wchar_t *pwText, StrLen_t iSizeMax=StrT::k_LEN_MAX)
 
void AssignLen (const wchar_t *pwStr, StrLen_t iLenMax)
 
void AssignLen (const char *pszStr, StrLen_t iLenMax)
 
void AssignLen (const char *pszStr, StrLen_t iLenMax)
 
void AssignLen (const wchar_t *pwStr, StrLen_t iLenMax)
 
void FormatV (const char *pszStr, va_list args)
 
void _cdecl Format (const char *pszStr,...)
 
COMPARE_t Compare (const char *pszStr) const
 
COMPARE_t CompareNoCase (const char *pszStr) const
 
void MakeUpper ()
 
void MakeLower ()
 
THIS_t Left (StrLen_t nCount) const
 
THIS_t Right (StrLen_t nCount) const
 
THIS_t Mid (StrLen_t nFirst, StrLen_t nCount=StrT::k_LEN_MAX) const
 
void TrimRight ()
 
void TrimLeft ()
 
StrLen_t Find (char ch, StrLen_t nPosStart=0) const
 
char operator[] (StrLen_t nIndex) const
 
const char & operator[] (StrLen_t nIndex)
 
 operator const char * () const
 
StrLen_t Insert (StrLen_t nIndex, char ch)
 
StrLen_t Insert (StrLen_t nIndex, const char *pszStr, StrLen_t iLenCat)
 
StrLen_t Insert (StrLen_t nIndex, const char *pszStr)
 
const THIS_toperator+= (char ch)
 
const THIS_toperator+= (const char *psz)
 
void Assign (const THIS_t &str)
 
void Assign (const wchar_t *pwText)
 
void Assign (const char *pszStr)
 
void Assign (const wchar_t *pwStr)
 
void Assign (const char *pszStr)
 
void Assign (const wchar_t *pwStr)
 
void Assign (const char *pszStr)
 

Static Public Member Functions

static THIS_t _cdecl GetFormatf (const _TYPE_CH *pszFormat,...)
 
static THIS_t __stdcall GetErrorStringV (HRESULT nFormatID, void *pSource, va_list vargs)
 
static THIS_t __stdcall GetErrorString (HRESULT nFormatID, void *pSource=nullptr)
 
static THIS_t _cdecl GetErrorStringf (HRESULT nFormatID, void *pSource,...)
 
static THIS_t __stdcall GetSizeK (UINT64 uVal, UINT nKUnit=1024, bool bSpace=false)
 

Static Public Attributes

static const int npos = -1
 

Friends

class cStringTests
 

Additional Inherited Members

- Protected Member Functions inherited from Gray::CStringT< char >
const char m_Nil
 
const wchar_t m_Nil
 
void Init () noexcept
 
void EmptyValid ()
 
void AssignFirst (const THIS_t &s) noexcept
 
void AllocBuffer (StrLen_t iStrLength)
 
void CopyBeforeWrite ()
 
- Protected Attributes inherited from Gray::CStringT< char >
char * m_pchData
 
- Static Protected Attributes inherited from Gray::CStringT< char >
static const char m_Nil
 

Detailed Description

template<typename _TYPE_CH = char>
class Gray::cStringT< _TYPE_CH >

A string with added functions over the MFC CString core set. Use this for best string functionality.

Member Typedef Documentation

◆ CharType_t

template<typename _TYPE_CH = char>
typedef _TYPE_CH Gray::cStringT< _TYPE_CH >::CharType_t

ALA std::string::value_type.

Constructor & Destructor Documentation

◆ cStringT() [1/6]

template<typename _TYPE_CH = char>
Gray::cStringT< _TYPE_CH >::cStringT ( )
inlinenoexcept

◆ cStringT() [2/6]

template<typename _TYPE_CH = char>
Gray::cStringT< _TYPE_CH >::cStringT ( SUPER_t str)
inlinenoexcept

◆ cStringT() [3/6]

template<typename _TYPE_CH = char>
Gray::cStringT< _TYPE_CH >::cStringT ( const char *  pszText)
inline

◆ cStringT() [4/6]

template<typename _TYPE_CH = char>
Gray::cStringT< _TYPE_CH >::cStringT ( const char *  pszText,
StrLen_t  iLenMax 
)
inline

iLenMax = _countof(StrT::k_LEN_MAX)-1 default. not including '\0' iLenMax = max chars, not including '\0' ! NOT sizeof() or _countof() like StrT::CopyLen

◆ cStringT() [5/6]

template<typename _TYPE_CH = char>
Gray::cStringT< _TYPE_CH >::cStringT ( const wchar_t *  pwText)
inline

◆ cStringT() [6/6]

template<typename _TYPE_CH = char>
Gray::cStringT< _TYPE_CH >::cStringT ( const wchar_t *  pwText,
StrLen_t  iLenMax 
)
inline

iLenMax = _countof(StrT::k_LEN_MAX)-1 default iLenMax = max chars, not including '\0' ! NOT sizeof() or _countof() like StrT::CopyLen

Member Function Documentation

◆ append()

template<typename _TYPE_CH = char>
void Gray::cStringT< _TYPE_CH >::append ( const _TYPE_CH *  pszStr,
StrLen_t  iLenCat 
)
inline

◆ assign()

template<typename _TYPE_CH = char>
void Gray::cStringT< _TYPE_CH >::assign ( const _TYPE_CH *  pszStr,
StrLen_t  iLenCat 
)
inline

◆ c_str()

template<typename _TYPE_CH = char>
const _TYPE_CH* Gray::cStringT< _TYPE_CH >::c_str ( ) const
inline

◆ Contains()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::Contains ( const _TYPE_CH *  pSubStr)
inline

◆ ContainsI()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::ContainsI ( const _TYPE_CH *  pSubStr)
inline

◆ empty()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::empty ( ) const
inline

◆ EndsWithI()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::EndsWithI ( const _TYPE_CH *  pSubStr) const
inline

◆ find()

template<typename _TYPE_CH = char>
StrLen_t Gray::cStringT< _TYPE_CH >::find ( _TYPE_CH  ch) const
inline
Returns
npos = -1 = not found.

◆ get_CPtr()

template<typename _TYPE_CH = char>
const _TYPE_CH* Gray::cStringT< _TYPE_CH >::get_CPtr ( ) const
inlinenoexcept

◆ get_HashCode()

template<typename _TYPE_CH = char>
HASHCODE_t Gray::cStringT< _TYPE_CH >::get_HashCode ( ) const
inlinenoexcept

Get a hash code good on this machine alone. Must use something like StrT::GetHashCode32() for use on multiple machines or processes.

◆ get_RefCount()

template<typename _TYPE_CH = char>
int Gray::cStringT< _TYPE_CH >::get_RefCount ( ) const
inline

◆ GetCodePage() [1/3]

StrLen_t Gray::cStringT< char >::GetCodePage ( OUT wchar_t *  pwText,
StrLen_t  iLenMax,
CODEPAGE_t  uCodePage 
) const

Convert char with CODEPAGE_t to UNICODE.

◆ GetCodePage() [2/3]

StrLen_t Gray::cStringT< wchar_t >::GetCodePage ( OUT wchar_t *  pwText,
StrLen_t  iLenMax,
CODEPAGE_t  uCodePage 
) const

Just copy. No conversion if already UNICODE.

◆ GetCodePage() [3/3]

template<typename _TYPE_CH = char>
StrLen_t Gray::cStringT< _TYPE_CH >::GetCodePage ( OUT wchar_t *  pwText,
StrLen_t  iLenMax,
CODEPAGE_t  uCodePage = CP_UTF8 
) const

◆ GetErrorString()

template<typename _TYPE_CH >
cStringT< _TYPE_CH > Gray::cStringT< _TYPE_CH >::GetErrorString ( HRESULT  nFormatID,
void *  pSource = nullptr 
)
static

hResError = HRESULT_WIN32_C(ERROR_INTERNAL_ERROR) etc.

Note
use HResult::FromWin32(x) instead of raw "::GetLastError()"

◆ GetErrorStringf()

template<typename _TYPE_CH >
cStringT< _TYPE_CH > _cdecl Gray::cStringT< _TYPE_CH >::GetErrorStringf ( HRESULT  nFormatID,
void *  pSource,
  ... 
)
static

hResError = HRESULT_WIN32_C(ERROR_INTERNAL_ERROR) etc.

Note
Must use HResult::FromWin32(x) instead of raw "::GetLastError()"

◆ GetErrorStringV()

template<typename _TYPE_CH >
cStringT< _TYPE_CH > Gray::cStringT< _TYPE_CH >::GetErrorStringV ( HRESULT  nFormatID,
void *  pSource,
va_list  vargs 
)
static

Describe a system error code as a string. hResError = HRESULT_WIN32_C(ERROR_INTERNAL_ERROR) etc.

Note
Must use HResult::FromWin32(x) instead of raw "::GetLastError()"

◆ GetFormatf()

template<typename _TYPE_CH >
cStringT< _TYPE_CH > _cdecl Gray::cStringT< _TYPE_CH >::GetFormatf ( const _TYPE_CH *  pszFormat,
  ... 
)
static

Make a formatted string.

◆ GetHeapStats()

template<typename _TYPE_CH = char>
size_t Gray::cStringT< _TYPE_CH >::GetHeapStats ( OUT ITERATE_t iAllocCount) const
inline

Get data allocations for all children. does not include sizeof(*this)

◆ GetSizeK()

template<typename _TYPE_CH >
cStringT< _TYPE_CH > Gray::cStringT< _TYPE_CH >::GetSizeK ( UINT64  uVal,
UINT  nKUnit = 1024,
bool  bSpace = false 
)
static

◆ GetTrimWhitespace()

template<typename _TYPE_CH >
cStringT< _TYPE_CH > Gray::cStringT< _TYPE_CH >::GetTrimWhitespace

Trim whitespace from both ends.

◆ isPrintableString()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::isPrintableString ( ) const
inline

◆ isValidCheck()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::isValidCheck ( ) const
inlinenoexcept

◆ isValidString()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::isValidString ( ) const
inlinenoexcept

◆ IsWhitespace()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::IsWhitespace ( ) const
inline

Like .NET String.IsNullOrWhitespace

◆ length()

template<typename _TYPE_CH = char>
StrLen_t Gray::cStringT< _TYPE_CH >::length ( ) const
inline

◆ operator=() [1/3]

template<typename _TYPE_CH = char>
const THIS_t& Gray::cStringT< _TYPE_CH >::operator= ( const char *  pszStr)
inline

◆ operator=() [2/3]

template<typename _TYPE_CH = char>
const THIS_t& Gray::cStringT< _TYPE_CH >::operator= ( const THIS_t s)
inline

◆ operator=() [3/3]

template<typename _TYPE_CH = char>
const THIS_t& Gray::cStringT< _TYPE_CH >::operator= ( const wchar_t *  pwStr)
inline

◆ push_back()

template<typename _TYPE_CH = char>
void Gray::cStringT< _TYPE_CH >::push_back ( _TYPE_CH  ch)
inline

◆ ReadZ()

template<typename _TYPE_CH >
HRESULT Gray::cStringT< _TYPE_CH >::ReadZ ( cStreamInput File,
StrLen_t  iLenMax 
)

Read in a new string from an open binary file. No length prefix.

  • pFile = the open file. iLenMax = The length of the string to read. NOT THE '\0' !
    Returns
    <= 0 = error or no valid string. length of the string.

◆ reserve()

template<typename _TYPE_CH = char>
void Gray::cStringT< _TYPE_CH >::reserve ( StrLen_t  iSize)
inline

◆ resize()

template<typename _TYPE_CH = char>
void Gray::cStringT< _TYPE_CH >::resize ( StrLen_t  iSize)
inline

◆ Serialize()

template<typename _TYPE_CH >
HRESULT Gray::cStringT< _TYPE_CH >::Serialize ( cArchive a)

Serialize in either direction.

◆ SerializeInput()

template<typename _TYPE_CH >
HRESULT Gray::cStringT< _TYPE_CH >::SerializeInput ( cStreamInput File,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)

Read in a new string from an open cStreamInput. CString Assume a size prefix. (in bytes not chars)

  • File = the open file. iLenMax = Truncate to MAX length of the string to read. NOT THE '\0' !
    Returns
    < 0 = error or no valid string. 0 = empty string. length of the string.

◆ SerializeOutput() [1/2]

template<typename _TYPE_CH >
HRESULT Gray::cStringT< _TYPE_CH >::SerializeOutput ( cArchive a) const

◆ SerializeOutput() [2/2]

template<typename _TYPE_CH >
HRESULT Gray::cStringT< _TYPE_CH >::SerializeOutput ( cStreamOutput File) const

Write a string AND length (in bytes not chars) out to the file.

  • File = the open file.
    Note
    This is NOT '\0' term. though Standard RIFF strings are!

◆ SetCodePage() [1/3]

StrLen_t Gray::cStringT< char >::SetCodePage ( const wchar_t *  pwStr,
CODEPAGE_t  uCodePage 
)

Convert UNICODE to CODEPAGE_t ASCII type string.

◆ SetCodePage() [2/3]

StrLen_t Gray::cStringT< wchar_t >::SetCodePage ( const wchar_t *  pwStr,
CODEPAGE_t  uCodePage 
)

Just copy. No conversion since its already UNICODE.

◆ SetCodePage() [3/3]

template<typename _TYPE_CH = char>
StrLen_t Gray::cStringT< _TYPE_CH >::SetCodePage ( const wchar_t *  pwText,
CODEPAGE_t  uCodePage = CP_UTF8 
)

◆ SetErase()

template<typename _TYPE_CH = char>
void Gray::cStringT< _TYPE_CH >::SetErase ( )
inline

Clear this more thoroughly for security reasons. passwords, etc ZeroSecure ?

◆ SetStringStatic()

template<typename _TYPE_CH = char>
void Gray::cStringT< _TYPE_CH >::SetStringStatic ( )
inline

Make this string permanent. never removed from memory.

◆ size()

template<typename _TYPE_CH = char>
StrLen_t Gray::cStringT< _TYPE_CH >::size ( ) const
inline

◆ StartsWithI()

template<typename _TYPE_CH = char>
bool Gray::cStringT< _TYPE_CH >::StartsWithI ( const _TYPE_CH *  pSubStr)
inline

◆ substr()

template<typename _TYPE_CH = char>
THIS_t Gray::cStringT< _TYPE_CH >::substr ( StrLen_t  nFirst,
StrLen_t  nCount = StrT::k_LEN_MAX 
) const
inline

◆ WriteZ()

template<typename _TYPE_CH >
bool Gray::cStringT< _TYPE_CH >::WriteZ ( cStreamOutput File) const

Write a string AND '\0' out to the file. No length prefix.

  • File = the open file.
    Note
    Standard RIFF strings are '\0' terminated !

Friends And Related Function Documentation

◆ cStringTests

template<typename _TYPE_CH = char>
friend class cStringTests
friend

Member Data Documentation

◆ npos

template<typename _TYPE_CH = char>
const int Gray::cStringT< _TYPE_CH >::npos = -1
static

emulate STL string operators. Is any of this needed ??


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