added: Toa() for long long, int, short and unsigned as well
fixed: when serializing Date the year has at least 4 digits e.g. 0001 when the year is equal to one git-svn-id: svn://ttmath.org/publicrep/pikotools/trunk@1093 e52654a7-88a9-db11-a3e9-0013d4bc506e
This commit is contained in:
@@ -52,7 +52,7 @@ namespace PT
|
||||
// if the buffer is too small it will be terminated at the beginning (empty string)
|
||||
// and the function returns false
|
||||
template<class CharType>
|
||||
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
bool Toa(unsigned long long value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
size_t i1, i2;
|
||||
long rest;
|
||||
@@ -105,7 +105,7 @@ return true;
|
||||
// if the buffer is too small it will be terminated at the beginning (empty string)
|
||||
// and the function returns false
|
||||
template<class CharType>
|
||||
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
bool Toa(long long value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
if( len_out )
|
||||
*len_out = 0;
|
||||
@@ -125,7 +125,7 @@ bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10, size_t *
|
||||
is_sign = true;
|
||||
}
|
||||
|
||||
bool res = Toa(static_cast<unsigned long>(value), buf, buf_len, base, len_out);
|
||||
bool res = Toa(static_cast<unsigned long long>(value), buf, buf_len, base, len_out);
|
||||
|
||||
if( res )
|
||||
{
|
||||
@@ -144,13 +144,47 @@ return res;
|
||||
|
||||
|
||||
|
||||
template<class CharType>
|
||||
bool Toa(unsigned long value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
return Toa(static_cast<unsigned long long>(value), buffer, buf_len, base, len_out);
|
||||
}
|
||||
|
||||
template<class CharType>
|
||||
bool Toa(long value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
return Toa(static_cast<long long>(value), buffer, buf_len, base, len_out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class CharType>
|
||||
bool Toa(unsigned int value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
return Toa(static_cast<unsigned long long>(value), buffer, buf_len, base, len_out);
|
||||
}
|
||||
|
||||
|
||||
template<class CharType>
|
||||
bool Toa(int value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
return Toa(static_cast<long long>(value), buffer, buf_len, base, len_out);
|
||||
}
|
||||
|
||||
|
||||
template<class CharType>
|
||||
bool Toa(unsigned short value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
return Toa(static_cast<unsigned long long>(value), buffer, buf_len, base, len_out);
|
||||
}
|
||||
|
||||
|
||||
template<class CharType>
|
||||
bool Toa(short value, CharType * buffer, size_t buf_len, int base = 10, size_t * len_out = 0)
|
||||
{
|
||||
return Toa(static_cast<long long>(value), buffer, buf_len, base, len_out);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user