[DEV] stream write correct integer

This commit is contained in:
Edouard DUPIN 2013-05-16 22:03:00 +02:00
parent b75f2ea698
commit 7dca8979c6
3 changed files with 56 additions and 22 deletions

View File

@ -39,7 +39,7 @@
free(demangled);
}
}
//assert(false);
assert(false);
}
#else
void etk::DisplayBacktrace(void)
@ -139,14 +139,6 @@ etk::CCout::~CCout()
};
etk::CCout& etk::CCout::operator << (int t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (const etk::UniChar& t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t.Get());
@ -154,25 +146,60 @@ etk::CCout& etk::CCout::operator << (const etk::UniChar& t)
return *this;
}
etk::CCout& etk::CCout::operator << (unsigned int t)
etk::CCout& etk::CCout::operator << (int8_t t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (int16_t t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (int32_t t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (int64_t t)
{
#if __WORDSIZE == 64
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t);
#else
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t);
#endif
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (uint8_t t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (long t)
etk::CCout& etk::CCout::operator << (uint16_t t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (long long t)
etk::CCout& etk::CCout::operator << (uint32_t t)
{
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t);
snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t);
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}
etk::CCout& etk::CCout::operator << (uint64_t t)
{
#if __WORDSIZE == 64
snprintf(tmp, MAX_LOG_SIZE_TMP, "%lu", t);
#else
snprintf(tmp, MAX_LOG_SIZE_TMP, "%llu", t);
#endif
strncat(m_tmpChar, tmp, MAX_LOG_SIZE);
return *this;
}

View File

@ -32,10 +32,14 @@ namespace etk
CCout(void);
~CCout(void);
CCout& operator << (const etk::UniChar& t);;
CCout& operator << (int t);
CCout& operator << (unsigned int t);
CCout& operator << (long t);
CCout& operator << (long long t);
CCout& operator << (int8_t t);
CCout& operator << (int16_t t);
CCout& operator << (int32_t t);
CCout& operator << (int64_t t);
CCout& operator << (uint8_t t);
CCout& operator << (uint16_t t);
CCout& operator << (uint32_t t);
CCout& operator << (uint64_t t);
CCout& operator << (double t);
CCout& operator << (float t);
CCout& operator << (char * t);

View File

@ -9,6 +9,7 @@
#include <etk/UString.h>
#include <etk/os/Memory.h>
#include <etk/unicode.h>
#include <etk/Debug.h>
int32_t strlen(const uniChar_t * data)
{
@ -157,6 +158,7 @@ void etk::UString::Set(const int64_t& _inputData, etk::UString::printMode_te _mo
}
}
Set((uint64_t)tmpData, _mode, _preset);
//TK_ERROR(" convert : " << _inputData << " in : " << *this);
}
void etk::UString::Set(const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset)
@ -227,6 +229,7 @@ void etk::UString::Set(const uint64_t& _inputData, etk::UString::printMode_te _m
//TK_ERROR (" " << ploppp);
}
m_data.PushBack('\0');
//TK_ERROR(" convert : " << _inputData << " in : " << *this);
}
// multiple element add