Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
Gray::StrT Struct Reference

#include <StrT.h>

Inheritance diagram for Gray::StrT:
Gray::StrX< TYPE >

Public Member Functions

template<typename TYPE >
COMPARE_t __stdcall Cmp (const TYPE *pszStr1, const TYPE *pszStr2)
 
template<typename TYPE >
COMPARE_t __stdcall CmpN (const TYPE *pszStr1, const TYPE *pszStr2, StrLen_t iLenMaxChars) noexcept
 
template<typename TYPE >
COMPARE_t __stdcall CmpI (const TYPE *pszStr1, const TYPE *pszStr2)
 
template<typename TYPE >
COMPARE_t __stdcall CmpIN (const TYPE *pszStr1, const TYPE *pszStr2, StrLen_t iLenMaxChars) noexcept
 
template<typename TYPE >
bool StartsWithI (const TYPE *pszStr1, const TYPE *pszPrefix)
 
template<typename TYPE >
bool __stdcall EndsWithI (const TYPE *pszStr1, const TYPE *pszPostfix, StrLen_t nLenStr)
 
template<typename TYPE >
COMPARE_t __stdcall CmpHeadI (const TYPE *pszFindHead, const TYPE *pszTableElem)
 
template<typename TYPE >
HASHCODE32_t __stdcall GetHashCode32 (const TYPE *pszStr, StrLen_t nLen, HASHCODE32_t nHash) noexcept
 
template<typename TYPE >
StrLen_t __stdcall FindCharN (const TYPE *pszStr, TYPE chFind) noexcept
 
template<typename TYPE >
TYPE *__stdcall FindChar (const TYPE *pszStr, TYPE chFind, StrLen_t iLenMax) noexcept
 
template<typename TYPE >
TYPE *__stdcall FindCharRev (const TYPE *pszStr, TYPE chFind, StrLen_t iLenMax)
 
template<typename TYPE >
TYPE *__stdcall FindTokens (const TYPE *pszStr, const TYPE *pszTokens, StrLen_t iLenMaxChars)
 
template<typename TYPE >
TYPE *__stdcall FindStr (const TYPE *pszText, const TYPE *pszSubStr, StrLen_t iLenMaxChars)
 
template<typename TYPE >
TYPE *__stdcall FindStrI (const TYPE *pszText, const TYPE *pszSubStr, StrLen_t iLenMaxChars)
 
template<typename TYPE >
StrLen_t __stdcall FindWord (const TYPE *pszText, const TYPE *pszKeyWord, StrLen_t iLenMaxChars)
 
template<typename TYPE >
bool __stdcall IsWhitespace (const TYPE *pStr, StrLen_t iLenMaxChars)
 
template<typename TYPE >
StrLen_t __stdcall GetWhitespaceEnd (const TYPE *pStr, StrLen_t iLenChars)
 
template<typename TYPE >
bool __stdcall IsPrintable (const TYPE *pStr, StrLen_t iLenChars)
 
template<typename TYPE >
ITERATE_t __stdcall TableFindHead (const TYPE *pszFindHead, const void *ppszTableInit, size_t nElemSize)
 
template<typename TYPE >
ITERATE_t __stdcall TableFindHeadSorted (const TYPE *pszFindHead, const void *ppszTableInit, ITERATE_t iCountMax, size_t nElemSize)
 
template<typename TYPE >
ITERATE_t __stdcall TableFind (const TYPE *pszFindThis, const void *ppszTableInit, size_t nElemSize)
 
template<typename TYPE >
ITERATE_t __stdcall TableFindSorted (const TYPE *pszFindThis, const void *ppszTableInit, ITERATE_t iCountMax, size_t nElemSize)
 
template<typename TYPE >
StrLen_t __stdcall CopyLen (TYPE *pDst, const TYPE *pSrc, StrLen_t iLenMaxChars) noexcept
 
template<typename TYPE >
StrLen_t __stdcall TrimWhitespaceEnd (TYPE *pStr, StrLen_t iLenChars)
 
template<typename TYPE >
TYPE *__stdcall TrimWhitespace (TYPE *pStr, StrLen_t iLenMax)
 
template<typename TYPE >
StrLen_t __stdcall ReplaceX (TYPE *pDst, StrLen_t iDstLenMax, StrLen_t iDstIdx, StrLen_t iDstSegLen, const TYPE *pSrc, StrLen_t iSrcLen)
 
template<typename TYPE >
TYPE *__stdcall FindBlockEnd (STR_BLOCK_TYPE eBlockType, const TYPE *pszLine, StrLen_t iLenMaxChars)
 
template<typename TYPE >
TYPE *__stdcall StripBlock (TYPE *pszText)
 
template<typename TYPE >
StrLen_t __stdcall EscSeqRemove (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax, StrLen_t iLenInMax)
 
template<typename TYPE >
StrLen_t __stdcall EscSeqRemoveQ (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax, StrLen_t iLenInMax)
 
template<typename TYPE >
StrLen_t __stdcall EscSeqAdd (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax)
 
template<typename TYPE >
StrLen_t __stdcall EscSeqAddQ (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax)
 
template<typename TYPE >
ITERATE_t __stdcall ParseCmds (TYPE *pszCmdLine, StrLen_t nCmdLenMax, TYPE **ppCmd, ITERATE_t iCmdQtyMax, const TYPE *pszSep, STRP_MASK_t uFlags)
 
template<typename TYPE >
ITERATE_t __stdcall ParseCmdsTmp (TYPE *pszTmp, StrLen_t iTmpSizeMax, const TYPE *pszCmdLine, TYPE **ppCmd, ITERATE_t iCmdQtyMax, const TYPE *pszSep, STRP_MASK_t uFlags)
 
template<typename TYPE >
StrLen_t __stdcall MatchRegEx (const TYPE *pText, const TYPE *pPattern, bool bIgnoreCase, StrLen_t nTextMax)
 
template<typename TYPE >
StrLen_t __stdcall ULtoAK (UINT64 uVal, OUT TYPE *pszOut, StrLen_t iStrMax, UINT nKUnit, bool bSpace)
 

Static Public Member Functions

template<typename TYPE >
static StrLen_t Len (const TYPE *pszStr) noexcept
 
template<typename TYPE >
static const TYPECast (const TYPE *pszStr)
 
template<typename TYPE >
static bool IsNullOrEmpty (const TYPE *pszStr) noexcept
 
template<typename TYPE >
static const TYPECheckEmpty (const TYPE *pszStr) noexcept
 
template<typename TYPE >
static StrLen_t Len (const TYPE *pszStr, StrLen_t iLenMax) noexcept
 
template<typename TYPE >
static StrLen_t Diff (const TYPE *pszEnd, const TYPE *pszStart)
 
template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall Cmp (const TYPE *pszStr1, const TYPE *pszStr2)
 
template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall CmpN (const TYPE *pszStr1, const TYPE *pszStr2, StrLen_t iLenMaxChars) noexcept
 
template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall CmpI (const TYPE *pszStr1, const TYPE *pszStr2)
 
template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall CmpIN (const TYPE *pszStr1, const TYPE *pszStr2, StrLen_t iLenMaxChars) noexcept
 
template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall CmpHeadI (const TYPE *pszFind, const TYPE *pszTableElem)
 
template<typename TYPE >
static __DECL_IMPORT bool __stdcall StartsWithI (const TYPE *pszStr2, const TYPE *pszPrefix)
 
template<typename TYPE >
static __DECL_IMPORT bool __stdcall EndsWithI (const TYPE *pszStr2, const TYPE *pszPostfix, StrLen_t nLenStr=k_StrLen_UNK)
 
template<typename TYPE >
static __DECL_IMPORT HASHCODE32_t __stdcall GetHashCode32 (const TYPE *pszStr, StrLen_t nLen=k_StrLen_UNK, HASHCODE32_t nHash=k_HASHCODE_CLEAR) noexcept
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall FindChar (const TYPE *pszStr, TYPE ch, StrLen_t iLen=StrT::k_LEN_MAX) noexcept
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall FindCharN (const TYPE *pszStr, TYPE ch) noexcept
 
template<typename TYPE >
static bool HasChar (const TYPE *pszStr, TYPE ch) noexcept
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall FindCharRev (const TYPE *pszStr, TYPE ch, StrLen_t iLen=k_StrLen_UNK)
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall FindTokens (const TYPE *pszStr, const TYPE *pszTokens, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall FindStr (const TYPE *pszStr, const TYPE *pszFind, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall FindStrI (const TYPE *pszStr, const TYPE *pszFind, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall FindWord (const TYPE *pTextSearch, const TYPE *pszKeyWord, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static StrLen_t GetNonWhitespaceI (const TYPE *pStr, StrLen_t iLenMax=StrT::k_LEN_MAX) noexcept
 
template<typename TYPE >
static const TYPEGetNonWhitespace (const TYPE *pStr, StrLen_t iLenMax=StrT::k_LEN_MAX) noexcept
 
template<typename TYPE >
static TYPEGetNonWhitespace (TYPE *pStr, StrLen_t iLenMax=StrT::k_LEN_MAX) noexcept
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall GetWhitespaceEnd (const TYPE *pStr, StrLen_t iLenChars=k_StrLen_UNK)
 
template<typename TYPE >
static __DECL_IMPORT bool __stdcall IsWhitespace (const TYPE *pStr, StrLen_t iLenChars=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT bool __stdcall IsPrintable (const TYPE *pStr, StrLen_t iLenChars=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall TableFind (const TYPE *pszFindThis, const void *ppszTableInit, size_t nElemSize=sizeof(const TYPE *))
 
template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall TableFindHead (const TYPE *pszFindHead, const void *ppszTableInit, size_t nElemSize=sizeof(const TYPE *))
 
template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall TableFindSorted (const TYPE *pszFindThis, const void *ppszTableInit, ITERATE_t iCountMax, size_t nElemSize=sizeof(const TYPE *))
 
template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall TableFindHeadSorted (const TYPE *pszFindHead, const void *ppszTableInit, ITERATE_t iCountMax, size_t nElemSize=sizeof(const TYPE *))
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall MatchRegEx (const TYPE *pText, const TYPE *pRegExPattern, bool bIgnoreCase, StrLen_t nTextMax=k_StrLen_UNK)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall CopyLen (TYPE *pszDst, const TYPE *pSrc, StrLen_t iLenCharsMax) noexcept
 
template<typename TYPE >
static void MakeUpperCase (TYPE *pszDst, StrLen_t iLenCharsMax) noexcept
 
template<typename TYPE >
static void MakeLowerCase (TYPE *pszDst, StrLen_t iLenCharsMax) noexcept
 
template<typename TYPE >
static StrLen_t vsprintfN (OUT TYPE *pszOut, StrLen_t iLenOutMax, const TYPE *pszFormat, va_list vlist)
 
template<typename TYPE >
static StrLen_t _cdecl sprintfN (OUT TYPE *pszOut, StrLen_t iLenOutMax, const TYPE *pszFormat,...)
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall FindBlockEnd (STR_BLOCK_TYPE eBlockType, const TYPE *pLine, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall StripBlock (TYPE *pszText)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall EscSeqRemove (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax=StrT::k_LEN_MAX, StrLen_t iLenInMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall EscSeqRemoveQ (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax=StrT::k_LEN_MAX, StrLen_t iLenInMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall EscSeqAdd (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall EscSeqAddQ (TYPE *pStrOut, const TYPE *pStrIn, StrLen_t iLenOutMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall TrimWhitespaceEnd (TYPE *pStr, StrLen_t iLenChars=k_StrLen_UNK)
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall TrimWhitespace (TYPE *pStr, StrLen_t iLenMax=StrT::k_LEN_MAX)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall ReplaceX (TYPE *pDst, StrLen_t iDstLenMax, StrLen_t nDstIdx, StrLen_t iDstSegLen, const TYPE *pSrc, StrLen_t iSrcLen=k_StrLen_UNK)
 
template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall ParseCmds (TYPE *pszCmdLine, StrLen_t nCmdLenMax, TYPE **ppCmds, ITERATE_t iQtyMax, const TYPE *pszSep=nullptr, STRP_MASK_t uFlags=STRP_DEF)
 
template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall ParseCmdsTmp (TYPE *pszTmp, StrLen_t iTmpSizeMax, const TYPE *pszCmdLine, TYPE **ppCmds, ITERATE_t iCmdQtyMax, const TYPE *pszSep=nullptr, STRP_MASK_t uFlags=STRP_DEF)
 
template<typename TYPE >
static __DECL_IMPORT UINT64 __stdcall toUL (const TYPE *pszStr, const TYPE **ppszStrEnd=nullptr, RADIX_t nBaseRadix=0)
 
template<typename TYPE >
static __DECL_IMPORT INT64 __stdcall toIL (const TYPE *pszStr, const TYPE **ppszStrEnd=nullptr, RADIX_t nBaseRadix=10)
 
template<typename TYPE >
static UINT_PTR toUP (const TYPE *pszStr, const TYPE **ppszStrEnd=nullptr, RADIX_t nBaseRadix=0)
 
template<typename TYPE >
static INT_PTR toIP (const TYPE *pszStr, const TYPE **ppszStrEnd=nullptr, RADIX_t nBaseRadix=10)
 
template<typename TYPE >
static UINT toU (const TYPE *pszStr, const TYPE **ppszStrEnd=nullptr, RADIX_t nBaseRadix=0)
 
template<typename TYPE >
static int toI (const TYPE *pszStr, const TYPE **ppszStrEnd=nullptr, RADIX_t nBaseRadix=10)
 
template<typename TYPE >
static __DECL_IMPORT TYPE *__stdcall ULtoA2 (UINT64 uVal, TYPE *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix=10, char chRadixA='A')
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall ULtoA (UINT64 nVal, TYPE *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix=10)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall ILtoA (INT64 nVal, OUT TYPE *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix=10)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall ULtoAK (UINT64 uVal, OUT TYPE *pszStr, StrLen_t iStrMax, UINT nKUnit=1024, bool bSpace=true)
 
template<typename TYPE >
static StrLen_t UtoA (UINT32 nVal, OUT TYPE *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10)
 
template<typename TYPE >
static StrLen_t ItoA (INT32 nVal, OUT TYPE *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10)
 
template<typename TYPE >
static __DECL_IMPORT double __stdcall toDouble (const TYPE *pszStr, const TYPE **ppszStrEnd=nullptr)
 
template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall DtoA (double nVal, OUT TYPE *pszOut, StrLen_t iStrMax, int iDecPlaces=-1, char chE=- 'e')
 
template<>
StrLen_t Len (const char *pszStr) noexcept
 
template<>
StrLen_t Len (const wchar_t *pszStr) noexcept
 
template<>
UINT64 toUL (const char *pszStr, const char **ppszStrEnd, RADIX_t nBaseRadix)
 
template<>
UINT64 toUL (const wchar_t *pszStr, const wchar_t **ppszStrEnd, RADIX_t nBaseRadix)
 
template<>
INT64 toIL (const char *pszStr, const char **ppszStrEnd, RADIX_t nBaseRadix)
 
template<>
INT64 toIL (const wchar_t *pszStr, const wchar_t **ppszStrEnd, RADIX_t nBaseRadix)
 
template<>
double toDouble (const char *pszStr, const char **ppszStrEnd)
 
template<>
double toDouble (const wchar_t *pszStr, const wchar_t **ppszStrEnd)
 
template<>
char * ULtoA2 (UINT64 uVal, char *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix, char chRadixA)
 
template<>
wchar_t * ULtoA2 (UINT64 uVal, wchar_t *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix, char chRadixA)
 
template<>
StrLen_t ULtoA (UINT64 uVal, char *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix)
 
template<>
StrLen_t ULtoA (UINT64 uVal, wchar_t *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix)
 
template<>
StrLen_t ILtoA (INT64 uVal, char *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix)
 
template<>
StrLen_t ILtoA (INT64 uVal, wchar_t *pszOut, StrLen_t iOutMax, RADIX_t nBaseRadix)
 
template<>
StrLen_t DtoA (double nVal, OUT char *pszOut, StrLen_t iStrMax, int iDecPlaces, char chE)
 
template<>
StrLen_t DtoA (double nVal, OUT wchar_t *pszOut, StrLen_t iOutMax, int iDecPlaces, char chE)
 
template<>
StrLen_t ULtoAK (UINT64 uVal, OUT char *pszOut, StrLen_t iStrMax, UINT nKUnit, bool bSpace)
 
template<>
StrLen_t ULtoAK (UINT64 uVal, OUT wchar_t *pszOut, StrLen_t iStrMax, UINT nKUnit, bool bSpace)
 
template<>
StrLen_t vsprintfN (OUT char *pszOut, StrLen_t iLenOutMax, const char *pszFormat, va_list vlist)
 
template<>
StrLen_t vsprintfN (OUT wchar_t *pszOut, StrLen_t iLenOutMax, const wchar_t *pszFormat, va_list vlist)
 

Static Public Attributes

static const StrLen_t k_LEN_MAX = 15000
 arbitrary max size for Format() etc. NOTE: _MSC_VER says stack frame should be at least 16384 More...
 
static const StrLen_t k_LEN_MAX_KEY = 128
 arbitrary max size of (Symbolic Identifier) keys. More...
 
static const char k_szBlockStart [STR_BLOCK_QTY+1] = "\"{[("
 array of STR_BLOCK_TYPE "\"{[(" More...
 
static const char k_szBlockEnd [STR_BLOCK_QTY+1] = "\"}])"
 
static const char k_szEscEncode [12] = "\'\"\?\\abtnvfr"
 The encoded version of escape chars. More...
 
static const char k_szEscDecode [12] = "\'\"\?\\\a\b\t\n\v\f\r"
 

Friends

class StrTTests
 

Detailed Description

A bunch of common string functions that adapt regardless of UNICODE or UTF8

Note
This works similar to MFC StringTraits, StrTraitMFC<>? similar to char_traits<TYPE> for STL

Member Function Documentation

◆ Cast()

template<typename TYPE >
static const TYPE* Gray::StrT::Cast ( const TYPE pszStr)
inlinestatic

a template based caster is useful for templates. rather than (const TYPE*) because it isn't really a cast. (so is safer) Its just a rule for type conversion and will fail if type is not provided. Can use with cStrConst

◆ CheckEmpty()

template<typename TYPE >
static const TYPE* Gray::StrT::CheckEmpty ( const TYPE pszStr)
inlinestaticnoexcept

If this is an empty string then make it nullptr.

◆ Cmp() [1/2]

template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall Gray::StrT::Cmp ( const TYPE pszStr1,
const TYPE pszStr2 
)
static

◆ Cmp() [2/2]

template<typename TYPE >
COMPARE_t __stdcall Gray::StrT::Cmp ( const TYPE pszStr1,
const TYPE pszStr2 
)

replace _strcmp() How does pszStr1 compare to pszStr2

◆ CmpHeadI() [1/2]

template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall Gray::StrT::CmpHeadI ( const TYPE pszFind,
const TYPE pszTableElem 
)
static

◆ CmpHeadI() [2/2]

template<typename TYPE >
COMPARE_t __stdcall Gray::StrT::CmpHeadI ( const TYPE pszFindHead,
const TYPE pszTableElem 
)

Does pszTabkleElem start with the prefix pszFindHead? Compare only up to the length of pszTableElem. If pszFindHead has more chars but are separated by non alnum() then ignore. Follows the rules for symbolic names. similar to StartsWithI ?

Note
we may want to allow /- in names for HTTP?
Returns
0 = match.

◆ CmpI() [1/2]

template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall Gray::StrT::CmpI ( const TYPE pszStr1,
const TYPE pszStr2 
)
static

◆ CmpI() [2/2]

template<typename TYPE >
COMPARE_t __stdcall Gray::StrT::CmpI ( const TYPE pszStr1,
const TYPE pszStr2 
)
Note
for some reason the M$ version fails in static initializers in release mode !? replace _strcmpi strcmpi _stricmp "#define _stricmp strcasecmp"

◆ CmpIN() [1/2]

template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall Gray::StrT::CmpIN ( const TYPE pszStr1,
const TYPE pszStr2,
StrLen_t  iLenMaxChars 
)
staticnoexcept

◆ CmpIN() [2/2]

template<typename TYPE >
COMPARE_t __stdcall Gray::StrT::CmpIN ( const TYPE pszStr1,
const TYPE pszStr2,
StrLen_t  iLenMaxChars 
)
noexcept

Find matching string up to length iLenMaxChars. (unless '/0' is found) replaces _strnicmp strnicmp "#define _strnicmp strncasecmp"

◆ CmpN() [1/2]

template<typename TYPE >
static __DECL_IMPORT COMPARE_t __stdcall Gray::StrT::CmpN ( const TYPE pszStr1,
const TYPE pszStr2,
StrLen_t  iLenMaxChars 
)
staticnoexcept

◆ CmpN() [2/2]

template<typename TYPE >
COMPARE_t __stdcall Gray::StrT::CmpN ( const TYPE pszStr1,
const TYPE pszStr2,
StrLen_t  iLenMaxChars 
)
noexcept

How does pszStr1 compare to pszStr2 replace strncmp()

◆ CopyLen() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::CopyLen ( TYPE pDst,
const TYPE pSrc,
StrLen_t  iLenMaxChars 
)
noexcept

Copy a string. replaces strncpy (sort of)

  • iLenMaxChars = _countof(Dst) = includes room for '\0'. (just like memcpy) so iLenMaxChars=_countof(Dst) is OK !
    Note
    DO NOT assume pSrc is null terminated. tho it might be. just use iLenMaxChars
    This will ALWAYS terminate the string (unlike strncpy)
    Returns
    Length of pDst in chars. (Not including null.)

◆ CopyLen() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::CopyLen ( TYPE pszDst,
const TYPE pSrc,
StrLen_t  iLenCharsMax 
)
staticnoexcept

◆ Diff()

template<typename TYPE >
static StrLen_t Gray::StrT::Diff ( const TYPE pszEnd,
const TYPE pszStart 
)
inlinestatic

Difference between 2 pointers in chars (not bytes). Check for 64 bit overflow. Safer.

◆ DtoA() [1/3]

template<>
StrLen_t Gray::StrT::DtoA ( double  nVal,
OUT char *  pszOut,
StrLen_t  iStrMax,
int  iDecPlaces,
char  chE 
)
inlinestatic

◆ DtoA() [2/3]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::DtoA ( double  nVal,
OUT TYPE pszOut,
StrLen_t  iStrMax,
int  iDecPlaces = -1,
char  chE = - 'e' 
)
static

◆ DtoA() [3/3]

template<>
StrLen_t Gray::StrT::DtoA ( double  nVal,
OUT wchar_t *  pszOut,
StrLen_t  iOutMax,
int  iDecPlaces,
char  chE 
)
inlinestatic

◆ EndsWithI() [1/2]

template<typename TYPE >
bool __stdcall Gray::StrT::EndsWithI ( const TYPE pszStr1,
const TYPE pszPostfix,
StrLen_t  nLenStr 
)

Compare the end of pszStr1 with pszPostfix Similar to .NET EndsWith() Look for a pszPostfix ignoring case.

◆ EndsWithI() [2/2]

template<typename TYPE >
static __DECL_IMPORT bool __stdcall Gray::StrT::EndsWithI ( const TYPE pszStr2,
const TYPE pszPostfix,
StrLen_t  nLenStr = k_StrLen_UNK 
)
static

◆ EscSeqAdd() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::EscSeqAdd ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax 
)

Encode/Replace odd chars with escape sequences. e.g. "\n" This makes the string larger! opposite of StrT::EscSeqRemove()

  • pStrOut = nullptr = test output. 0 = no quotes needed.
    Returns
    pStrOut has chars ONLY in the range of 32 to 127 new length of the string. same or more than input
    Note
    Only double quotes and "\\\b\f\n\r\t" are needed for JSON strings.

◆ EscSeqAdd() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::EscSeqAdd ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax = StrT::k_LEN_MAX 
)
static

◆ EscSeqAddQ() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::EscSeqAddQ ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax 
)

Encode the string and add quotes.

◆ EscSeqAddQ() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::EscSeqAddQ ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax = StrT::k_LEN_MAX 
)
static

◆ EscSeqRemove() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::EscSeqRemove ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax,
StrLen_t  iLenInMax 
)

Filter/decode out the 'C like' embedded escape sequences. "\n\r" etc This string will shrink. Assumed to be inside quotes ending at iLenInMax. opposite of StrT::EscSeqAdd()

Note
Since we are removing, allow pStrOut = pStrIn.
  • iLenMax = the string length NOT including null.
Returns
new length of the string. same or less than input
pStrOut
Note
should we check for internal chars < 32 NOT encoded ? THIS would be an error !!!

◆ EscSeqRemove() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::EscSeqRemove ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax = StrT::k_LEN_MAX,
StrLen_t  iLenInMax = StrT::k_LEN_MAX 
)
static

◆ EscSeqRemoveQ() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::EscSeqRemoveQ ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax,
StrLen_t  iLenInMax 
)

Remove the opening and closing quotes. Put enclosed string (decoded) into pStrOut.

Returns
the consumed length of pStrIn. NOT the length of pStrOut.

◆ EscSeqRemoveQ() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::EscSeqRemoveQ ( TYPE pStrOut,
const TYPE pStrIn,
StrLen_t  iLenOutMax = StrT::k_LEN_MAX,
StrLen_t  iLenInMax = StrT::k_LEN_MAX 
)
static

◆ FindBlockEnd() [1/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::FindBlockEnd ( STR_BLOCK_TYPE  eBlockType,
const TYPE pLine,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
static

◆ FindBlockEnd() [2/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::FindBlockEnd ( STR_BLOCK_TYPE  eBlockType,
const TYPE pszLine,
StrLen_t  iLenMaxChars 
)

Find the end of an STR_BLOCK_TYPE sequence. (quote,brace,bracket,parenthesis) skip nested blocks. deal with quoted and escaped strings.

  • eBlockType = what type of block is this? 0 = STR_BLOCK_QUOTE. STR_BLOCK_NONE = just look for nested blocks. pszLine = the TYPE char AFTER the opening quote/brace/etc STR_BLOCK_TYPE char. iLenMaxChars = StrT::k_LEN_MAX
    Returns
    Pointer to the end of the block sequence. Perhaps caller will replace it with '\0' ? nullptr = FAIL, same pointer = FAIL.

◆ FindChar() [1/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::FindChar ( const TYPE pszStr,
TYPE  ch,
StrLen_t  iLen = StrT::k_LEN_MAX 
)
staticnoexcept

◆ FindChar() [2/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::FindChar ( const TYPE pszStr,
TYPE  chFind,
StrLen_t  iLenMax 
)
noexcept

Find first occurrence of a single char in a string. replace strchr(), and memchr()

Returns
nullptr = not found.

◆ FindCharN() [1/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::FindCharN ( const TYPE pszStr,
TYPE  ch 
)
staticnoexcept

◆ FindCharN() [2/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::FindCharN ( const TYPE pszStr,
TYPE  chFind 
)
noexcept

Find index of the first occurrence of a single char in a string.

Returns
-1 = k_StrLen_UNK = not found.

◆ FindCharRev() [1/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::FindCharRev ( const TYPE pszStr,
TYPE  ch,
StrLen_t  iLen = k_StrLen_UNK 
)
static

◆ FindCharRev() [2/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::FindCharRev ( const TYPE pszStr,
TYPE  chFind,
StrLen_t  iLenMax 
)

Find last occurrence of a single char in a string. replace strrchr() or _tcsrchr(). find TYPE from end.

◆ FindStr() [1/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::FindStr ( const TYPE pszStr,
const TYPE pszFind,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
static

◆ FindStr() [2/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::FindStr ( const TYPE pszText,
const TYPE pszSubStr,
StrLen_t  iLenMaxChars 
)

Find pszSubStr inside pszText. (exact case match of all chars in pszSubStr) replaces strstr(), or .NET Contains()

◆ FindStrI() [1/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::FindStrI ( const TYPE pszStr,
const TYPE pszFind,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
static

◆ FindStrI() [2/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::FindStrI ( const TYPE pszText,
const TYPE pszSubStr,
StrLen_t  iLenMaxChars 
)

Find pszSubStr in pszText. (ignores case) like strstr() but ignores case like stristr()

Returns
nullptr = can't find it.

◆ FindTokens() [1/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::FindTokens ( const TYPE pszStr,
const TYPE pszTokens,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
static

◆ FindTokens() [2/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::FindTokens ( const TYPE pszStr,
const TYPE pszTokens,
StrLen_t  iLenMaxChars 
)

Find one of the char pszTokens in pszStr.

Returns
nullptr = none found.

◆ FindWord() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::FindWord ( const TYPE pszText,
const TYPE pszKeyWord,
StrLen_t  iLenMaxChars 
)

Find the pszKeyWord in the pszText string. Ignore Case. like FindStrI() but looks for starts of words. not match mid word.

Returns
index of the END of the word match. <=0 = not found.

◆ FindWord() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::FindWord ( const TYPE pTextSearch,
const TYPE pszKeyWord,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
static

◆ GetHashCode32() [1/2]

template<typename TYPE >
HASHCODE32_t __stdcall Gray::StrT::GetHashCode32 ( const TYPE pszStr,
StrLen_t  nLen,
HASHCODE32_t  nHash 
)
noexcept

Get a HASHCODE32_t for the string. Ignore case. based on http://www.azillionmonkeys.com/qed/hash.html super fast hash. Need not be truly unique. Just most likely unique. Low chance of collision in random set. Even distribution preferred. Simple CRC32 does not produce good distribution? Never return 0 except for empty string. not k_HASHCODE_CLEAR Others: http://sites.google.com/site/murmurhash/, boost string_hash()

Note
equivalent UNICODE and char strings should return the same HASHCODE32_t.

◆ GetHashCode32() [2/2]

template<typename TYPE >
static __DECL_IMPORT HASHCODE32_t __stdcall Gray::StrT::GetHashCode32 ( const TYPE pszStr,
StrLen_t  nLen = k_StrLen_UNK,
HASHCODE32_t  nHash = k_HASHCODE_CLEAR 
)
staticnoexcept

◆ GetNonWhitespace() [1/2]

template<typename TYPE >
static const TYPE* Gray::StrT::GetNonWhitespace ( const TYPE pStr,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
inlinestaticnoexcept

◆ GetNonWhitespace() [2/2]

template<typename TYPE >
static TYPE* Gray::StrT::GetNonWhitespace ( TYPE pStr,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
inlinestaticnoexcept

◆ GetNonWhitespaceI()

template<typename TYPE >
static StrLen_t Gray::StrT::GetNonWhitespaceI ( const TYPE pStr,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
inlinestaticnoexcept

Skip tabs and spaces but NOT new lines. NOT '\0' either.

◆ GetWhitespaceEnd() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::GetWhitespaceEnd ( const TYPE pStr,
StrLen_t  iLenChars 
)

Walk backwards from the end of the string.

Returns
get Length of the string minus ending whitespace. (strips new lines) 0 = it was all spaces.

◆ GetWhitespaceEnd() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::GetWhitespaceEnd ( const TYPE pStr,
StrLen_t  iLenChars = k_StrLen_UNK 
)
static

◆ HasChar()

template<typename TYPE >
static bool Gray::StrT::HasChar ( const TYPE pszStr,
TYPE  ch 
)
inlinestaticnoexcept

◆ ILtoA() [1/3]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::ILtoA ( INT64  nVal,
OUT TYPE pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix = 10 
)
static

◆ ILtoA() [2/3]

template<>
StrLen_t Gray::StrT::ILtoA ( INT64  uVal,
char *  pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ ILtoA() [3/3]

template<>
StrLen_t Gray::StrT::ILtoA ( INT64  uVal,
wchar_t *  pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ IsNullOrEmpty()

template<typename TYPE >
static bool Gray::StrT::IsNullOrEmpty ( const TYPE pszStr)
inlinestaticnoexcept

Like .NET String.IsNullOrEmpty. Similar to IsWhitespace().

◆ IsPrintable() [1/2]

template<typename TYPE >
bool __stdcall Gray::StrT::IsPrintable ( const TYPE pStr,
StrLen_t  iLenChars 
)

Is this a normally printable string?

◆ IsPrintable() [2/2]

template<typename TYPE >
static __DECL_IMPORT bool __stdcall Gray::StrT::IsPrintable ( const TYPE pStr,
StrLen_t  iLenChars = StrT::k_LEN_MAX 
)
static

◆ IsWhitespace() [1/2]

template<typename TYPE >
static __DECL_IMPORT bool __stdcall Gray::StrT::IsWhitespace ( const TYPE pStr,
StrLen_t  iLenChars = StrT::k_LEN_MAX 
)
static

◆ IsWhitespace() [2/2]

template<typename TYPE >
bool __stdcall Gray::StrT::IsWhitespace ( const TYPE pStr,
StrLen_t  iLenMaxChars 
)

Is the whole string whitespace, empty or nullptr? Like .NET String.IsNullOrWhiteSpace()

  • iLenMaxChars = don't bother checking more than this.

◆ ItoA()

template<typename TYPE >
static StrLen_t Gray::StrT::ItoA ( INT32  nVal,
OUT TYPE pszOut,
StrLen_t  iStrMax,
RADIX_t  nBaseRadix = 10 
)
inlinestatic

Convert an int/INT32 to a string. Assume auto convert char, short to INT32. like ltoa(); or ToString(), or like sprintf("%d") Just cast up to 64.

◆ Len() [1/4]

template<>
StrLen_t Gray::StrT::Len ( const char *  pszStr)
inlinestaticnoexcept

Get length of string not including '\0'. Like strlen() Danger. ASSUME sane iLenMax <= k_LEN_MAX ?? Dont use this function. use length limited version. nullptr is NOT allowed by ::strlen(). ASSERT?

◆ Len() [2/4]

template<typename TYPE >
static StrLen_t Gray::StrT::Len ( const TYPE pszStr)
staticnoexcept

◆ Len() [3/4]

template<typename TYPE >
static StrLen_t Gray::StrT::Len ( const TYPE pszStr,
StrLen_t  iLenMax 
)
inlinestaticnoexcept

Get length (up to iLenMax <= k_LEN_MAX ) avoiding read errors for un-terminated sources. like strlen() but with limit. AKA strnlen().

Returns
the length of the string up to (including) iLenMax

◆ Len() [4/4]

template<>
StrLen_t Gray::StrT::Len ( const wchar_t *  pszStr)
inlinestaticnoexcept

Get length of string not including '\0' Danger. ASSUME sane iLenMax <= k_LEN_MAX ?? Dont use this function. use length limited version. nullptr is NOT allowed by wcslen. ASSERT?

◆ MakeLowerCase()

template<typename TYPE >
static void Gray::StrT::MakeLowerCase ( TYPE pszDst,
StrLen_t  iLenCharsMax 
)
inlinestaticnoexcept

replaces strlwr() No portable linux equiv to strlwr()?

◆ MakeUpperCase()

template<typename TYPE >
static void Gray::StrT::MakeUpperCase ( TYPE pszDst,
StrLen_t  iLenCharsMax 
)
inlinestaticnoexcept

replaces _strupr No portable linux equiv to _strupr()?

◆ MatchRegEx() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::MatchRegEx ( const TYPE pText,
const TYPE pPattern,
bool  bIgnoreCase,
StrLen_t  nTextMax 
)

Recursive very simple regex pattern match with backtracking. Will cope with match( "a.b.c", "*.c" ) regex like. Case sensitive.

  • nTextMax > 0 = allow partial matches. effectively adds a * to the end.
    Returns
    length of the match in pText. if < Len(pText) then its only a partial match. pText has extra stuff.

◆ MatchRegEx() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::MatchRegEx ( const TYPE pText,
const TYPE pRegExPattern,
bool  bIgnoreCase,
StrLen_t  nTextMax = k_StrLen_UNK 
)
static

◆ ParseCmds() [1/2]

template<typename TYPE >
ITERATE_t __stdcall Gray::StrT::ParseCmds ( TYPE pszCmdLine,
StrLen_t  nCmdLenMax,
TYPE **  ppCmd,
ITERATE_t  iCmdQtyMax,
const TYPE pszSep,
STRP_MASK_t  uFlags 
)

Parse a separated list of tokens/arguments to a function/command

  • pszCmdLine = NOTE: this is modified / chopped up buffer. ppCmd = an array of pointers inside pszCmdLine iCmdQtyMax = _countof(ppCmd); pszSep = what are the valid separators.
  • uFlags = STRP_MASK_t = STRP_TYPE_. deal with quoted and escaped strings.
    Returns
    Number of args. in ppCmd 0 = empty string/array. EXAMPLES: "tag=word&tag2=word" for HTML pages. "arg \t arg" preserve 1 space.

◆ ParseCmds() [2/2]

template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall Gray::StrT::ParseCmds ( TYPE pszCmdLine,
StrLen_t  nCmdLenMax,
TYPE **  ppCmds,
ITERATE_t  iQtyMax,
const TYPE pszSep = nullptr,
STRP_MASK_t  uFlags = STRP_DEF 
)
static

◆ ParseCmdsTmp() [1/2]

template<typename TYPE >
ITERATE_t __stdcall Gray::StrT::ParseCmdsTmp ( TYPE pszTmp,
StrLen_t  iTmpSizeMax,
const TYPE pszCmdLine,
TYPE **  ppCmd,
ITERATE_t  iCmdQtyMax,
const TYPE pszSep,
STRP_MASK_t  uFlags 
)

Make a temporary copy of the string for parsing.

  • iTmpSizeMax = StrT::k_LEN_MAX
  • uFlags = deal with quoted and escaped strings.
    Returns
    Quantity of arguments

◆ ParseCmdsTmp() [2/2]

template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall Gray::StrT::ParseCmdsTmp ( TYPE pszTmp,
StrLen_t  iTmpSizeMax,
const TYPE pszCmdLine,
TYPE **  ppCmds,
ITERATE_t  iCmdQtyMax,
const TYPE pszSep = nullptr,
STRP_MASK_t  uFlags = STRP_DEF 
)
static

◆ ReplaceX() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::ReplaceX ( TYPE pDst,
StrLen_t  iDstLenMax,
StrLen_t  iDstIdx,
StrLen_t  iDstSegLen,
const TYPE pSrc,
StrLen_t  iSrcLen 
)

Replace a segment of a string with pSrc, Maybe change length!

  • iDstLenMax = don't let the pDst get bigger than this. iDstSegLen = Replace old segment length
    Returns
    length of the resulting string. e.g. pStr = "this are a string"; StrT::ReplaceX( pStr, _MAX_PATH, 5, 3, "is", -1 ); pStr = "this is a string";

◆ ReplaceX() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::ReplaceX ( TYPE pDst,
StrLen_t  iDstLenMax,
StrLen_t  nDstIdx,
StrLen_t  iDstSegLen,
const TYPE pSrc,
StrLen_t  iSrcLen = k_StrLen_UNK 
)
static

◆ sprintfN()

template<typename TYPE >
static StrLen_t _cdecl Gray::StrT::sprintfN ( OUT TYPE pszOut,
StrLen_t  iLenOutMax,
const TYPE pszFormat,
  ... 
)
inlinestatic

Format a string with variadic arguments. Truncate at iLenOutMax if necessary.

  • iLenOutMax = max output size in characters. (Not Bytes) Must allow space for '\0'
    Returns
    size in characters. -1 = too small. (NOT CONSISTENT WITH LINUX!)

◆ StartsWithI() [1/2]

template<typename TYPE >
bool Gray::StrT::StartsWithI ( const TYPE pszStr1,
const TYPE pszPrefix 
)

Compare pszStr1 up to the length of pszPrefix Similar to .NET StartsWith() https://msdn.microsoft.com/en-us/library/system.string.startswith%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396 Look for a prefix. Similar to CmpHeadI

◆ StartsWithI() [2/2]

template<typename TYPE >
static __DECL_IMPORT bool __stdcall Gray::StrT::StartsWithI ( const TYPE pszStr2,
const TYPE pszPrefix 
)
static

◆ StripBlock() [1/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::StripBlock ( TYPE pszText)
static

◆ StripBlock() [2/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::StripBlock ( TYPE pszText)

strip block based on the very first character of the string. If the string is encased in "" or () then remove them.

◆ TableFind() [1/2]

template<typename TYPE >
ITERATE_t __stdcall Gray::StrT::TableFind ( const TYPE pszFindThis,
const void *  ppszTableInit,
size_t  nElemSize 
)

Find a string in a non-sorted table. Ignores case Used with STR_TABLEFIND_N

Returns
-1 = no match. k_ITERATE_BAD

◆ TableFind() [2/2]

template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall Gray::StrT::TableFind ( const TYPE pszFindThis,
const void *  ppszTableInit,
size_t  nElemSize = sizeof(const TYPE *) 
)
static

◆ TableFindHead() [1/2]

template<typename TYPE >
ITERATE_t __stdcall Gray::StrT::TableFindHead ( const TYPE pszFindHead,
const void *  ppszTableInit,
size_t  nElemSize 
)

Find a string in a table. Ignores case. unsorted table. Use rules for StrT::CmpHeadI for compare. compare only up to the CSYM values.

Returns
-1 = not found. k_ITERATE_BAD

◆ TableFindHead() [2/2]

template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall Gray::StrT::TableFindHead ( const TYPE pszFindHead,
const void *  ppszTableInit,
size_t  nElemSize = sizeof(const TYPE *) 
)
static

◆ TableFindHeadSorted() [1/2]

template<typename TYPE >
ITERATE_t __stdcall Gray::StrT::TableFindHeadSorted ( const TYPE pszFindHead,
const void *  ppszTableInit,
ITERATE_t  iCountMax,
size_t  nElemSize 
)

Find a string in a table. Do a binary search (un-cased) on a sorted table. Use rules for StrT::CmpHeadI for compare. compare only up to the CSYM values.

Returns
-1 = not found k_ITERATE_BAD

◆ TableFindHeadSorted() [2/2]

template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall Gray::StrT::TableFindHeadSorted ( const TYPE pszFindHead,
const void *  ppszTableInit,
ITERATE_t  iCountMax,
size_t  nElemSize = sizeof(const TYPE *) 
)
static

◆ TableFindSorted() [1/2]

template<typename TYPE >
ITERATE_t __stdcall Gray::StrT::TableFindSorted ( const TYPE pszFindThis,
const void *  ppszTableInit,
ITERATE_t  iCountMax,
size_t  nElemSize 
)

Find a string in a table. Do a binary search (un-cased) on a sorted table.

Returns
-1 = not found k_ITERATE_BAD

◆ TableFindSorted() [2/2]

template<typename TYPE >
static __DECL_IMPORT ITERATE_t __stdcall Gray::StrT::TableFindSorted ( const TYPE pszFindThis,
const void *  ppszTableInit,
ITERATE_t  iCountMax,
size_t  nElemSize = sizeof(const TYPE *) 
)
static

◆ toDouble() [1/3]

template<>
double Gray::StrT::toDouble ( const char *  pszStr,
const char **  ppszStrEnd 
)
inlinestatic

◆ toDouble() [2/3]

template<typename TYPE >
static __DECL_IMPORT double __stdcall Gray::StrT::toDouble ( const TYPE pszStr,
const TYPE **  ppszStrEnd = nullptr 
)
static

◆ toDouble() [3/3]

template<>
double Gray::StrT::toDouble ( const wchar_t *  pszStr,
const wchar_t **  ppszStrEnd 
)
inlinestatic

◆ toI()

template<typename TYPE >
static int Gray::StrT::toI ( const TYPE pszStr,
const TYPE **  ppszStrEnd = nullptr,
RADIX_t  nBaseRadix = 10 
)
inlinestatic

atoi() Just cast down from 64.

◆ toIL() [1/3]

template<>
INT64 Gray::StrT::toIL ( const char *  pszStr,
const char **  ppszStrEnd,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ toIL() [2/3]

template<typename TYPE >
static __DECL_IMPORT INT64 __stdcall Gray::StrT::toIL ( const TYPE pszStr,
const TYPE **  ppszStrEnd = nullptr,
RADIX_t  nBaseRadix = 10 
)
static

◆ toIL() [3/3]

template<>
INT64 Gray::StrT::toIL ( const wchar_t *  pszStr,
const wchar_t **  ppszStrEnd,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ toIP()

template<typename TYPE >
static INT_PTR Gray::StrT::toIP ( const TYPE pszStr,
const TYPE **  ppszStrEnd = nullptr,
RADIX_t  nBaseRadix = 10 
)
inlinestatic

◆ toU()

template<typename TYPE >
static UINT Gray::StrT::toU ( const TYPE pszStr,
const TYPE **  ppszStrEnd = nullptr,
RADIX_t  nBaseRadix = 0 
)
inlinestatic

Just cast down from 64.

◆ toUL() [1/3]

template<>
UINT64 Gray::StrT::toUL ( const char *  pszStr,
const char **  ppszStrEnd,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ toUL() [2/3]

template<typename TYPE >
static __DECL_IMPORT UINT64 __stdcall Gray::StrT::toUL ( const TYPE pszStr,
const TYPE **  ppszStrEnd = nullptr,
RADIX_t  nBaseRadix = 0 
)
static

◆ toUL() [3/3]

template<>
UINT64 Gray::StrT::toUL ( const wchar_t *  pszStr,
const wchar_t **  ppszStrEnd,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ toUP()

template<typename TYPE >
static UINT_PTR Gray::StrT::toUP ( const TYPE pszStr,
const TYPE **  ppszStrEnd = nullptr,
RADIX_t  nBaseRadix = 0 
)
inlinestatic

◆ TrimWhitespace() [1/2]

template<typename TYPE >
TYPE* __stdcall Gray::StrT::TrimWhitespace ( TYPE pStr,
StrLen_t  iLenMax 
)

Trim starting AND ending whitespace

◆ TrimWhitespace() [2/2]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::TrimWhitespace ( TYPE pStr,
StrLen_t  iLenMax = StrT::k_LEN_MAX 
)
static

◆ TrimWhitespaceEnd() [1/2]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::TrimWhitespaceEnd ( TYPE pStr,
StrLen_t  iLenChars 
)

Trim any whitespace off the end of the string.

Returns
new length of the line. (without whitespace and comments)

◆ TrimWhitespaceEnd() [2/2]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::TrimWhitespaceEnd ( TYPE pStr,
StrLen_t  iLenChars = k_StrLen_UNK 
)
static

◆ ULtoA() [1/3]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::ULtoA ( UINT64  nVal,
TYPE pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix = 10 
)
static

◆ ULtoA() [2/3]

template<>
StrLen_t Gray::StrT::ULtoA ( UINT64  uVal,
char *  pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ ULtoA() [3/3]

template<>
StrLen_t Gray::StrT::ULtoA ( UINT64  uVal,
wchar_t *  pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix 
)
inlinestatic

◆ ULtoA2() [1/3]

template<>
char* Gray::StrT::ULtoA2 ( UINT64  uVal,
char *  pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix,
char  chRadixA 
)
inlinestatic

◆ ULtoA2() [2/3]

template<typename TYPE >
static __DECL_IMPORT TYPE* __stdcall Gray::StrT::ULtoA2 ( UINT64  uVal,
TYPE pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix = 10,
char  chRadixA = 'A' 
)
static

◆ ULtoA2() [3/3]

template<>
wchar_t* Gray::StrT::ULtoA2 ( UINT64  uVal,
wchar_t *  pszOut,
StrLen_t  iOutMax,
RADIX_t  nBaseRadix,
char  chRadixA 
)
inlinestatic

◆ ULtoAK() [1/4]

template<>
StrLen_t Gray::StrT::ULtoAK ( UINT64  uVal,
OUT char *  pszOut,
StrLen_t  iStrMax,
UINT  nKUnit,
bool  bSpace 
)
inlinestatic

◆ ULtoAK() [2/4]

template<typename TYPE >
StrLen_t __stdcall Gray::StrT::ULtoAK ( UINT64  uVal,
OUT TYPE pszOut,
StrLen_t  iStrMax,
UINT  nKUnit,
bool  bSpace 
)

Make string describing a value in K/M/G/T/P/E/Z/Y units. (Kilo,Mega,Giga,Tera,Peta,Exa,Zetta,Yotta)

◆ ULtoAK() [3/4]

template<typename TYPE >
static __DECL_IMPORT StrLen_t __stdcall Gray::StrT::ULtoAK ( UINT64  uVal,
OUT TYPE pszStr,
StrLen_t  iStrMax,
UINT  nKUnit = 1024,
bool  bSpace = true 
)
static

◆ ULtoAK() [4/4]

template<>
StrLen_t Gray::StrT::ULtoAK ( UINT64  uVal,
OUT wchar_t *  pszOut,
StrLen_t  iStrMax,
UINT  nKUnit,
bool  bSpace 
)
inlinestatic

◆ UtoA()

template<typename TYPE >
static StrLen_t Gray::StrT::UtoA ( UINT32  nVal,
OUT TYPE pszOut,
StrLen_t  iStrMax,
RADIX_t  nBaseRadix = 10 
)
inlinestatic

Convert an UINT/UINT32/DWORD to a string. like sprintf("%u") Assume auto convert BYTE, WORD to UINT/UINT32/DWORD. Just cast up to 64.

◆ vsprintfN() [1/3]

template<>
StrLen_t Gray::StrT::vsprintfN ( OUT char *  pszOut,
StrLen_t  iLenOutMax,
const char *  pszFormat,
va_list  vlist 
)
inlinestatic

UTF8 sprintf version.

Note
Use StrArg<char>(s) for safe "%s" args.
Windows _snprintf and _vsnprintf are not compatible to Linux versions. Linux result is the size of the buffer that it should have. Windows Result value is not size of buffer needed, but -1 if no fit is possible. Newer Windows versions have a _TRUNCATE option to just truncate the string. ?? try to 'fix' this by at least suggesting enlarging the size by 20 ?? _vscwprintf can be used to estimate the size needed in advance using a 2 pass method.
  • pszOut = vsnprintf is OK with nullptr and size=0. iLenOutMax = size in characters. (Not Bytes) Must allow space for '\0'
Returns
size in characters. negative value if an output error occurs.

◆ vsprintfN() [2/3]

template<typename TYPE >
static StrLen_t Gray::StrT::vsprintfN ( OUT TYPE pszOut,
StrLen_t  iLenOutMax,
const TYPE pszFormat,
va_list  vlist 
)
static

◆ vsprintfN() [3/3]

template<>
StrLen_t Gray::StrT::vsprintfN ( OUT wchar_t *  pszOut,
StrLen_t  iLenOutMax,
const wchar_t *  pszFormat,
va_list  vlist 
)
inlinestatic

UNICODE sprintf version.

Note
Use StrArg<wchar_t>(s) for safe "%s" args.
  • pszOut = vsnprintf is ok with nullptr and size=0. iLenOutMax = size in characters. (Not Bytes) Must allow space for '\0'
Returns
size in characters. -1 = too small.

Friends And Related Function Documentation

◆ StrTTests

friend class StrTTests
friend

Member Data Documentation

◆ k_LEN_MAX

const StrLen_t Gray::StrT::k_LEN_MAX = 15000
static

arbitrary max size for Format() etc. NOTE: _MSC_VER says stack frame should be at least 16384

◆ k_LEN_MAX_KEY

const StrLen_t Gray::StrT::k_LEN_MAX_KEY = 128
static

arbitrary max size of (Symbolic Identifier) keys.

◆ k_szBlockEnd

const char Gray::StrT::k_szBlockEnd = "\"}])"
static

◆ k_szBlockStart

const char Gray::StrT::k_szBlockStart = "\"{[("
static

array of STR_BLOCK_TYPE "\"{[("

◆ k_szEscDecode

const char Gray::StrT::k_szEscDecode = "\'\"\?\\\a\b\t\n\v\f\r"
static

◆ k_szEscEncode

const char Gray::StrT::k_szEscEncode = "\'\"\?\\abtnvfr"
static

The encoded version of escape chars.


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