ZFFramework
 
Loading...
Searching...
No Matches
ZFCoreStringConvert.h File Reference

utilities for ZFFramework More...

#include "ZFCoreTypeDef.h"

Go to the source code of this file.

Functions

template<typename T_Int>
zfbool zfsFromIntT (zfstring &s, T_Int n, zfindex radix=10, zfbool useUpperCase=_ZFT_t_zftrue)
 convert integer number (int, long, etc) to string
 
template<typename T_Int>
zfstring zfsFromInt (T_Int n, zfindex radix=10, zfbool useUpperCase=_ZFT_t_zftrue)
 see zfsFromIntT
 
template<typename T_Int>
zfbool zfsToIntT (T_Int &ret, const zfchar *src, zfindex srcLen=((zfindex) -1), zfindex radix=10, zfbool allowNegative=_ZFT_t_zftrue)
 convert string to int, return error position if failed, or null if success
 
template<typename T_Int>
T_Int zfsToInt (const zfchar *src, zfindex srcLen=((zfindex) -1), zfindex radix=10, zfbool allowNegative=_ZFT_t_zftrue)
 see zfsToIntT
 
zfint zfsToInt (const zfchar *src, zfindex srcLen=((zfindex) -1), zfindex radix=10, zfbool allowNegative=_ZFT_t_zftrue)
 see zfsToIntT
 
template<typename T_Float>
zfbool zfsFromFloatT (zfstring &s, T_Float n)
 convert float number (int, long, etc) to string
 
template<typename T_Float>
zfstring zfsFromFloat (T_Float n)
 see zfsFromFloatT
 
template<typename T_Float>
zfbool zfsToFloatT (T_Float &ret, const zfchar *src, zfindex srcLen=((zfindex) -1))
 convert string to float
 
template<typename T_Float>
T_Float zfsToFloat (const zfchar *src, zfindex srcLen=((zfindex) -1))
 see zfsToFloatT
 
zffloat zfsToFloat (const zfchar *src, zfindex srcLen=((zfindex) -1))
 see zfsToFloatT
 
zfbool zfsFromPointerT (zfstring &s, const void *p)
 convert pointer value to string
 
zfstring zfsFromPointer (const void *p)
 see zfsFromPointerT
 

Detailed Description

utilities for ZFFramework

Function Documentation

◆ zfsFromIntT()

template<typename T_Int>
zfbool zfsFromIntT ( zfstring & s,
T_Int n,
zfindex radix = 10,
zfbool useUpperCase = _ZFT_t_zftrue )

convert integer number (int, long, etc) to string

integer number can be signed or unsigned, whatever your compiler support
typical usage:

zfstring s = ...;
zfint n = ...;
// append result to s and return it as result
// return a new zfstring as result
s = zfsFromInt(n);
zfbool zfsFromIntT(zfstring &s, T_Int n, zfindex radix=10, zfbool useUpperCase=_ZFT_t_zftrue)
convert integer number (int, long, etc) to string
Definition ZFCoreStringConvert.h:32
zfstring zfsFromInt(T_Int n, zfindex radix=10, zfbool useUpperCase=_ZFT_t_zftrue)
see zfsFromIntT
Definition ZFCoreStringConvert.h:73
_ZFT_t_zfint zfint
same as int, see zfindex
Definition ZFCoreTypeDef_CoreType.h:165
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15

◆ zfsToIntT()

template<typename T_Int>
zfbool zfsToIntT ( T_Int & ret,
const zfchar * src,
zfindex srcLen = ((zfindex)-1),
zfindex radix = 10,
zfbool allowNegative = _ZFT_t_zftrue )

convert string to int, return error position if failed, or null if success

it's your responsibility to make sure the template int type is correct, otherwise, the result may be unexpected (for example, specify a short int type while numbers in src is too long)

◆ zfsFromFloatT()

template<typename T_Float>
zfbool zfsFromFloatT ( zfstring & s,
T_Float n )

convert float number (int, long, etc) to string

float number can be any type such as float, double, long double, whatever your compiler support
for typical usage, see zfsFromIntT

◆ zfsToFloatT()

template<typename T_Float>
zfbool zfsToFloatT ( T_Float & ret,
const zfchar * src,
zfindex srcLen = ((zfindex)-1) )

convert string to float

it's your responsibility to make sure int type is correct, otherwise, the result may be unexpected
for typical usage, see zfsToIntT

Note
if src is null, pErrPos would be null