diff --git a/sources/appl/Highlight.cpp b/sources/appl/Highlight.cpp index 994f890..14b9944 100644 --- a/sources/appl/Highlight.cpp +++ b/sources/appl/Highlight.cpp @@ -40,79 +40,79 @@ void appl::Highlight::init(const std::string& _xmlFilename, const std::string& _ APPL_ERROR(" can not load file XML : " << _xmlFilename); return; } - std::shared_ptr root = doc.getNamed("EdnLang"); - if (root ==nullptr) { - APPL_ERROR("(l ?) main node not find: \"EdnLang\" ..."); + exml::Element root = doc.nodes["EdnLang"]; + if (root.exist() == false) { + APPL_ERROR("(l ?) main node not find: 'EdnLang' ..."); return; } - m_typeName = root->getAttribute("lang"); + m_typeName = root.attributes["lang"]; int32_t level1 = 0; int32_t level2 = 0; // parse all the elements : - for(size_t iii = 0; iii < root->size(); ++iii) { - std::shared_ptr child = root->getElement(iii); - if (child == nullptr) { + for (const auto it : root.nodes) { + const exml::Element child = it.toElement(); + if (child.exist() == false) { // trash here all that is not element ... continue; } - if (child->getValue() == "ext") { - std::string myData = child->getText(); + if (child.getValue() == "ext") { + std::string myData = child.getText(); if (myData.size()!=0) { //HL_DEBUG("(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData); m_listExtentions.push_back(myData); } - } else if (child->getValue() == "pass1") { + } else if (child.getValue() == "pass1") { // get sub Nodes ... - for(size_t jjj=0; jjj< child->size(); jjj++) { - std::shared_ptr passChild = child->getElement(jjj); - if (passChild == nullptr) { + for (const auto it2 : child.nodes) { + const exml::Element passChild = it2.toElement(); + if (passChild.exist() == false) { continue; } - if (passChild->getValue() != "rule") { - APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); + if (passChild.getValue() != "rule") { + APPL_ERROR("(l "<< passChild.getPos() << ") node not suported : '"<< passChild.getValue() << "' must be [rule]" ); continue; } // Create the patern in list m_listHighlightPass1.push_back(HighlightPattern(m_paintingProperties, passChild, level1++)); } - } else if (child->getValue() == "pass2") { + } else if (child.getValue() == "pass2") { // get sub Nodes ... - for(size_t jjj=0; jjj< child->size(); jjj++) { - std::shared_ptr passChild = child->getElement(jjj); - if (passChild == nullptr) { + for (const auto it2 : child.nodes) { + const exml::Element passChild = it2.toElement(); + if (passChild.exist() == false) { continue; } - if (passChild->getValue() != "rule") { - APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); + if (passChild.getValue() != "rule") { + APPL_ERROR("(l "<< passChild.getPos() << ") node not suported : '"<< passChild.getValue() << "' must be [rule]" ); continue; } // Create the patern in list m_listHighlightPass2.push_back(HighlightPattern(m_paintingProperties, passChild, level2++)); } - } else if (child->getValue() == "pass") { - std::string attributeName = child->getAttribute("name"); + } else if (child.getValue() == "pass") { + std::string attributeName = child.attributes["name"]; if (attributeName == "") { - APPL_ERROR("Can not parse an element pass with no attribute name ... ligne=" << child->getPos()); + APPL_ERROR("Can not parse an element pass with no attribute name ... ligne=" << child.getPos()); continue; } m_listHighlightNamed.insert(std::pair>(attributeName, std::vector())); - auto it = m_listHighlightNamed.find(attributeName); + auto it3 = m_listHighlightNamed.find(attributeName); int32_t level3=0; // get sub Nodes ... - for(size_t jjj=0; jjj< child->size(); jjj++) { - std::shared_ptr passChild = child->getElement(jjj); - if (passChild == nullptr) { + for (const auto it2 : child.nodes) { + const exml::Element passChild = it2.toElement(); + if (passChild.exist() == false) { continue; } - if (passChild->getValue() != "rule") { - APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); + if (passChild.getValue() != "rule") { + APPL_ERROR("(l "<< passChild.getPos() << ") node not suported : '"<< passChild.getValue() << "' must be [rule]" ); continue; } // add element in the list - it->second.push_back(HighlightPattern(m_paintingProperties, passChild, level3++)); + it3->second.push_back(HighlightPattern(m_paintingProperties, passChild, level3++)); } } else { - APPL_ERROR("(l "<< child->getPos() << ") node not suported : \""<< child->getValue() << "\" must be [ext,pass1,pass2]" ); + APPL_ERROR("(l "<< child.getPos() << ") node not suported : '"<< child.getValue() << "' must be [ext,pass1,pass2]" ); } } } diff --git a/sources/appl/HighlightPattern.cpp b/sources/appl/HighlightPattern.cpp index 875249e..b6df0c2 100644 --- a/sources/appl/HighlightPattern.cpp +++ b/sources/appl/HighlightPattern.cpp @@ -13,7 +13,7 @@ #undef __class__ #define __class__ "HighlightPattern" -appl::HighlightPattern::HighlightPattern(const std::shared_ptr& _glyphPainting, const std::shared_ptr& _child, int32_t _level) : +appl::HighlightPattern::HighlightPattern(const std::shared_ptr& _glyphPainting, const exml::Element& _child, int32_t _level) : m_glyphPainting(_glyphPainting), m_paternName(""), m_hasParsingError(true), @@ -68,7 +68,7 @@ void appl::HighlightPattern::display() { APPL_INFO(" == > regex '" << m_regexValue << "'"); } -void appl::HighlightPattern::parseRules(const std::shared_ptr& _child, int32_t _level) { +void appl::HighlightPattern::parseRules(const exml::Element& _child, int32_t _level) { //-------------------------------------------------------------------------------------------- /* @@ -79,7 +79,7 @@ void appl::HighlightPattern::parseRules(const std::shared_ptrgetAttribute("name"); + std::string highLightName = _child.attributes["name"]; std::string myEdnDataTmp = "???"; if (highLightName.size()!=0) { myEdnDataTmp = highLightName; @@ -87,25 +87,25 @@ void appl::HighlightPattern::parseRules(const std::shared_ptr xChild = _child->getNamed("color"); - if (nullptr != xChild) { - std::string myData = xChild->getText(); + exml::Element xChild = _child.nodes["color"]; + if (xChild.exist() == true) { + std::string myData = xChild.getText(); if (myData.size() != 0) { //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); setColorGlyph(myData); } } - xChild = _child->getNamed("regex"); - if (nullptr != xChild) { - std::string myData = xChild->getText(); + xChild = _child.nodes["regex"]; + if (xChild.exist() == true) { + std::string myData = xChild.getText(); if (myData.size() != 0) { //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); setPatern(myData); } } - xChild = _child->getNamed("sub"); - if (nullptr != xChild) { - std::string myData = xChild->getText(); + xChild = _child.nodes["sub"]; + if (xChild.exist() == true) { + std::string myData = xChild.getText(); if (myData.size() != 0) { //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); setSubPatternName(myData); diff --git a/sources/appl/HighlightPattern.h b/sources/appl/HighlightPattern.h index 1b8172c..32f8e5c 100644 --- a/sources/appl/HighlightPattern.h +++ b/sources/appl/HighlightPattern.h @@ -25,7 +25,7 @@ namespace appl { public: // Constructeur HighlightPattern(); - HighlightPattern(const std::shared_ptr& _glyphPainting, const std::shared_ptr& _child, int32_t _level); + HighlightPattern(const std::shared_ptr& _glyphPainting, const exml::Element& _child, int32_t _level); virtual ~HighlightPattern(); private: std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") @@ -87,7 +87,7 @@ namespace appl { appl::HighlightInfo& _resultat, const std::string& _buffer); - void parseRules(const std::shared_ptr& _child, int32_t _level); + void parseRules(const exml::Element& _child, int32_t _level); }; };