[DEV] Update with the new exml API

This commit is contained in:
Edouard DUPIN 2016-04-18 21:01:17 +02:00
parent 1a2f0b6d91
commit ac0ab974f6
3 changed files with 46 additions and 46 deletions

View File

@ -40,79 +40,79 @@ void appl::Highlight::init(const std::string& _xmlFilename, const std::string& _
APPL_ERROR(" can not load file XML : " << _xmlFilename); APPL_ERROR(" can not load file XML : " << _xmlFilename);
return; return;
} }
std::shared_ptr<exml::Element> root = doc.getNamed("EdnLang"); exml::Element root = doc.nodes["EdnLang"];
if (root ==nullptr) { if (root.exist() == false) {
APPL_ERROR("(l ?) main node not find: \"EdnLang\" ..."); APPL_ERROR("(l ?) main node not find: 'EdnLang' ...");
return; return;
} }
m_typeName = root->getAttribute("lang"); m_typeName = root.attributes["lang"];
int32_t level1 = 0; int32_t level1 = 0;
int32_t level2 = 0; int32_t level2 = 0;
// parse all the elements : // parse all the elements :
for(size_t iii = 0; iii < root->size(); ++iii) { for (const auto it : root.nodes) {
std::shared_ptr<exml::Element> child = root->getElement(iii); const exml::Element child = it.toElement();
if (child == nullptr) { if (child.exist() == false) {
// trash here all that is not element ... // trash here all that is not element ...
continue; continue;
} }
if (child->getValue() == "ext") { if (child.getValue() == "ext") {
std::string myData = child->getText(); std::string myData = child.getText();
if (myData.size()!=0) { if (myData.size()!=0) {
//HL_DEBUG("(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData); //HL_DEBUG("(l %d) node fined : %s=\"%s\"", child->Row(), child->Value() , myData);
m_listExtentions.push_back(myData); m_listExtentions.push_back(myData);
} }
} else if (child->getValue() == "pass1") { } else if (child.getValue() == "pass1") {
// get sub Nodes ... // get sub Nodes ...
for(size_t jjj=0; jjj< child->size(); jjj++) { for (const auto it2 : child.nodes) {
std::shared_ptr<exml::Element> passChild = child->getElement(jjj); const exml::Element passChild = it2.toElement();
if (passChild == nullptr) { if (passChild.exist() == false) {
continue; continue;
} }
if (passChild->getValue() != "rule") { if (passChild.getValue() != "rule") {
APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); APPL_ERROR("(l "<< passChild.getPos() << ") node not suported : '"<< passChild.getValue() << "' must be [rule]" );
continue; continue;
} }
// Create the patern in list // Create the patern in list
m_listHighlightPass1.push_back(HighlightPattern(m_paintingProperties, passChild, level1++)); m_listHighlightPass1.push_back(HighlightPattern(m_paintingProperties, passChild, level1++));
} }
} else if (child->getValue() == "pass2") { } else if (child.getValue() == "pass2") {
// get sub Nodes ... // get sub Nodes ...
for(size_t jjj=0; jjj< child->size(); jjj++) { for (const auto it2 : child.nodes) {
std::shared_ptr<exml::Element> passChild = child->getElement(jjj); const exml::Element passChild = it2.toElement();
if (passChild == nullptr) { if (passChild.exist() == false) {
continue; continue;
} }
if (passChild->getValue() != "rule") { if (passChild.getValue() != "rule") {
APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); APPL_ERROR("(l "<< passChild.getPos() << ") node not suported : '"<< passChild.getValue() << "' must be [rule]" );
continue; continue;
} }
// Create the patern in list // Create the patern in list
m_listHighlightPass2.push_back(HighlightPattern(m_paintingProperties, passChild, level2++)); m_listHighlightPass2.push_back(HighlightPattern(m_paintingProperties, passChild, level2++));
} }
} else if (child->getValue() == "pass") { } else if (child.getValue() == "pass") {
std::string attributeName = child->getAttribute("name"); std::string attributeName = child.attributes["name"];
if (attributeName == "") { 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; continue;
} }
m_listHighlightNamed.insert(std::pair<std::string, std::vector<HighlightPattern>>(attributeName, std::vector<HighlightPattern>())); m_listHighlightNamed.insert(std::pair<std::string, std::vector<HighlightPattern>>(attributeName, std::vector<HighlightPattern>()));
auto it = m_listHighlightNamed.find(attributeName); auto it3 = m_listHighlightNamed.find(attributeName);
int32_t level3=0; int32_t level3=0;
// get sub Nodes ... // get sub Nodes ...
for(size_t jjj=0; jjj< child->size(); jjj++) { for (const auto it2 : child.nodes) {
std::shared_ptr<exml::Element> passChild = child->getElement(jjj); const exml::Element passChild = it2.toElement();
if (passChild == nullptr) { if (passChild.exist() == false) {
continue; continue;
} }
if (passChild->getValue() != "rule") { if (passChild.getValue() != "rule") {
APPL_ERROR("(l "<< passChild->getPos() << ") node not suported : \""<< passChild->getValue() << "\" must be [rule]" ); APPL_ERROR("(l "<< passChild.getPos() << ") node not suported : '"<< passChild.getValue() << "' must be [rule]" );
continue; continue;
} }
// add element in the list // add element in the list
it->second.push_back(HighlightPattern(m_paintingProperties, passChild, level3++)); it3->second.push_back(HighlightPattern(m_paintingProperties, passChild, level3++));
} }
} else { } 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]" );
} }
} }
} }

View File

@ -13,7 +13,7 @@
#undef __class__ #undef __class__
#define __class__ "HighlightPattern" #define __class__ "HighlightPattern"
appl::HighlightPattern::HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting, const std::shared_ptr<const exml::Element>& _child, int32_t _level) : appl::HighlightPattern::HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting, const exml::Element& _child, int32_t _level) :
m_glyphPainting(_glyphPainting), m_glyphPainting(_glyphPainting),
m_paternName(""), m_paternName(""),
m_hasParsingError(true), m_hasParsingError(true),
@ -68,7 +68,7 @@ void appl::HighlightPattern::display() {
APPL_INFO(" == > regex '" << m_regexValue << "'"); APPL_INFO(" == > regex '" << m_regexValue << "'");
} }
void appl::HighlightPattern::parseRules(const std::shared_ptr<const exml::Element>& _child, int32_t _level) { void appl::HighlightPattern::parseRules(const exml::Element& _child, int32_t _level) {
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
/* /*
<rule name="my preprocesseur"> <rule name="my preprocesseur">
@ -79,7 +79,7 @@ void appl::HighlightPattern::parseRules(const std::shared_ptr<const exml::Elemen
*/ */
//-------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------
// process attribute // process attribute
std::string highLightName = _child->getAttribute("name"); std::string highLightName = _child.attributes["name"];
std::string myEdnDataTmp = "???"; std::string myEdnDataTmp = "???";
if (highLightName.size()!=0) { if (highLightName.size()!=0) {
myEdnDataTmp = highLightName; myEdnDataTmp = highLightName;
@ -87,25 +87,25 @@ void appl::HighlightPattern::parseRules(const std::shared_ptr<const exml::Elemen
setName(myEdnDataTmp); setName(myEdnDataTmp);
setLevel(_level); setLevel(_level);
std::shared_ptr<const exml::Element> xChild = _child->getNamed("color"); exml::Element xChild = _child.nodes["color"];
if (nullptr != xChild) { if (xChild.exist() == true) {
std::string myData = xChild->getText(); std::string myData = xChild.getText();
if (myData.size() != 0) { if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
setColorGlyph(myData); setColorGlyph(myData);
} }
} }
xChild = _child->getNamed("regex"); xChild = _child.nodes["regex"];
if (nullptr != xChild) { if (xChild.exist() == true) {
std::string myData = xChild->getText(); std::string myData = xChild.getText();
if (myData.size() != 0) { if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
setPatern(myData); setPatern(myData);
} }
} }
xChild = _child->getNamed("sub"); xChild = _child.nodes["sub"];
if (nullptr != xChild) { if (xChild.exist() == true) {
std::string myData = xChild->getText(); std::string myData = xChild.getText();
if (myData.size() != 0) { if (myData.size() != 0) {
//APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData); //APPL_INFO(PFX"(l %d) node fined : %s=\"%s\"", xChild->Row(), xChild->Value() , myData);
setSubPatternName(myData); setSubPatternName(myData);

View File

@ -25,7 +25,7 @@ namespace appl {
public: public:
// Constructeur // Constructeur
HighlightPattern(); HighlightPattern();
HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting, const std::shared_ptr<const exml::Element>& _child, int32_t _level); HighlightPattern(const std::shared_ptr<appl::GlyphPainting>& _glyphPainting, const exml::Element& _child, int32_t _level);
virtual ~HighlightPattern(); virtual ~HighlightPattern();
private: private:
std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash") std::string m_paternName; //!< Current style name (like "c++" or "c" or "script Bash")
@ -87,7 +87,7 @@ namespace appl {
appl::HighlightInfo& _resultat, appl::HighlightInfo& _resultat,
const std::string& _buffer); const std::string& _buffer);
void parseRules(const std::shared_ptr<const exml::Element>& _child, int32_t _level); void parseRules(const exml::Element& _child, int32_t _level);
}; };
}; };