[DEV] Update with the new exml API
This commit is contained in:
parent
1a2f0b6d91
commit
ac0ab974f6
@ -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<exml::Element> 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<exml::Element> 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<exml::Element> 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<exml::Element> 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<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;
|
||||
// get sub Nodes ...
|
||||
for(size_t jjj=0; jjj< child->size(); jjj++) {
|
||||
std::shared_ptr<exml::Element> 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]" );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,7 +13,7 @@
|
||||
#undef __class__
|
||||
#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_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<const exml::Element>& _child, int32_t _level) {
|
||||
void appl::HighlightPattern::parseRules(const exml::Element& _child, int32_t _level) {
|
||||
//--------------------------------------------------------------------------------------------
|
||||
/*
|
||||
<rule name="my preprocesseur">
|
||||
@ -79,7 +79,7 @@ void appl::HighlightPattern::parseRules(const std::shared_ptr<const exml::Elemen
|
||||
*/
|
||||
//--------------------------------------------------------------------------------------------
|
||||
// process attribute
|
||||
std::string highLightName = _child->getAttribute("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<const exml::Elemen
|
||||
setName(myEdnDataTmp);
|
||||
setLevel(_level);
|
||||
|
||||
std::shared_ptr<const exml::Element> 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);
|
||||
|
@ -25,7 +25,7 @@ namespace appl {
|
||||
public:
|
||||
// Constructeur
|
||||
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();
|
||||
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<const exml::Element>& _child, int32_t _level);
|
||||
void parseRules(const exml::Element& _child, int32_t _level);
|
||||
};
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user