![]() |
Gray C++ Libraries
0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
|
#include <StrNum.h>
Static Public Member Functions | |
static StrLen_t __stdcall | GetTrimCharsLen (const char *pStr, StrLen_t nLen, char ch) |
static StrLen_t __stdcall | GetNumberString (OUT char *pszOut, const wchar_t *pszInp, StrLen_t iStrMax=k_LEN_MAX_DIGITS) |
static UINT64 __stdcall | toUL (const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=0) |
static INT64 __stdcall | toIL (const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=10) |
static UINT32 __stdcall | toU (const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=0) |
static INT32 __stdcall | toI (const char *pszInp, const char **ppszInpEnd=(const char **) nullptr, RADIX_t nBaseRadix=10) |
static StrLen_t __stdcall | ULtoAK (UINT64 uVal, OUT char *pszOut, StrLen_t iStrMax, UINT nKUnit, bool bSpace) |
static char *__stdcall | ULtoA2 (UINT64 uVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10, char chRadixA='A') |
static StrLen_t __stdcall | ULtoA (UINT64 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10) |
static StrLen_t __stdcall | ILtoA (INT64 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10) |
static StrLen_t __stdcall | UtoA (UINT32 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10) |
static StrLen_t __stdcall | ItoA (INT32 nVal, OUT char *pszOut, StrLen_t iStrMax, RADIX_t nBaseRadix=10) |
static double __stdcall | toDouble (const char *pszInp, const char **ppszInpEnd=(const char **) nullptr) |
static StrLen_t __stdcall | DtoAG2 (double dVal, OUT char *pszOut, int iDecPlacesWanted=-1, char chE=- 'e') |
static StrLen_t __stdcall | DtoAG (double dVal, OUT char *pszOut, StrLen_t iStrMax, int iDecPlacesWanted=-1, char chE=- 'e') |
template<typename _TYPE > | |
static _TYPE | toValue (const char *pszInp, const char **ppszInpEnd=(const char **) nullptr) |
template<typename _TYPE > | |
static StrLen_t | ValueToA (_TYPE val, OUT char *pszOut, StrLen_t iStrMax) |
template<typename _TYPE > | |
static size_t __stdcall | ToValArray (OUT _TYPE *pOut, size_t iQtyMax, const char *pszInp) |
template<typename _TYPE > | |
static StrLen_t __stdcall | ValArrayToA (OUT char *pszOut, StrLen_t nDstMax, const _TYPE *pSrc, size_t nSrcSize) |
template<typename _TYPE > | |
static StrLen_t _cdecl | ValArrayToAF (OUT char *pszDst, StrLen_t iSizeDstMax, size_t nSrcQty,...) |
template<> | |
INT32 | toValue (const char *pszInp, const char **ppszInpEnd) |
template<> | |
UINT32 | toValue (const char *pszInp, const char **ppszInpEnd) |
template<> | |
INT64 | toValue (const char *pszInp, const char **ppszInpEnd) |
template<> | |
UINT64 | toValue (const char *pszInp, const char **ppszInpEnd) |
template<> | |
float | toValue (const char *pszInp, const char **ppszInpEnd) |
template<> | |
double | toValue (const char *pszInp, const char **ppszInpEnd) |
template<> | |
StrLen_t | ValueToA (INT32 val, OUT char *pszOut, StrLen_t iStrMax) |
template<> | |
StrLen_t | ValueToA (UINT32 val, OUT char *pszOut, StrLen_t iStrMax) |
template<> | |
StrLen_t | ValueToA (INT64 val, OUT char *pszOut, StrLen_t iStrMax) |
template<> | |
StrLen_t | ValueToA (UINT64 val, OUT char *pszOut, StrLen_t iStrMax) |
template<> | |
StrLen_t | ValueToA (float val, OUT char *pszOut, StrLen_t iStrMax) |
template<> | |
StrLen_t | ValueToA (double val, OUT char *pszOut, StrLen_t iStrMax) |
Static Public Attributes | |
static const StrLen_t | k_LEN_MAX_DIGITS = (309 + 40) |
Largest number we can represent in double format + some extra places for post decimal. (). like _CVTBUFSIZE or StrT::k_LEN_MAX_KEY. More... | |
static const StrLen_t | k_LEN_MAX_DIGITS_INT = 64 |
Largest 64 bits base 2 not including sign or '\0' is only 64 digits. More... | |
Friends | |
class | StrNumTests |
Convert ASCII (8 bit) string to/from numbers. Numbers are in a restricted set of ASCII (8 bit) characters. It doesn't make sense to have UTF8 and UNICODE versions of these. All actions are in 'char' type. Just convert to/from UNICODE as needed using StrU::UTF8toUNICODE and GetNumberString.
|
static |
|
static |
Make a string from a double float number. like _gcvt() or "%g" like dtoa(), gcvt(), fcvt(), ecvt(), _fcvt() and the opposite of toDouble(),
|
static |
Get a string in ASCII from UNICODE that represents a number. Only get numeric type chars. Like a simple version of StrU::UNICODEtoUTF8() and Opposite of StrU::UTF8toUNICODE()
|
static |
Get Length of string if all ch chars are trimmed from the end.
|
static |
Make a string from a number. like ltoa(). upper case radix default.
|
inlinestatic |
Just cast up to 64.
|
static |
Convert a string to a double precision decimal value. MUST emulate/match the C compiler. The C++ compiler will generate a double value from a string in code. MUST be reversible using DtoA(). like atof(), wcstod() or strtod() and opposite of DtoA(), dtoa() don't bother with toFloat() since it will do the same thing. e.g. decode stuff in format. "12.2", ".12", "123e234",
http://www.cplusplus.com/reference/cstdlib/strtod/ see http://www.exploringbinary.com/how-strtod-works-and-sometimes-doesnt/ for why this is dangerous/difficult. http://www.opensource.apple.com/source/tcl/tcl-10/tcl/compat/strtod.c It can have rounding problems? e.g. "3.1416" = 3.1415999999999999. Deal with this issue on conversion to string. http://www.ampl.com/netlib/fp/dtoa.c (David Gay)
|
inlinestatic |
Just cast down from 64.
|
static |
convert string to integer value. like strtol(), or a bit like atoi() May have 0x# prefix to indicate hex
|
inlinestatic |
Just cast down from 64.
|
static |
Similar to ::strtoul(). skip leading spaces. BUT NOT newlines. We should use StrNum::GetNumberString ? May have 0x# prefix to indicate hex
X digits is an overflow ?
|
static |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
static |
Format a number as a string similar to sprintf("%u") upper case radix default. like _itoa(iValue,pszOut,iRadix), FromInteger() and RtlIntegerToUnicodeString() or _itoa_s() Leading zero on hex string. (if room)
|
static |
Internal function to format a number BACKWARDS as a string similar to sprintf("%u") padded from right. Padded from right. No lead padding. upper case radix default.
|
static |
Make string describing a value in K/M/G/T/P/E/Z/Y units. (Kilo,Mega,Giga,Tera,Peta,Exa,Zetta,Yotta)
|
inlinestatic |
Just cast up to 64.
|
static |
|
static |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
inlinestatic |
|
friend |
|
static |
Largest number we can represent in double format + some extra places for post decimal. (). like _CVTBUFSIZE or StrT::k_LEN_MAX_KEY.
|
static |
Largest 64 bits base 2 not including sign or '\0' is only 64 digits.