26 static const StrLen_t k_LEN_MAX_DIGITS = (309 + 40);
27 static const StrLen_t k_LEN_MAX_DIGITS_INT = 64;
30 static StrLen_t GRAYCALL GetNumberString(OUT
char* pszOut,
const wchar_t* pszInp,
StrLen_t iStrMax = k_LEN_MAX_DIGITS);
32 static UINT64
GRAYCALL toUL(
const char* pszInp,
const char** ppszInpEnd = (
const char**)
nullptr,
RADIX_t nBaseRadix = 0);
33 static INT64
GRAYCALL toIL(
const char* pszInp,
const char** ppszInpEnd = (
const char**)
nullptr,
RADIX_t nBaseRadix = 10);
35 static UINT32
GRAYCALL toU(
const char* pszInp,
const char** ppszInpEnd = (
const char**)
nullptr,
RADIX_t nBaseRadix = 0)
38 return (UINT32)toUL(pszInp, ppszInpEnd, nBaseRadix);
40 static INT32
GRAYCALL toI(
const char* pszInp,
const char** ppszInpEnd = (
const char**)
nullptr,
RADIX_t nBaseRadix = 10)
43 return (INT32)toIL(pszInp, ppszInpEnd, nBaseRadix);
48 static char*
GRAYCALL ULtoA2(UINT64 uVal, OUT
char* pszOut,
StrLen_t iStrMax,
RADIX_t nBaseRadix = 10,
char chRadixA =
'A');
55 return ULtoA(nVal, pszOut, iStrMax, nBaseRadix);
60 return ILtoA(nVal, pszOut, iStrMax, nBaseRadix);
63 static double GRAYCALL toDouble(
const char* pszInp,
const char** ppszInpEnd = (
const char**)
nullptr);
64 static StrLen_t GRAYCALL DtoAG2(
double dVal, OUT
char* pszOut,
int iDecPlacesWanted = -1,
char chE = -
'e');
65 static StrLen_t GRAYCALL DtoAG(
double dVal, OUT
char* pszOut,
StrLen_t iStrMax,
int iDecPlacesWanted = -1,
char chE = -
'e');
67 template <
typename _TYPE >
68 static _TYPE
inline toValue(
const char* pszInp,
const char** ppszInpEnd = (
const char**)
nullptr);
69 template <
typename _TYPE >
72 template <
typename _TYPE >
73 static size_t GRAYCALL ToValArray(OUT _TYPE* pOut,
size_t iQtyMax,
const char* pszInp);
75 template <
typename _TYPE >
78 template <
typename _TYPE >
79 static StrLen_t _cdecl ValArrayToAF(OUT
char* pszDst,
StrLen_t iSizeDstMax,
size_t nSrcQty, ...);
84 template<>
inline INT32 StrNum::toValue<INT32>(
const char* pszInp,
const char** ppszInpEnd)
88 template<>
inline UINT32 StrNum::toValue<UINT32>(
const char* pszInp,
const char** ppszInpEnd)
92 template<>
inline INT64 StrNum::toValue<INT64>(
const char* pszInp,
const char** ppszInpEnd)
96 template<>
inline UINT64 StrNum::toValue<UINT64>(
const char* pszInp,
const char** ppszInpEnd)
100 template<>
inline float StrNum::toValue<float>(
const char* pszInp,
const char** ppszInpEnd)
104 template<>
inline double StrNum::toValue<double>(
const char* pszInp,
const char** ppszInpEnd)
109 template<>
inline StrLen_t StrNum::ValueToA<INT32>(INT32 val, OUT
char* pszOut,
StrLen_t iStrMax)
113 template<>
inline StrLen_t StrNum::ValueToA<UINT32>(UINT32 val, OUT
char* pszOut,
StrLen_t iStrMax)
117 template<>
inline StrLen_t StrNum::ValueToA<INT64>(INT64 val, OUT
char* pszOut,
StrLen_t iStrMax)
121 template<>
inline StrLen_t StrNum::ValueToA<UINT64>(UINT64 val, OUT
char* pszOut,
StrLen_t iStrMax)
125 template<>
inline StrLen_t StrNum::ValueToA<float>(
float val, OUT
char* pszOut,
StrLen_t iStrMax)
129 template<>
inline StrLen_t StrNum::ValueToA<double>(
double val, OUT
char* pszOut,
StrLen_t iStrMax)
134 template <
typename _TYPE >
140 if (pszInp ==
nullptr)
148 const char* pszInpStart = pszInp;
149 if (*pszInpStart ==
'\0')
151 pOut[i++] = StrNum::toValue<_TYPE>(pszInpStart, &pszInp);
152 if (pszInpStart == pszInp)
157 if (pszInp[0] !=
',')
164 template <
typename _TYPE >
176 for (
size_t i = 0; i < nSrcQty; i++)
180 pszDst[iLenOut++] =
',';
183 StrLen_t iLenThis = StrNum::ValueToA<_TYPE>(pSrc[i], pszDst + iLenOut, iSizeDstMax - iLenOut);
187 if (iLenOut >= iSizeDstMax)
193 template <
typename _TYPE >
#define GRAYCORE_LINK
Definition: GrayCore.h:47
#define GRAYCALL
declare calling convention for static functions so everyone knows the arg passing scheme....
Definition: GrayCore.h:36
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
< The main namespace for all Core functions.
Definition: GrayCore.cpp:14
int StrLen_t
the length of a string in chars (bytes for UTF8, wchar_t for UNICODE). or offset in characters....
Definition: StrConst.h:32
WORD RADIX_t
Base for convert of numbers to strings. e.g. 10 base vs 16 base hex numbers.
Definition: StrChar.h:27
static bool IsSpace(wchar_t ch) noexcept
Definition: StrChar.h:89
static StrLen_t __stdcall ILtoA(INT64 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10)
Definition: StrNum.cpp:239
static INT64 __stdcall toIL(const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=10)
Definition: StrNum.cpp:129
static _TYPE toValue(const char *pszInp, const char **ppszInpEnd=(const char **) nullptr)
static size_t __stdcall ToValArray(OUT _TYPE *pOut, size_t iQtyMax, const char *pszInp)
Definition: StrNum.h:135
static UINT32 __stdcall toU(const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=0)
Definition: StrNum.h:35
static StrLen_t __stdcall ItoA(INT32 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10)
Definition: StrNum.h:57
static StrLen_t __stdcall DtoAG(double dVal, OUT char *pszOut, StrLen_t iStrMax, int iDecPlacesWanted=-1, char chE=- 'e')
Definition: StrNum.cpp:345
static double __stdcall toDouble(const char *pszInp, const char **ppszInpEnd=(const char **) nullptr)
Definition: StrNum.cpp:356
static StrLen_t ValueToA(_TYPE val, OUT char *pszOut, StrLen_t iStrMax)
static StrLen_t __stdcall UtoA(UINT32 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10)
Definition: StrNum.h:52
static StrLen_t _cdecl ValArrayToAF(OUT char *pszDst, StrLen_t iSizeDstMax, size_t nSrcQty,...)
Definition: StrNum.h:194
static StrLen_t __stdcall ValArrayToA(OUT char *pszOut, StrLen_t nDstMax, const _TYPE *pSrc, size_t nSrcSize)
Definition: StrNum.h:165
static StrLen_t __stdcall ULtoA(UINT64 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10)
Definition: StrNum.cpp:215
static INT32 __stdcall toI(const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=10)
Definition: StrNum.h:40
static UINT64 __stdcall toUL(const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=0)
Definition: StrNum.cpp:54