[DEV] Add capacity to the etk::FSNode ==> all is not good, but it is a good start
This commit is contained in:
parent
4ee34e6815
commit
edfe4d2aa6
@ -47,7 +47,7 @@
|
|||||||
#include <agg/agg_color_rgba.h>
|
#include <agg/agg_color_rgba.h>
|
||||||
#include <agg/agg_pixfmt_rgba.h>
|
#include <agg/agg_pixfmt_rgba.h>
|
||||||
|
|
||||||
svg::Parser::Parser(etk::FSNode fileName) : m_renderedElement(NULL)
|
svg::Parser::Parser(etk::UString fileName) : m_renderedElement(NULL)
|
||||||
{
|
{
|
||||||
m_fileName = fileName;
|
m_fileName = fileName;
|
||||||
m_version = "0.0";
|
m_version = "0.0";
|
||||||
@ -66,21 +66,22 @@ svg::Parser::Parser(etk::FSNode fileName) : m_renderedElement(NULL)
|
|||||||
|
|
||||||
// Start loading the XML :
|
// Start loading the XML :
|
||||||
SVG_DEBUG("open file (SVG) \"" << m_fileName << "\"");
|
SVG_DEBUG("open file (SVG) \"" << m_fileName << "\"");
|
||||||
|
etk::FSNode tmpFile(m_fileName);
|
||||||
|
|
||||||
// allocate the document in the stack
|
// allocate the document in the stack
|
||||||
TiXmlDocument XmlDocument;
|
TiXmlDocument XmlDocument;
|
||||||
if (false == m_fileName.Exist()) {
|
if (false == tmpFile.Exist()) {
|
||||||
SVG_ERROR("File Does not exist : " << m_fileName);
|
SVG_ERROR("File Does not exist : " << m_fileName);
|
||||||
m_loadOK = false;
|
m_loadOK = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int32_t fileSize = m_fileName.FileSize();
|
int64_t fileSize = tmpFile.FileSize();
|
||||||
if (0==fileSize) {
|
if (0==fileSize) {
|
||||||
SVG_ERROR("This file is empty : " << m_fileName);
|
SVG_ERROR("This file is empty : " << m_fileName);
|
||||||
m_loadOK = false;
|
m_loadOK = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (false == m_fileName.FileOpenRead()) {
|
if (false == tmpFile.FileOpenRead()) {
|
||||||
SVG_ERROR("Can not open the file : " << m_fileName);
|
SVG_ERROR("Can not open the file : " << m_fileName);
|
||||||
m_loadOK = false;
|
m_loadOK = false;
|
||||||
return;
|
return;
|
||||||
@ -94,9 +95,9 @@ svg::Parser::Parser(etk::FSNode fileName) : m_renderedElement(NULL)
|
|||||||
}
|
}
|
||||||
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
|
memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
|
||||||
// load data from the file :
|
// load data from the file :
|
||||||
m_fileName.FileRead(fileBuffer, 1, fileSize);
|
tmpFile.FileRead(fileBuffer, 1, fileSize);
|
||||||
// close the file:
|
// close the file:
|
||||||
m_fileName.FileClose();
|
tmpFile.FileClose();
|
||||||
// load the XML from the memory
|
// load the XML from the memory
|
||||||
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
|
XmlDocument.Parse((const char*)fileBuffer, 0, TIXML_ENCODING_UTF8);
|
||||||
|
|
||||||
@ -155,8 +156,14 @@ svg::Parser::Parser(etk::FSNode fileName) : m_renderedElement(NULL)
|
|||||||
elementParser = new svg::Polygon(m_paint);
|
elementParser = new svg::Polygon(m_paint);
|
||||||
} else if (localValue == "text") {
|
} else if (localValue == "text") {
|
||||||
elementParser = new svg::Text(m_paint);
|
elementParser = new svg::Text(m_paint);
|
||||||
|
} else if (localValue == "defs") {
|
||||||
|
// Node ignore : must implement it later ...
|
||||||
|
normalNoElement = true;
|
||||||
|
} else if (localValue == "sodipodi:namedview") {
|
||||||
|
// Node ignore : generaly inkscape data
|
||||||
|
normalNoElement = true;
|
||||||
} else if (localValue == "metadata") {
|
} else if (localValue == "metadata") {
|
||||||
// nothing to do : generaly inkscape data
|
// Node ignore : generaly inkscape data
|
||||||
normalNoElement = true;
|
normalNoElement = true;
|
||||||
} else {
|
} else {
|
||||||
SVG_ERROR("(l "<<child->Row()<<") node not suported : \""<<localValue<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
|
SVG_ERROR("(l "<<child->Row()<<") node not suported : \""<<localValue<<"\" must be [title,g,a,path,rect,circle,ellipse,line,polyline,polygon,text,metadata]");
|
||||||
@ -255,7 +262,7 @@ void svg::Parser::GenerateTestFile(void)
|
|||||||
|
|
||||||
AggDraw(*m_renderedElement, basicTrans);
|
AggDraw(*m_renderedElement, basicTrans);
|
||||||
etk::UString tmpFileOut = "yyy_out_";
|
etk::UString tmpFileOut = "yyy_out_";
|
||||||
tmpFileOut += m_fileName.GetNameFile();
|
tmpFileOut += m_fileName;
|
||||||
tmpFileOut += ".ppm";
|
tmpFileOut += ".ppm";
|
||||||
m_renderedElement->WritePpm(tmpFileOut);
|
m_renderedElement->WritePpm(tmpFileOut);
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ namespace svg
|
|||||||
class Parser : public svg::Base
|
class Parser : public svg::Base
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
etk::FSNode m_fileName;
|
etk::UString m_fileName;
|
||||||
bool m_loadOK;
|
bool m_loadOK;
|
||||||
etk::UString m_version;
|
etk::UString m_version;
|
||||||
etk::UString m_title;
|
etk::UString m_title;
|
||||||
@ -44,7 +44,7 @@ namespace svg
|
|||||||
svg::Renderer* m_renderedElement;
|
svg::Renderer* m_renderedElement;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Parser(etk::FSNode fileName);
|
Parser(etk::UString fileName);
|
||||||
~Parser(void);
|
~Parser(void);
|
||||||
bool IsLoadOk(void) { return m_loadOK; };
|
bool IsLoadOk(void) { return m_loadOK; };
|
||||||
void DisplayDebug(void);
|
void DisplayDebug(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user