[DEV] update new xml interface
This commit is contained in:
parent
738ee25fb8
commit
d61f0b9607
@ -20,8 +20,8 @@ esvg::Base::Base(PaintState _parentPaintState) {
|
||||
m_paint = _parentPaintState;
|
||||
}
|
||||
|
||||
void esvg::Base::parseTransform(exml::Element* _element) {
|
||||
if (NULL == _element) {
|
||||
void esvg::Base::parseTransform(const std::shared_ptr<exml::Element>& _element) {
|
||||
if (_element == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string inputString = _element->getAttribute("transform");
|
||||
@ -85,11 +85,11 @@ void esvg::Base::parseTransform(exml::Element* _element) {
|
||||
* @param[out] _pos parsed position
|
||||
* @param[out] _size parsed dimention
|
||||
*/
|
||||
void esvg::Base::parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size) {
|
||||
void esvg::Base::parsePosition(const std::shared_ptr<const exml::Element>& _element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size) {
|
||||
_pos.setValue(0,0);
|
||||
_size.setValue(0,0);
|
||||
|
||||
if (NULL == _element) {
|
||||
if (_element == nullptr) {
|
||||
return;
|
||||
}
|
||||
std::string content = _element->getAttribute("x");
|
||||
@ -194,8 +194,8 @@ int32_t extractPartOfStyle(const std::string& _data, std::string& _outputType, s
|
||||
* @brief parse a Painting attribute of a specific node
|
||||
* @param[in] _element Basic node of the XML that might be parsed
|
||||
*/
|
||||
void esvg::Base::parsePaintAttr(const exml::Element *_element) {
|
||||
if (_element == NULL) {
|
||||
void esvg::Base::parsePaintAttr(const std::shared_ptr<const exml::Element>& _element) {
|
||||
if (_element == nullptr) {
|
||||
return;
|
||||
}
|
||||
bool fillNone = false;
|
||||
@ -389,7 +389,7 @@ draw::Color esvg::Base::parseColor(const std::string& _inputData) {
|
||||
* @param[in] _element standart XML node
|
||||
* @return true if no problem arrived
|
||||
*/
|
||||
bool esvg::Base::parse(exml::Element* _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
bool esvg::Base::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
SVG_ERROR("NOT IMPLEMENTED");
|
||||
_sizeMax.setValue(0,0);
|
||||
return false;
|
||||
|
@ -38,15 +38,15 @@ namespace esvg {
|
||||
Base() {};
|
||||
Base(PaintState _parentPaintState);
|
||||
virtual ~Base() { };
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
//specific drawing for AAG librairy ...
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans) { };
|
||||
|
||||
virtual void display(int32_t _spacing) { };
|
||||
void parseTransform(exml::Element *_element);
|
||||
void parsePosition(const exml::Element *_element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size);
|
||||
void parseTransform(const std::shared_ptr<exml::Element>& _element);
|
||||
void parsePosition(const std::shared_ptr<const exml::Element>& _element, etk::Vector2D<float> &_pos, etk::Vector2D<float> &_size);
|
||||
float parseLength(const std::string& _dataInput);
|
||||
void parsePaintAttr(const exml::Element *_element);
|
||||
void parsePaintAttr(const std::shared_ptr<const exml::Element>& _element);
|
||||
draw::Color parseColor(const std::string& _inputData);
|
||||
};
|
||||
};
|
||||
|
@ -22,10 +22,10 @@ esvg::Circle::~Circle() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Circle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
bool esvg::Circle::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
m_radius = 0.0;
|
||||
m_position.setValue(0,0);
|
||||
if (NULL == _element) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
parseTransform(_element);
|
||||
|
@ -19,7 +19,7 @@ namespace esvg {
|
||||
public:
|
||||
Circle(PaintState _parentPaintState);
|
||||
~Circle();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
|
@ -22,8 +22,8 @@ esvg::Ellipse::~Ellipse() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Ellipse::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (NULL == _element) {
|
||||
bool esvg::Ellipse::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
parseTransform(_element);
|
||||
|
@ -19,7 +19,7 @@ namespace esvg {
|
||||
public:
|
||||
Ellipse(PaintState _parentPaintState);
|
||||
~Ellipse();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
|
@ -31,8 +31,8 @@ esvg::Group::~Group() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (NULL == _element) {
|
||||
bool esvg::Group::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
// parse ...
|
||||
@ -52,12 +52,12 @@ bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTran
|
||||
vec2 tmpPos(0,0);
|
||||
// parse all sub node :
|
||||
for(int32_t iii=0; iii<_element->size() ; iii++) {
|
||||
exml::Element* child = _element->getElement(iii);
|
||||
if (NULL == child) {
|
||||
std::shared_ptr<exml::Element> child = _element->getElement(iii);
|
||||
if (child == nullptr) {
|
||||
// can be a comment ...
|
||||
continue;
|
||||
}
|
||||
esvg::Base *elementParser = NULL;
|
||||
esvg::Base *elementParser = nullptr;
|
||||
if (child->getValue() == "g") {
|
||||
elementParser = new esvg::Group(m_paint);
|
||||
} else if (child->getValue() == "a") {
|
||||
@ -81,13 +81,13 @@ bool esvg::Group::parse(exml::Element * _element, agg::trans_affine& _parentTran
|
||||
} else {
|
||||
SVG_ERROR("(l "<<child->getPos()<<") node not suported : \""<<child->getValue()<<"\" must be [g,a,path,rect,circle,ellipse,line,polyline,polygon,text]");
|
||||
}
|
||||
if (NULL == elementParser) {
|
||||
if (elementParser == nullptr) {
|
||||
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" allocation error or not supported ...");
|
||||
} else {
|
||||
if (false == elementParser->parse(child, m_transformMatrix, tmpPos)) {
|
||||
SVG_ERROR("(l "<<child->getPos()<<") error on node: \""<<child->getValue()<<"\" Sub Parsing ERROR");
|
||||
delete(elementParser);
|
||||
elementParser = NULL;
|
||||
elementParser = nullptr;
|
||||
} else {
|
||||
_sizeMax.setValue(std::max(_sizeMax.x(), tmpPos.x()),
|
||||
std::max(_sizeMax.y(), tmpPos.y()));
|
||||
|
@ -19,7 +19,7 @@ namespace esvg {
|
||||
public:
|
||||
Group(PaintState _parentPaintState);
|
||||
~Group();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t spacing);
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
|
@ -23,10 +23,10 @@ esvg::Line::~Line() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Line::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
bool esvg::Line::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
// line must have a minimum size...
|
||||
m_paint.strokeWidth = 1;
|
||||
if (NULL == _element) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
parseTransform(_element);
|
||||
|
@ -19,7 +19,7 @@ namespace esvg {
|
||||
public:
|
||||
Line(PaintState _parentPaintState);
|
||||
~Line();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
|
@ -29,17 +29,17 @@ esvg::Path::~Path() {
|
||||
// return the next char position ... (after 'X' or NULL)
|
||||
const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _outputList) {
|
||||
if (*_input == '\0') {
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
_outputList.clear();
|
||||
_cmd = '\0';
|
||||
const char * outputPointer = NULL;
|
||||
const char * outputPointer = nullptr;
|
||||
if (!( ( _input[0] <= 'Z'
|
||||
&& _input[0] >= 'A')
|
||||
|| ( _input[0] <= 'z'
|
||||
&& _input[0] >= 'a') ) ) {
|
||||
SVG_ERROR("Error in the SVG Path : \"" << _input << "\"");
|
||||
return NULL;
|
||||
return nullptr;
|
||||
}
|
||||
_cmd = _input[0];
|
||||
SVG_VERBOSE("Find command : " << _cmd);
|
||||
@ -65,8 +65,8 @@ const char * extractCmd(const char* _input, char& _cmd, std::vector<float>& _out
|
||||
return outputPointer;
|
||||
}
|
||||
|
||||
bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (NULL == _element) {
|
||||
bool esvg::Path::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
parseTransform(_element);
|
||||
@ -89,7 +89,7 @@ bool esvg::Path::parse(exml::Element * _element, agg::trans_affine& _parentTrans
|
||||
const char* elementXML = elementXML1.c_str();
|
||||
|
||||
for( const char *sss=extractCmd(elementXML, command, listDot);
|
||||
NULL != sss;
|
||||
sss != nullptr;
|
||||
sss=extractCmd(sss, command, listDot) ) {
|
||||
PathBasic pathElement;
|
||||
switch(command) {
|
||||
|
@ -42,7 +42,7 @@ namespace esvg {
|
||||
public:
|
||||
Path(PaintState _parentPaintState);
|
||||
~Path();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
private:
|
||||
|
@ -22,8 +22,8 @@ esvg::Polygon::~Polygon() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Polygon::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (NULL == _element) {
|
||||
bool esvg::Polygon::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
parseTransform(_element);
|
||||
|
@ -26,7 +26,7 @@ namespace esvg {
|
||||
public:
|
||||
Polygon(PaintState parentPaintState);
|
||||
~Polygon();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& parentTrans, etk::Vector2D<float>& sizeMax);
|
||||
virtual void display(int32_t spacing);
|
||||
virtual void aggDraw(esvg::Renderer& myRenderer, agg::trans_affine& basicTrans);
|
||||
};
|
||||
|
@ -19,10 +19,10 @@ esvg::Polyline::~Polyline() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Polyline::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
bool esvg::Polyline::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
// line must have a minimum size...
|
||||
m_paint.strokeWidth = 1;
|
||||
if (NULL == _element) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
parseTransform(_element);
|
||||
|
@ -19,7 +19,7 @@ namespace esvg {
|
||||
public:
|
||||
Polyline(PaintState _parentPaintState);
|
||||
~Polyline();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
|
@ -25,8 +25,8 @@ esvg::Rectangle::~Rectangle() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Rectangle::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (NULL == _element) {
|
||||
bool esvg::Rectangle::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
if (_element == nullptr) {
|
||||
return false;
|
||||
}
|
||||
m_position.setValue(0,0);
|
||||
|
@ -20,7 +20,7 @@ namespace esvg {
|
||||
public:
|
||||
Rectangle(PaintState _parentPaintState);
|
||||
~Rectangle();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
virtual void aggDraw(esvg::Renderer& _myRenderer, agg::trans_affine& _basicTrans);
|
||||
};
|
||||
|
@ -20,7 +20,7 @@ esvg::Text::~Text() {
|
||||
|
||||
}
|
||||
|
||||
bool esvg::Text::parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
bool esvg::Text::parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax) {
|
||||
_sizeMax.setValue(0,0);
|
||||
SVG_ERROR("NOT IMPLEMENTED");
|
||||
return false;
|
||||
|
@ -16,7 +16,7 @@ namespace esvg {
|
||||
public:
|
||||
Text(PaintState _parentPaintState);
|
||||
~Text();
|
||||
virtual bool parse(exml::Element * _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual bool parse(const std::shared_ptr<exml::Element>& _element, agg::trans_affine& _parentTrans, etk::Vector2D<float>& _sizeMax);
|
||||
virtual void display(int32_t _spacing);
|
||||
};
|
||||
};
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
|
||||
esvg::Document::Document(const std::string& _fileName) :
|
||||
m_renderedElement(NULL) {
|
||||
m_renderedElement(nullptr) {
|
||||
m_fileName = _fileName;
|
||||
m_version = "0.0";
|
||||
m_loadOK = true;
|
||||
@ -56,15 +56,13 @@ esvg::Document::Document(const std::string& _fileName) :
|
||||
m_loadOK = false;
|
||||
return;
|
||||
}
|
||||
|
||||
if (0 == doc.size() ) {
|
||||
SVG_ERROR("(l ?) No nodes in the xml file ... \"" << m_fileName << "\"");
|
||||
m_loadOK = false;
|
||||
return;
|
||||
}
|
||||
|
||||
exml::Element* root = (exml::Element*)doc.getNamed("svg" );
|
||||
if (NULL == root ) {
|
||||
std::shared_ptr<exml::Element> root = doc.getNamed("svg" );
|
||||
if (root == nullptr) {
|
||||
SVG_ERROR("(l ?) main node not find: \"svg\" in \"" << m_fileName << "\"");
|
||||
m_loadOK = false;
|
||||
return;
|
||||
@ -81,12 +79,12 @@ esvg::Document::Document(const std::string& _fileName) :
|
||||
vec2 size(0,0);
|
||||
// parse all sub node :
|
||||
for(int32_t iii=0; iii< root->size(); iii++) {
|
||||
exml::Element* child = root->getElement(iii);
|
||||
if (child == NULL) {
|
||||
std::shared_ptr<exml::Element> child = root->getElement(iii);
|
||||
if (child == nullptr) {
|
||||
// comment trsh here...
|
||||
continue;
|
||||
}
|
||||
esvg::Base *elementParser = NULL;
|
||||
esvg::Base *elementParser = nullptr;
|
||||
if (child->getValue() == "g") {
|
||||
elementParser = new esvg::Group(m_paint);
|
||||
} else if (child->getValue() == "a") {
|
||||
|
Loading…
x
Reference in New Issue
Block a user