[DEV] parsing work corectly
This commit is contained in:
parent
7b5c575bb0
commit
e1520b0515
@ -95,7 +95,7 @@ bool exml::EXmlAttribute::Parse(const etk::UString& _data, int32_t& _pos, bool _
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exml::EXmlAttribute::Generate(etk::UString& _data, int32_t _indent)
|
bool exml::EXmlAttribute::Generate(etk::UString& _data, int32_t _indent) const
|
||||||
{
|
{
|
||||||
_data += " ";
|
_data += " ";
|
||||||
_data += m_name;
|
_data += m_name;
|
||||||
|
@ -20,14 +20,16 @@ namespace exml
|
|||||||
EXmlAttribute(void) { };
|
EXmlAttribute(void) { };
|
||||||
EXmlAttribute(const etk::UString& _name, const etk::UString& _value);
|
EXmlAttribute(const etk::UString& _name, const etk::UString& _value);
|
||||||
virtual ~EXmlAttribute(void) { };
|
virtual ~EXmlAttribute(void) { };
|
||||||
virtual nodeType_te GetType(void) { return exml::typeAttribute; };
|
virtual nodeType_te GetType(void) const { return exml::typeAttribute; };
|
||||||
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
||||||
virtual bool Generate(etk::UString& _data, int32_t _indent);
|
virtual bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||||
protected:
|
protected:
|
||||||
etk::UString m_name;
|
etk::UString m_name;
|
||||||
public:
|
public:
|
||||||
virtual void SetName(etk::UString _name) { m_name = _name; };
|
virtual void SetName(etk::UString _name) { m_name = _name; };
|
||||||
virtual const etk::UString& GetName(void) { return m_name; };
|
virtual const etk::UString& GetName(void) const { return m_name; };
|
||||||
|
virtual operator exml::EXmlAttribute* () { return this; };
|
||||||
|
virtual operator const exml::EXmlAttribute* () const { return this; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ bool exml::EXmlComment::Parse(const etk::UString& _data, int32_t& _pos, bool _ca
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exml::EXmlComment::Generate(etk::UString& _data, int32_t _indent)
|
bool exml::EXmlComment::Generate(etk::UString& _data, int32_t _indent) const
|
||||||
{
|
{
|
||||||
AddIndent(_data, _indent);
|
AddIndent(_data, _indent);
|
||||||
_data += "<!--";
|
_data += "<!--";
|
||||||
|
@ -19,9 +19,11 @@ namespace exml
|
|||||||
public:
|
public:
|
||||||
EXmlComment(void) { };
|
EXmlComment(void) { };
|
||||||
virtual ~EXmlComment(void) { };
|
virtual ~EXmlComment(void) { };
|
||||||
virtual nodeType_te GetType(void) { return typeAttribute; };
|
virtual nodeType_te GetType(void) const { return typeAttribute; };
|
||||||
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
||||||
virtual bool Generate(etk::UString& _data, int32_t _indent);
|
virtual bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||||
|
virtual operator exml::EXmlComment* () { return this; };
|
||||||
|
virtual operator const exml::EXmlComment* () const { return this; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,15 +9,17 @@
|
|||||||
#include <exml/EXmlDeclaration.h>
|
#include <exml/EXmlDeclaration.h>
|
||||||
#include <exml/debug.h>
|
#include <exml/debug.h>
|
||||||
|
|
||||||
bool exml::EXmlDeclaration::Generate(etk::UString& _data, int32_t _indent)
|
bool exml::EXmlDeclaration::Generate(etk::UString& _data, int32_t _indent) const
|
||||||
{
|
{
|
||||||
AddIndent(_data, _indent);
|
AddIndent(_data, _indent);
|
||||||
_data += "<?";
|
_data += "<?";
|
||||||
_data += m_name;
|
_data += m_value;
|
||||||
|
/*
|
||||||
if (m_value.Size()!=0) {
|
if (m_value.Size()!=0) {
|
||||||
_data += " ";
|
_data += " ";
|
||||||
_data += m_value;
|
_data += m_value;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
_data += "?>\n";
|
_data += "?>\n";
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -19,10 +19,11 @@ namespace exml
|
|||||||
public:
|
public:
|
||||||
EXmlDeclaration(void) { };
|
EXmlDeclaration(void) { };
|
||||||
virtual ~EXmlDeclaration(void) { };
|
virtual ~EXmlDeclaration(void) { };
|
||||||
virtual nodeType_te GetType(void) { return typeAttribute; };
|
virtual nodeType_te GetType(void) const { return typeAttribute; };
|
||||||
virtual bool Generate(etk::UString& _data, int32_t _indent);
|
virtual bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||||
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
||||||
|
virtual operator exml::EXmlDeclaration* () { return this; };
|
||||||
|
virtual operator const exml::EXmlDeclaration* () const { return this; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ exml::EXmlDocument::EXmlDocument(void) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool exml::EXmlDocument::Generate(etk::UString& _data, int32_t _indent)
|
bool exml::EXmlDocument::Generate(etk::UString& _data, int32_t _indent) const
|
||||||
{
|
{
|
||||||
for (int32_t iii=0; iii<m_listSub.Size(); iii++) {
|
for (int32_t iii=0; iii<m_listSub.Size(); iii++) {
|
||||||
if (NULL!=m_listSub[iii]) {
|
if (NULL!=m_listSub[iii]) {
|
||||||
|
@ -20,17 +20,17 @@ namespace exml
|
|||||||
public:
|
public:
|
||||||
EXmlDocument(void);
|
EXmlDocument(void);
|
||||||
virtual ~EXmlDocument(void) { };
|
virtual ~EXmlDocument(void) { };
|
||||||
virtual nodeType_te GetType(void) { return typeDocument; };
|
virtual nodeType_te GetType(void) const { return typeDocument; };
|
||||||
private:
|
private:
|
||||||
unicode::charset_te m_charset;
|
unicode::charset_te m_charset;
|
||||||
public:
|
public:
|
||||||
virtual void SetCharset(unicode::charset_te _charset) { m_charset = _charset; };
|
virtual void SetCharset(unicode::charset_te _charset) { m_charset = _charset; };
|
||||||
virtual unicode::charset_te GetCharset(void) { return m_charset; };
|
virtual unicode::charset_te GetCharset(void) const { return m_charset; };
|
||||||
private:
|
private:
|
||||||
bool m_caseSensitive;
|
bool m_caseSensitive;
|
||||||
public:
|
public:
|
||||||
virtual void SetCaseSensitive(bool _val) { m_caseSensitive = _val; };
|
virtual void SetCaseSensitive(bool _val) { m_caseSensitive = _val; };
|
||||||
virtual bool GetCaseSensitive(void) { return m_caseSensitive; };
|
virtual bool GetCaseSensitive(void) const { return m_caseSensitive; };
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Parse a string that contain an XML
|
* @brief Parse a string that contain an XML
|
||||||
@ -63,7 +63,9 @@ namespace exml
|
|||||||
|
|
||||||
void Display(void);
|
void Display(void);
|
||||||
bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
||||||
bool Generate(etk::UString& _data, int32_t _indent);
|
bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||||
|
virtual operator exml::EXmlDocument* () { return this; };
|
||||||
|
virtual operator const exml::EXmlDocument* () const { return this; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,6 +22,14 @@ exml::EXmlNode* exml::EXmlElement::GetSub(int32_t _id)
|
|||||||
return m_listSub[_id];
|
return m_listSub[_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const exml::EXmlNode* exml::EXmlElement::GetSub(int32_t _id) const
|
||||||
|
{
|
||||||
|
if (_id <0 || _id>m_listSub.Size()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return m_listSub[_id];
|
||||||
|
}
|
||||||
|
|
||||||
void exml::EXmlElement::AppendSub(exml::EXmlNode* _node)
|
void exml::EXmlElement::AppendSub(exml::EXmlNode* _node)
|
||||||
{
|
{
|
||||||
if (_node == NULL) {
|
if (_node == NULL) {
|
||||||
@ -51,8 +59,29 @@ exml::EXmlNode* exml::EXmlElement::GetNode(const etk::UString& _name)
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
const exml::EXmlNode* exml::EXmlElement::GetNode(const etk::UString& _name) const
|
||||||
|
{
|
||||||
|
if (_name.Size()==0) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
for (int32_t iii=0; iii<m_listSub.Size(); iii++) {
|
||||||
|
if( NULL != m_listSub[iii]
|
||||||
|
&& m_listSub[iii]->GetType() == exml::typeElement
|
||||||
|
&& m_listSub[iii]->GetValue() == _name) {
|
||||||
|
return m_listSub[iii];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
exml::EXmlAttribute* exml::EXmlElement::GetAttribute(int32_t _id)
|
exml::EXmlAttribute* exml::EXmlElement::GetAttr(int32_t _id)
|
||||||
|
{
|
||||||
|
if (_id <0 || _id>m_listAttribute.Size()) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
return m_listAttribute[_id];
|
||||||
|
}
|
||||||
|
const exml::EXmlAttribute* exml::EXmlElement::GetAttr(int32_t _id) const
|
||||||
{
|
{
|
||||||
if (_id <0 || _id>m_listAttribute.Size()) {
|
if (_id <0 || _id>m_listAttribute.Size()) {
|
||||||
return NULL;
|
return NULL;
|
||||||
@ -74,9 +103,9 @@ void exml::EXmlElement::AppendAttribute(exml::EXmlAttribute* _node)
|
|||||||
m_listAttribute.PushBack(_node);
|
m_listAttribute.PushBack(_node);
|
||||||
}
|
}
|
||||||
|
|
||||||
const etk::UString& exml::EXmlElement::GetAttribute(const etk::UString& _name)
|
const etk::UString& exml::EXmlElement::GetAttribute(const etk::UString& _name) const
|
||||||
{
|
{
|
||||||
static const etk::Ustring errorReturn("");
|
static const etk::UString errorReturn("");
|
||||||
if (_name.Size()==0) {
|
if (_name.Size()==0) {
|
||||||
return errorReturn;
|
return errorReturn;
|
||||||
}
|
}
|
||||||
@ -89,11 +118,11 @@ const etk::UString& exml::EXmlElement::GetAttribute(const etk::UString& _name)
|
|||||||
return errorReturn;
|
return errorReturn;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exml::EXmlElement::Generate(etk::UString& _data, int32_t _indent)
|
bool exml::EXmlElement::Generate(etk::UString& _data, int32_t _indent) const
|
||||||
{
|
{
|
||||||
AddIndent(_data, _indent);
|
AddIndent(_data, _indent);
|
||||||
_data += "<";
|
_data += "<";
|
||||||
_data += m_name;
|
_data += m_value;
|
||||||
for (int32_t iii=0; iii<m_listAttribute.Size(); iii++) {
|
for (int32_t iii=0; iii<m_listAttribute.Size(); iii++) {
|
||||||
if (NULL!=m_listAttribute[iii]) {
|
if (NULL!=m_listAttribute[iii]) {
|
||||||
m_listAttribute[iii]->Generate(_data, _indent);
|
m_listAttribute[iii]->Generate(_data, _indent);
|
||||||
@ -118,7 +147,7 @@ bool exml::EXmlElement::Generate(etk::UString& _data, int32_t _indent)
|
|||||||
AddIndent(_data, _indent);
|
AddIndent(_data, _indent);
|
||||||
}
|
}
|
||||||
_data += "</";
|
_data += "</";
|
||||||
_data += m_name;
|
_data += m_value;
|
||||||
_data += ">\n";
|
_data += ">\n";
|
||||||
} else {
|
} else {
|
||||||
_data += "/>\n";
|
_data += "/>\n";
|
||||||
@ -255,7 +284,7 @@ bool exml::EXmlElement::SubParse(const etk::UString& _data, int32_t& _pos, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
EXML_ERROR(_filePos << " ==> end node error : '" << tmpname << "' != '" << m_name << "'");
|
EXML_ERROR(_filePos << " ==> end node error : '" << tmpname << "' != '" << m_value << "'");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -334,7 +363,7 @@ bool exml::EXmlElement::SubParse(const etk::UString& _data, int32_t& _pos, bool
|
|||||||
|
|
||||||
bool exml::EXmlElement::Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos)
|
bool exml::EXmlElement::Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos)
|
||||||
{
|
{
|
||||||
EXML_DEBUG("start parse : 'element' named='" << m_name << "'");
|
EXML_DEBUG("start parse : 'element' named='" << m_value << "'");
|
||||||
// note : When start parsing the upper element must have set the value of the element and set the position after this one
|
// note : When start parsing the upper element must have set the value of the element and set the position after this one
|
||||||
|
|
||||||
// find a normal node ...
|
// find a normal node ...
|
||||||
|
@ -21,26 +21,31 @@ namespace exml
|
|||||||
EXmlElement(void) { };
|
EXmlElement(void) { };
|
||||||
EXmlElement(const etk::UString& _value) : exml::EXmlNode(_value) { };
|
EXmlElement(const etk::UString& _value) : exml::EXmlNode(_value) { };
|
||||||
virtual ~EXmlElement(void) { };
|
virtual ~EXmlElement(void) { };
|
||||||
virtual nodeType_te GetType(void) { return typeElement; };
|
virtual nodeType_te GetType(void) const { return typeElement; };
|
||||||
protected:
|
protected:
|
||||||
etk::Vector<exml::EXmlNode*> m_listSub;
|
etk::Vector<exml::EXmlNode*> m_listSub;
|
||||||
public:
|
public:
|
||||||
int32_t SizeSub(void) const { return m_listSub.Size(); };
|
int32_t SizeSub(void) const { return m_listSub.Size(); };
|
||||||
EXmlNode* GetSub(int32_t _id);
|
|
||||||
void AppendSub(EXmlNode* _node);
|
void AppendSub(EXmlNode* _node);
|
||||||
|
EXmlNode* GetSub(int32_t _id);
|
||||||
|
const EXmlNode* GetSub(int32_t _id) const;
|
||||||
|
EXmlNode* GetNode(const etk::UString& _name);
|
||||||
|
const EXmlNode* GetNode(const etk::UString& _name) const;
|
||||||
protected:
|
protected:
|
||||||
etk::Vector<exml::EXmlAttribute*> m_listAttribute;
|
etk::Vector<exml::EXmlAttribute*> m_listAttribute;
|
||||||
public:
|
public:
|
||||||
int32_t SizeAttribute(void) const { return m_listSub.Size(); };
|
int32_t SizeAttribute(void) const { return m_listSub.Size(); };
|
||||||
EXmlAttribute* GetAttribute(int32_t _id);
|
|
||||||
void AppendAttribute(EXmlAttribute* _node);
|
void AppendAttribute(EXmlAttribute* _node);
|
||||||
|
EXmlAttribute* GetAttr(int32_t _id);
|
||||||
|
const EXmlAttribute* GetAttr(int32_t _id) const;
|
||||||
|
const etk::UString& GetAttribute(const etk::UString& _name) const;
|
||||||
public:
|
public:
|
||||||
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
||||||
virtual bool Generate(etk::UString& _data, int32_t _indent);
|
virtual bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||||
protected:
|
protected:
|
||||||
bool SubParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos, bool _mainNode=false);
|
bool SubParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos, bool _mainNode=false);
|
||||||
|
virtual operator exml::EXmlElement* () { return this; };
|
||||||
const etk::UString& GetAttribute(const etk::UString& _name);
|
virtual operator const exml::EXmlElement* () const { return this; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -11,19 +11,20 @@
|
|||||||
|
|
||||||
|
|
||||||
exml::EXmlNode::EXmlNode(const etk::UString& _value) :
|
exml::EXmlNode::EXmlNode(const etk::UString& _value) :
|
||||||
|
m_pos(0,0),
|
||||||
m_value(_value)
|
m_value(_value)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void exml::EXmlNode::AddIndent(etk::UString& _data, int32_t _indent)
|
void exml::EXmlNode::AddIndent(etk::UString& _data, int32_t _indent) const
|
||||||
{
|
{
|
||||||
for (int32_t iii=0; iii<_indent; iii++) {
|
for (int32_t iii=0; iii<_indent; iii++) {
|
||||||
_data+="\t";
|
_data+="\t";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void exml::EXmlNode::DrawElementParsed(const etk::UniChar& _val, const ivec2& _filePos)
|
void exml::EXmlNode::DrawElementParsed(const etk::UniChar& _val, const ivec2& _filePos) const
|
||||||
{
|
{
|
||||||
if (_val=='\n') {
|
if (_val=='\n') {
|
||||||
EXML_DEBUG(_filePos << " Parse '\\n'");
|
EXML_DEBUG(_filePos << " Parse '\\n'");
|
||||||
@ -36,7 +37,7 @@ void exml::EXmlNode::DrawElementParsed(const etk::UniChar& _val, const ivec2& _f
|
|||||||
|
|
||||||
|
|
||||||
// !"#$%&'()*+,/;<=>?@[\]^`{|}~ ou une espace et ne peut pas commencer par -. ou un chiffre.
|
// !"#$%&'()*+,/;<=>?@[\]^`{|}~ ou une espace et ne peut pas commencer par -. ou un chiffre.
|
||||||
bool exml::EXmlNode::CheckAvaillable(const etk::UniChar& _val, bool _firstChar)
|
bool exml::EXmlNode::CheckAvaillable(const etk::UniChar& _val, bool _firstChar) const
|
||||||
{
|
{
|
||||||
if( _val == '!'
|
if( _val == '!'
|
||||||
|| _val == '"'
|
|| _val == '"'
|
||||||
@ -83,7 +84,7 @@ bool exml::EXmlNode::CheckAvaillable(const etk::UniChar& _val, bool _firstChar)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t exml::EXmlNode::CountWhiteChar(const etk::UString& _data, int32_t _pos)
|
int32_t exml::EXmlNode::CountWhiteChar(const etk::UString& _data, int32_t _pos) const
|
||||||
{
|
{
|
||||||
int32_t white=0;
|
int32_t white=0;
|
||||||
for (int32_t iii=_pos; iii<_data.Size(); iii++) {
|
for (int32_t iii=_pos; iii<_data.Size(); iii++) {
|
||||||
@ -99,62 +100,3 @@ int32_t exml::EXmlNode::CountWhiteChar(const etk::UString& _data, int32_t _pos)
|
|||||||
return white;
|
return white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool IsDocument(void) { return GetType()==exml::typeDocument; };
|
|
||||||
bool IsAttribute(void) { return GetType()==exml::typeAttribute; };
|
|
||||||
bool IsComment(void) { return GetType()==exml::typeComment; };
|
|
||||||
bool IsDeclaration(void) { return GetType()==exml::typeDeclaration; };
|
|
||||||
bool IsElement(void) { return GetType()==exml::typeElement; };
|
|
||||||
bool IsText(void) { return GetType()==exml::typeText; };
|
|
||||||
|
|
||||||
|
|
||||||
exml::EXmlDocument* exml::EXmlNode::ToDocument(void)
|
|
||||||
{
|
|
||||||
if (GetType()==exml::typeDocument) {
|
|
||||||
return static_cast<exml::*>(*this);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
exml::EXmlAttribute* exml::EXmlNode::ToAttribute(void)
|
|
||||||
{
|
|
||||||
if (GetType()==exml::typeDocument) {
|
|
||||||
return static_cast<exml::EXmlAttribute*>(*this);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
exml::EXmlComment* exml::EXmlNode::ToComment(void)
|
|
||||||
{
|
|
||||||
if (GetType()==exml::typeDocument) {
|
|
||||||
return static_cast<exml::EXmlComment*>(*this);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
exml::EXmlDeclaration* exml::EXmlNode::ToDeclaration(void)
|
|
||||||
{
|
|
||||||
if (GetType()==exml::typeDocument) {
|
|
||||||
return static_cast<exml::EXmlDeclaration*>(*this);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
exml::EXmlElement* exml::EXmlNode::ToElement(void)
|
|
||||||
{
|
|
||||||
if (GetType()==exml::typeDocument) {
|
|
||||||
return static_cast<exml::EXmlElement*>(*this);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
exml::EXmlText* exml::EXmlNode::ToText(void)
|
|
||||||
{
|
|
||||||
if (GetType()==exml::typeDocument) {
|
|
||||||
return static_cast<exml::EXmlText*>(*this);
|
|
||||||
}
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,42 +35,52 @@ namespace exml
|
|||||||
class EXmlNode
|
class EXmlNode
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EXmlNode(void) { };
|
EXmlNode(void) : m_pos(0,0) { };
|
||||||
EXmlNode(const etk::UString& _value);
|
EXmlNode(const etk::UString& _value);
|
||||||
virtual ~EXmlNode(void) { };
|
virtual ~EXmlNode(void) { };
|
||||||
protected:
|
protected:
|
||||||
void AddIndent(etk::UString& _data, int32_t _indent);
|
void AddIndent(etk::UString& _data, int32_t _indent) const;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Parse the sub nodes and current nodes ...
|
* Parse the sub nodes and current nodes ...
|
||||||
*/
|
*/
|
||||||
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos) = 0;
|
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos) = 0;
|
||||||
virtual bool Generate(etk::UString& _data, int32_t _indent) { return true; };
|
virtual bool Generate(etk::UString& _data, int32_t _indent) const { return true; };
|
||||||
|
private:
|
||||||
|
ivec2 m_pos; // position in the readed file
|
||||||
|
public:
|
||||||
|
const ivec2& Pos(void) { return m_pos; };
|
||||||
protected:
|
protected:
|
||||||
etk::UString m_value;
|
etk::UString m_value;
|
||||||
public:
|
public:
|
||||||
virtual void SetValue(etk::UString _value) { m_value = _value; };
|
virtual void SetValue(etk::UString _value) { m_value = _value; };
|
||||||
virtual const etk::UString& GetValue(void) { return m_value; };
|
virtual const etk::UString& GetValue(void) const { return m_value; };
|
||||||
public:
|
public:
|
||||||
virtual nodeType_te GetType(void) { return typeNode; };
|
virtual nodeType_te GetType(void) const { return typeNode; };
|
||||||
protected:
|
protected:
|
||||||
void DrawElementParsed(const etk::UniChar& _val, const ivec2& _firstChar);
|
void DrawElementParsed(const etk::UniChar& _val, const ivec2& _firstChar) const;
|
||||||
bool CheckAvaillable(const etk::UniChar& _val, bool _firstChar);
|
bool CheckAvaillable(const etk::UniChar& _val, bool _firstChar) const;
|
||||||
int32_t CountWhiteChar(const etk::UString& _data, int32_t _pos);
|
int32_t CountWhiteChar(const etk::UString& _data, int32_t _pos) const;
|
||||||
public:
|
public:
|
||||||
exml::EXmlDocument* ToDocument(void);
|
virtual operator exml::EXmlDocument* () { return NULL; };
|
||||||
exml::EXmlAttribute* ToAttribute(void);
|
virtual operator const exml::EXmlDocument* () const { return NULL; };
|
||||||
exml::EXmlComment* ToComment(void);
|
virtual operator exml::EXmlAttribute* () { return NULL; };
|
||||||
exml::EXmlDeclaration* ToDeclaration(void);
|
virtual operator const exml::EXmlAttribute* () const { return NULL; };
|
||||||
exml::EXmlElement* ToElement(void);
|
virtual operator exml::EXmlComment* () { return NULL; };
|
||||||
exml::EXmlText* ToText(void);
|
virtual operator const exml::EXmlComment* () const { return NULL; };
|
||||||
|
virtual operator exml::EXmlDeclaration* () { return NULL; };
|
||||||
|
virtual operator const exml::EXmlDeclaration* () const { return NULL; };
|
||||||
|
virtual operator exml::EXmlElement* () { return NULL; };
|
||||||
|
virtual operator const exml::EXmlElement* () const { return NULL; };
|
||||||
|
virtual operator exml::EXmlText* () { return NULL; };
|
||||||
|
virtual operator const exml::EXmlText* () const{ return NULL; };
|
||||||
|
|
||||||
bool IsDocument(void) { return GetType()==exml::typeDocument; };
|
bool IsDocument(void) const { return GetType()==exml::typeDocument; };
|
||||||
bool IsAttribute(void) { return GetType()==exml::typeAttribute; };
|
bool IsAttribute(void) const { return GetType()==exml::typeAttribute; };
|
||||||
bool IsComment(void) { return GetType()==exml::typeComment; };
|
bool IsComment(void) const { return GetType()==exml::typeComment; };
|
||||||
bool IsDeclaration(void) { return GetType()==exml::typeDeclaration; };
|
bool IsDeclaration(void) const { return GetType()==exml::typeDeclaration; };
|
||||||
bool IsElement(void) { return GetType()==exml::typeElement; };
|
bool IsElement(void) const { return GetType()==exml::typeElement; };
|
||||||
bool IsText(void) { return GetType()==exml::typeText; };
|
bool IsText(void) const { return GetType()==exml::typeText; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -9,13 +9,13 @@
|
|||||||
#include <exml/EXmlText.h>
|
#include <exml/EXmlText.h>
|
||||||
#include <exml/debug.h>
|
#include <exml/debug.h>
|
||||||
|
|
||||||
bool exml::EXmlText::Generate(etk::UString& _data, int32_t _indent)
|
bool exml::EXmlText::Generate(etk::UString& _data, int32_t _indent) const
|
||||||
{
|
{
|
||||||
_data += m_value;
|
_data += m_value;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t exml::EXmlText::CountLines(void)
|
int32_t exml::EXmlText::CountLines(void) const
|
||||||
{
|
{
|
||||||
int32_t count = 1;
|
int32_t count = 1;
|
||||||
for (int32_t iii=0; iii<m_value.Size(); iii++) {
|
for (int32_t iii=0; iii<m_value.Size(); iii++) {
|
||||||
|
@ -19,10 +19,12 @@ namespace exml
|
|||||||
public:
|
public:
|
||||||
EXmlText(void) { };
|
EXmlText(void) { };
|
||||||
virtual ~EXmlText(void) { };
|
virtual ~EXmlText(void) { };
|
||||||
virtual nodeType_te GetType(void) { return typeText; };
|
virtual nodeType_te GetType(void) const { return typeText; };
|
||||||
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
virtual bool Parse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, ivec2& _filePos);
|
||||||
virtual bool Generate(etk::UString& _data, int32_t _indent);
|
virtual bool Generate(etk::UString& _data, int32_t _indent) const;
|
||||||
int32_t CountLines(void);
|
int32_t CountLines(void) const;
|
||||||
|
virtual operator exml::EXmlText* () { return this; };
|
||||||
|
virtual operator const exml::EXmlText* () const { return this; };
|
||||||
};
|
};
|
||||||
class EXmlTextCDATA : public EXmlText
|
class EXmlTextCDATA : public EXmlText
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user