version 1.21, 2002/03/21 22:41:14
|
version 1.22, 2002/03/22 01:42:01
|
|
|
// | // |
//////////////////////////////////////////////////////////////////////////////// | //////////////////////////////////////////////////////////////////////////////// |
| |
|
// Too complicated. Commented out in favor of sprintf("%lld"/"%llu"). |
|
#if 0 |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
// _SignedIntToStr() | // _SignedIntToStr() |
|
|
return; | return; |
} | } |
| |
char buffer[256]; |
char buffer[32]; |
Uint32 len = 0; | Uint32 len = 0; |
Boolean negative = false; | Boolean negative = false; |
| |
for (Uint32 i = 0; 1; i++) |
while (x) |
{ | { |
Sint64 q = x / 10; |
|
Sint32 r = x % 10; | Sint32 r = x % 10; |
|
x = x / 10; |
if (q == 0 && r == 0) |
|
break; |
|
| |
if (r < 0) | if (r < 0) |
{ | { |
|
|
} | } |
| |
buffer[len++] = r + '0'; | buffer[len++] = r + '0'; |
|
|
x = q ; |
|
} | } |
| |
buffer[len] = '\0'; | buffer[len] = '\0'; |
|
|
return; | return; |
} | } |
| |
char buffer[256]; |
char buffer[32]; |
Uint32 len = 0; | Uint32 len = 0; |
| |
for (Uint32 i = 0; 1; i++) |
while (x) |
{ | { |
Uint64 q = x / 10; |
|
Uint32 r = x % 10; | Uint32 r = x % 10; |
|
x = x / 10; |
if (q == 0 && r == 0) |
|
break; |
|
| |
buffer[len++] = r + '0'; | buffer[len++] = r + '0'; |
|
|
x = q ; |
|
} | } |
| |
buffer[len] = '\0'; | buffer[len] = '\0'; |
|
|
| |
*q++ = '\0'; | *q++ = '\0'; |
} | } |
|
#endif |
| |
//------------------------------------------------------------------------------ | //------------------------------------------------------------------------------ |
// | // |
|
|
inline void _toXml(Array<Sint8>& out, Boolean x) { _toString(out, x); } | inline void _toXml(Array<Sint8>& out, Boolean x) { _toString(out, x); } |
inline void _toMof(Array<Sint8>& out, Boolean x) { _toString(out, x); } | inline void _toMof(Array<Sint8>& out, Boolean x) { _toString(out, x); } |
| |
template<class T> |
inline void _integerToString(Array<Sint8>& out, Sint32 x) |
inline void _integerToString(Array<Sint8>& out, const T& x) |
|
{ | { |
char buffer[32]; | char buffer[32]; |
sprintf(buffer, "%d", x); | sprintf(buffer, "%d", x); |
out << (char*)buffer; | out << (char*)buffer; |
} | } |
| |
template<class T> |
inline void _unsignedIntegerToString(Array<Sint8>& out, Uint32 x) |
inline void _unsignedIntegerToString(Array<Sint8>& out, const T& x) |
|
{ | { |
char buffer[32]; | char buffer[32]; |
sprintf(buffer, "%u", Uint32(x)); |
sprintf(buffer, "%u", x); |
out << (char*)buffer; | out << (char*)buffer; |
} | } |
| |
|
|
| |
inline void _toString(Array<Sint8>& out, Uint64 x) | inline void _toString(Array<Sint8>& out, Uint64 x) |
{ | { |
char buffer[128]; |
char buffer[32]; // Should need 21 chars max |
_UnsignedIntToStr(x, buffer); |
// I know I shouldn't put platform flags here, but the other was is too hard |
|
#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) |
|
sprintf(buffer, "%I64u", x); |
|
#else |
|
sprintf(buffer, "%llu", x); |
|
#endif |
out << buffer; | out << buffer; |
} | } |
| |
|
|
| |
inline void _toString(Array<Sint8>& out, Sint64 x) | inline void _toString(Array<Sint8>& out, Sint64 x) |
{ | { |
char buffer[128]; |
char buffer[32]; // Should need 21 chars max |
_SignedIntToStr(x, buffer); |
// I know I shouldn't put platform flags here, but the other was is too hard |
|
#if defined(PEGASUS_PLATFORM_WIN32_IX86_MSVC) |
|
sprintf(buffer, "%I64d", x); |
|
#else |
|
sprintf(buffer, "%lld", x); |
|
#endif |
out << buffer; | out << buffer; |
} | } |
| |
inline void _toXml(Array<Sint8>& out, Sint64 x) { _toString(out, x); } | inline void _toXml(Array<Sint8>& out, Sint64 x) { _toString(out, x); } |
inline void _toMof(Array<Sint8>& out, Sint64 x) { _toString(out, x); } | inline void _toMof(Array<Sint8>& out, Sint64 x) { _toString(out, x); } |
| |
void _toString(Array<Sint8>& out, Real32 x) |
|
{ |
|
char buffer[128]; |
|
// ATTN: Does this format match the CIM/XML format? |
|
sprintf(buffer, "%f", x); |
|
out << buffer; |
|
} |
|
|
|
inline void _toXml(Array<Sint8>& out, Real32 x) { _toString(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Real32 x) { _toString(out, x); } |
|
|
|
void _toString(Array<Sint8>& out, Real64 x) | void _toString(Array<Sint8>& out, Real64 x) |
{ | { |
char buffer[128]; | char buffer[128]; |
// ATTN: Does this format match the CIM/XML format? |
// %g gives '[-]m.dddddd[e+/-xx]', which seems compatible with CIM/XML spec |
sprintf(buffer, "%f", x); |
sprintf(buffer, "%g", x); |
out << buffer; | out << buffer; |
} | } |
| |
inline void _toXml(Array<Sint8>& out, Real64 x) { _toString(out, x); } | inline void _toXml(Array<Sint8>& out, Real64 x) { _toString(out, x); } |
inline void _toMof(Array<Sint8>& out, Real64 x) { _toString(out, x); } | inline void _toMof(Array<Sint8>& out, Real64 x) { _toString(out, x); } |
| |
|
inline void _toString(Array<Sint8>& out, Real32 x) { _toString(out, Real64(x)); } |
|
inline void _toXml(Array<Sint8>& out, Real32 x) { _toString(out, x); } |
|
inline void _toMof(Array<Sint8>& out, Real32 x) { _toString(out, x); } |
|
|
inline void _toString(Array<Sint8>& out, Char16 x) | inline void _toString(Array<Sint8>& out, Char16 x) |
{ | { |
// ATTN: How to convert 16-bit characters to printable form? | // ATTN: How to convert 16-bit characters to printable form? |