diff --git a/etk/Debug.h b/etk/Debug.h index a5a5c12..c9e81b2 100644 --- a/etk/Debug.h +++ b/etk/Debug.h @@ -34,7 +34,10 @@ void GeneralDebugSetLevel(etk::logLevel_te ccc); }while(0) -#define ETK_CRITICAL(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_CRITICAL, data) +#define ETK_CRITICAL(libName, data) do { \ + ETK_DBG_COMMON(libName, etk::LOG_LEVEL_CRITICAL, data); \ + etk::DisplayBacktrace(); \ + }while(0) #if DEBUG_LEVEL > 0 # define ETK_WARNING(libName, data) ETK_DBG_COMMON(libName, etk::LOG_LEVEL_WARNING, data) diff --git a/etk/RegExp.cpp b/etk/RegExp.cpp index b7d979c..23f5402 100644 --- a/etk/RegExp.cpp +++ b/etk/RegExp.cpp @@ -64,21 +64,11 @@ const etk::convertionTable_ts etk::constConvertionTable[] = { }; const int32_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ; - -void etk::DisplayData(etk::Vector &data) +void etk::DisplayElem(const etk::Vector& _data, int32_t _start, int32_t _stop) { - int32_t i; - for (i=0; i<(int32_t)data.Size() ; i++) { - etk::cout<< (char)(data[i]&0x00FF ); - } -} - -void etk::DisplayElem(etk::Vector &data, int32_t start, int32_t stop) -{ - int32_t i; etk::cout<< ETK_BASH_COLOR_NORMAL; - for (i=start; i<(int32_t)data.Size() && i &data, int32_t start, int32_t stop) case REGEXP_OPCODE_WORD_NOT: etk::cout< &data, int32_t startPos) +int32_t etk::GetLenOfPTheseElem(const etk::Vector& _data, int32_t _startPos) { - if (startPos>=data.Size()){ + if (_startPos>=_data.Size()){ return 0; } - int32_t pos = startPos; + int32_t pos = _startPos; int32_t nbOpen = 0; // special case of the (...) or | ==> we search '|' or ')' - if( REGEXP_OPCODE_PTHESE_OUT == data[pos] - || REGEXP_OPCODE_PIPE == data[pos]) { + if( _data[pos] == REGEXP_OPCODE_PTHESE_OUT + || _data[pos] == REGEXP_OPCODE_PIPE) { return 0; } // find size ... - while (pos < (int32_t)data.Size() ) { - if(REGEXP_OPCODE_PTHESE_IN == data[pos]) { + while (pos < (int32_t)_data.Size() ) { + if(_data[pos] == REGEXP_OPCODE_PTHESE_IN) { // find a sub section : nbOpen++; } else if(0 < nbOpen) { - if (REGEXP_OPCODE_PTHESE_OUT == data[pos]) - { + if (_data[pos] == REGEXP_OPCODE_PTHESE_OUT) { nbOpen--; if (0 > nbOpen) { TK_ERROR("Error in the (...) find element at "<< pos); return -1; } } - } else if( REGEXP_OPCODE_PTHESE_OUT == data[pos] - || REGEXP_OPCODE_PIPE == data[pos]) - { + } else if( _data[pos] == REGEXP_OPCODE_PTHESE_OUT + || _data[pos] == REGEXP_OPCODE_PIPE) { // Find the end of the (...) // just return the size inside - int32_t sizeInside = pos - startPos; + int32_t sizeInside = pos - _startPos; if (0 >= sizeInside) { TK_ERROR("Error in the (...) no data at "<< pos-1); return -1; } else { - return sizeInside; + return sizeInside; } } pos++; } - return pos - startPos; + return pos - _startPos; } -int32_t etk::GetLenOfPThese(etk::Vector &data, int32_t startPos) +int32_t etk::GetLenOfPThese(const etk::Vector& _data, int32_t _startPos) { - int32_t pos = startPos; + int32_t pos = _startPos; int32_t nbOpen = 0; // special case of the (...) or | ==> we search '|' or ')' - if( REGEXP_OPCODE_PTHESE_OUT == data[pos]) { + if(_data[pos]==REGEXP_OPCODE_PTHESE_OUT) { return 0; - } else if( REGEXP_OPCODE_PTHESE_IN == data[pos]) - { + } else if(_data[pos]==REGEXP_OPCODE_PTHESE_IN) { pos++; // find size ... - while (pos < (int32_t)data.Size() ) { - if(REGEXP_OPCODE_PTHESE_IN == data[pos]) { + while (pos < _data.Size() ) { + if(_data[pos]==REGEXP_OPCODE_PTHESE_IN) { // find a sub section : nbOpen++; } else if(0 < nbOpen) { - if (REGEXP_OPCODE_PTHESE_OUT == data[pos]) - { + if (_data[pos]==REGEXP_OPCODE_PTHESE_OUT) { nbOpen--; if (0 > nbOpen) { TK_ERROR("Error in the (...) find element at "<< pos); return -1; } } - } else if( REGEXP_OPCODE_PTHESE_OUT == data[pos]) - { + } else if(_data[pos]==REGEXP_OPCODE_PTHESE_OUT) { // Find the end of the (...) // just return the size inside - int32_t sizeInside = pos - startPos-1; + int32_t sizeInside = pos - _startPos-1; if (0 >= sizeInside) { TK_ERROR("Error in the (...) no data at "<< pos-1); return -1; @@ -224,31 +209,29 @@ int32_t etk::GetLenOfPThese(etk::Vector &data, int32_t startPos) } -int32_t etk::GetLenOfBracket(etk::Vector &data, int32_t startPos) +int32_t etk::GetLenOfBracket(const etk::Vector& _data, int32_t _startPos) { - int32_t pos = startPos; + int32_t pos = _startPos; // special case of the (...) or | ==> we search '|' or ')' - if( REGEXP_OPCODE_BRACKET_OUT == data[pos]) { + if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) { return 0; - } else if( REGEXP_OPCODE_BRACKET_IN == data[pos]) { + } else if(_data[pos] == REGEXP_OPCODE_BRACKET_IN) { pos++; // find size ... - while (pos < (int32_t)data.Size() ) { - if(REGEXP_OPCODE_BRACKET_OUT == data[pos]) { + while (pos < _data.Size() ) { + if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) { // Find the end of the [...] // just return the size inside - int32_t sizeInside = pos - startPos -1 ; + int32_t sizeInside = pos - _startPos -1 ; if (0 >= sizeInside) { TK_ERROR("Error in the [...] no data at "<< pos-1); return sizeInside; } else { return sizeInside; } - } else if( REGEXP_OPCODE_TO != data[pos] - && ( 0 > data[pos] - || 0xFF < data[pos]) ) - { - TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)data[pos] << "'"); + } else if( _data[pos] != REGEXP_OPCODE_TO + && _data[pos] > 0xFF ) { + TK_ERROR("Error in the [...] not permited element at "<< pos << " '" << (char)_data[pos].Get() << "'"); return false; } pos++; @@ -260,31 +243,30 @@ int32_t etk::GetLenOfBracket(etk::Vector &data, int32_t startPos) } -int32_t etk::GetLenOfBrace(etk::Vector &data, int32_t startPos) +int32_t etk::GetLenOfBrace(const etk::Vector& _data, int32_t _startPos) { - int32_t pos = startPos; + int32_t pos = _startPos; // special case of the (...) or | ==> we search '|' or ')' - if( REGEXP_OPCODE_BRACE_OUT == data[pos]) { + if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) { return 0; - } else if( REGEXP_OPCODE_BRACE_IN == data[pos]) { + } else if(_data[pos]==REGEXP_OPCODE_BRACE_IN) { pos++; // find size ... - while (pos < (int32_t)data.Size() ) { - if(REGEXP_OPCODE_BRACE_OUT == data[pos]) { + while (pos < _data.Size() ) { + if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) { // Find the end of the [...] // just return the size inside - int32_t sizeInside = pos - startPos -1 ; + int32_t sizeInside = pos - _startPos -1 ; if (0 >= sizeInside) { TK_ERROR("Error in the {...} no data at "<< pos-1); return sizeInside; } else { return sizeInside; } - } else if( ',' != data[pos] - && ( '0' > data[pos] - || '9' < data[pos]) ) - { - TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << (char)data[pos] << "'"); + } else if( _data[pos] != ',' + && ( _data[pos] < '0' + || _data[pos] > '9') ) { + TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << _data[pos].Get() << "'"); return false; } pos++; @@ -296,13 +278,13 @@ int32_t etk::GetLenOfBrace(etk::Vector &data, int32_t startPos) } -int32_t etk::GetLenOfNormal(etk::Vector &data, int32_t startPos) +int32_t etk::GetLenOfNormal(const etk::Vector& _data, int32_t _startPos) { - int32_t pos = startPos; + int32_t pos = _startPos; // find size ... - while (pos < (int32_t)data.Size() ) { - switch(data[pos]) + while (pos < _data.Size() ) { + switch(_data[pos].Get()) { case REGEXP_OPCODE_PTHESE_IN: case REGEXP_OPCODE_PTHESE_OUT: @@ -328,7 +310,7 @@ int32_t etk::GetLenOfNormal(etk::Vector &data, int32_t startPos) case REGEXP_OPCODE_WORD_NOT: { // just return the size inside - int32_t sizeInside = pos - startPos; + int32_t sizeInside = pos - _startPos; if (0 >= sizeInside) { TK_ERROR("Error in the normal data : no data ..."); } @@ -341,11 +323,11 @@ int32_t etk::GetLenOfNormal(etk::Vector &data, int32_t startPos) } pos++; } - return pos - startPos ; + return pos - _startPos ; } -bool etk::ParseBrace(etk::Vector &data, int32_t &min, int32_t &max) +bool etk::ParseBrace(const etk::Vector& _data, int32_t& _min, int32_t& _max) { //TK_INFO("parse {...} in "; DisplayElem(data); ); int32_t k=0; @@ -353,36 +335,36 @@ bool etk::ParseBrace(etk::Vector &data, int32_t &min, int32_t &max) int32_t firstElement = 0; int32_t SecondElement = 0; - while(k= (char)data[k]) { + } else if(true==_data[k].IsInteger()) { firstElement *=10; - firstElement += (char)data[k] - '0'; + firstElement += _data[k].ToInt32(); } else { - TK_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k); + TK_ERROR("Can not parse this element " << (char)_data[k].Get() << " at pos " << k); return false; } k++; } - if (k==data.Size()) { + if (k==_data.Size()) { SecondElement = firstElement; } - while(k= (char)data[k]) { + } else if (true==_data[k].IsInteger()) { SecondElement *=10; - SecondElement += (char)data[k] - '0'; + SecondElement += _data[k].ToInt32(); } else { - TK_ERROR("Can not parse this element " << (char)data[k] << " at pos " << k); + TK_ERROR("Can not parse this element " << _data[k] << " at pos " << k); return false; } k++; @@ -390,14 +372,14 @@ bool etk::ParseBrace(etk::Vector &data, int32_t &min, int32_t &max) allIsSet: if (SecondElement == 0 && firstElement != 0) { - min = 0; - max = firstElement; + _min = 0; + _max = firstElement; } else { - min = firstElement; - max = SecondElement; + _min = firstElement; + _max = SecondElement; } - if (min > max) { - TK_ERROR("Minimum=" << min << " can not be < maximum=" << max ); + if (_min > _max) { + TK_ERROR("Minimum=" << _min << " can not be < maximum=" << _max ); return false; } return true; diff --git a/etk/RegExp.h b/etk/RegExp.h index 0a7a688..b7cf812 100644 --- a/etk/RegExp.h +++ b/etk/RegExp.h @@ -43,50 +43,23 @@ multiplicity : {x,y} ==> {x, y} */ - -// internal define to permit to have all needed system -#define REGEXP_OPCODE_PTHESE_IN (-300) /* ( */ -#define REGEXP_OPCODE_PTHESE_OUT ( 300) /* ) */ -#define REGEXP_OPCODE_BRACKET_IN (-301) /* [ */ -#define REGEXP_OPCODE_BRACKET_OUT ( 301) /* ] */ -#define REGEXP_OPCODE_BRACE_IN (-302) /* { */ -#define REGEXP_OPCODE_BRACE_OUT ( 302) /* } */ -#define REGEXP_OPCODE_TO (-305) /* - */ -#define REGEXP_OPCODE_STAR (-306) /* * */ -#define REGEXP_OPCODE_DOT (-307) /* . */ -#define REGEXP_OPCODE_QUESTION (-308) /* ? */ -#define REGEXP_OPCODE_PLUS (-309) /* + */ -#define REGEXP_OPCODE_PIPE (-310) /* | */ -#define REGEXP_OPCODE_START_OF_LINE (-311) /* ^ this is also NOT, but not manage */ -#define REGEXP_OPCODE_END_OF_LINE (-312) /* $ */ -#define REGEXP_OPCODE_DIGIT ( 313) /* \d */ -#define REGEXP_OPCODE_DIGIT_NOT (-313) /* \D */ -#define REGEXP_OPCODE_LETTER ( 314) /* \l */ -#define REGEXP_OPCODE_LETTER_NOT (-314) /* \L */ -#define REGEXP_OPCODE_SPACE ( 315) /* \s */ -#define REGEXP_OPCODE_SPACE_NOT (-315) /* \S */ -#define REGEXP_OPCODE_WORD ( 316) /* \w */ -#define REGEXP_OPCODE_WORD_NOT (-316) /* \W */ -#define REGEXP_OPCODE_NO_CHAR (-317) /* \@ */ - typedef struct { - bool haveBackSlash; - char inputValue; - int16_t newValue; + bool haveBackSlash; + uint32_t inputValue; + uint32_t newValue; }convertionTable_ts; extern const convertionTable_ts constConvertionTable[]; extern const int32_t constConvertionTableSize; -void DisplayData(etk::Vector &data); -void DisplayElem(etk::Vector &data, int32_t start=0, int32_t stop=0x7FFFFFFF); -char * levelSpace(int32_t level); -int32_t GetLenOfPTheseElem(etk::Vector &data, int32_t startPos); -int32_t GetLenOfPThese(etk::Vector &data, int32_t startPos); -int32_t GetLenOfBracket(etk::Vector &data, int32_t startPos); -int32_t GetLenOfBrace(etk::Vector &data, int32_t startPos); -int32_t GetLenOfNormal(etk::Vector &data, int32_t startPos); -bool ParseBrace(etk::Vector &data, int32_t &min, int32_t &max); +void DisplayElem(const etk::Vector& _data, int32_t _start=0, int32_t _stop=0x7FFFFFFF); +char * levelSpace(int32_t _level); +int32_t GetLenOfPTheseElem(const etk::Vector& _data, int32_t _startPos); +int32_t GetLenOfPThese(const etk::Vector& _data, int32_t _startPos); +int32_t GetLenOfBracket(const etk::Vector& _data, int32_t _startPos); +int32_t GetLenOfBrace(const etk::Vector& _data, int32_t _startPos); +int32_t GetLenOfNormal(const etk::Vector& _data, int32_t _startPos); +bool ParseBrace(const etk::Vector& _data, int32_t& _min, int32_t& _max); #undef __class__ @@ -95,147 +68,118 @@ bool ParseBrace(etk::Vector &data, int32_t &min, int32_t &max); /** * @brief Node Elements for every-one */ -template class RegExpNode{ +template class RegExpNode +{ + protected : + int32_t m_multipleMin; //!< minimum repetition (included) + int32_t m_multipleMax; //!< maximum repetition (included) + // Data Section ... (can have no data...) + etk::Vector m_RegExpData; //!< data to parse and compare in some case ... public : + /** + * @brief Constructor + */ + RegExpNode(void) : + m_multipleMin(1), + m_multipleMax(1) + { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - RegExpNode(void) - { - SetMult(1,1); - }; + virtual ~RegExpNode(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Generate the regular expression with the current "converted string" + * @param[in] _data Property of the regexp + * @return the number of element used */ - virtual ~RegExpNode(void) - { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - virtual int32_t Generate(etk::Vector &data) + virtual int32_t Generate(const etk::Vector& _data) { return 0; }; /** - * @brief - * @param[in,out] - * @return + * @brief Parse the current node + * @param[in] _data Data to parse (start pointer / or class that have access with operator[] ) + * @param[in] _currentPos Current parsing position. + * @param[in] _lenMax Maximum position to parse the data (can be not hte end of the data due to the fact sometime we want to parse sub section). + * @param[in] _findLen number of element parssed + * @return true : Find something + * @return false : Find nothing */ - virtual bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen)=0; + /* { findLen = 0; return false; }; - + */ /** - * @brief - * @param[in,out] - * @return + * @brief Display the current node properties + * @param[in] level of the node */ - virtual void Display(int32_t level) + virtual void Display(int32_t _level) { - TK_INFO("Find NODE : " << levelSpace(level) << "@???@ {" << GetMultMin() << "," << GetMultMax() << "} subdata="; DisplayElem(m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@???@ {" << GetMultMin() << "," << GetMultMax() << "} subdata="; DisplayElem(m_RegExpData);); }; - /** - * @brief - * @param[in,out] - * @return + * @brief Set the multiplicity of this Node. + * @param[in] _min The minimum appear time. + * @param[in] _max The maximum appear time. */ - void SetMult(int32_t min, int32_t max) + void SetMult(int32_t _min, int32_t _max) { - m_multipleMin = etk_max(min, 0); - m_multipleMax = etk_max(max, 1); + m_multipleMin = etk_max(_min, 0); + m_multipleMax = etk_max(_max, 1); } protected: /** - * @brief - * @param[in,out] - * @return + * @brief Get the minimum multiplicity. + * @return The minimum appear availlable. */ - int32_t GetMultMin(void) - { - return m_multipleMin; - }; - + int32_t GetMultMin(void) const { return m_multipleMin; }; /** - * @brief - * @param[in,out] - * @return + * @brief Get the maximum multiplicity. + * @return The maximum appear availlable. */ - int32_t GetMultMax(void) - { - return m_multipleMax; - }; - protected : - int32_t m_multipleMin; //!< minimum repetition (included) - int32_t m_multipleMax; //!< maximum repetition (included) - // Data Section ... (can have no data...) - etk::Vector m_RegExpData; //!< data to parse and compare in some case ... + int32_t GetMultMax(void) const { return m_multipleMax; }; }; #undef __class__ #define __class__ "etk::RegExpNodeValue" -template class RegExpNodeValue : public RegExpNode { +template class RegExpNodeValue : public RegExpNode +{ + protected : + // SubNodes : + etk::Vector m_data; public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeValue(void) - { - - }; + RegExpNodeValue(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeValue(void) - { - - }; + ~RegExpNodeValue(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Generate(etk::Vector &data) + int32_t Generate(const etk::Vector& _data) { - RegExpNode::m_RegExpData = data; + RegExpNode::m_RegExpData = _data; //TK_DEBUG("Request Parse \"Value\" data="; DisplayElem(RegExpNode::m_RegExpData);); m_data.Clear(); for (int32_t i=0; i::m_RegExpData.Size(); i++) { - m_data.PushBack((char)RegExpNode::m_RegExpData[i]); + m_data.PushBack(RegExpNode::m_RegExpData[i]); } - return data.Size(); + return _data.Size(); }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : Value{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); if (0==m_data.Size()) { TK_ERROR("No data inside type elemTypeValue"); @@ -247,8 +191,8 @@ template class RegExpNodeValue : public RegExpNode for (j=0; j::m_multipleMax && tmpFind == true; j++) { int32_t ofset = 0; int32_t k; - for (k=0; findLen+k class RegExpNodeValue : public RegExpNode } // Update local ofset of data if (true == tmpFind) { - findLen += ofset; + _findLen += ofset; } } if( j>=RegExpNode::m_multipleMin && j<=RegExpNode::m_multipleMax - && findLen>0 ) + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; @@ -276,57 +220,38 @@ template class RegExpNodeValue : public RegExpNode return false; }; - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) + void Display(int32_t _level) { - TK_INFO("Find NODE : " << levelSpace(level) << "@Value@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); etk::cout<< " data: "; DisplayData(m_data); ); + TK_INFO("Find NODE : " << levelSpace(_level) << "@Value@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); etk::cout<< " data: "; DisplayElem(m_data); ); }; - protected : - // SubNodes : - etk::Vector m_data; }; #undef __class__ #define __class__ "etk::RegExpNodeBracket" -template class RegExpNodeBracket : public RegExpNode { +template class RegExpNodeBracket : public RegExpNode +{ + protected : + // SubNodes : + etk::Vector m_data; public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeBracket(void) - { - - }; + RegExpNodeBracket(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeBracket(void) - { - - }; + ~RegExpNodeBracket(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Generate(etk::Vector &data) + int32_t Generate(const etk::Vector& _data) { - RegExpNode::m_RegExpData = data; + RegExpNode::m_RegExpData = _data; //TK_DEBUG("Request Parse [...] data="; DisplayElem(RegExpNode::m_RegExpData);); m_data.Clear(); - char lastElement = 'a'; + etk::UniChar lastElement = 'a'; bool multipleElement = false; // for (int32_t k=0; k::m_RegExpData.Size(); k++) { @@ -334,15 +259,15 @@ template class RegExpNodeBracket : public RegExpNode::m_RegExpData[k]; j++) { + etk::UniChar j='\0'; + for (j=lastElement+1; j <= RegExpNode::m_RegExpData[k]; j+=1) { m_data.PushBack(j); } multipleElement = false; } else if(RegExpNode::m_RegExpData[k] == REGEXP_OPCODE_TO) { multipleElement = true; } else { - lastElement = (char)RegExpNode::m_RegExpData[k]; + lastElement = RegExpNode::m_RegExpData[k]; m_data.PushBack(lastElement); } } @@ -351,31 +276,26 @@ template class RegExpNodeBracket : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); if (0==m_data.Size()) { TK_ERROR("No data inside type elemTypeValue"); return false; } - //TK_DEBUG("one of element value List : "; DisplayData(element->m_data);); + //TK_DEBUG("one of element value List : "; DisplayElem(element->m_data);); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { int32_t i; tmpFind=false; for (i=0; i class RegExpNodeBracket : public RegExpNode=RegExpNode::m_multipleMin && j<=RegExpNode::m_multipleMax - && findLen>0 ) + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; @@ -394,70 +314,48 @@ template class RegExpNodeBracket : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); etk::cout<< " data: "; DisplayData(m_data); ); + TK_INFO("Find NODE : " << levelSpace(_level) << "@[...]@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); etk::cout<< " data: "; DisplayElem(m_data); ); }; - protected : - // SubNodes : - etk::Vector m_data; }; #undef __class__ #define __class__ "etk::RegExpNodeDigit" -template class RegExpNodeDigit : public RegExpNode { +template class RegExpNodeDigit : public RegExpNode +{ public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeDigit(void) - { - - }; + RegExpNodeDigit(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeDigit(void) - { - - }; + ~RegExpNodeDigit(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : Digit{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} : "<< data[currentPos] << " lenMax=" << lenMax); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; //TK_DEBUG("compare : " << tmpVal); - if( '0' <= tmpVal - && '9' >= tmpVal) + if( tmpVal >= '0' + && tmpVal <= '9') { //TK_DEBUG("find ++"); - findLen += 1; + _findLen += 1; } else { tmpFind=false; } } if( j>=RegExpNode::m_multipleMin && j<=RegExpNode::m_multipleMax - && findLen>0 ) + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; @@ -468,61 +366,45 @@ template class RegExpNodeDigit : public RegExpNode return false; }; - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) + void Display(int32_t _level) { - TK_INFO("Find NODE : " << levelSpace(level) << "@Digit@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@Digit@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ -#define __class__ "etk::RegExpNodeDigitNot" +#define __class__ "etk::RegExpNodeDigitNot" -template class RegExpNodeDigitNot : public RegExpNode { +template class RegExpNodeDigitNot : public RegExpNode +{ public : - RegExpNodeDigitNot(void) - { - - }; + /** + * @brief Constructor + */ + RegExpNodeDigitNot(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeDigitNot(void) - { - - }; + ~RegExpNodeDigitNot(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : DigitNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( '0' > tmpVal - || '9' < tmpVal) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( tmpVal < '0' + || tmpVal > '9') { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -532,69 +414,48 @@ template class RegExpNodeDigitNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@DigitNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeLetter" -template class RegExpNodeLetter : public RegExpNode { +template class RegExpNodeLetter : public RegExpNode +{ public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeLetter(void) - { - - }; + RegExpNodeLetter(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeLetter(void) - { - - }; + ~RegExpNodeLetter(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : Letter{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal )) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( ( tmpVal >= 'a' + && tmpVal <= 'z') + || ( tmpVal >= 'A' + && tmpVal <= 'Z') ) { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -604,69 +465,48 @@ template class RegExpNodeLetter : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@Letter@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeLetterNot" -template class RegExpNodeLetterNot : public RegExpNode { +template class RegExpNodeLetterNot : public RegExpNode +{ public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeLetterNot(void) - { - - }; + RegExpNodeLetterNot(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeLetterNot(void) - { - - }; + ~RegExpNodeLetterNot(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : LetterNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'a' > tmpVal - && 'Z' < tmpVal ) - || 'A' > tmpVal - || 'z' < tmpVal ) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( ( tmpVal < 'a' + && tmpVal > 'Z') + || tmpVal < 'A' + || tmpVal > 'z') { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -676,71 +516,50 @@ template class RegExpNodeLetterNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@LetterNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeWhiteSpace" -template class RegExpNodeWhiteSpace : public RegExpNode { +template class RegExpNodeWhiteSpace : public RegExpNode +{ public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeWhiteSpace(void) - { - - }; + RegExpNodeWhiteSpace(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeWhiteSpace(void) - { - - }; + ~RegExpNodeWhiteSpace(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : Space{" << m_multipleMin << "," << m_multipleMax << "}"); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ' ' == tmpVal - || '\t' == tmpVal - || '\n' == tmpVal - || '\r' == tmpVal - || '\f' == tmpVal - || '\v' == tmpVal ) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( tmpVal == ' ' + || tmpVal == '\t' + || tmpVal == '\n' + || tmpVal == '\r' + || tmpVal == '\f' + || tmpVal == '\v' ) { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -750,71 +569,50 @@ template class RegExpNodeWhiteSpace : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@Space@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeWhiteSpaceNot" -template class RegExpNodeWhiteSpaceNot : public RegExpNode { +template class RegExpNodeWhiteSpaceNot : public RegExpNode +{ public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeWhiteSpaceNot(void) - { - - }; + RegExpNodeWhiteSpaceNot(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeWhiteSpaceNot(void) - { - - }; + ~RegExpNodeWhiteSpaceNot(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : SpaceNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ' ' != tmpVal - && '\t' != tmpVal - && '\n' != tmpVal - && '\r' != tmpVal - && '\f' != tmpVal - && '\v' != tmpVal ) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( tmpVal != ' ' + && tmpVal != '\t' + && tmpVal != '\n' + && tmpVal != '\r' + && tmpVal != '\f' + && tmpVal != '\v' ) { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -824,71 +622,49 @@ template class RegExpNodeWhiteSpaceNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@SpaceNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeWordChar" -template class RegExpNodeWordChar : public RegExpNode { +template class RegExpNodeWordChar : public RegExpNode +{ public : + /** + * @brief Constructor + */ + RegExpNodeWordChar(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - RegExpNodeWordChar(void) - { - - }; + ~RegExpNodeWordChar(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeWordChar(void) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : Word{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal )) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( ( tmpVal >= 'a' + && tmpVal <= 'z' ) + || ( tmpVal >= 'A' + && tmpVal <= 'Z' ) + || ( tmpVal >= '0' + && tmpVal <= '9' ) ) { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -898,71 +674,49 @@ template class RegExpNodeWordChar : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@Word@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeWordCharNot" -template class RegExpNodeWordCharNot : public RegExpNode { +template class RegExpNodeWordCharNot : public RegExpNode +{ public : + /** + * @brief Constructor + */ + RegExpNodeWordCharNot(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - RegExpNodeWordCharNot(void) - { - - }; + ~RegExpNodeWordCharNot(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeWordCharNot(void) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : WordNot{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 'A' > tmpVal - && '9' < tmpVal ) - || ( 'a' > tmpVal - && 'Z' < tmpVal ) - || '0' > tmpVal - || 'z' < tmpVal ) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( ( tmpVal < 'A' + && tmpVal > '9' ) + || ( tmpVal < 'a' + && tmpVal > 'Z' ) + || tmpVal < '0' + || tmpVal > 'z') { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -972,72 +726,51 @@ template class RegExpNodeWordCharNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@WordNot@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeDot" -template class RegExpNodeDot : public RegExpNode { +template class RegExpNodeDot : public RegExpNode +{ public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeDot(void) - { - - }; + RegExpNodeDot(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeDot(void) - { - - }; + ~RegExpNodeDot(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; //TK_INFO("Parse node : '.'{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); // equivalent a : [^\x00-\x08\x0A-\x1F\x7F] bool tmpFind = true; int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < lenMax; j++) { - char tmpVal = data[currentPos+j]; - if( ( 0x08 < tmpVal - && 0x0A > tmpVal ) - || ( 0x1F < tmpVal - && 0x7F > tmpVal ) - || ( 0x7F < tmpVal - && 0xFF > tmpVal )) - { - findLen += 1; + for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { + etk::UniChar tmpVal = _data[_currentPos+j]; + if( ( tmpVal > 0x08 + && tmpVal < 0x0A ) + || ( tmpVal > 0x1F + && tmpVal < 0x7F ) + || ( tmpVal > 0x7F + && tmpVal < 0xFF ) ) { + _findLen += 1; } else { tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax - && findLen>0 ) - { + if( j>=RegExpNode::m_multipleMin + && j<=RegExpNode::m_multipleMax + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; } else if( 0 == RegExpNode::m_multipleMin ) { @@ -1047,112 +780,70 @@ template class RegExpNodeDot : public RegExpNode { return false; }; - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) + void Display(int32_t _level) { - TK_INFO("Find NODE : " << levelSpace(level) << "@.@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@.@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeSOL" -template class RegExpNodeSOL : public RegExpNode { +template class RegExpNodeSOL : public RegExpNode +{ public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ - RegExpNodeSOL(void) - { - - }; + RegExpNodeSOL(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - ~RegExpNodeSOL(void) - { - - }; + ~RegExpNodeSOL(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - findLen = 0; + _findLen = 0; + // TODO : ... TK_INFO("Parse node : SOL{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); return false; }; - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) + void Display(int32_t _level) { - TK_INFO("Find NODE : " << levelSpace(level) << "@SOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@SOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; #undef __class__ #define __class__ "etk::RegExpNodeEOL" -template class RegExpNodeEOL : public RegExpNode { +template class RegExpNodeEOL : public RegExpNode +{ public : + /** + * @brief Constructor + */ + RegExpNodeEOL(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - RegExpNodeEOL(void) - { - - }; + ~RegExpNodeEOL(void) { }; - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodeEOL(void) + virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - bool Parse(const CLASS_TYPE &data, int32_t currentPos, int32_t lenMax, int32_t &findLen) - { - findLen = 0; + _findLen = 0; + // TODO : ... TK_INFO("Parse node : EOL{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); return false; }; - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) + void Display(int32_t _level) { - TK_INFO("Find NODE : " << levelSpace(level) << "@EOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@EOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; }; @@ -1166,47 +857,32 @@ typedef struct { template class RegExpNodePThese; -template class RegExpNodePTheseElem : public RegExpNode { +template class RegExpNodePTheseElem : public RegExpNode +{ + protected : + // SubNodes : + etk::Vector*> m_subNode; public : + /** + * @brief Constructor + */ + RegExpNodePTheseElem(void) { }; /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ - RegExpNodePTheseElem(void) - { - - }; + ~RegExpNodePTheseElem(void) { }; - - /** - * @brief - * @param[in,out] - * @return - */ - ~RegExpNodePTheseElem(void) + int32_t Generate(const etk::Vector& _data) { - - }; - - /** - * @brief - * @param[in,out] - * @return - */ - int32_t Generate(etk::Vector &data) - { - RegExpNode::m_RegExpData = data; + RegExpNode::m_RegExpData = _data; //TK_DEBUG("Request Parse (elem) data="; DisplayElem(RegExpNode::m_RegExpData);); - int32_t pos = 0; int32_t elementSize = 0; - etk::Vector tmpData; + etk::Vector tmpData; while (pos < RegExpNode::m_RegExpData.Size()) { tmpData.Clear(); - switch (RegExpNode::m_RegExpData[pos]) - { + switch (RegExpNode::m_RegExpData[pos].Get()) { case REGEXP_OPCODE_PTHESE_IN: { elementSize=GetLenOfPThese(RegExpNode::m_RegExpData, pos); @@ -1224,7 +900,6 @@ template class RegExpNodePTheseElem : public RegExpNode::m_RegExpData, pos); @@ -1242,7 +917,6 @@ template class RegExpNodePTheseElem : public RegExpNode::m_RegExpData, pos); @@ -1261,71 +935,55 @@ template class RegExpNodePTheseElem : public RegExpNode()); break; - case REGEXP_OPCODE_START_OF_LINE: m_subNode.PushBack(new RegExpNodeSOL()); break; - case REGEXP_OPCODE_END_OF_LINE: m_subNode.PushBack(new RegExpNodeEOL()); break; - case REGEXP_OPCODE_DIGIT: m_subNode.PushBack(new RegExpNodeDigit()); break; - case REGEXP_OPCODE_DIGIT_NOT: m_subNode.PushBack(new RegExpNodeDigitNot()); break; - case REGEXP_OPCODE_LETTER: m_subNode.PushBack(new RegExpNodeLetter()); break; - case REGEXP_OPCODE_LETTER_NOT: m_subNode.PushBack(new RegExpNodeLetterNot()); break; - case REGEXP_OPCODE_SPACE: m_subNode.PushBack(new RegExpNodeWhiteSpace()); break; - case REGEXP_OPCODE_SPACE_NOT: m_subNode.PushBack(new RegExpNodeWhiteSpaceNot()); break; - case REGEXP_OPCODE_WORD: m_subNode.PushBack(new RegExpNodeWordChar()); break; - case REGEXP_OPCODE_WORD_NOT: m_subNode.PushBack(new RegExpNodeWordCharNot()); break; - + default: { elementSize=GetLenOfNormal(RegExpNode::m_RegExpData, pos); @@ -1343,63 +1001,47 @@ template class RegExpNodePTheseElem : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); // NOTE 1 : Must done only one time in EVERY case ... // NOTE 2 : All element inside must be OK if (0 == m_subNode.Size()) { return false; } - int32_t tmpCurrentPos = currentPos; + int32_t tmpCurrentPos = _currentPos; for (int32_t i=0; iParse(data, tmpCurrentPos, lenMax, tmpFindLen)) { - findLen = 0; + if (false == m_subNode[i]->Parse(_data, tmpCurrentPos, _lenMax, tmpFindLen)) { + _findLen = 0; return false; } else { tmpCurrentPos += tmpFindLen; } } - findLen = tmpCurrentPos - currentPos; + _findLen = tmpCurrentPos - _currentPos; return true; }; - /** - * @brief - * @param[in,out] - * @return - */ - void Display(int32_t level) + void Display(int32_t _level) { - TK_INFO("Find NODE : " << levelSpace(level) << "@(Elem)@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); - for(int32_t i=0; iDisplay(level+1); + TK_INFO("Find NODE : " << levelSpace(_level) << "@(Elem)@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + for(int32_t iii=0; iiiDisplay(_level+1); } }; - protected : - // SubNodes : - etk::Vector*> m_subNode; private : /** * @brief Set the number of repeate time on a the last node in the list ... - * - * @param[in] min Minimum of the multiplicity - * @param[in] max Maximum of the multiplicity - * + * @param[in] _min Minimum of the multiplicity + * @param[in] _max Maximum of the multiplicity * @return true if we find the node, false otherwise - * */ - bool SetMultiplicityOnLastNode(int32_t min, int32_t max) + bool SetMultiplicityOnLastNode(int32_t _min, int32_t _max) { if (0==m_subNode.Size()) { TK_ERROR("Set multiplicity on an inexistant element ...."); @@ -1410,7 +1052,7 @@ template class RegExpNodePTheseElem : public RegExpNode node not generated"); return false; } - myNode->SetMult(min, max); + myNode->SetMult(_min, _max); return true; } }; @@ -1418,12 +1060,13 @@ template class RegExpNodePTheseElem : public RegExpNode class RegExpNodePThese : public RegExpNode { +template class RegExpNodePThese : public RegExpNode +{ + protected : + etk::Vector*> m_subNode; //!< Subnode list public : /** - * @brief - * @param[in,out] - * @return + * @brief Constructor */ RegExpNodePThese(void) { @@ -1431,23 +1074,16 @@ template class RegExpNodePThese : public RegExpNode &data) + int32_t Generate(const etk::Vector& _data) { - RegExpNode::m_RegExpData = data; + RegExpNode::m_RegExpData = _data; //TK_DEBUG("Request Parse (...) data="; DisplayElem(RegExpNode::m_RegExpData);); //Find all the '|' in the string (and at the good level ...) int32_t pos = 0; @@ -1455,7 +1091,7 @@ template class RegExpNodePThese : public RegExpNode0) { // geerate output deta ... - etk::Vector tmpData; + etk::Vector tmpData; for (int32_t k=pos; k::m_RegExpData[k]); } @@ -1472,17 +1108,12 @@ template class RegExpNodePThese : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); if (0 == m_subNode.Size()) { return false; @@ -1493,15 +1124,15 @@ template class RegExpNodePThese : public RegExpNodeParse(data, currentPos+findLen, lenMax, tmpFindLen)) { - findLen += tmpFindLen; + if (true == m_subNode[i]->Parse(_data, _currentPos+_findLen, _lenMax, tmpFindLen)) { + _findLen += tmpFindLen; tmpFind = true; } } } if( j>=RegExpNode::m_multipleMin && j<=RegExpNode::m_multipleMax - && findLen>0 ) + && _findLen>0 ) { //TK_DEBUG("find " << findLen); return true; @@ -1512,112 +1143,67 @@ template class RegExpNodePThese : public RegExpNode::m_RegExpData);); } else { - TK_INFO("Find NODE : " << levelSpace(level) << "@(...)@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); + TK_INFO("Find NODE : " << levelSpace(_level) << "@(...)@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); for(int32_t i=0; iDisplay(level+1); + m_subNode[i]->Display(_level+1); } } }; - - protected : - // SubNodes : - etk::Vector*> m_subNode; - //int32_t m_posPthese; //!< position of the element is detected in the output element }; #undef __class__ #define __class__ "etk::RegExp" // Regular expression manager -template class RegExp { - // public API : +template class RegExp +{ + private: + etk::UString m_expressionRequested; //!< Regular expression parsed ... + elementPos_ts m_areaFind; //!< position around selection + RegExpNodePThese m_exprRootNode; //!< The tree where data is set + bool m_isOk; //!< Known if we can process with this regExp + bool m_notBeginWithChar; //!< The regular expression must not have previously a char [a-zA-Z0-9_] + bool m_notEndWithChar; //!< The regular expression must not have after the end a char [a-zA-Z0-9_] public: // create the regular expression /** - * @brief - * @param[in,out] - * @return + * @brief Constructor + * @param[in,out] _exp Regular expression to parse */ - RegExp(const char *exp) + RegExp(const etk::UString &_exp) : + m_expressionRequested(""), + m_isOk(false), + m_notBeginWithChar(false), + m_notEndWithChar(false) { - m_isOk = false; m_areaFind.start=0; m_areaFind.stop=0; - m_notBeginWithChar = false; - m_notEndWithChar = false; - SetRegExp(exp); + if (_exp.Size() != 0) { + SetRegExp(_exp); + } }; /** - * @brief - * @param[in,out] - * @return - */ - RegExp(etk::UString &exp) - { - m_isOk = false; - m_areaFind.start=0; - m_areaFind.stop=0; - m_notBeginWithChar = false; - m_notEndWithChar = false; - SetRegExp(exp); - }; - - /** - * @brief - * @param[in,out] - * @return - */ - RegExp(void) - { - m_isOk = false; - m_areaFind.start=0; - m_areaFind.stop=0; - m_notBeginWithChar = false; - m_notEndWithChar = false; - }; - - /** - * @brief - * @param[in,out] - * @return + * @brief Destructor */ ~RegExp(void) { - // TODO : remove all under nodes... m_isOk = false; }; - /** - * @brief - * @param[in,out] - * @return - */ - void SetRegExp(const char *exp) - { - TK_CHECK_INOUT(exp); - etk::UString expressionRequested = exp; - SetRegExp(expressionRequested); - }; - /** * @brief Set a new regular expression matching - * @param[in] expressionRequested the new expression to search + * @param[in] _regexp the new expression to search */ - void SetRegExp(const etk::UString &expressionRequested) + void SetRegExp(const etk::UString &_regexp) { - m_expressionRequested = expressionRequested; // TODO : Must be deprecated ... - etk::Vector tmpExp; + m_expressionRequested = _regexp; + etk::Vector tmpExp; //TK_DEBUG("Parse RegExp : " << expressionRequested.c_str() ); m_isOk = false; @@ -1626,10 +1212,6 @@ template class RegExp { m_notBeginWithChar = false; m_notEndWithChar = false; - // TODO : Check this ... ==> could create some errors ... - etk::Char tmppChar = expressionRequested.c_str(); - const char * exp = tmppChar; - int32_t regExpLen = strlen(exp); // change in the regular Opcode ==> replace \x with the corect element ... x if needed int32_t iii; int32_t countBraceIn = 0; @@ -1638,9 +1220,9 @@ template class RegExp { int32_t countPTheseOut = 0; int32_t countBracketIn = 0; int32_t countBracketOut = 0; - for (iii=0; iii=regExpLen) { + for (iii=0; iii<_regexp.Size(); iii++) { + if (_regexp[iii] == '\\') { + if(iii+1>=_regexp.Size()) { TK_ERROR("Dangerous parse of the element pos " << iii << " \\ with nothing after"); // TODO : Generate Exeption ... return; @@ -1649,7 +1231,7 @@ template class RegExp { // Find the element in the list... for (j=0; j class RegExp { } // check error : if (j==constConvertionTableSize) { - TK_ERROR("Dangerous parse of the \\ " << exp[iii+1] << " at element " << iii); + TK_ERROR("Dangerous parse of the \\ " << _regexp[iii+1] << " at element " << iii); // TODO : Generate Exeption ... return; } // less one char in the regular expression ... iii++; } else { - if ('(' == exp[iii]) { + if (_regexp[iii] == '(') { countPTheseIn++; - } else if (')' == exp[iii]) { + } else if (_regexp[iii] == ')') { countPTheseOut++; - } else if ('[' == exp[iii]) { + } else if (_regexp[iii] == '[') { countBracketIn++; - } else if (']' == exp[iii]) { + } else if (_regexp[iii] == ']') { countBracketOut++; - } else if ('{' == exp[iii]) { + } else if (_regexp[iii] == '{') { countBraceIn++; - } else if ('}' == exp[iii]) { + } else if (_regexp[iii] == '}') { countBraceOut++; } int32_t j; // find the element in the list... for (j=0; j class RegExp { } // not find : normal element if (j==constConvertionTableSize) { - tmpExp.PushBack( ((int16_t)exp[iii]) & 0x00FF); + // TODO : It might have an error ... +// tmpExp.PushBack(_regexp[iii]); } } } @@ -1716,7 +1299,7 @@ template class RegExp { //TK_DEBUG("Main element :"; DisplayElem(tmpExp, 0, tmpExp.Size()); ); if( tmpExp.Size()>0 - && REGEXP_OPCODE_NO_CHAR == tmpExp[0]) + && tmpExp[0] == REGEXP_OPCODE_NO_CHAR) { //TK_DEBUG("=> must not begin with char"); m_notBeginWithChar = true; @@ -1724,7 +1307,7 @@ template class RegExp { tmpExp.Erase(0); } if( tmpExp.Size()>0 - && REGEXP_OPCODE_NO_CHAR == tmpExp[tmpExp.Size()-1]) + && tmpExp[tmpExp.Size()-1] == REGEXP_OPCODE_NO_CHAR) { //TK_DEBUG("=> must not end with char"); m_notEndWithChar = true; @@ -1736,7 +1319,6 @@ template class RegExp { return; } // TODO : optimize node here ... - //Display(); // all OK ... play again @@ -1765,68 +1347,66 @@ template class RegExp { /** * @brief process the seach of the regular expression in a defined class type - * @param[in] SearchIn table of element to seach in - * @param[in] startPos start position to search - * @param[in] endPos end position to search - * @param[in] escapeChar special char that remove other char real type + * @param[in] _SearchIn table of element to seach in + * @param[in] _startPos start position to search + * @param[in] _endPos end position to search + * @param[in] _escapeChar special char that remove other char real type * @return true : find something, false otherwise */ - bool Process( const CLASS_TYPE& SearchIn, - int32_t startPos, - int32_t endPos, - char escapeChar=0) + bool Process( const CLASS_TYPE& _SearchIn, + int32_t _startPos, + int32_t _endPos, + char _escapeChar=0) { if (false == m_isOk) { return false; } - int32_t buflen = SearchIn.Size(); - if (endPos > buflen) { - endPos = buflen; + int32_t buflen = _SearchIn.Size(); + if (_endPos > buflen) { + _endPos = buflen; } - if (startPos > endPos) { + if (_startPos > _endPos) { return false; } int32_t i = 0; - for (i=startPos; i0) { - char tmpVal = SearchIn[i-1]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { + etk::UniChar tmpVal = _SearchIn[i-1]; + if( ( tmpVal >= 'a' + && tmpVal <= 'z' ) + || ( tmpVal >= 'A' + && tmpVal <= 'Z' ) + || ( tmpVal >= '0' + && tmpVal <= '9' ) + || ( tmpVal == '_' ) ) { // go on the next char ... continue; } } } - if (true == m_exprRootNode.Parse(SearchIn, i, maxlen, findLen)) { - if( 0!=escapeChar + if (true == m_exprRootNode.Parse(_SearchIn, i, maxlen, findLen)) { + if( _escapeChar != 0 && i>0) { - if (escapeChar == (char)SearchIn[i-1]) { + if ((char)_SearchIn[i-1] == _escapeChar) { //==> detected escape char ==> try find again ... continue; } } // Check end : if (true == m_notEndWithChar) { - if (i+findLen < SearchIn.Size() ) { - char tmpVal = SearchIn[i+findLen]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { + if (i+findLen < _SearchIn.Size() ) { + etk::UniChar tmpVal = _SearchIn[i+findLen]; + if( ( tmpVal >= 'a' + && tmpVal <= 'z' ) + || ( tmpVal >= 'A' + && tmpVal <= 'Z' ) + || ( tmpVal >= '0' + && tmpVal <= '9' ) + || ( tmpVal == '_' ) ) { // go on the next char ... continue; } @@ -1852,67 +1432,65 @@ template class RegExp { return false; }; - bool ProcessOneElement( const CLASS_TYPE& SearchIn, - int32_t startPos, - int32_t endPos, - char escapeChar=0) + bool ProcessOneElement( const CLASS_TYPE& _SearchIn, + int32_t _startPos, + int32_t _endPos, + char _escapeChar=0) { if (false == m_isOk) { return false; } - int32_t buflen = SearchIn.Size(); - if (endPos > buflen) { - endPos = buflen; + int32_t buflen = _SearchIn.Size(); + if (_endPos > buflen) { + _endPos = buflen; } - if (startPos > endPos) { + if (_startPos > _endPos) { return false; } int32_t findLen=0; - int32_t maxlen = endPos-startPos; + int32_t maxlen = _endPos-_startPos; if (true == m_notBeginWithChar) { - if (startPos>0) { - char tmpVal = SearchIn[startPos-1]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { + if (_startPos>0) { + etk::UniChar tmpVal = _SearchIn[_startPos-1]; + if( ( tmpVal >= 'a' + && tmpVal <= 'z' ) + || ( tmpVal >= 'A' + && tmpVal <= 'Z' ) + || ( tmpVal >= '0' + && tmpVal <= '9' ) + || ( tmpVal == '_' ) ) { // go on the next char ... return false; } } } - if (true == m_exprRootNode.Parse(SearchIn, startPos, maxlen, findLen)) { - if( 0!=escapeChar - && startPos>0) + if (true == m_exprRootNode.Parse(_SearchIn, _startPos, maxlen, findLen)) { + if( _escapeChar != 0 + && _startPos>0) { - if (escapeChar == (char)SearchIn[startPos-1]) { + if (_SearchIn[_startPos-1] == _escapeChar) { //==> detected escape char ==> try find again ... return false; } } // Check end : if (true == m_notEndWithChar) { - if (startPos+findLen < SearchIn.Size() ) { - char tmpVal = SearchIn[startPos+findLen]; - if( ( 'a' <= tmpVal - && 'z' >= tmpVal ) - || ( 'A' <= tmpVal - && 'Z' >= tmpVal ) - || ( '0' <= tmpVal - && '9' >= tmpVal ) - || ( '_' == tmpVal ) ) - { + if (_startPos+findLen < _SearchIn.Size() ) { + etk::UniChar tmpVal = _SearchIn[_startPos+findLen]; + if( ( tmpVal >= 'a' + && tmpVal <= 'z' ) + || ( tmpVal >= 'A' + && tmpVal <= 'Z' ) + || ( tmpVal >= '0' + && tmpVal <= '9' ) + || ( tmpVal == '_' ) ) { // go on the next char ... return false; } } } - m_areaFind.start = startPos; - m_areaFind.stop = startPos + findLen; + m_areaFind.start = _startPos; + m_areaFind.stop = _startPos + findLen; return true; } return false; @@ -1920,79 +1498,60 @@ template class RegExp { /** - * @brief - * @param[in,out] - * @return + * @brief Get the expression start position detected + * @return position of the start regExp */ - int32_t Start(void) - { - return m_areaFind.start; - }; + int32_t Start(void) { return m_areaFind.start; }; /** - * @brief - * @param[in,out] - * @return + * @brief Get the expression stop position detected + * @return position of the stop regExp */ - int32_t Stop(void) - { - return m_areaFind.stop; - }; + int32_t Stop(void) { return m_areaFind.stop; }; /** - * @brief - * @param[in,out] - * @return + * @brief Display the reg Exp */ void Display(void) { m_exprRootNode.Display(0); }; - // internal parameters - private: - etk::UString m_expressionRequested; // TODO : Remove ... - elementPos_ts m_areaFind; //!< position around selection - RegExpNodePThese m_exprRootNode; //!< The tree where data is set - bool m_isOk; //!< Known if we can process with this regExp - bool m_notBeginWithChar; //!< The regular expression must not have previously a char [a-zA-Z0-9_] - bool m_notEndWithChar; //!< The regular expression must not have after the end a char [a-zA-Z0-9_] - // internal access private: /** * @brief * @param[in,out] * @return */ - bool CheckGoodPosition(etk::Vector tmpExp, int32_t &pos) + bool CheckGoodPosition(const etk::Vector& _tmpExp, int32_t& _pos) { - int16_t curentCode = tmpExp[pos]; - int16_t endCode = REGEXP_OPCODE_PTHESE_OUT; - char *input = (char*)"(...)"; - if (REGEXP_OPCODE_BRACKET_IN == curentCode) { + etk::UniChar curentCode = _tmpExp[_pos]; + etk::UniChar endCode = REGEXP_OPCODE_PTHESE_OUT; + const char *input = "(...)"; + if (curentCode == REGEXP_OPCODE_BRACKET_IN) { endCode = REGEXP_OPCODE_BRACKET_OUT; - input = (char*)"[...]"; - } else if (REGEXP_OPCODE_BRACE_IN == curentCode){ + input = "[...]"; + } else if (curentCode == REGEXP_OPCODE_BRACE_IN){ endCode = REGEXP_OPCODE_BRACE_OUT; - input = (char*)"{x,x}"; + input = "{x,x}"; } - pos++; - if (pos >= (int32_t)tmpExp.Size()) { + _pos++; + if (_pos >= _tmpExp.Size()) { TK_ERROR("ended with: ( or { or [ ... not permited"); return false; } //TK_DEBUG(" ==> Find ELEMENT : ([{"); // case dependent : - if( REGEXP_OPCODE_BRACKET_IN == curentCode - || REGEXP_OPCODE_BRACE_IN == curentCode) { - while(pos< (int32_t)tmpExp.Size()) { + if( curentCode == REGEXP_OPCODE_BRACKET_IN + || curentCode == REGEXP_OPCODE_BRACE_IN) { + while(_pos<_tmpExp.Size()) { //TK_DEBUG("check : " << tmpExp[pos]); // if we find the end : - if (endCode == tmpExp[pos]) { + if (endCode == _tmpExp[_pos]) { return true; } else { // otherwise, we check the error in the element ... char *find = NULL; - switch (tmpExp[pos]) + switch (_tmpExp[_pos].Get()) { case REGEXP_OPCODE_PTHESE_IN: find = (char*)"("; break; case REGEXP_OPCODE_BRACKET_IN: find = (char*)"["; break; @@ -2024,30 +1583,29 @@ template class RegExp { return false; } } - pos++; + _pos++; } } else { - while(pos< (int32_t)tmpExp.Size()) { - if (endCode == tmpExp[pos]) { + while(_pos< _tmpExp.Size()) { + if (endCode == _tmpExp[_pos]) { // find the last element return true; - } else if ( REGEXP_OPCODE_BRACE_OUT == tmpExp[pos]) { + } else if ( _tmpExp[_pos] == REGEXP_OPCODE_BRACE_OUT) { TK_ERROR("find } inside a (...) without start {"); return false; - } else if ( REGEXP_OPCODE_BRACKET_OUT == tmpExp[pos]) { + } else if ( _tmpExp[_pos] == REGEXP_OPCODE_BRACKET_OUT) { TK_ERROR("find ] inside a (...) without start ["); return false; } else { - if( REGEXP_OPCODE_PTHESE_IN == tmpExp[pos] - || REGEXP_OPCODE_BRACKET_IN == tmpExp[pos] - || REGEXP_OPCODE_BRACE_IN == tmpExp[pos]) - { - if (false==CheckGoodPosition(tmpExp, pos) ) { + if( _tmpExp[_pos] == REGEXP_OPCODE_PTHESE_IN + || _tmpExp[_pos] == REGEXP_OPCODE_BRACKET_IN + || _tmpExp[_pos] == REGEXP_OPCODE_BRACE_IN ) { + if (false==CheckGoodPosition(_tmpExp, _pos) ) { return false; } } } - pos++; + _pos++; } } @@ -2069,29 +1627,29 @@ template class RegExp { * @param[in,out] * @return */ - bool CheckGoodPosition(etk::Vector tmpExp) + bool CheckGoodPosition(const etk::Vector& _tmpExp) { int32_t pos = 0; - while (pos < (int32_t)tmpExp.Size()) { + while (pos < _tmpExp.Size()) { //TK_DEBUG("check : " << tmpExp[pos]); - if( REGEXP_OPCODE_PTHESE_IN == tmpExp[pos] - || REGEXP_OPCODE_BRACKET_IN == tmpExp[pos] - || REGEXP_OPCODE_BRACE_IN == tmpExp[pos]) + if( _tmpExp[pos] == REGEXP_OPCODE_PTHESE_IN + || _tmpExp[pos] == REGEXP_OPCODE_BRACKET_IN + || _tmpExp[pos] == REGEXP_OPCODE_BRACE_IN) { // attention the i position change inside the finction... - if (false==CheckGoodPosition(tmpExp, pos) ) { + if (false==CheckGoodPosition(_tmpExp, pos) ) { TK_ERROR("Error at position : " << pos+1 ); return false; } else { //TK_DEBUG(" <== Find ELEMENT : ]})"); } - } else if(REGEXP_OPCODE_PTHESE_OUT == tmpExp[pos]) { + } else if(_tmpExp[pos] == REGEXP_OPCODE_PTHESE_OUT) { TK_ERROR("can find ')' with no start : ')'"); return false; - } else if(REGEXP_OPCODE_BRACKET_OUT == tmpExp[pos]) { + } else if(_tmpExp[pos] == REGEXP_OPCODE_BRACKET_OUT) { TK_ERROR("can find ']' with no start : '['"); return false; - } else if(REGEXP_OPCODE_BRACE_OUT == tmpExp[pos]) { + } else if(_tmpExp[pos] == REGEXP_OPCODE_BRACE_OUT) { TK_ERROR("can find '}' with no start : '{'"); return false; } diff --git a/etk/Stream.cpp b/etk/Stream.cpp index b990b7d..5728e76 100644 --- a/etk/Stream.cpp +++ b/etk/Stream.cpp @@ -8,18 +8,53 @@ #include #include +#include + +#if defined(__TARGET_OS__Linux) && DEBUG_LEVEL > 2 + #include + #include + #include + #define MAX_DEPTH (256) + void etk::DisplayBacktrace(void) + { + // retrieve call-stack + void * trace[MAX_DEPTH]; + int stack_depth = backtrace(trace, MAX_DEPTH); + + TK_ERROR("Back-trace : "); + for (int32_t i = 1; i < stack_depth; i++) { + Dl_info dlinfo; + if(!dladdr(trace[i], &dlinfo)) { + break; + } + const char * symname = dlinfo.dli_sname; + int status; + char * demangled = abi::__cxa_demangle(symname, NULL, 0, &status); + if(status == 0 && demangled) { + symname = demangled; + } + TK_WARNING(" " << dlinfo.dli_fname << ": "); + TK_ERROR(" " << symname); + if(NULL != demangled) { + free(demangled); + } + } + //assert(false); + } +#else + void etk::DisplayBacktrace(void) + { + + } +#endif etk::CCout etk::cout; etk::CEndl etk::endl; -etk::CHex etk::hex; etk::CStart etk::cstart; #if defined(__TARGET_OS__Android) # include -# define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "EWOL", __VA_ARGS__)) -# define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "EWOL", __VA_ARGS__)) -# define LOGE(...) ((void)__android_log_print(ANDROID_LOG_ERROR, "EWOL", __VA_ARGS__)) #endif etk::CCout& etk::operator <<(etk::CCout &os, const etk::logLevel_te obj) @@ -30,36 +65,54 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::logLevel_te obj) #if !defined(__TARGET_OS__Windows) os << ETK_BASH_COLOR_BOLD_RED; #endif + #if defined(__TARGET_OS__Android) + m_levelAndroid = ANDROID_LOG_FATAL; + #endif os << "[C]"; break; case LOG_LEVEL_ERROR: #if !defined(__TARGET_OS__Windows) os << ETK_BASH_COLOR_RED; #endif + #if defined(__TARGET_OS__Android) + m_levelAndroid = ANDROID_LOG_ERROR; + #endif os << "[E]"; break; case LOG_LEVEL_WARNING: #if !defined(__TARGET_OS__Windows) os << ETK_BASH_COLOR_MAGENTA; #endif + #if defined(__TARGET_OS__Android) + m_levelAndroid = ANDROID_LOG_WARN; + #endif os << "[W]"; break; case LOG_LEVEL_INFO: #if !defined(__TARGET_OS__Windows) os << ETK_BASH_COLOR_CYAN; #endif + #if defined(__TARGET_OS__Android) + m_levelAndroid = ANDROID_LOG_INFO; + #endif os << "[I]"; break; case LOG_LEVEL_DEBUG: #if !defined(__TARGET_OS__Windows) os << ETK_BASH_COLOR_YELLOW; #endif + #if defined(__TARGET_OS__Android) + m_levelAndroid = ANDROID_LOG_DEBUG; + #endif os << "[D]"; break; case LOG_LEVEL_VERBOSE: #if !defined(__TARGET_OS__Windows) os << ETK_BASH_COLOR_WHITE; #endif + #if defined(__TARGET_OS__Android) + m_levelAndroid = ANDROID_LOG_VERBOSE; + #endif os << "[V]"; break; default: @@ -73,7 +126,9 @@ etk::CCout& etk::operator <<(etk::CCout &os, const etk::logLevel_te obj) etk::CCout::CCout() { - hex=false; + #if defined(__TARGET_OS__Android) + m_levelAndroid = 0; + #endif memset(m_tmpChar, 0, (MAX_LOG_SIZE+1)*sizeof(char)); }; @@ -84,18 +139,10 @@ etk::CCout::~CCout() }; -etk::CCout& etk::CCout::operator << (CHex t) -{ - hex = true; - return *this; -} - - etk::CCout& etk::CCout::operator << (int t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%d", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } @@ -104,7 +151,6 @@ etk::CCout& etk::CCout::operator << (const etk::UniChar& t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t.Get()); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } @@ -112,35 +158,22 @@ etk::CCout& etk::CCout::operator << (unsigned int t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%u", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } etk::CCout& etk::CCout::operator << (long t) { - if (true == hex) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X", (unsigned int)t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - } else { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - } + snprintf(tmp, MAX_LOG_SIZE_TMP, "%ld", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); return *this; } etk::CCout& etk::CCout::operator << (long long t) { - if (true == hex) { - snprintf(tmp, MAX_LOG_SIZE_TMP, "0x%08X%08X", (unsigned int)(t>>32), (unsigned int)(t)); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; - } else { - snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t); - strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - } + snprintf(tmp, MAX_LOG_SIZE_TMP, "%lld", t); + strncat(m_tmpChar, tmp, MAX_LOG_SIZE); return *this; } @@ -149,7 +182,6 @@ etk::CCout& etk::CCout::operator << (double t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } @@ -158,7 +190,6 @@ etk::CCout& etk::CCout::operator << (float t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%f", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } @@ -167,7 +198,6 @@ etk::CCout& etk::CCout::operator << (char * t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } @@ -176,7 +206,6 @@ etk::CCout& etk::CCout::operator << (const char * t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%s", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } @@ -185,7 +214,6 @@ etk::CCout& etk::CCout::operator << (char t) { snprintf(tmp, MAX_LOG_SIZE_TMP, "%c", t); strncat(m_tmpChar, tmp, MAX_LOG_SIZE); - hex = false; return *this; } @@ -214,7 +242,7 @@ etk::CCout& etk::CCout::operator << (etk::CEndl t) strncat(m_tmpChar, "\n", MAX_LOG_SIZE); m_tmpChar[MAX_LOG_SIZE] = '\0'; #if defined(__TARGET_OS__Android) - LOGI("%s", m_tmpChar); + __android_log_print(m_levelAndroid, "EWOL", "%s", m_tmpChar); #else printf("%s", m_tmpChar); #endif diff --git a/etk/Stream.h b/etk/Stream.h index 8bf6b84..387acde 100644 --- a/etk/Stream.h +++ b/etk/Stream.h @@ -18,19 +18,19 @@ namespace etk #define MAX_LOG_SIZE_TMP (512) class CEndl{}; - class CHex{}; class CStart{}; class CCout{ private: - bool hex; char m_tmpChar[MAX_LOG_SIZE+1]; char tmp[MAX_LOG_SIZE_TMP]; + #if defined(__TARGET_OS__Android) + int8_t m_levelAndroid; //!< specific level for Android + #endif etk::Mutex m_mutex; public: CCout(void); ~CCout(void); - CCout& operator << (CHex t); CCout& operator << (const etk::UniChar& t);; CCout& operator << (int t); CCout& operator << (unsigned int t); @@ -47,7 +47,6 @@ namespace etk }; extern etk::CCout cout; extern etk::CEndl endl; - extern etk::CHex hex; extern etk::CStart cstart; typedef enum { @@ -64,6 +63,8 @@ namespace etk * @brief Debug operator To display the curent element in a Human redeable information */ etk::CCout& operator <<(etk::CCout &os, const etk::logLevel_te obj); + + void DisplayBacktrace(void); }; //regular colors diff --git a/etk/UString.cpp b/etk/UString.cpp index 84adac7..c700296 100644 --- a/etk/UString.cpp +++ b/etk/UString.cpp @@ -139,9 +139,14 @@ void etk::UString::Set(const int64_t& _inputData, etk::UString::printMode_te _mo Set((uint64_t)_inputData, _mode, _preset); return; } - int64_t tmpData = _inputData * (int64_t)(-1); + uint64_t tmpData; if (_inputData < 0) { - if (_mode != etk::UString::printModeString) { + tmpData = (uint64_t)((int64_t)_inputData * (int64_t)(-1)); + } else { + tmpData = _inputData; + } + if (_inputData < 0) { + if (_mode == etk::UString::printModeString) { m_data.PushBack('l'); m_data.PushBack('e'); m_data.PushBack('s'); @@ -177,84 +182,49 @@ void etk::UString::Set(const uint64_t& _inputData, etk::UString::printMode_te _m break; } } - bool startDisplay=false; - switch(_mode) { - case etk::UString::printModeBinary : - for(int32_t iii=63; iii>=0; iii--) { - if ((_inputData & (1<=0; iii-=3) { - uint64_t tmpVal = (_inputData & (((uint64_t)7)<> iii; - - if (tmpVal != 0) { - startDisplay = true; - } - if (true == startDisplay) { - tmpVal += '0'; - m_data.PushBack(tmpVal); - } - } - break; - case etk::UString::printModeDecimal : - { - uint64_t tmpVal = _inputData; - etk::UString tmpString; - while (tmpVal>0) { - int32_t val = tmpVal % 10; - tmpString.Add(0,(val+'0')); - tmpVal /= 10; - } - if (tmpString.Size() == 0) { - m_data.PushBack('0'); - } else { - *this += tmpString; - } - } - break; - case etk::UString::printModeHexadecimal : - for(int32_t iii=59; iii>=0; iii-=4) { - uint64_t tmpVal = (_inputData & (((uint64_t)0xF)<> iii; - if (tmpVal != 0) { - startDisplay = true; - } - if (true == startDisplay) { - if (tmpVal < 10) { - tmpVal += '0'; - } else { - tmpVal += 'A'-10; - } - m_data.PushBack(tmpVal); - } - } - break; - default: - case etk::UString::printModeString : - m_data.PushBack('T'); - m_data.PushBack('O'); - m_data.PushBack('D'); - m_data.PushBack('O'); - m_data.PushBack('.'); - m_data.PushBack('.'); - m_data.PushBack('.'); - break; + if (_mode == etk::UString::printModeString) { + m_data.PushBack('T'); + m_data.PushBack('O'); + m_data.PushBack('D'); + m_data.PushBack('O'); + m_data.PushBack('.'); + m_data.PushBack('.'); + m_data.PushBack('.'); + } else { + int32_t base=8; + //char ploppp[256]=""; + switch(_mode) { + case etk::UString::printModeBinary : + base=2; + break; + case etk::UString::printModeOctal : + //sprintf(ploppp, "%llo", _inputData); + base=8; + break; + default: + case etk::UString::printModeDecimal : + //sprintf(ploppp, "%llu", _inputData); + base=10; + break; + case etk::UString::printModeHexadecimal : + //sprintf(ploppp, "%llx", _inputData); + base=16; + break; + } + uint64_t tmpVal = _inputData; + etk::UString tmpString; + while (tmpVal>0) { + uint64_t quotient = tmpVal / base; + uint64_t rest = tmpVal - quotient*base; + tmpString.Add(0,(rest+'0')); + tmpVal = quotient; + } + if (tmpString.Size() == 0) { + m_data.PushBack('0'); + } else { + *this += tmpString; + } + //TK_ERROR (" " << ploppp); } m_data.PushBack('\0'); } @@ -708,7 +678,7 @@ bool etk::UString::EndWith(const etk::UString& _data, bool _caseSensitive) const for( int32_t iii=Size()-1, jjj=_data.Size()-1; iii>=0 && jjj>=0; iii--, jjj--) { - if (false==m_data[iii].CompareNoCase(_data[iii])) { + if (false==m_data[iii].CompareNoCase(_data[jjj])) { return false; } } diff --git a/etk/UniChar.h b/etk/UniChar.h index c54dab1..3851627 100644 --- a/etk/UniChar.h +++ b/etk/UniChar.h @@ -11,6 +11,35 @@ namespace etk { + + //in the unicode section we have : [E000..F8FF] private area ==> we will store element in this area: + // internal define to permit to have all needed system + typedef enum { + REGEXP_OPCODE_PTHESE_IN=0xE000, /* ( */ + REGEXP_OPCODE_PTHESE_OUT,/* ) */ + REGEXP_OPCODE_BRACKET_IN,/* [ */ + REGEXP_OPCODE_BRACKET_OUT,/* ] */ + REGEXP_OPCODE_BRACE_IN,/* { */ + REGEXP_OPCODE_BRACE_OUT,/* } */ + REGEXP_OPCODE_TO,/* - */ + REGEXP_OPCODE_STAR,/* * */ + REGEXP_OPCODE_DOT,/* . */ + REGEXP_OPCODE_QUESTION,/* ? */ + REGEXP_OPCODE_PLUS,/* + */ + REGEXP_OPCODE_PIPE,/* | */ + REGEXP_OPCODE_START_OF_LINE,/* ^ this is also NOT, but not manage */ + REGEXP_OPCODE_END_OF_LINE,/* $ */ + REGEXP_OPCODE_DIGIT,/* \d */ + REGEXP_OPCODE_DIGIT_NOT,/* \D */ + REGEXP_OPCODE_LETTER,/* \l */ + REGEXP_OPCODE_LETTER_NOT,/* \L */ + REGEXP_OPCODE_SPACE,/* \s */ + REGEXP_OPCODE_SPACE_NOT,/* \S */ + REGEXP_OPCODE_WORD,/* \w */ + REGEXP_OPCODE_WORD_NOT,/* \W */ + REGEXP_OPCODE_NO_CHAR,/* \@ */ + } regExpPrivateSection_te; + class UniChar { private: @@ -24,6 +53,9 @@ namespace etk UniChar(const char _obj) : m_value((uint32_t)_obj) { }; + UniChar(const regExpPrivateSection_te _obj) : + m_value((uint32_t)_obj) + { }; ~UniChar(void) {} /***************************************************** diff --git a/etk/math/Vector2D.cpp b/etk/math/Vector2D.cpp index 239dbe5..f58bab0 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_VERBOSE("Parse : \"" << _str << "\" ==> " << *this); + TK_DEBUG("Parse : \"" << _str << "\" ==> " << *this); } template<> Vector2D::operator etk::UString(void) const diff --git a/lutin_etk.py b/lutin_etk.py index 8784dd6..4655917 100644 --- a/lutin_etk.py +++ b/lutin_etk.py @@ -56,6 +56,8 @@ def Create(target): else: myModule.AddExportFlag_CC("-DDEBUG_LEVEL=3") myModule.AddExportFlag_CC("-DDEBUG=1") + # Bor backtrace display : + myModule.AddExportflag_LD("-ldl -rdynamic") if target.name=="Windows": None