diff --git a/etk/RegExp.cpp b/etk/RegExp.cpp index 13392b6..ea2e44e 100644 --- a/etk/RegExp.cpp +++ b/etk/RegExp.cpp @@ -62,12 +62,12 @@ const etk::convertionTable_ts etk::constConvertionTable[] = { { true , '0' , '\0', REGEXP_OPCODE_ERROR}, { true , '@' , 0 , REGEXP_OPCODE_NO_CHAR}, }; -const int32_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ; +const esize_t etk::constConvertionTableSize = sizeof(etk::constConvertionTable) / sizeof(etk::convertionTable_ts) ; -void etk::DisplayElem(const etk::Vector& _data, int32_t _start, int32_t _stop) +void etk::DisplayElem(const etk::Vector& _data, esize_t _start, esize_t _stop) { etk::cout<< ETK_BASH_COLOR_NORMAL; - for (int32_t iii=_start; iii<_data.Size() && iii<_stop ; iii++) { + for (esize_t iii=_start; iii<_data.Size() && iii<_stop ; iii++) { switch(_data[iii].Get()) { case REGEXP_OPCODE_PTHESE_IN: etk::cout<& _data, int32_t _start, in } } } -char * etk::levelSpace(int32_t _level) +char * etk::levelSpace(uint32_t _level) { switch(_level) { @@ -125,12 +125,12 @@ char * etk::levelSpace(int32_t _level) } -int32_t etk::GetLenOfPTheseElem(const etk::Vector& _data, int32_t _startPos) +esize_t etk::GetLenOfPTheseElem(const etk::Vector& _data, esize_t _startPos) { if (_startPos>=_data.Size()){ return 0; } - int32_t pos = _startPos; + esize_t pos = _startPos; int32_t nbOpen = 0; // special case of the (...) or | ==> we search '|' or ')' if( _data[pos] == REGEXP_OPCODE_PTHESE_OUT @@ -138,7 +138,7 @@ int32_t etk::GetLenOfPTheseElem(const etk::Vector& _data, int32_t return 0; } // find size ... - while (pos < (int32_t)_data.Size() ) { + while (pos < _data.Size() ) { if(_data[pos] == REGEXP_OPCODE_PTHESE_IN) { // find a sub section : nbOpen++; @@ -157,130 +157,129 @@ int32_t etk::GetLenOfPTheseElem(const etk::Vector& _data, int32_t int32_t sizeInside = pos - _startPos; if (0 >= sizeInside) { TK_ERROR("Error in the (...) no data at "<< pos-1); - return -1; - } else { - return sizeInside; + return 0; } + return sizeInside; } pos++; } return pos - _startPos; } -int32_t etk::GetLenOfPThese(const etk::Vector& _data, int32_t _startPos) +esize_t etk::GetLenOfPThese(const etk::Vector& _data, esize_t _startPos) { - int32_t pos = _startPos; + esize_t pos = _startPos; int32_t nbOpen = 0; // special case of the (...) or | ==> we search '|' or ')' if(_data[pos]==REGEXP_OPCODE_PTHESE_OUT) { return 0; - } else if(_data[pos]==REGEXP_OPCODE_PTHESE_IN) { - pos++; - // find size ... - while (pos < _data.Size() ) { - if(_data[pos]==REGEXP_OPCODE_PTHESE_IN) { - // find a sub section : - nbOpen++; - } else if(0 < nbOpen) { - if (_data[pos]==REGEXP_OPCODE_PTHESE_OUT) { - nbOpen--; - if (0 > nbOpen) { - TK_ERROR("Error in the (...) find element at "<< pos); - return -1; - } - } - } else if(_data[pos]==REGEXP_OPCODE_PTHESE_OUT) { - // Find the end of the (...) - // just return the size inside - int32_t sizeInside = pos - _startPos-1; - if (0 >= sizeInside) { - TK_ERROR("Error in the (...) no data at "<< pos-1); - return -1; - } else { - return sizeInside; + } + if(_data[pos]!=REGEXP_OPCODE_PTHESE_IN) { + TK_ERROR(" find error in PThese"); + return 0; + } + pos++; + // find size ... + while (pos < _data.Size() ) { + if(_data[pos]==REGEXP_OPCODE_PTHESE_IN) { + // find a sub section : + nbOpen++; + } else if(0 < nbOpen) { + if (_data[pos]==REGEXP_OPCODE_PTHESE_OUT) { + nbOpen--; + if (0 > nbOpen) { + TK_ERROR("Error in the (...) find element at "<< pos); + return 0; } } - 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; + if (0 >= sizeInside) { + TK_ERROR("Error in the (...) no data at "<< pos-1); + return 0; + } + return sizeInside; } - } else { - return -1; + pos++; } return 0; } -int32_t etk::GetLenOfBracket(const etk::Vector& _data, int32_t _startPos) +esize_t etk::GetLenOfBracket(const etk::Vector& _data, esize_t _startPos) { - int32_t pos = _startPos; + esize_t pos = _startPos; // special case of the (...) or | ==> we search '|' or ')' if(_data[pos]==REGEXP_OPCODE_BRACKET_OUT) { return 0; - } else if(_data[pos] == REGEXP_OPCODE_BRACKET_IN) { - pos++; - // find size ... - 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 ; - if (0 >= sizeInside) { - TK_ERROR("Error in the [...] no data at "<< pos-1); - return sizeInside; - } else { - return sizeInside; - } - } 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; + } + if(_data[pos] != REGEXP_OPCODE_BRACKET_IN) { + TK_ERROR("find no {..."); + return 0; + } + pos++; + // find size ... + 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 ; + if (0 >= sizeInside) { + TK_ERROR("Error in the [...] no data at "<< pos-1); + return 0; } - pos++; + return sizeInside; + } 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 0; } - } else { - return -1; + pos++; } return 0; } -int32_t etk::GetLenOfBrace(const etk::Vector& _data, int32_t _startPos) +esize_t etk::GetLenOfBrace(const etk::Vector& _data, esize_t _startPos) { int32_t pos = _startPos; // special case of the (...) or | ==> we search '|' or ')' if(_data[pos]==REGEXP_OPCODE_BRACE_OUT) { return 0; - } else if(_data[pos]==REGEXP_OPCODE_BRACE_IN) { - pos++; - // find size ... - 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 ; - if (0 >= sizeInside) { - TK_ERROR("Error in the {...} no data at "<< pos-1); - return sizeInside; - } else { - return sizeInside; - } - } 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; + } + if(_data[pos]!=REGEXP_OPCODE_BRACE_IN) { + TK_ERROR(" did not find brace IN { "); + return 0; + } + pos++; + // find size ... + 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 ; + if (0 >= sizeInside) { + TK_ERROR("Error in the {...} no data at "<< pos-1); + return 0; } - pos++; + return sizeInside; + } else if( _data[pos] != ',' + && ( _data[pos] < '0' + || _data[pos] > '9') ) { + TK_ERROR("Error in the {...} not permited element at "<< pos << " '" << _data[pos].Get() << "'"); + return 0; } - } else { - return -1; + pos++; } return 0; } -int32_t etk::GetLenOfNormal(const etk::Vector& _data, int32_t _startPos) +esize_t etk::GetLenOfNormal(const etk::Vector& _data, esize_t _startPos) { - int32_t pos = _startPos; + esize_t pos = _startPos; // find size ... while (pos < _data.Size() ) { @@ -323,14 +322,17 @@ int32_t etk::GetLenOfNormal(const etk::Vector& _data, int32_t _sta } pos++; } + if ((int64_t)pos - (int64_t)_startPos < 0) { + return 0; + } return pos - _startPos ; } -bool etk::ParseBrace(const etk::Vector& _data, int32_t& _min, int32_t& _max) +bool etk::ParseBrace(const etk::Vector& _data, uint32_t& _min, uint32_t& _max) { //TK_INFO("parse {...} in "; DisplayElem(data); ); - int32_t k=0; + esize_t k=0; int32_t firstElement = 0; int32_t SecondElement = 0; diff --git a/etk/RegExp.h b/etk/RegExp.h index c7f1f74..283b1f5 100644 --- a/etk/RegExp.h +++ b/etk/RegExp.h @@ -55,16 +55,16 @@ typedef struct { }convertionTable_ts; extern const convertionTable_ts constConvertionTable[]; -extern const int32_t constConvertionTableSize; +extern const esize_t constConvertionTableSize; -void DisplayElem(const etk::Vector& _data, int32_t _start=0, int32_t _stop=0x7FFFFFFF); -char * levelSpace(int32_t _level); -size_t GetLenOfPTheseElem(const etk::Vector& _data, int32_t _startPos); -size_t GetLenOfPThese(const etk::Vector& _data, int32_t _startPos); -size_t GetLenOfBracket(const etk::Vector& _data, int32_t _startPos); -size_t GetLenOfBrace(const etk::Vector& _data, int32_t _startPos); -size_t GetLenOfNormal(const etk::Vector& _data, int32_t _startPos); -bool ParseBrace(const etk::Vector& _data, int32_t& _min, int32_t& _max); +void DisplayElem(const etk::Vector& _data, esize_t _start=0, esize_t _stop=0x7FFFFFFF); +char * levelSpace(uint32_t _level); +esize_t GetLenOfPTheseElem(const etk::Vector& _data, esize_t _startPos); +esize_t GetLenOfPThese(const etk::Vector& _data, esize_t _startPos); +esize_t GetLenOfBracket(const etk::Vector& _data, esize_t _startPos); +esize_t GetLenOfBrace(const etk::Vector& _data, esize_t _startPos); +esize_t GetLenOfNormal(const etk::Vector& _data, esize_t _startPos); +bool ParseBrace(const etk::Vector& _data, uint32_t& _min, uint32_t& _max); #undef __class__ @@ -76,8 +76,8 @@ bool ParseBrace(const etk::Vector& _data, int32_t& _min, int32_t& template class RegExpNode { protected : - int32_t m_multipleMin; //!< minimum repetition (included) - int32_t m_multipleMax; //!< maximum repetition (included) + uint32_t m_multipleMin; //!< minimum repetition (included) + uint32_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 : @@ -113,12 +113,12 @@ template class RegExpNode * @return true : Find something * @return false : Find nothing */ - virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen)=0; + virtual bool Parse(const CLASS_TYPE& _data, esize_t _currentPos, esize_t _lenMax, esize_t& _findLen)=0; /** * @brief Display the current node properties * @param[in] level of the node */ - virtual void Display(int32_t _level) + virtual void Display(uint32_t _level) { TK_INFO("Find NODE : " << levelSpace(_level) << "@???@ {" << GetMultMin() << "," << GetMultMax() << "} subdata="; DisplayElem(m_RegExpData);); }; @@ -127,7 +127,7 @@ template class RegExpNode * @param[in] _min The minimum appear time. * @param[in] _max The maximum appear time. */ - void SetMult(int32_t _min, int32_t _max) + void SetMult(uint32_t _min, uint32_t _max) { m_multipleMin = etk_max(_min, 0); m_multipleMax = etk_max(_max, 1); @@ -137,12 +137,12 @@ template class RegExpNode * @brief Get the minimum multiplicity. * @return The minimum appear availlable. */ - int32_t GetMultMin(void) const { return m_multipleMin; }; + uint32_t GetMultMin(void) const { return m_multipleMin; }; /** * @brief Get the maximum multiplicity. * @return The maximum appear availlable. */ - int32_t GetMultMax(void) const { return m_multipleMax; }; + uint32_t GetMultMax(void) const { return m_multipleMax; }; }; #undef __class__ @@ -176,7 +176,7 @@ template class RegExpNodeValue : public RegExpNode return _data.Size(); }; - virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) + virtual bool Parse(const CLASS_TYPE& _data, esize_t _currentPos, esize_t _lenMax, esize_t& _findLen) { _findLen = 0; TK_REG_EXP_DBG_MODE("Parse node : Value{" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); @@ -186,18 +186,18 @@ template class RegExpNodeValue : public RegExpNode } TK_REG_EXP_DBG_MODE("check element value : '" << m_data[0] << "'"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind == true; j++) { - int32_t ofset = 0; - int32_t k; - for (k=0; _findLen+k<_lenMax && k < m_data.Size(); k++) { - if (m_data[k] != _data[_currentPos+_findLen+k]) { + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind == true; jjj++) { + uint32_t ofset = 0; + esize_t kkk; + for (kkk=0; _findLen+kkk<_lenMax && kkk < m_data.Size(); kkk++) { + if (m_data[kkk] != _data[_currentPos+_findLen+kkk]) { tmpFind=false; break; } ofset++; } - if (k != (int32_t)m_data.Size()) { + if (kkk != m_data.Size()) { // parsing not ended ... tmpFind=false; } @@ -206,8 +206,8 @@ template class RegExpNodeValue : public RegExpNode _findLen += ofset; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); @@ -219,7 +219,7 @@ template class RegExpNodeValue : public RegExpNode return false; }; - void Display(int32_t _level) + void Display(uint32_t _level) { TK_INFO("Find NODE : " << levelSpace(_level) << "@Value@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); etk::cout<< " data: "; DisplayElem(m_data); ); }; @@ -253,20 +253,20 @@ template class RegExpNodeBracket : public RegExpNode::m_RegExpData.Size(); k++) { - if (RegExpNode::m_RegExpData[k] == REGEXP_OPCODE_TO && multipleElement == true) { + for (int32_t kkk=0; kkk::m_RegExpData.Size(); kkk++) { + if (RegExpNode::m_RegExpData[kkk] == REGEXP_OPCODE_TO && multipleElement == true) { TK_ERROR("Can not have 2 consecutive - in [...]"); return 0; } else if (multipleElement == true) { - etk::UniChar j='\0'; - for (j=lastElement+1; j <= RegExpNode::m_RegExpData[k]; j+=1) { - m_data.PushBack(j); + etk::UniChar jjj='\0'; + for (jjj=lastElement+1; jjj <= RegExpNode::m_RegExpData[kkk]; jjj+=1) { + m_data.PushBack(jjj); } multipleElement = false; - } else if(RegExpNode::m_RegExpData[k] == REGEXP_OPCODE_TO) { + } else if(RegExpNode::m_RegExpData[kkk] == REGEXP_OPCODE_TO) { multipleElement = true; } else { - lastElement = RegExpNode::m_RegExpData[k]; + lastElement = RegExpNode::m_RegExpData[kkk]; m_data.PushBack(lastElement); } } @@ -278,7 +278,7 @@ template class RegExpNodeBracket : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); @@ -288,20 +288,19 @@ template class RegExpNodeBracket : public RegExpNode::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - int32_t i; + uint32_t jjj=0; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { tmpFind=false; - for (i=0; i=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); @@ -313,7 +312,7 @@ template class RegExpNodeBracket : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData); etk::cout<< " data: "; DisplayElem(m_data); ); }; @@ -334,14 +333,14 @@ template class RegExpNodeDigit : public RegExpNode */ ~RegExpNodeDigit(void) { }; - virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) + virtual bool Parse(const CLASS_TYPE& _data, esize_t _currentPos, esize_t _lenMax, esize_t& _findLen) { _findLen = 0; TK_REG_EXP_DBG_MODE("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++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; TK_REG_EXP_DBG_MODE("compare : " << tmpVal); if( tmpVal >= '0' && tmpVal <= '9') @@ -352,8 +351,8 @@ template class RegExpNodeDigit : public RegExpNode tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); @@ -365,7 +364,7 @@ template class RegExpNodeDigit : public RegExpNode return false; }; - void Display(int32_t _level) + void Display(uint32_t _level) { TK_INFO("Find NODE : " << levelSpace(_level) << "@Digit@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -386,14 +385,14 @@ template class RegExpNodeDigitNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( tmpVal < '0' || tmpVal > '9') { _findLen += 1; @@ -401,8 +400,8 @@ template class RegExpNodeDigitNot : public RegExpNode=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -413,7 +412,7 @@ template class RegExpNodeDigitNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -435,14 +434,14 @@ template class RegExpNodeLetter : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( ( tmpVal >= 'a' && tmpVal <= 'z') || ( tmpVal >= 'A' @@ -452,8 +451,8 @@ template class RegExpNodeLetter : public RegExpNode=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -464,7 +463,7 @@ template class RegExpNodeLetter : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -486,14 +485,14 @@ template class RegExpNodeLetterNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( ( tmpVal < 'a' && tmpVal > 'Z') || tmpVal < 'A' @@ -503,8 +502,8 @@ template class RegExpNodeLetterNot : public RegExpNode=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -515,7 +514,7 @@ template class RegExpNodeLetterNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -537,14 +536,14 @@ template class RegExpNodeWhiteSpace : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( tmpVal == ' ' || tmpVal == '\t' || tmpVal == '\n' @@ -556,8 +555,8 @@ template class RegExpNodeWhiteSpace : public RegExpNode=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -568,7 +567,7 @@ template class RegExpNodeWhiteSpace : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -590,14 +589,14 @@ template class RegExpNodeWhiteSpaceNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( tmpVal != ' ' && tmpVal != '\t' && tmpVal != '\n' @@ -609,8 +608,8 @@ template class RegExpNodeWhiteSpaceNot : public RegExpNode=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -621,7 +620,7 @@ template class RegExpNodeWhiteSpaceNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -642,14 +641,14 @@ template class RegExpNodeWordChar : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( ( tmpVal >= 'a' && tmpVal <= 'z' ) || ( tmpVal >= 'A' @@ -661,8 +660,8 @@ template class RegExpNodeWordChar : public RegExpNode=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -673,7 +672,7 @@ template class RegExpNodeWordChar : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -694,14 +693,14 @@ template class RegExpNodeWordCharNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); bool tmpFind = true; - int32_t j; - for (j=0; j::m_multipleMax && tmpFind ==true && j < _lenMax; j++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( ( tmpVal < 'A' && tmpVal > '9' ) || ( tmpVal < 'a' @@ -713,8 +712,8 @@ template class RegExpNodeWordCharNot : public RegExpNode=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -725,7 +724,7 @@ template class RegExpNodeWordCharNot : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -747,15 +746,15 @@ template class RegExpNodeDot : public RegExpNode */ ~RegExpNodeDot(void) { }; - virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) + virtual bool Parse(const CLASS_TYPE& _data, esize_t _currentPos, esize_t _lenMax, esize_t& _findLen) { _findLen = 0; TK_REG_EXP_DBG_MODE("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++) { - etk::UniChar tmpVal = _data[_currentPos+j]; + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind ==true && jjj < _lenMax; jjj++) { + etk::UniChar tmpVal = _data[_currentPos+jjj]; if( ( tmpVal > 0x08 && tmpVal < 0x0A ) || ( tmpVal > 0x1F @@ -767,8 +766,8 @@ template class RegExpNodeDot : public RegExpNode tmpFind=false; } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); return true; @@ -779,7 +778,7 @@ template class RegExpNodeDot : public RegExpNode return false; }; - void Display(int32_t _level) + void Display(uint32_t _level) { TK_INFO("Find NODE : " << levelSpace(_level) << "@.@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -802,7 +801,7 @@ template class RegExpNodeSOL : public RegExpNode */ ~RegExpNodeSOL(void) { }; - virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) + virtual bool Parse(const CLASS_TYPE& _data, esize_t _currentPos, esize_t _lenMax, esize_t& _findLen) { _findLen = 0; // TODO : ... @@ -810,7 +809,7 @@ template class RegExpNodeSOL : public RegExpNode return false; }; - void Display(int32_t _level) + void Display(uint32_t _level) { TK_INFO("Find NODE : " << levelSpace(_level) << "@SOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -832,7 +831,7 @@ template class RegExpNodeEOL : public RegExpNode */ ~RegExpNodeEOL(void) { }; - virtual bool Parse(const CLASS_TYPE& _data, int32_t _currentPos, int32_t _lenMax, int32_t& _findLen) + virtual bool Parse(const CLASS_TYPE& _data, esize_t _currentPos, esize_t _lenMax, esize_t& _findLen) { _findLen = 0; // TODO : ... @@ -840,7 +839,7 @@ template class RegExpNodeEOL : public RegExpNode return false; }; - void Display(int32_t _level) + void Display(uint32_t _level) { TK_INFO("Find NODE : " << levelSpace(_level) << "@EOL@ {" << RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "} subdata="; DisplayElem(RegExpNode::m_RegExpData);); }; @@ -876,8 +875,8 @@ template class RegExpNodePTheseElem : public RegExpNode::m_RegExpData = _data; TK_REG_EXP_DBG_MODE("Request Parse (elem) data="; DisplayElem(RegExpNode::m_RegExpData);); - int32_t pos = 0; - int32_t elementSize = 0; + esize_t pos = 0; + esize_t elementSize = 0; etk::Vector tmpData; while (pos < RegExpNode::m_RegExpData.Size()) { tmpData.Clear(); @@ -885,8 +884,8 @@ template class RegExpNodePTheseElem : public RegExpNode::m_RegExpData, pos); - for (int32_t k=pos+1; k::m_RegExpData[k]); + for (esize_t kkk=pos+1; kkk::m_RegExpData[kkk]); } RegExpNodePThese * myElem = new RegExpNodePThese(); (void)myElem->Generate(tmpData); @@ -902,8 +901,8 @@ template class RegExpNodePTheseElem : public RegExpNode::m_RegExpData, pos); - for (int32_t k=pos+1; k::m_RegExpData[k]); + for (esize_t kkk=pos+1; kkk::m_RegExpData[kkk]); } RegExpNodeBracket * myElem = new RegExpNodeBracket(); (void)myElem->Generate(tmpData); @@ -919,11 +918,11 @@ template class RegExpNodePTheseElem : public RegExpNode::m_RegExpData, pos); - for (int32_t k=pos+1; k::m_RegExpData[k]); + for (esize_t kkk=pos+1; kkk::m_RegExpData[kkk]); } - int32_t min = 0; - int32_t max = 0; + uint32_t min = 0; + uint32_t max = 0; if (false == ParseBrace(tmpData, min, max)) { return false; } @@ -986,8 +985,8 @@ template class RegExpNodePTheseElem : public RegExpNode::m_RegExpData, pos); - for (int32_t k=pos; k::m_RegExpData[k]); + for (esize_t kkk=pos; kkk::m_RegExpData[kkk]); } RegExpNodeValue * myElem = new RegExpNodeValue(); (void)myElem->Generate(tmpData); @@ -1003,7 +1002,7 @@ template class RegExpNodePTheseElem : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); @@ -1012,24 +1011,28 @@ template class RegExpNodePTheseElem : public RegExpNodeParse(_data, tmpCurrentPos, _lenMax, tmpFindLen)) { + esize_t tmpCurrentPos = _currentPos; + for (esize_t iii=0; iiiParse(_data, tmpCurrentPos, _lenMax, tmpFindLen)) { _findLen = 0; return false; } else { tmpCurrentPos += tmpFindLen; } } - _findLen = tmpCurrentPos - _currentPos; + if (tmpCurrentPos<_currentPos) { + _findLen = 0; + } else { + _findLen = tmpCurrentPos - _currentPos; + } return true; }; - void Display(int32_t _level) + void Display(uint32_t _level) { 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); } }; @@ -1040,7 +1043,7 @@ template class RegExpNodePTheseElem : public RegExpNode class RegExpNodePThese : public RegExpNode0) { // geerate output deta ... etk::Vector tmpData; - for (int32_t k=pos; k::m_RegExpData[k]); + for (esize_t kkk=pos; kkk::m_RegExpData[kkk]); } RegExpNodePTheseElem * myElem = new RegExpNodePTheseElem(); (void)myElem->Generate(tmpData); @@ -1110,7 +1113,7 @@ template class RegExpNodePThese : public RegExpNode::m_multipleMin << "," << RegExpNode::m_multipleMax << "}"); @@ -1118,19 +1121,19 @@ template class RegExpNodePThese : public RegExpNode::m_multipleMax && tmpFind == true ; j++) { + uint32_t jjj; + for (jjj=0; jjj::m_multipleMax && tmpFind == true ; jjj++) { tmpFind = false; - for (int32_t i=0; iParse(_data, _currentPos+_findLen, _lenMax, tmpFindLen)) { + for (esize_t iii=0; iiiParse(_data, _currentPos+_findLen, _lenMax, tmpFindLen)) { _findLen += tmpFindLen; tmpFind = true; } } } - if( j>=RegExpNode::m_multipleMin - && j<=RegExpNode::m_multipleMax + if( jjj>=RegExpNode::m_multipleMin + && jjj<=RegExpNode::m_multipleMax && _findLen>0 ) { TK_REG_EXP_DBG_MODE("find " << _findLen); @@ -1142,7 +1145,7 @@ template class RegExpNodePThese : public RegExpNode::m_RegExpData);); @@ -1213,36 +1216,35 @@ template class RegExp m_notEndWithChar = false; // change in the regular Opcode ==> replace \x with the corect element ... x if needed - int32_t iii; int32_t countBraceIn = 0; int32_t countBraceOut = 0; int32_t countPTheseIn = 0; int32_t countPTheseOut = 0; int32_t countBracketIn = 0; int32_t countBracketOut = 0; - for (iii=0; iii<_regexp.Size(); iii++) { + for (esize_t 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; } - int32_t j; + esize_t jjj; // Find the element in the list... - for (j=0; j class RegExp } else if (_regexp[iii] == '}') { countBraceOut++; } - int32_t j; + esize_t jjj; // find the element in the list... - for (j=0; j class RegExp * @return true : find something, false otherwise */ bool Process( const CLASS_TYPE& _SearchIn, - int32_t _startPos, - int32_t _endPos, + esize_t _startPos, + esize_t _endPos, etk::UniChar _escapeChar=0) { if (false == m_isOk) { return false; } - int32_t buflen = _SearchIn.Size(); + esize_t buflen = _SearchIn.Size(); if (_endPos > buflen) { _endPos = buflen; } if (_startPos > _endPos) { return false; } - int32_t i = 0; - for (i=_startPos; i<_endPos; i++) { - int32_t findLen=0; - int32_t maxlen = _endPos-i; + for (esize_t iii=_startPos; iii<_endPos; iii++) { + esize_t findLen=0; + esize_t maxlen = _endPos-iii; if (true == m_notBeginWithChar) { - if (i>0) { - etk::UniChar tmpVal = _SearchIn[i-1]; + if (iii>0) { + etk::UniChar tmpVal = _SearchIn[iii-1]; if( ( tmpVal >= 'a' && tmpVal <= 'z' ) || ( tmpVal >= 'A' @@ -1395,19 +1396,19 @@ template class RegExp } } } - if (true == m_exprRootNode.Parse(_SearchIn, i, maxlen, findLen)) { + if (true == m_exprRootNode.Parse(_SearchIn, iii, maxlen, findLen)) { if( _escapeChar != 0 - && i>0) + && iii>0) { - if (_escapeChar == _SearchIn[i-1]) { + if (_escapeChar == _SearchIn[iii-1]) { //==> detected escape char ==> try find again ... continue; } } // Check end : if (true == m_notEndWithChar) { - if (i+findLen < _SearchIn.Size() ) { - etk::UniChar tmpVal = _SearchIn[i+findLen]; + if (iii+findLen < _SearchIn.Size() ) { + etk::UniChar tmpVal = _SearchIn[iii+findLen]; if( ( tmpVal >= 'a' && tmpVal <= 'z' ) || ( tmpVal >= 'A' @@ -1420,10 +1421,10 @@ template class RegExp } } } - m_areaFind.start = i; - m_areaFind.stop = i + findLen; + m_areaFind.start = iii; + m_areaFind.stop = iii + findLen; /* - if (i == 812) { + if (iii == 812) { std::cout << std::endl; for(int32_t k=startPos; k class RegExp }; bool ProcessOneElement( const CLASS_TYPE& _SearchIn, - int32_t _startPos, - int32_t _endPos, + esize_t _startPos, + esize_t _endPos, etk::UniChar _escapeChar=0) { if (false == m_isOk) { return false; } - int32_t buflen = _SearchIn.Size(); + esize_t buflen = _SearchIn.Size(); if (_endPos > buflen) { _endPos = buflen; } if (_startPos > _endPos) { return false; } - int32_t findLen=0; - int32_t maxlen = _endPos-_startPos; + esize_t findLen=0; + esize_t maxlen = _endPos-_startPos; if (true == m_notBeginWithChar) { if (_startPos>0) { etk::UniChar tmpVal = _SearchIn[_startPos-1]; @@ -1530,7 +1531,7 @@ template class RegExp * @param[in,out] * @return */ - bool CheckGoodPosition(const etk::Vector& _tmpExp, int32_t& _pos) + bool CheckGoodPosition(const etk::Vector& _tmpExp, esize_t& _pos) { etk::UniChar curentCode = _tmpExp[_pos]; etk::UniChar endCode = REGEXP_OPCODE_PTHESE_OUT; @@ -1637,7 +1638,7 @@ template class RegExp */ bool CheckGoodPosition(const etk::Vector& _tmpExp) { - int32_t pos = 0; + esize_t pos = 0; while (pos < _tmpExp.Size()) { //TK_DEBUG("check : " << tmpExp[pos]); if( _tmpExp[pos] == REGEXP_OPCODE_PTHESE_IN diff --git a/etk/Vector.h b/etk/Vector.h index e02ef5d..9139d38 100644 --- a/etk/Vector.h +++ b/etk/Vector.h @@ -58,7 +58,7 @@ namespace etk { // Private data : private: - size_t m_current; //!< curent Id on the vector + esize_t m_current; //!< curent Id on the vector Vector* m_vector; //!< Pointer on the curent element of the vectorBin public: /** @@ -181,8 +181,8 @@ namespace etk private: MY_TYPE* m_data; //!< pointer on the curetn table of Data - size_t m_size; //!< nb Element in the buffer - size_t m_allocated; //!< Current allocated size + esize_t m_size; //!< nb Element in the buffer + esize_t m_allocated; //!< Current allocated size public: /** * @brief Create an empty vector @@ -212,7 +212,7 @@ namespace etk return; } // Copy all data ... - for(size_t iii=0; iii & _obj) { - size_t nbElememt = _obj.Size(); - size_t idx = m_size; + esize_t nbElememt = _obj.Size(); + esize_t idx = m_size; Resize(m_size+nbElememt); if (m_size<=idx) { TK_CRITICAL("allocation error"); return *this; } - for(size_t iii=0; iii idx) { // initialize data ... - for(size_t iii=idx; iii<_newSize; iii++) { + for(esize_t iii=idx; iii<_newSize; iii++) { m_data[iii] = _basicElement; } } @@ -331,7 +331,7 @@ namespace etk * @brief Get the Allocated size in the vector * @return The size of allocation */ - size_t AllocatedSize(void) const + esize_t AllocatedSize(void) const { return m_allocated; } @@ -340,7 +340,7 @@ namespace etk * @param[in] _pos Desired position read * @return Reference on the Element */ - MY_TYPE& Get(size_t _pos) + MY_TYPE& Get(esize_t _pos) { // NOTE :Do not change log level, this generate error only in debug mode #if DEBUG_LEVEL > 2 @@ -355,7 +355,7 @@ namespace etk * @param[in] _pos Position in the vector that might be get [0..Size()] * @return An reference on the copy of selected element */ - MY_TYPE& operator[] (size_t _pos) + MY_TYPE& operator[] (esize_t _pos) { return Get(_pos); } @@ -364,12 +364,11 @@ namespace etk * @param[in] _pos Position in the vector that might be get [0..Size()] * @return An reference on the selected element */ - const MY_TYPE& operator[] (size_t _pos) const + const MY_TYPE& operator[] (esize_t _pos) const { // NOTE :Do not change log level, this generate error only in debug mode #if DEBUG_LEVEL > 2 - if( _pos>m_size - || _pos<0){ + if(_pos>m_size){ TK_CRITICAL("[CRITICAL] Access to an unexistant data in vector : " << _pos << "/ " << m_size); } #endif @@ -388,7 +387,7 @@ namespace etk * @param[in] _item Pointer on a list of Element to add at the start of vector * @param[in] _nbElement Number of element to add. */ - void PushFront(const MY_TYPE * _item, size_t _nbElement) + void PushFront(const MY_TYPE * _item, esize_t _nbElement) { Insert(0, _item, _nbElement); } @@ -398,7 +397,7 @@ namespace etk */ void PushBack(const MY_TYPE& _item) { - size_t idx = m_size; + esize_t idx = m_size; Resize(m_size+1); if (idx < m_size) { m_data[idx] = _item; @@ -411,18 +410,18 @@ namespace etk * @param[in] _item Pointer on a list of Element to add at the end of vector * @param[in] _nbElement Number of element to add. */ - void PushBack(const MY_TYPE * _item, size_t _nbElement) + void PushBack(const MY_TYPE * _item, esize_t _nbElement) { if (NULL == _item) { return; } - size_t idx = m_size; + esize_t idx = m_size; Resize(m_size+_nbElement); if (idx > m_size) { TK_ERROR("Resize does not work corectly ... not added item"); return; } - for (size_t iii=0; iii<_nbElement; iii++) { + for (esize_t iii=0; iii<_nbElement; iii++) { m_data[idx+iii] = _item[iii]; } } @@ -450,14 +449,14 @@ namespace etk * @param[in] _item Pointer on a table of the elements to add. * @param[in] _nbElement Number of element to add in the Vector */ - void Insert(size_t _pos, const MY_TYPE * _item, size_t _nbElement) + void Insert(esize_t _pos, const MY_TYPE * _item, esize_t _nbElement) { if (_pos>m_size) { TK_WARNING(" can not insert Element at this position : " << _pos << " > " << m_size << " add it at the end ... "); PushBack(_item, _nbElement); return; } - size_t idx = m_size; + esize_t idx = m_size; // Request resize of the current buffer Resize(m_size+_nbElement); if (idx>=m_size) { @@ -465,14 +464,14 @@ namespace etk return; } // move curent data (after the position) - size_t sizeToMove = (idx - _pos); + esize_t sizeToMove = (idx - _pos); if ( 0 < sizeToMove) { - for (size_t iii=1; iii<=sizeToMove; iii++) { + for (esize_t iii=1; iii<=sizeToMove; iii++) { m_data[m_size-iii] = m_data[idx-iii]; } } // affectation of all input element - for (size_t iii=0; iii<_nbElement; iii++) { + for (esize_t iii=0; iii<_nbElement; iii++) { m_data[_pos+iii] = _item[iii]; } } @@ -481,7 +480,7 @@ namespace etk * @param[in] _pos Position to add the elements. * @param[in] _item Element to add. */ - void Insert(size_t _pos, const MY_TYPE& _item) + void Insert(esize_t _pos, const MY_TYPE& _item) { Insert(_pos, &_item, 1); } @@ -490,7 +489,7 @@ namespace etk * @param[in] _pos Position to remove the data * @param[in] _nbElement number of element to remove */ - void EraseLen(size_t _pos, size_t _nbElement) + void EraseLen(esize_t _pos, esize_t _nbElement) { if (_pos>m_size) { TK_ERROR(" can not Erase Len Element at this position : " << _pos << " > " << m_size); @@ -499,11 +498,11 @@ namespace etk if (_pos+_nbElement>m_size) { _nbElement = m_size - _pos; } - size_t idx = m_size; + esize_t idx = m_size; // move curent data - size_t sizeToMove = (idx - (_pos+_nbElement)); + esize_t sizeToMove = (idx - (_pos+_nbElement)); if ( 0 < sizeToMove) { - for (size_t iii=0; iiim_size) { TK_ERROR(" can not Erase Element at this position : " << _pos << " > " << m_size); @@ -540,12 +539,12 @@ namespace etk if (_posEnd>m_size) { _posEnd = m_size; } - size_t nbElement = m_size - _pos; - size_t tmpSize = m_size; + esize_t nbElement = m_size - _pos; + esize_t tmpSize = m_size; // move curent data - size_t sizeToMove = (tmpSize - (_pos+nbElement)); + esize_t sizeToMove = (tmpSize - (_pos+nbElement)); if ( 0 < sizeToMove) { - for (size_t iii=0; iii Extract(size_t _posStart = 0, size_t _posEnd=0x7FFFFFFF) const + Vector Extract(esize_t _posStart = 0, esize_t _posEnd=0x7FFFFFFF) const { Vector out; - if (_posStart < 0) { - _posStart = 0; - } else if (_posStart >= Size() ) { + if (_posStart >= Size() ) { return out; } - if (_posEnd < 0) { - return out; - } else if (_posEnd >= Size() ) { + if (_posEnd >= Size() ) { _posEnd = Size(); } out.PushBack(&m_data[_posStart], _posEnd-_posStart); @@ -587,7 +582,7 @@ namespace etk * @param[in] _pos Requested position of the iterator in the vector * @return The Iterator */ - Iterator Position(size_t _pos) + Iterator Position(esize_t _pos) { return Iterator(this, _pos); } @@ -612,7 +607,7 @@ namespace etk * @brief Change the current size of the vector * @param[in] _newSize New requested size of element in the vector */ - void Resize(size_t _newSize) + void Resize(esize_t _newSize) { // Reallocate memory if (_newSize > m_allocated) { @@ -624,16 +619,13 @@ namespace etk * @brief Change the current allocation to the corect one (depend on the current size) * @param[in] _newSize Minimum number of element needed */ - void ChangeAllocation(size_t _newSize) + void ChangeAllocation(esize_t _newSize) { // set the minimal size to 1 if(_newSize == 0) { _newSize = 1; } - if (m_allocated<0) { - m_allocated = 0; - } - size_t requestSize = m_allocated; + esize_t requestSize = m_allocated; // set the size with the corect chose type : if (_newSize == requestSize) { return; @@ -672,8 +664,8 @@ namespace etk return; } // copy data in the new pool - size_t nbElements = etk_min(requestSize, m_allocated); - for(size_t iii=0; iii(elem)) ? (minimim) : ((maximum)<(elem)) ? (maximum) : (elem)) #include - - +#if 1 + typedef size_t esize_t; + #define ESIZE_T_IS_UNSIGNED +#else + typedef int32_t esize_t; + #define ESIZE_T_IS_SIGNED +#endif #endif