From b433625df8188ca5d27d5adb1eedbf42c4590744 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 20 May 2013 22:05:56 +0200 Subject: [PATCH] [DEV] add some _ in the function imput and remode debug display --- etk/UString.cpp | 178 +++++++++++++++++++++++++++--------------- etk/UString.h | 41 +++++----- etk/math/Vector2D.cpp | 2 +- 3 files changed, 140 insertions(+), 81 deletions(-) diff --git a/etk/UString.cpp b/etk/UString.cpp index 7c1b6d5..9d20820 100644 --- a/etk/UString.cpp +++ b/etk/UString.cpp @@ -11,14 +11,14 @@ #include #include -int32_t strlen(const uniChar_t * data) +int32_t strlen(const uniChar_t * _data) { - if (NULL == data) { + if (NULL == _data) { return 0; } int32_t iii=0; - while (*data != 0) { - data++; + while (*_data != 0) { + _data++; iii++; if (iii > 0x7FFFFFF0) { return iii; @@ -30,13 +30,13 @@ int32_t strlen(const uniChar_t * data) #undef __class__ #define __class__ "etk::UString" -etk::CCout& etk::operator <<(etk::CCout &os, const etk::UString &obj) +etk::CCout& etk::operator <<(etk::CCout& _os, const etk::UString& _obj) { etk::Vector output_UTF8; - unicode::convertUnicodeToUtf8(obj.m_data, output_UTF8); + unicode::convertUnicodeToUtf8(_obj.m_data, output_UTF8); output_UTF8.PushBack('\0'); - os << &output_UTF8[0]; - return os; + _os << &output_UTF8[0]; + return _os; } etk::UString::UString(void) @@ -134,19 +134,10 @@ etk::UString::UString(const double _inputData) Set(tmpVal); } -void etk::UString::Set(const int64_t& _inputData, etk::UString::printMode_te _mode, bool _preset) +void etk::UString::SetNumber(bool _negative, const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset) { - if (_preset==true && _mode != etk::UString::printModeString) { - Set((uint64_t)_inputData, _mode, _preset); - return; - } - uint64_t tmpData; - if (_inputData < 0) { - tmpData = (uint64_t)((int64_t)_inputData * (int64_t)(-1)); - } else { - tmpData = _inputData; - } - if (_inputData < 0) { + m_data.Clear(); + if (true==_negative) { if (_mode == etk::UString::printModeString) { m_data.PushBack('l'); m_data.PushBack('e'); @@ -157,12 +148,6 @@ void etk::UString::Set(const int64_t& _inputData, etk::UString::printMode_te _mo m_data.PushBack('-'); } } - 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) -{ if (_preset==true) { switch(_mode) { case etk::UString::printModeBinary : @@ -228,19 +213,42 @@ 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); + if (m_data.Size()==0) { + m_data.PushBack('\0'); + } else if (m_data[m_data.Size()-1]!='\0') { + m_data.PushBack('\0'); + } + //TK_ERROR(" convert : " << _inputData << " in : " << *this << " len=" << m_data.Size()); +} + +void etk::UString::Set(const int64_t& _inputData, etk::UString::printMode_te _mode, bool _preset) +{ + if (_preset==true && _mode != etk::UString::printModeString) { + SetNumber(false, (uint64_t)_inputData, _mode, _preset); + return; + } + if (_inputData < 0) { + uint64_t tmpData = (uint64_t)((int64_t)_inputData * (int64_t)(-1)); + SetNumber(true, (uint64_t)tmpData, _mode, _preset); + } else { + SetNumber(false, (uint64_t)_inputData, _mode, _preset); + } +} + +void etk::UString::Set(const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset) +{ + SetNumber(false, (uint64_t)_inputData, _mode, _preset); } // multiple element add -etk::UString::UString(const uniChar_t* _inputData, int32_t len) +etk::UString::UString(const uniChar_t* _inputData, int32_t _len) { - Set(_inputData, len); + Set(_inputData, _len); } -etk::UString::UString(const char* _inputData, int32_t len) +etk::UString::UString(const char* _inputData, int32_t _len) { - Set(_inputData, len); + Set(_inputData, _len); } etk::UString::UString(const etk::Vector& _inputData) @@ -282,9 +290,9 @@ void etk::UString::Set(const etk::Vector& _inputData) } -void etk::UString::Set(const etk::Vector& inputData) +void etk::UString::Set(const etk::Vector& _inputData) { - m_data = inputData; + m_data = _inputData; if (m_data.Size()>0) { if (m_data[m_data.Size()-1] != '\0') { m_data.PushBack('\0'); @@ -295,53 +303,62 @@ void etk::UString::Set(const etk::Vector& inputData) //TK_DEBUG("m_dataLen="<& inputData); - UString(const etk::Vector& inputData); - UString(const etk::Vector& inputData); + UString(const uniChar_t* _inputData, int32_t _len = -1); + UString(const char* _inputData, int32_t _len = -1); + UString(const etk::Vector& _inputData); + UString(const etk::Vector& _inputData); + UString(const etk::Vector& _inputData); // generic setter - void Set(const uniChar_t* inputData, int32_t len=-1); - void Set(const char* inputData, int32_t len=-1); - void Set(const etk::Vector& inputData); - void Set(const etk::Vector& inputData); - void Set(const etk::Vector& inputData); + void Set(const uniChar_t* _inputData, int32_t _len=-1); + void Set(const char* _inputData, int32_t _len=-1); + void Set(const etk::Vector& _inputData); + void Set(const etk::Vector& _inputData); + void Set(const etk::Vector& _inputData); + private: + void SetNumber(bool _negative, const uint64_t& _inputData, etk::UString::printMode_te _mode, bool _preset); + public: void Set(const int64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false); void Set(const uint64_t& _inputData, printMode_te _mode=printModeDecimal, bool _preset=false); @@ -135,10 +138,10 @@ namespace etk /***************************************************** * Generic modification function *****************************************************/ - void Add(int32_t currentID, const char* inputData); - void Add(int32_t currentID, const uniChar_t* inputData); - void Add(int32_t currentID, const uniChar_t inputData); - void Remove(int32_t currentID, int32_t len); + void Add(int32_t _currentID, const char* _inputData); + void Add(int32_t _currentID, const uniChar_t* _inputData); + void Add(int32_t _currentID, const uniChar_t _inputData); + void Remove(int32_t _currentID, int32_t _len); void Clear(void); etk::Vector GetVector(void); @@ -147,13 +150,13 @@ namespace etk etk::Char c_str(void) const; void Lower(void); - etk::UString ToLower(void); + etk::UString ToLower(void) const; void Upper(void); - etk::UString ToUpper(void); + etk::UString ToUpper(void) const; // Sting operation : - etk::UString Extract(int32_t posStart=0, int32_t posEnd=0x7FFFFFFF) const; + etk::UString Extract(int32_t _posStart=0, int32_t _posEnd=0x7FFFFFFF) const; /** * @brief Transform the current string in an int64_t * @return the requested int @@ -211,11 +214,11 @@ namespace etk bool ToBool(void) const; }; - etk::CCout& operator <<(etk::CCout &os, const etk::UString &obj); + etk::CCout& operator <<(etk::CCout& _os, const etk::UString& _obj); } -int32_t strlen(const uniChar_t * data); +int32_t strlen(const uniChar_t * _data); diff --git a/etk/math/Vector2D.cpp b/etk/math/Vector2D.cpp index f58bab0..239dbe5 100644 --- a/etk/math/Vector2D.cpp +++ b/etk/math/Vector2D.cpp @@ -85,7 +85,7 @@ namespace etk tmpStr.Remove(0,posComa+1); m_floats[1] = tmpStr.ToBool(); } - TK_DEBUG("Parse : \"" << _str << "\" ==> " << *this); + TK_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); } template<> Vector2D::operator etk::UString(void) const