From 0cfb9c2130d5fadeb46c2b08d28dde609a6736af Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Wed, 27 Nov 2013 21:33:34 +0100 Subject: [PATCH] [DEV] add extra compilation flags & correct warning --- exml/Attribute.cpp | 12 ++++++------ exml/AttributeList.cpp | 24 ++++++++++++------------ exml/AttributeList.h | 2 +- exml/Comment.cpp | 2 +- exml/Declaration.cpp | 2 +- exml/Document.cpp | 10 +++++----- exml/Element.cpp | 36 ++++++++++++++++++------------------ exml/Element.h | 2 +- exml/Node.cpp | 2 +- exml/Text.cpp | 10 +++++----- lutin_exml.py | 3 +++ 11 files changed, 54 insertions(+), 51 deletions(-) diff --git a/exml/Attribute.cpp b/exml/Attribute.cpp index 453960e..01baf52 100644 --- a/exml/Attribute.cpp +++ b/exml/Attribute.cpp @@ -35,8 +35,8 @@ bool exml::Attribute::iParse(const std::string& _data, int32_t& _pos, bool _case EXML_VERBOSE("start parse : 'attribute'"); m_pos = _filePos; // search end of the comment : - int32_t lastElementName = _pos; - for (int32_t iii=_pos; iii<_data.size(); iii++) { + size_t lastElementName = _pos; + for (size_t iii=_pos; iii<_data.size(); iii++) { _filePos.check(_data[iii]); #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); @@ -73,8 +73,8 @@ bool exml::Attribute::iParse(const std::string& _data, int32_t& _pos, bool _case if (_data[lastElementName+white+2] != '"') { // parse with no element " == > direct value separate with space ... ++_filePos; - int32_t lastAttributePos = lastElementName+white+2; - for (int32_t iii=lastElementName+white+2; iii<_data.size(); iii++) { + size_t lastAttributePos = lastElementName+white+2; + for (size_t iii=lastElementName+white+2; iii<_data.size(); iii++) { #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); #endif @@ -98,8 +98,8 @@ bool exml::Attribute::iParse(const std::string& _data, int32_t& _pos, bool _case _pos = lastAttributePos-1; return true; } - int32_t lastAttributePos = lastElementName+white+3; - for (int32_t iii=lastElementName+white+3; iii<_data.size(); iii++) { + size_t lastAttributePos = lastElementName+white+3; + for (size_t iii=lastElementName+white+3; iii<_data.size(); iii++) { #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); #endif diff --git a/exml/AttributeList.cpp b/exml/AttributeList.cpp index f1ee178..8e2df6c 100644 --- a/exml/AttributeList.cpp +++ b/exml/AttributeList.cpp @@ -13,7 +13,7 @@ #define __class__ "AttributeList" exml::AttributeList::~AttributeList(void) { - for (int32_t iii=0; iiim_listAttribute.size()) { + if (_id <0 || (size_t)_id>m_listAttribute.size()) { return NULL; } return m_listAttribute[_id]; } const exml::Attribute* exml::AttributeList::getAttr(int32_t _id) const { - if (_id <0 || _id>m_listAttribute.size()) { + if (_id <0 || (size_t)_id>m_listAttribute.size()) { return NULL; } return m_listAttribute[_id]; @@ -41,7 +41,7 @@ void exml::AttributeList::appendAttribute(exml::Attribute* _attr) { EXML_ERROR("Try to set an empty node"); return; } - for (int32_t iii=0; iiigetName() == _name) { return m_listAttribute[iii]->getValue(); @@ -69,7 +69,7 @@ std::u32string exml::AttributeList::getAttribute(const std::u32string& _name) co if (_name.size() == 0) { return errorReturn; } - for (int32_t iii=0; iiigetUName() == _name) { return m_listAttribute[iii]->getUValue(); @@ -82,7 +82,7 @@ bool exml::AttributeList::existAttribute(const std::string& _name) const { if (_name.size() == 0) { return false; } - for (int32_t iii=0; iiigetName() == _name) { return true; @@ -95,7 +95,7 @@ bool exml::AttributeList::existAttribute(const std::u32string& _name) const { if (_name.size() == 0) { return false; } - for (int32_t iii=0; iiigetUName() == _name) { return true; @@ -106,7 +106,7 @@ bool exml::AttributeList::existAttribute(const std::u32string& _name) const { void exml::AttributeList::setAttribute(const std::string& _name, const std::string& _value) { // check if attribute already det : - for (int32_t iii=0; iiigetName() == _name) { // update the value : @@ -123,7 +123,7 @@ void exml::AttributeList::setAttribute(const std::string& _name, const std::stri void exml::AttributeList::setAttribute(const std::u32string& _name, const std::u32string& _value) { // check if attribute already det : - for (int32_t iii=0; iiigetUName() == _name) { // update the value : @@ -139,7 +139,7 @@ void exml::AttributeList::setAttribute(const std::u32string& _name, const std::u } bool exml::AttributeList::iGenerate(std::string& _data, int32_t _indent) const { - for (int32_t iii=0; iiiiGenerate(_data, _indent); } @@ -149,7 +149,7 @@ bool exml::AttributeList::iGenerate(std::string& _data, int32_t _indent) const { void exml::AttributeList::clear(void) { exml::Node::clear(); - for (int32_t iii=0; iii=0 */ - int32_t sizeAttribute(void) const { + size_t sizeAttribute(void) const { return m_listAttribute.size(); }; /** diff --git a/exml/Comment.cpp b/exml/Comment.cpp index 8111936..0a3dd14 100644 --- a/exml/Comment.cpp +++ b/exml/Comment.cpp @@ -20,7 +20,7 @@ bool exml::Comment::iParse(const std::string& _data, int32_t& _pos, bool _caseSe int32_t white = countWhiteChar(_data, _pos, tmpPos); _filePos += tmpPos; // search end of the comment : - for (int32_t iii=_pos+white; iii+2<_data.size(); iii++) { + for (size_t iii=_pos+white; iii+2<_data.size(); iii++) { #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); #endif diff --git a/exml/Declaration.cpp b/exml/Declaration.cpp index 600a21b..a58df81 100644 --- a/exml/Declaration.cpp +++ b/exml/Declaration.cpp @@ -69,7 +69,7 @@ bool exml::Declaration::iParse(const std::string& _data, int32_t& _pos, bool _ca EXML_VERBOSE("start parse : 'declaration' : '" << m_value << "'"); m_pos = _filePos; // search end of the comment : - for (int32_t iii=_pos; iii+1<_data.size(); iii++) { + for (size_t iii=_pos; iii+1<_data.size(); iii++) { #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); #endif diff --git a/exml/Document.cpp b/exml/Document.cpp index 5dce2a4..3d5a361 100644 --- a/exml/Document.cpp +++ b/exml/Document.cpp @@ -25,7 +25,7 @@ exml::Document::Document(void) : bool exml::Document::iGenerate(std::string& _data, int32_t _indent) const { - for (int32_t iii=0; iiiiGenerate(_data, _indent); } @@ -116,7 +116,7 @@ bool exml::Document::store(const std::string& _file) { EXML_ERROR("Can not open (w) the file : " << _file); return false; } - if (tmpFile.fileWrite((char*)createData.c_str(), sizeof(char), createData.size()) != createData.size()) { + if (tmpFile.fileWrite((char*)createData.c_str(), sizeof(char), createData.size()) != (int64_t)createData.size()) { EXML_ERROR("Error while writing output XML file : " << _file); tmpFile.fileClose(); return false; @@ -133,15 +133,15 @@ void exml::Document::display(void) { std::string createPosPointer(const std::string& _line, int32_t _pos) { std::string out; - int32_t iii; - for (iii=0; iii<_pos && iii<_line.size(); iii++) { + size_t iii; + for (iii=0; (int64_t)iii<_pos && iii<_line.size(); iii++) { if (_line[iii] == '\t') { out += "\t"; } else { out += " "; } } - for (; iii<_pos; iii++) { + for (; (int64_t)iii<_pos; iii++) { out += " "; } out += "^"; diff --git a/exml/Element.cpp b/exml/Element.cpp index 938203b..de04b9d 100644 --- a/exml/Element.cpp +++ b/exml/Element.cpp @@ -19,7 +19,7 @@ exml::Element::~Element(void) { - for (int32_t iii=0; iiim_listSub.size()) { + if (_id <0 || (size_t)_id>m_listSub.size()) { return NULL; } return m_listSub[_id]; } const exml::Node* exml::Element::getNode(int32_t _id) const { - if (_id <0 || _id>m_listSub.size()) { + if (_id <0 || (size_t)_id>m_listSub.size()) { return NULL; } return m_listSub[_id]; @@ -78,7 +78,7 @@ exml::Element* exml::Element::getNamed(const std::string& _name) { if (_name.size() == 0) { return NULL; } - for (int32_t iii=0; iiigetType() == exml::typeElement && m_listSub[iii]->getValue() == _name) { @@ -98,7 +98,7 @@ const exml::Element* exml::Element::getNamed(const std::string& _name) const { if (_name.size() == 0) { return NULL; } - for (int32_t iii=0; iiigetType() == exml::typeElement && m_listSub[iii]->getValue() == _name) { @@ -123,7 +123,7 @@ void exml::Element::append(exml::Node* _node) { appendAttribute(_node->toAttribute()); return; } - for (int32_t iii=0; iiiiGenerate(res, 0); } @@ -159,7 +159,7 @@ bool exml::Element::iGenerate(std::string& _data, int32_t _indent) const { } else { _data += ">\n"; - for (int32_t iii=0; iiiiGenerate(_data, _indent+1); } @@ -178,7 +178,7 @@ bool exml::Element::iGenerate(std::string& _data, int32_t _indent) const { bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode) { EXML_PARSE_ELEMENT(" start subParse ... " << _pos << " " << _filePos); - for (int32_t iii=_pos; iii<_data.size(); iii++) { + for (size_t iii=_pos; iii<_data.size(); iii++) { _filePos.check(_data[iii]); #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); @@ -208,9 +208,9 @@ bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _case return false; } //EXML_DEBUG("Generate node name : '" << _data[iii+1] << "'"); - int32_t endPosName = iii+white+1; + size_t endPosName = iii+white+1; // generate element name ... - for (int32_t jjj=iii+white+2; jjj<_data.size(); jjj++) { + for (size_t jjj=iii+white+2; jjj<_data.size(); jjj++) { if(true == checkAvaillable(_data[jjj], false) ) { // we find the end ... endPosName = jjj; @@ -311,9 +311,9 @@ bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _case if(_data[iii+white+1] == '/') { ++tmpPos; //EXML_DEBUG("Generate node name : '" << _data[iii+1] << "'"); - int32_t endPosName = iii+white+1; + size_t endPosName = iii+white+1; // generate element name ... - for (int32_t jjj=iii+white+2; jjj<_data.size(); jjj++) { + for (size_t jjj=iii+white+2; jjj<_data.size(); jjj++) { if(true == checkAvaillable(_data[jjj], false) ) { // we find the end ... endPosName = jjj; @@ -329,7 +329,7 @@ bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _case if( tmpname == m_value) { // find end of node : // find > element ... - for (int32_t jjj=endPosName+1; jjj<_data.size(); jjj++) { + for (size_t jjj=endPosName+1; jjj<_data.size(); jjj++) { #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[jjj], _filePos); #endif @@ -362,9 +362,9 @@ bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _case if (checkAvaillable(_data[iii+white+1], true) == true) { ++tmpPos; //EXML_DEBUG("Generate node name : '" << _data[iii+1] << "'"); - int32_t endPosName = iii+white+1; + size_t endPosName = iii+white+1; // generate element name ... - for (int32_t jjj=iii+white+2; jjj<_data.size(); jjj++) { + for (size_t jjj=iii+white+2; jjj<_data.size(); jjj++) { if(checkAvaillable(_data[jjj], false) == true) { // we find the end ... endPosName = jjj; @@ -439,7 +439,7 @@ bool exml::Element::iParse(const std::string& _data, int32_t& _pos, bool _caseSe // note : When start parsing the upper element must have set the value of the element and set the position after this one m_pos=_filePos; // find a normal node ... - for (int32_t iii=_pos; iii<_data.size(); iii++) { + for (size_t iii=_pos; iii<_data.size(); iii++) { _filePos.check(_data[iii]); #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); @@ -491,7 +491,7 @@ bool exml::Element::iParse(const std::string& _data, int32_t& _pos, bool _caseSe void exml::Element::clear(void) { exml::AttributeList::clear(); - for (int32_t iii=0; iii=0. */ - int32_t size(void) const { + size_t size(void) const { return m_listSub.size(); }; /** diff --git a/exml/Node.cpp b/exml/Node.cpp index cbf2a66..2a00a50 100644 --- a/exml/Node.cpp +++ b/exml/Node.cpp @@ -99,7 +99,7 @@ bool exml::Node::checkAvaillable(char32_t _val, bool _firstChar) const { int32_t exml::Node::countWhiteChar(const std::string& _data, int32_t _pos, exml::filePos& _filePos) const { _filePos.clear(); int32_t white=0; - for (int32_t iii=_pos; iii<_data.size(); iii++) { + for (size_t iii=_pos; iii<_data.size(); iii++) { _filePos.check(_data[iii]); if(true == etk::isWhiteChar(_data[iii])) { white++; diff --git a/exml/Text.cpp b/exml/Text.cpp index 2cb0703..ed66705 100644 --- a/exml/Text.cpp +++ b/exml/Text.cpp @@ -20,7 +20,7 @@ bool exml::Text::iGenerate(std::string& _data, int32_t _indent) const { int32_t exml::Text::countLines(void) const { int32_t count = 1; - for (int32_t iii=0; iii' || _data[iii] == '<') { // search whitespace : - int32_t newEnd=iii; - for( int32_t jjj=iii-1; jjj>_pos; jjj--) { + size_t newEnd=iii; + for (int64_t jjj=(int64_t)iii-1; jjj>(int64_t)_pos; --jjj) { if(true == etk::isWhiteChar(_data[jjj])) { newEnd = jjj; } else { @@ -66,7 +66,7 @@ bool exml::TextCDATA::iParse(const std::string& _data, int32_t& _pos, bool _case EXML_VERBOSE("start parse : 'text::CDATA'"); m_pos = _filePos; // search end of the comment : - for (int32_t iii=_pos; iii+2<_data.size(); iii++) { + for (size_t iii=_pos; iii+2<_data.size(); iii++) { #ifdef ENABLE_DISPLAY_PARSED_ELEMENT drawElementParsed(_data[iii], _filePos); #endif diff --git a/lutin_exml.py b/lutin_exml.py index 2a209c6..57aef64 100644 --- a/lutin_exml.py +++ b/lutin_exml.py @@ -7,6 +7,9 @@ def Create(target): myModule.AddModuleDepend(['etk']) + # add extra compilation flags : + myModule.add_extra_compile_flags() + # add sources files myModule.AddSrcFile([ 'exml/debug.cpp', 'exml/Attribute.cpp',