[DEV] integarate std x11

This commit is contained in:
Edouard DUPIN 2013-11-11 20:19:09 +01:00
parent c9f7abcd96
commit 2325808997
17 changed files with 256 additions and 255 deletions

View File

@ -13,13 +13,13 @@
#undef __class__ #undef __class__
#define __class__ "Attribute" #define __class__ "Attribute"
exml::Attribute::Attribute(const etk::UString& _name, const etk::UString& _value) : exml::Attribute::Attribute(const std::u32string& _name, const std::u32string& _value) :
exml::Node(_value), exml::Node(_value),
m_name(_name) { m_name(_name) {
} }
bool exml::Attribute::iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_VERBOSE("start parse : 'attribute'"); EXML_VERBOSE("start parse : 'attribute'");
m_pos = _filePos; m_pos = _filePos;
// search end of the comment : // search end of the comment :
@ -35,27 +35,27 @@ bool exml::Attribute::iParse(const etk::UString& _data, int32_t& _pos, bool _cas
break; break;
} }
} }
m_name = _data.extract(_pos, lastElementName+1); m_name = std::u32string(_data, _pos, lastElementName+1);
if (true == _caseSensitive) { if (true == _caseSensitive) {
m_name.lower(); m_name = to_lower(m_name);
} }
// count white space : // count white space :
exml::filePos tmpPos; exml::filePos tmpPos;
int32_t white = countWhiteChar(_data, lastElementName+1, tmpPos); int32_t white = countWhiteChar(_data, lastElementName+1, tmpPos);
_filePos += tmpPos; _filePos += tmpPos;
if (lastElementName+white+1>=_data.size()) { if (lastElementName+white+1 >= _data.size()) {
CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, " parse an xml end with an attribute parsing..."); CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, U" parse an xml end with an attribute parsing...");
return false; return false;
} }
if (_data[lastElementName+white+1] != '=') { if (_data[lastElementName+white+1] != '=') {
CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, " error attribute parsing == > missing '=' ..."); CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, U" error attribute parsing == > missing '=' ...");
return false; return false;
} }
white += countWhiteChar(_data, lastElementName+white+2, tmpPos); white += countWhiteChar(_data, lastElementName+white+2, tmpPos);
_filePos += tmpPos; _filePos += tmpPos;
if (lastElementName+white+2>=_data.size()) { if (lastElementName+white+2>=_data.size()) {
CREATE_ERROR(_doc, _data, lastElementName+white+2, _filePos, " parse an xml end with an attribute parsing..."); CREATE_ERROR(_doc, _data, lastElementName+white+2, _filePos, U" parse an xml end with an attribute parsing...");
return false; return false;
} }
if (_data[lastElementName+white+2] != '"') { if (_data[lastElementName+white+2] != '"') {
@ -67,19 +67,19 @@ bool exml::Attribute::iParse(const etk::UString& _data, int32_t& _pos, bool _cas
drawElementParsed(_data[iii], _filePos); drawElementParsed(_data[iii], _filePos);
#endif #endif
if (_filePos.check(_data[iii]) == true) { if (_filePos.check(_data[iii]) == true) {
CREATE_ERROR(_doc, _data, iii, _filePos, "unexpected '\\n' in an attribute parsing"); CREATE_ERROR(_doc, _data, iii, _filePos, U"unexpected '\\n' in an attribute parsing");
return false; return false;
} }
if( _data[iii]!=' ' if( _data[iii] != ' '
&& _data[iii]!='/' && _data[iii] != '/'
&& _data[iii]!='?' && _data[iii] != '?'
&& _data[iii]!='>') { && _data[iii] != '>') {
lastAttributePos = iii+1; lastAttributePos = iii+1;
} else { } else {
break; break;
} }
} }
m_value = _data.extract(lastElementName+white+2, lastAttributePos); m_value = std::u32string(_data, lastElementName+white+2, lastAttributePos);
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\""); EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -92,13 +92,13 @@ bool exml::Attribute::iParse(const etk::UString& _data, int32_t& _pos, bool _cas
drawElementParsed(_data[iii], _filePos); drawElementParsed(_data[iii], _filePos);
#endif #endif
_filePos.check(_data[iii]); _filePos.check(_data[iii]);
if(_data[iii]!='"') { if(_data[iii] != '"') {
lastAttributePos = iii+1; lastAttributePos = iii+1;
} else { } else {
break; break;
} }
} }
m_value = _data.extract(lastElementName+white+3, lastAttributePos); m_value = std::u32string(_data, lastElementName+white+3, lastAttributePos);
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\""); EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -106,16 +106,16 @@ bool exml::Attribute::iParse(const etk::UString& _data, int32_t& _pos, bool _cas
return true; return true;
} }
bool exml::Attribute::iGenerate(etk::UString& _data, int32_t _indent) const { bool exml::Attribute::iGenerate(std::u32string& _data, int32_t _indent) const {
_data += " "; _data += U" ";
_data += m_name; _data += m_name;
_data += "=\""; _data += U"=\"";
_data += m_value; _data += m_value;
_data += "\""; _data += U"\"";
return true; return true;
} }
void exml::Attribute::clear(void) { void exml::Attribute::clear(void) {
m_name=""; m_name = U"";
} }

View File

@ -10,7 +10,7 @@
#define __ETK_XML_ATTRIBUTE_H__ #define __ETK_XML_ATTRIBUTE_H__
#include <exml/Node.h> #include <exml/Node.h>
#include <etk/Vector.h> #include <vector>
namespace exml { namespace exml {
class Attribute : public Node { class Attribute : public Node {
@ -24,34 +24,34 @@ namespace exml {
* @param[in] _name Name of the attribute. * @param[in] _name Name of the attribute.
* @param[in] _value Value of the attribute. * @param[in] _value Value of the attribute.
*/ */
Attribute(const etk::UString& _name, const etk::UString& _value); Attribute(const std::u32string& _name, const std::u32string& _value);
/** /**
* @brief Destructor * @brief Destructor
*/ */
virtual ~Attribute(void) { }; virtual ~Attribute(void) { };
protected: protected:
etk::UString m_name; std::u32string m_name;
public: public:
/** /**
* @brief set the name of the attribute * @brief set the name of the attribute
* @param[in] _name New name of the attribute * @param[in] _name New name of the attribute
*/ */
virtual void setName(etk::UString _name) { virtual void setName(std::u32string _name) {
m_name = _name; m_name = _name;
}; };
/** /**
* @brief get the current name of the Attribute * @brief get the current name of the Attribute
* @return String of the attribute * @return String of the attribute
*/ */
virtual const etk::UString& getName(void) const { virtual const std::u32string& getName(void) const {
return m_name; return m_name;
}; };
public: // herited function: public: // herited function:
virtual enum nodeType getType(void) const { virtual enum nodeType getType(void) const {
return exml::typeAttribute; return exml::typeAttribute;
}; };
virtual bool iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc); virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual exml::Attribute* toAttribute(void) { virtual exml::Attribute* toAttribute(void) {
return this; return this;
}; };

View File

@ -47,11 +47,11 @@ void exml::AttributeList::appendAttribute(exml::Attribute* _attr) {
return; return;
} }
} }
m_listAttribute.pushBack(_attr); m_listAttribute.push_back(_attr);
} }
const etk::UString& exml::AttributeList::getAttribute(const etk::UString& _name) const { const std::u32string& exml::AttributeList::getAttribute(const std::u32string& _name) const {
static const etk::UString errorReturn(""); static const std::u32string errorReturn(U"");
if (_name.size() == 0) { if (_name.size() == 0) {
return errorReturn; return errorReturn;
} }
@ -64,7 +64,7 @@ const etk::UString& exml::AttributeList::getAttribute(const etk::UString& _name)
return errorReturn; return errorReturn;
} }
bool exml::AttributeList::existAttribute(const etk::UString& _name) const { bool exml::AttributeList::existAttribute(const std::u32string& _name) const {
if (_name.size() == 0) { if (_name.size() == 0) {
return false; return false;
} }
@ -77,7 +77,7 @@ bool exml::AttributeList::existAttribute(const etk::UString& _name) const {
return false; return false;
} }
void exml::AttributeList::setAttribute(const etk::UString& _name, const etk::UString& _value) { void exml::AttributeList::setAttribute(const std::u32string& _name, const std::u32string& _value) {
// check if attribute already det : // check if attribute already det :
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]
@ -91,10 +91,10 @@ void exml::AttributeList::setAttribute(const etk::UString& _name, const etk::USt
if (NULL == attr) { if (NULL == attr) {
EXML_ERROR("memory allocation error..."); EXML_ERROR("memory allocation error...");
} }
m_listAttribute.pushBack(attr); m_listAttribute.push_back(attr);
} }
bool exml::AttributeList::iGenerate(etk::UString& _data, int32_t _indent) const { bool exml::AttributeList::iGenerate(std::u32string& _data, int32_t _indent) const {
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]->iGenerate(_data, _indent); m_listAttribute[iii]->iGenerate(_data, _indent);

View File

@ -10,7 +10,7 @@
#define __ETK_XML_ATTRIBUTE_LIST_H__ #define __ETK_XML_ATTRIBUTE_LIST_H__
#include <exml/Node.h> #include <exml/Node.h>
#include <etk/Vector.h> #include <vector>
#include <exml/Attribute.h> #include <exml/Attribute.h>
namespace exml { namespace exml {
@ -24,7 +24,7 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _value Node value; * @param[in] _value Node value;
*/ */
AttributeList(const etk::UString& _value) : AttributeList(const std::u32string& _value) :
exml::Node(_value) { exml::Node(_value) {
}; };
@ -33,7 +33,7 @@ namespace exml {
*/ */
virtual ~AttributeList(void); virtual ~AttributeList(void);
protected: protected:
etk::Vector<exml::Attribute*> m_listAttribute; //!< list of all attribute std::vector<exml::Attribute*> m_listAttribute; //!< list of all attribute
public: public:
/** /**
* @brief get the number of attribute in the Node * @brief get the number of attribute in the Node
@ -59,21 +59,21 @@ namespace exml {
* @param[in] _name Attribute Name. * @param[in] _name Attribute Name.
* @return Value of the attribute or no data in the string * @return Value of the attribute or no data in the string
*/ */
const etk::UString& getAttribute(const etk::UString& _name) const; const std::u32string& getAttribute(const std::u32string& _name) const;
/** /**
* @brief check if an attribute exist or not with his name. * @brief check if an attribute exist or not with his name.
* @param[in] _name Attribute Name. * @param[in] _name Attribute Name.
* @return true if the attribute exist or False * @return true if the attribute exist or False
*/ */
bool existAttribute(const etk::UString& _name) const; bool existAttribute(const std::u32string& _name) const;
/** /**
* @brief Sen A new attribute or replace data of the previous one * @brief Sen A new attribute or replace data of the previous one
* @param[in] _name Name of the attribute * @param[in] _name Name of the attribute
* @param[in] _value Value of the attribute * @param[in] _value Value of the attribute
*/ */
void setAttribute(const etk::UString& _name, const etk::UString& _value); void setAttribute(const std::u32string& _name, const std::u32string& _value);
public: // herited function: public: // herited function:
bool iGenerate(etk::UString& _data, int32_t _indent) const; bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual void clear(void); virtual void clear(void);
}; };
}; };

View File

@ -13,7 +13,7 @@
#undef __class__ #undef __class__
#define __class__ "Comment" #define __class__ "Comment"
bool exml::Comment::iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::Comment::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_VERBOSE("start parse : 'comment'"); EXML_VERBOSE("start parse : 'comment'");
m_pos = _filePos; m_pos = _filePos;
exml::filePos tmpPos; exml::filePos tmpPos;
@ -34,28 +34,28 @@ bool exml::Comment::iParse(const etk::UString& _data, int32_t& _pos, bool _caseS
// search whitespace : // search whitespace :
int32_t newEnd=iii; int32_t newEnd=iii;
for( int32_t jjj=iii-1; jjj>_pos; jjj--) { for( int32_t jjj=iii-1; jjj>_pos; jjj--) {
if(true == _data[jjj].isWhiteChar()) { if(true == etk::isWhiteChar(_data[jjj])) {
newEnd = jjj; newEnd = jjj;
} else { } else {
break; break;
} }
} }
// find end of value: // find end of value:
m_value = _data.extract(_pos+white, newEnd); m_value = std::u32string(_data, _pos+white, newEnd);
EXML_VERBOSE(" find comment '" << m_value << "'"); EXML_VERBOSE(" find comment '" << m_value << "'");
_pos = iii+2; _pos = iii+2;
return true; return true;
} }
} }
_pos = _data.size(); _pos = _data.size();
CREATE_ERROR(_doc, _data, _pos, _filePos, "comment got end of file without finding end node"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"comment got end of file without finding end node");
return false; return false;
} }
bool exml::Comment::iGenerate(etk::UString& _data, int32_t _indent) const { bool exml::Comment::iGenerate(std::u32string& _data, int32_t _indent) const {
addIndent(_data, _indent); addIndent(_data, _indent);
_data += "<!--"; _data += U"<!--";
_data += m_value; _data += m_value;
_data += "-->\n"; _data += U"-->\n";
return true; return true;
} }

View File

@ -10,7 +10,7 @@
#define __ETK_XML_COMMENT_H__ #define __ETK_XML_COMMENT_H__
#include <exml/Node.h> #include <exml/Node.h>
#include <etk/Vector.h> #include <vector>
namespace exml { namespace exml {
class Comment : public Node { class Comment : public Node {
@ -23,7 +23,7 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _value comment value * @param[in] _value comment value
*/ */
Comment(const etk::UString& _value) : Comment(const std::u32string& _value) :
exml::Node(_value) { exml::Node(_value) {
}; };
@ -35,8 +35,8 @@ namespace exml {
virtual enum nodeType getType(void) const { virtual enum nodeType getType(void) const {
return typeAttribute; return typeAttribute;
}; };
virtual bool iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc); virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual exml::Comment* toComment(void) { virtual exml::Comment* toComment(void) {
return this; return this;
}; };

View File

@ -20,34 +20,34 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
*/ */
exml::DeclarationXML::DeclarationXML(const etk::UString& _version, enum unicode::charset _format, bool _standalone) : exml::DeclarationXML::DeclarationXML(const std::u32string& _version, enum unicode::charset _format, bool _standalone) :
exml::Declaration("xml") { exml::Declaration(U"xml") {
if (_version.size()!=0) { if (_version.size()!=0) {
setAttribute("version", _version); setAttribute(U"version", _version);
} }
if (_format!=unicode::charsetUTF8) { if (_format!=unicode::charsetUTF8) {
setAttribute("encoding", "UTF-8"); setAttribute(U"encoding", U"UTF-8");
} else { } else {
EXML_ERROR("Actually does not supported other charset than UTF8"); EXML_ERROR("Actually does not supported other charset than UTF8");
setAttribute("encoding", "UTF-8"); setAttribute(U"encoding", U"UTF-8");
} }
if (_standalone == true) { if (_standalone == true) {
setAttribute("standalone", "true"); setAttribute(U"standalone", U"true");
} else { } else {
setAttribute("standalone", "true"); setAttribute(U"standalone", U"true");
} }
} }
bool exml::Declaration::iGenerate(etk::UString& _data, int32_t _indent) const { bool exml::Declaration::iGenerate(std::u32string& _data, int32_t _indent) const {
addIndent(_data, _indent); addIndent(_data, _indent);
_data += "<?"; _data += U"<?";
_data += m_value; _data += m_value;
exml::AttributeList::iGenerate(_data, _indent); exml::AttributeList::iGenerate(_data, _indent);
_data += "?>\n"; _data += U"?>\n";
return true; return true;
} }
bool exml::Declaration::iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::Declaration::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_VERBOSE("start parse : 'declaration' : '" << m_value << "'"); EXML_VERBOSE("start parse : 'declaration' : '" << m_value << "'");
m_pos = _filePos; m_pos = _filePos;
// search end of the comment : // search end of the comment :
@ -61,7 +61,7 @@ bool exml::Declaration::iParse(const etk::UString& _data, int32_t& _pos, bool _c
if( _data[iii] == '>' if( _data[iii] == '>'
|| _data[iii] == '<') { || _data[iii] == '<') {
// an error occured : // an error occured :
CREATE_ERROR(_doc, _data, _pos, _filePos, " find '>' or '<' instead of '?>'"); CREATE_ERROR(_doc, _data, _pos, _filePos, U" find '>' or '<' instead of '?>'");
return false; return false;
} }
if( _data[iii] == '?' if( _data[iii] == '?'
@ -75,7 +75,7 @@ bool exml::Declaration::iParse(const etk::UString& _data, int32_t& _pos, bool _c
// we find an attibute == > create a new and parse it : // we find an attibute == > create a new and parse it :
exml::Attribute* attribute = new exml::Attribute(); exml::Attribute* attribute = new exml::Attribute();
if (NULL == attribute) { if (NULL == attribute) {
CREATE_ERROR(_doc, _data, _pos, _filePos, " Allocation error ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U" Allocation error ...");
return false; return false;
} }
_pos = iii; _pos = iii;
@ -84,11 +84,11 @@ bool exml::Declaration::iParse(const etk::UString& _data, int32_t& _pos, bool _c
return false; return false;
} }
iii = _pos; iii = _pos;
m_listAttribute.pushBack(attribute); m_listAttribute.push_back(attribute);
continue; continue;
} }
} }
CREATE_ERROR(_doc, _data, _pos, _filePos, "Text got end of file without finding end node"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Text got end of file without finding end node");
_pos = _data.size(); _pos = _data.size();
return false; return false;
} }

View File

@ -10,6 +10,7 @@
#define __ETK_XML_DECLARATION_H__ #define __ETK_XML_DECLARATION_H__
#include <exml/AttributeList.h> #include <exml/AttributeList.h>
#include <etk/unicode.h>
namespace exml { namespace exml {
class Declaration : public exml::AttributeList { class Declaration : public exml::AttributeList {
@ -22,7 +23,7 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _name name of the declaration (xml, xml:xxxx ...) * @param[in] _name name of the declaration (xml, xml:xxxx ...)
*/ */
Declaration(const etk::UString& _name) : Declaration(const std::u32string& _name) :
exml::AttributeList(_name) { exml::AttributeList(_name) {
}; };
@ -34,8 +35,8 @@ namespace exml {
virtual enum nodeType getType(void) const { virtual enum nodeType getType(void) const {
return typeAttribute; return typeAttribute;
}; };
virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual bool iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc); virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual exml::Declaration* toDeclaration(void) { virtual exml::Declaration* toDeclaration(void) {
return this; return this;
}; };
@ -51,7 +52,7 @@ namespace exml {
* @param[in] _format charset of the XML * @param[in] _format charset of the XML
* @param[in] _standalone this document is standalone * @param[in] _standalone this document is standalone
*/ */
DeclarationXML(const etk::UString& _version, enum unicode::charset _format=unicode::charsetUTF8, bool _standalone=true); DeclarationXML(const std::u32string& _version, enum unicode::charset _format=unicode::charsetUTF8, bool _standalone=true);
/** /**
* @brief Destructor * @brief Destructor
*/ */

View File

@ -17,14 +17,14 @@ exml::Document::Document(void) :
m_charset(unicode::charsetUTF8), m_charset(unicode::charsetUTF8),
m_caseSensitive(false), m_caseSensitive(false),
m_writeErrorWhenDetexted(true), m_writeErrorWhenDetexted(true),
m_comment(""), m_comment(U""),
m_Line(""), m_Line(U""),
m_filePos(0,0) { m_filePos(0,0) {
} }
bool exml::Document::iGenerate(etk::UString& _data, int32_t _indent) const { bool exml::Document::iGenerate(std::u32string& _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]) {
m_listSub[iii]->iGenerate(_data, _indent); m_listSub[iii]->iGenerate(_data, _indent);
@ -33,7 +33,7 @@ bool exml::Document::iGenerate(etk::UString& _data, int32_t _indent) const {
return true; return true;
} }
bool exml::Document::parse(const etk::UString& _data) { bool exml::Document::parse(const std::u32string& _data) {
EXML_VERBOSE("Start parsing document (type: string) size=" << _data.size()); EXML_VERBOSE("Start parsing document (type: string) size=" << _data.size());
clear(); clear();
// came from char == > force in utf8 ... // came from char == > force in utf8 ...
@ -44,12 +44,12 @@ bool exml::Document::parse(const etk::UString& _data) {
return subParse(_data, parsePos, m_caseSensitive, filePos, *this, true); return subParse(_data, parsePos, m_caseSensitive, filePos, *this, true);
} }
bool exml::Document::generate(etk::UString& _data) { bool exml::Document::generate(std::u32string& _data) {
_data = ""; _data = U"";
return iGenerate(_data,0); return iGenerate(_data,0);
} }
bool exml::Document::load(const etk::UString& _file) { bool exml::Document::load(const std::u32string& _file) {
// Start loading the XML : // Start loading the XML :
EXML_VERBOSE("open file (xml) \"" << _file << "\""); EXML_VERBOSE("open file (xml) \"" << _file << "\"");
clear(); clear();
@ -81,7 +81,7 @@ bool exml::Document::load(const etk::UString& _file) {
tmpFile.fileClose(); tmpFile.fileClose();
// convert in UTF8 : // convert in UTF8 :
etk::UString tmpDataUnicode(fileBuffer, unicode::charsetUTF8); std::u32string tmpDataUnicode(to_u32string(fileBuffer));
// remove temporary buffer: // remove temporary buffer:
delete(fileBuffer); delete(fileBuffer);
// parse the data : // parse the data :
@ -90,8 +90,8 @@ bool exml::Document::load(const etk::UString& _file) {
return ret; return ret;
} }
bool exml::Document::store(const etk::UString& _file) { bool exml::Document::store(const std::u32string& _file) {
etk::UString createData; std::u32string createData;
if (false == generate(createData)) { if (false == generate(createData)) {
EXML_ERROR("Error while creating the XML : " << _file); EXML_ERROR("Error while creating the XML : " << _file);
return false; return false;
@ -101,8 +101,8 @@ bool exml::Document::store(const etk::UString& _file) {
EXML_ERROR("Can not open (w) the file : " << _file); EXML_ERROR("Can not open (w) the file : " << _file);
return false; return false;
} }
etk::Char endTable = createData.c_str(); std::string endTable = to_u8string(createData);
if (tmpFile.fileWrite(endTable, sizeof(char), endTable.size()) != endTable.size()) { if (tmpFile.fileWrite((char*)endTable.c_str(), sizeof(char), endTable.size()) != endTable.size()) {
EXML_ERROR("Error while writing output XML file : " << _file); EXML_ERROR("Error while writing output XML file : " << _file);
tmpFile.fileClose(); tmpFile.fileClose();
return false; return false;
@ -112,25 +112,25 @@ bool exml::Document::store(const etk::UString& _file) {
} }
void exml::Document::display(void) { void exml::Document::display(void) {
etk::UString tmpp; std::u32string tmpp;
iGenerate(tmpp, 0); iGenerate(tmpp, 0);
EXML_INFO("Generated XML : \n" << tmpp); EXML_INFO("Generated XML : \n" << tmpp);
} }
etk::UString createPosPointer(const etk::UString& _line, int32_t _pos) { std::u32string createPosPointer(const std::u32string& _line, int32_t _pos) {
etk::UString out; std::u32string out;
int32_t iii; int32_t iii;
for (iii=0; iii<_pos && iii<_line.size(); iii++) { for (iii=0; iii<_pos && iii<_line.size(); iii++) {
if (_line[iii] == '\t') { if (_line[iii] == '\t') {
out += "\t"; out += U"\t";
} else { } else {
out += " "; out += U" ";
} }
} }
for (; iii<_pos; iii++) { for (; iii<_pos; iii++) {
out += " "; out += U" ";
} }
out += "^"; out += U"^";
return out; return out;
} }
@ -147,9 +147,9 @@ void exml::Document::displayError(void) {
#endif #endif
} }
void exml::Document::createError(const etk::UString& _data, int32_t _pos, const exml::filePos& _filePos, const etk::UString& _comment) { void exml::Document::createError(const std::u32string& _data, int32_t _pos, const exml::filePos& _filePos, const std::u32string& _comment) {
m_comment = _comment; m_comment = _comment;
m_Line = _data.extractLine(_pos); m_Line = extract_line(_data, _pos);
m_filePos = _filePos; m_filePos = _filePos;
if (true == m_writeErrorWhenDetexted) { if (true == m_writeErrorWhenDetexted) {
displayError(); displayError();

View File

@ -11,7 +11,7 @@
#include <exml/Element.h> #include <exml/Element.h>
#include <etk/unicode.h> #include <etk/unicode.h>
#include <etk/Vector.h> #include <vector>
namespace exml { namespace exml {
class Document : public exml::Element { class Document : public exml::Element {
@ -65,36 +65,36 @@ namespace exml {
* @return false : An error occured * @return false : An error occured
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool parse(const etk::UString& _data); bool parse(const std::u32string& _data);
/** /**
* @brief generate a string that contain the created XML * @brief generate a string that contain the created XML
* @param[out] _data Data where the xml is stored * @param[out] _data Data where the xml is stored
* @return false : An error occured * @return false : An error occured
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool generate(etk::UString& _data); bool generate(std::u32string& _data);
/** /**
* @brief Load the file that might contain the xml * @brief Load the file that might contain the xml
* @param[in] _file Filename of the xml (compatible with etk FSNode naming) * @param[in] _file Filename of the xml (compatible with etk FSNode naming)
* @return false : An error occured * @return false : An error occured
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool load(const etk::UString& _file); bool load(const std::u32string& _file);
/** /**
* @brief Store the Xml in the file * @brief Store the Xml in the file
* @param[in] _file Filename of the xml (compatible with etk FSNode naming) * @param[in] _file Filename of the xml (compatible with etk FSNode naming)
* @return false : An error occured * @return false : An error occured
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool store(const etk::UString& _file); bool store(const std::u32string& _file);
/** /**
* @brief Display the Document on console * @brief Display the Document on console
*/ */
void display(void); void display(void);
private: private:
bool m_writeErrorWhenDetexted; bool m_writeErrorWhenDetexted;
etk::UString m_comment; std::u32string m_comment;
etk::UString m_Line; std::u32string m_Line;
exml::filePos m_filePos; exml::filePos m_filePos;
public: public:
void displayErrorWhenDetected(void) { void displayErrorWhenDetected(void) {
@ -104,13 +104,13 @@ namespace exml {
m_writeErrorWhenDetexted = false; m_writeErrorWhenDetexted = false;
}; };
void createError(const etk::UString& _data, int32_t _pos, const exml::filePos& _filePos, const etk::UString& _comment); void createError(const std::u32string& _data, int32_t _pos, const exml::filePos& _filePos, const std::u32string& _comment);
void displayError(void); void displayError(void);
public: // herited function: public: // herited function:
virtual enum nodeType getType(void) const { virtual enum nodeType getType(void) const {
return typeDocument; return typeDocument;
}; };
bool iGenerate(etk::UString& _data, int32_t _indent) const; bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual exml::Document* toDocument(void) { virtual exml::Document* toDocument(void) {
return this; return this;
}; };

View File

@ -74,7 +74,7 @@ const exml::Element* exml::Element::getElement(int32_t _id) const {
return tmpp->toElement(); return tmpp->toElement();
} }
exml::Element* exml::Element::getNamed(const etk::UString& _name) { exml::Element* exml::Element::getNamed(const std::u32string& _name) {
if (_name.size() == 0) { if (_name.size() == 0) {
return NULL; return NULL;
} }
@ -91,7 +91,7 @@ exml::Element* exml::Element::getNamed(const etk::UString& _name) {
return NULL; return NULL;
} }
const exml::Element* exml::Element::getNamed(const etk::UString& _name) const { const exml::Element* exml::Element::getNamed(const std::u32string& _name) const {
if (_name.size() == 0) { if (_name.size() == 0) {
return NULL; return NULL;
} }
@ -123,12 +123,12 @@ void exml::Element::append(exml::Node* _node) {
return; return;
} }
} }
m_listSub.pushBack(_node); m_listSub.push_back(_node);
} }
etk::UString exml::Element::getText(void) { std::u32string exml::Element::getText(void) {
// TODO : add more capabilities ... // TODO : add more capabilities ...
etk::UString res; std::u32string res;
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]) {
m_listSub[iii]->iGenerate(res, 0); m_listSub[iii]->iGenerate(res, 0);
@ -137,9 +137,9 @@ etk::UString exml::Element::getText(void) {
return res; return res;
} }
bool exml::Element::iGenerate(etk::UString& _data, int32_t _indent) const { bool exml::Element::iGenerate(std::u32string& _data, int32_t _indent) const {
addIndent(_data, _indent); addIndent(_data, _indent);
_data += "<"; _data += U"<";
_data += m_value; _data += m_value;
exml::AttributeList::iGenerate(_data, _indent); exml::AttributeList::iGenerate(_data, _indent);
@ -148,10 +148,10 @@ bool exml::Element::iGenerate(etk::UString& _data, int32_t _indent) const {
&& m_listSub[0] != NULL && m_listSub[0] != NULL
&& m_listSub[0]->getType() == exml::typeText && m_listSub[0]->getType() == exml::typeText
&& static_cast<exml::Text*>(m_listSub[0])->countLines() == 1) { && static_cast<exml::Text*>(m_listSub[0])->countLines() == 1) {
_data += ">"; _data += U">";
m_listSub[0]->iGenerate(_data,0); m_listSub[0]->iGenerate(_data,0);
} else { } else {
_data += ">\n"; _data += U">\n";
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]) {
@ -160,17 +160,17 @@ bool exml::Element::iGenerate(etk::UString& _data, int32_t _indent) const {
} }
addIndent(_data, _indent); addIndent(_data, _indent);
} }
_data += "</"; _data += U"</";
_data += m_value; _data += m_value;
_data += ">\n"; _data += U">\n";
} else { } else {
_data += "/>\n"; _data += U"/>\n";
} }
return true; return true;
} }
bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode) { bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode) {
EXML_PARSE_ELEMENT(" start subParse ... " << _pos << " " << _filePos); EXML_PARSE_ELEMENT(" start subParse ... " << _pos << " " << _filePos);
for (int32_t iii=_pos; iii<_data.size(); iii++) { for (int32_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]); _filePos.check(_data[iii]);
@ -182,14 +182,14 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
int32_t white = countWhiteChar(_data, iii+1, tmpPos); int32_t white = countWhiteChar(_data, iii+1, tmpPos);
if (iii+white+1>=_data.size()) { if (iii+white+1>=_data.size()) {
_filePos+=tmpPos; _filePos+=tmpPos;
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<' char == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<' char == > invalide XML");
_pos = iii+white; _pos = iii+white;
return false; return false;
} }
// Detect type of the element: // Detect type of the element:
if(_data[iii+white+1] == '>') { if(_data[iii+white+1] == '>') {
_filePos+=tmpPos; _filePos+=tmpPos;
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find '>' with no element in the element..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find '>' with no element in the element...");
_pos = iii+white+1; _pos = iii+white+1;
return false; return false;
} }
@ -197,7 +197,7 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
++tmpPos; ++tmpPos;
// TODO : white space ... // TODO : white space ...
if( false == checkAvaillable(_data[iii+white+2], true) ) { if( false == checkAvaillable(_data[iii+white+2], true) ) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find unavaillable name in the Declaration node..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find unavaillable name in the Declaration node...");
_pos = iii+white+1; _pos = iii+white+1;
return false; return false;
} }
@ -213,14 +213,14 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
} }
tmpPos.check(_data[jjj]); tmpPos.check(_data[jjj]);
} }
etk::UString tmpname = _data.extract(iii+white+2, endPosName+1); std::u32string tmpname = std::u32string(_data, iii+white+2, endPosName+1);
if (true == _caseSensitive) { if (true == _caseSensitive) {
tmpname.lower(); tmpname = to_lower(tmpname);
} }
// Find declaration balise // Find declaration balise
exml::Declaration* declaration = new exml::Declaration(tmpname); exml::Declaration* declaration = new exml::Declaration(tmpname);
if (NULL == declaration) { if (NULL == declaration) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation Error..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation Error...");
return false; return false;
} }
_filePos += tmpPos; _filePos += tmpPos;
@ -230,31 +230,31 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.pushBack(declaration); m_listSub.push_back(declaration);
continue; continue;
} }
if(_data[iii+white+1] == '!') { if(_data[iii+white+1] == '!') {
++tmpPos; ++tmpPos;
// Find special block element // Find special block element
if (iii+white+2>=_data.size()) { if (iii+white+2>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<!' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<!' chars == > invalide XML");
return false; return false;
} }
if(_data[iii+white+2] == '-') { if(_data[iii+white+2] == '-') {
++tmpPos; ++tmpPos;
if (iii+white+3>=_data.size()) { if (iii+white+3>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<!-' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<!-' chars == > invalide XML");
return false; return false;
} }
if(_data[iii+white+3] != '-') { if(_data[iii+white+3] != '-') {
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::UString("Element parse with '<!-") + _data[iii+3] + "' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Element parse with '<!-") + _data[iii+3] + U"' chars == > invalide XML");
return false; return false;
} }
++tmpPos; ++tmpPos;
// find comment: // find comment:
exml::Comment* comment = new exml::Comment(); exml::Comment* comment = new exml::Comment();
if (NULL == comment) { if (NULL == comment) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
return false; return false;
} }
_pos = iii+white+4; _pos = iii+white+4;
@ -264,11 +264,11 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.pushBack(comment); m_listSub.push_back(comment);
} else if (_data[iii+white+2] == '[') { } else if (_data[iii+white+2] == '[') {
++tmpPos; ++tmpPos;
if (iii+white+8>=_data.size()) { if (iii+white+8>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<![' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<![' chars == > invalide XML");
return false; return false;
} }
if( _data[iii+white+3] != 'C' if( _data[iii+white+3] != 'C'
@ -277,14 +277,14 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
|| _data[iii+white+6] != 'T' || _data[iii+white+6] != 'T'
|| _data[iii+white+7] != 'A' || _data[iii+white+7] != 'A'
|| _data[iii+white+8] != '[') { || _data[iii+white+8] != '[') {
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::UString("Element parse with '<![") + _data[iii+white+3] + _data[iii+white+4] + _data[iii+white+5] + _data[iii+white+6] + _data[iii+white+7] + _data[iii+white+8] + "' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Element parse with '<![") + _data[iii+white+3] + _data[iii+white+4] + _data[iii+white+5] + _data[iii+white+6] + _data[iii+white+7] + _data[iii+white+8] + U"' chars == > invalide XML");
return false; return false;
} }
tmpPos+=6; tmpPos+=6;
// find text: // find text:
exml::TextCDATA* text = new exml::TextCDATA(); exml::TextCDATA* text = new exml::TextCDATA();
if (NULL == text) { if (NULL == text) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
return false; return false;
} }
_pos = iii+9+white; _pos = iii+9+white;
@ -294,9 +294,9 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.pushBack(text); m_listSub.push_back(text);
} else { } else {
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::UString("End file with '<!") + _data[iii+white+2] + "' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"End file with '<!") + _data[iii+white+2] + U"' chars == > invalide XML");
return false; return false;
} }
@ -316,9 +316,9 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
} }
tmpPos.check(_data[jjj]); tmpPos.check(_data[jjj]);
} }
etk::UString tmpname = _data.extract(iii+white+2, endPosName+1); std::u32string tmpname = std::u32string(_data, iii+white+2, endPosName+1);
if (true == _caseSensitive) { if (true == _caseSensitive) {
tmpname.lower(); tmpname = to_lower(tmpname);
} }
if( tmpname == m_value) { if( tmpname == m_value) {
// find end of node : // find end of node :
@ -338,18 +338,18 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
&& _data[jjj] != ' ' && _data[jjj] != ' '
&& _data[jjj] != '\t') { && _data[jjj] != '\t') {
_filePos += tmpPos; _filePos += tmpPos;
CREATE_ERROR(_doc, _data, jjj, _filePos, etk::UString("End node error : have data inside end node other than [ \\n\\t\\r] ") + m_value + "'"); CREATE_ERROR(_doc, _data, jjj, _filePos, std::u32string(U"End node error : have data inside end node other than [ \\n\\t\\r] ") + m_value + U"'");
return false; return false;
} }
} }
} else { } else {
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::UString("End node error : '") + tmpname + "' != '" + m_value + "'"); CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"End node error : '") + tmpname + U"' != '" + m_value + U"'");
return false; return false;
} }
} }
if (_data[iii+white+1] == '>') { if (_data[iii+white+1] == '>') {
// end of something == > this is really bad // end of something == > this is really bad
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find '>' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find '>' chars == > invalide XML");
return false; return false;
} }
@ -367,15 +367,15 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
} }
tmpPos.check(_data[jjj]); tmpPos.check(_data[jjj]);
} }
etk::UString tmpname = _data.extract(iii+white+1, endPosName+1); std::u32string tmpname = std::u32string(_data, iii+white+1, endPosName+1);
if (true == _caseSensitive) { if (true == _caseSensitive) {
tmpname.lower(); to_lower(tmpname);
} }
//EXML_INFO("find node named : '" << tmpname << "'"); //EXML_INFO("find node named : '" << tmpname << "'");
// find text: // find text:
exml::Element* element = new exml::Element(tmpname); exml::Element* element = new exml::Element(tmpname);
if (NULL == element) { if (NULL == element) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
return false; return false;
} }
_pos = endPosName+1; _pos = endPosName+1;
@ -385,16 +385,16 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.pushBack(element); m_listSub.push_back(element);
continue; continue;
} }
_filePos+=tmpPos; _filePos+=tmpPos;
// here we have an error : // here we have an error :
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::UString("Find an ununderstanding element : '") + _data[iii+white+1] + "'"); CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Find an ununderstanding element : '") + _data[iii+white+1] + U"'");
return false; return false;
} else { } else {
if (_data[iii] == '>') { if (_data[iii] == '>') {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find elemement '>' == > no reason to be here ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find elemement '>' == > no reason to be here ...");
return false; return false;
} }
// might to be data text ... // might to be data text ...
@ -407,7 +407,7 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
// find data == > parse it... // find data == > parse it...
exml::Text* text = new exml::Text(); exml::Text* text = new exml::Text();
if (NULL == text) { if (NULL == text) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
return false; return false;
} }
_pos = iii; _pos = iii;
@ -417,18 +417,18 @@ bool exml::Element::subParse(const etk::UString& _data, int32_t& _pos, bool _cas
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.pushBack(text); m_listSub.push_back(text);
} }
} }
} }
if (_mainNode == true) { if (_mainNode == true) {
return true; return true;
} }
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::UString("Did not find end of the exml::Element : '") + m_value + "'"); CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Did not find end of the exml::Element : '") + m_value + U"'");
return false; return false;
} }
bool exml::Element::iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::Element::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_PARSE_ELEMENT("start parse : 'element' named='" << m_value << "'"); EXML_PARSE_ELEMENT("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
m_pos=_filePos; m_pos=_filePos;
@ -446,7 +446,7 @@ bool exml::Element::iParse(const etk::UString& _data, int32_t& _pos, bool _caseS
if (_data[iii] == '/') { if (_data[iii] == '/') {
// standalone node or error... // standalone node or error...
if (iii+1>=_data.size()) { if (iii+1>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find end of files ... == > bad case"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find end of files ... == > bad case");
return false; return false;
} }
// TODO : Can have white spaces .... // TODO : Can have white spaces ....
@ -455,14 +455,14 @@ bool exml::Element::iParse(const etk::UString& _data, int32_t& _pos, bool _caseS
return true; return true;
} }
// error // error
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find / without > char ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find / without > char ...");
return false; return false;
} }
if (true == checkAvaillable(_data[iii], true)) { if (true == checkAvaillable(_data[iii], true)) {
// we find an attibute == > create a new and parse it : // we find an attibute == > create a new and parse it :
exml::Attribute* attribute = new exml::Attribute(); exml::Attribute* attribute = new exml::Attribute();
if (NULL == attribute) { if (NULL == attribute) {
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ..."); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
return false; return false;
} }
_pos = iii; _pos = iii;
@ -471,15 +471,15 @@ bool exml::Element::iParse(const etk::UString& _data, int32_t& _pos, bool _caseS
return false; return false;
} }
iii = _pos; iii = _pos;
m_listAttribute.pushBack(attribute); m_listAttribute.push_back(attribute);
continue; continue;
} }
if (false == _data[iii].isWhiteChar()) { if (false == etk::isWhiteChar(_data[iii])) {
CREATE_ERROR(_doc, _data, iii, _filePos, etk::UString("Find an unknow element : '") + _data[iii] + "'"); CREATE_ERROR(_doc, _data, iii, _filePos, std::u32string(U"Find an unknow element : '") + _data[iii] + U"'");
return false; return false;
} }
} }
CREATE_ERROR(_doc, _data, _pos, _filePos, etk::UString("Unexpecting end of parsing exml::Element : '") + m_value + "' == > check if the '/>' is set or the end of element"); CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Unexpecting end of parsing exml::Element : '") + m_value + U"' == > check if the '/>' is set or the end of element");
return false; return false;
} }

View File

@ -10,7 +10,7 @@
#define __ETK_XML_ELEMENT_H__ #define __ETK_XML_ELEMENT_H__
#include <exml/Node.h> #include <exml/Node.h>
#include <etk/Vector.h> #include <vector>
#include <exml/AttributeList.h> #include <exml/AttributeList.h>
namespace exml { namespace exml {
@ -24,7 +24,7 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _value Element name; * @param[in] _value Element name;
*/ */
Element(const etk::UString& _value) : Element(const std::u32string& _value) :
exml::AttributeList(_value) { exml::AttributeList(_value) {
}; };
@ -33,7 +33,7 @@ namespace exml {
*/ */
virtual ~Element(void); virtual ~Element(void);
protected: protected:
etk::Vector<exml::Node*> m_listSub; std::vector<exml::Node*> m_listSub;
public: public:
/** /**
* @brief get the number of sub element in the node (can be exml::Comment ; exml::Element ; exml::Text :exml::Declaration). * @brief get the number of sub element in the node (can be exml::Comment ; exml::Element ; exml::Text :exml::Declaration).
@ -73,21 +73,21 @@ namespace exml {
* @param[in] _name Name of the element that is requested * @param[in] _name Name of the element that is requested
* @return Pointer on the element or NULL. * @return Pointer on the element or NULL.
*/ */
Element* getNamed(const etk::UString& _name); Element* getNamed(const std::u32string& _name);
const Element* getNamed(const etk::UString& _name) const; const Element* getNamed(const std::u32string& _name) const;
/** /**
* @brief get the internal data of the element (if the element has some sub node thay are converted in xml string == > like this it is not needed to use <![CDATA[...]]> * @brief get the internal data of the element (if the element has some sub node thay are converted in xml string == > like this it is not needed to use <![CDATA[...]]>
* @return the curent data string. * @return the curent data string.
*/ */
etk::UString getText(void); std::u32string getText(void);
protected: protected:
bool subParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode=false); bool subParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode=false);
public: // herited function: public: // herited function:
virtual enum nodeType getType(void) const { virtual enum nodeType getType(void) const {
return typeElement; return typeElement;
}; };
virtual bool iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc); virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual exml::Element* toElement(void) { virtual exml::Element* toElement(void) {
return this; return this;
}; };

View File

@ -14,27 +14,27 @@
etk::CCout& exml::operator <<(etk::CCout& _os, const exml::filePos& _obj) { etk::CCout& exml::operator <<(etk::CCout& _os, const exml::filePos& _obj) {
_os << "(l="; _os << U"(l=";
_os << _obj.getLine(); _os << _obj.getLine();
_os << ",c="; _os << U",c=";
_os << _obj.getCol(); _os << _obj.getCol();
_os << ")"; _os << U")";
return _os; return _os;
} }
exml::Node::Node(const etk::UString& _value) : exml::Node::Node(const std::u32string& _value) :
m_pos(0,0), m_pos(0,0),
m_value(_value) { m_value(_value) {
// nothing to do. // nothing to do.
} }
void exml::Node::addIndent(etk::UString& _data, int32_t _indent) const { void exml::Node::addIndent(std::u32string& _data, int32_t _indent) const {
for (int32_t iii=0; iii<_indent; iii++) { for (int32_t iii=0; iii<_indent; iii++) {
_data+="\t"; _data += U"\t";
} }
} }
void exml::Node::drawElementParsed(const etk::UChar& _val, const exml::filePos& _filePos) const { void exml::Node::drawElementParsed(char32_t _val, const exml::filePos& _filePos) const {
if (_val == '\n') { if (_val == '\n') {
EXML_DEBUG(_filePos << " parse '\\n'"); EXML_DEBUG(_filePos << " parse '\\n'");
} else if (_val == '\t') { } else if (_val == '\t') {
@ -44,7 +44,7 @@ void exml::Node::drawElementParsed(const etk::UChar& _val, const exml::filePos&
} }
} }
bool exml::Node::checkAvaillable(const etk::UChar& _val, bool _firstChar) const { bool exml::Node::checkAvaillable(char32_t _val, bool _firstChar) const {
if( _val == '!' if( _val == '!'
|| _val == '"' || _val == '"'
|| _val == '#' || _val == '#'
@ -91,12 +91,12 @@ bool exml::Node::checkAvaillable(const etk::UChar& _val, bool _firstChar) const
} }
int32_t exml::Node::countWhiteChar(const etk::UString& _data, int32_t _pos, exml::filePos& _filePos) const { int32_t exml::Node::countWhiteChar(const std::u32string& _data, int32_t _pos, exml::filePos& _filePos) const {
_filePos.clear(); _filePos.clear();
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++) {
_filePos.check(_data[iii]); _filePos.check(_data[iii]);
if(true == _data[iii].isWhiteChar()) { if(true == etk::isWhiteChar(_data[iii])) {
white++; white++;
} else { } else {
break; break;
@ -107,6 +107,6 @@ int32_t exml::Node::countWhiteChar(const etk::UString& _data, int32_t _pos, exml
} }
void exml::Node::clear(void) { void exml::Node::clear(void) {
m_value=""; m_value = U"";
m_pos.clear(); m_pos.clear();
} }

View File

@ -94,7 +94,7 @@ namespace exml
m_col=0; m_col=0;
m_line++; m_line++;
}; };
bool check(const etk::UChar& _val) { bool check(char32_t _val) {
m_col++; m_col++;
if (_val == '\n') { if (_val == '\n') {
newLine(); newLine();
@ -132,7 +132,7 @@ namespace exml
* @brief basic element of a xml structure * @brief basic element of a xml structure
* @param[in] value of the node * @param[in] value of the node
*/ */
Node(const etk::UString& _value); Node(const std::u32string& _value);
/** /**
* @brief destructor * @brief destructor
*/ */
@ -146,14 +146,14 @@ namespace exml
* @param[in,out] file parsing position (line x col x) * @param[in,out] file parsing position (line x col x)
* @return false if an error occured. * @return false if an error occured.
*/ */
virtual bool iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) = 0; virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) = 0;
/** /**
* @brief generate a string with the tree of the xml * @brief generate a string with the tree of the xml
* @param[in,out] _data string where to add the elements * @param[in,out] _data string where to add the elements
* @param[in] current indentation of the file * @param[in] current indentation of the file
* @return false if an error occured. * @return false if an error occured.
*/ */
virtual bool iGenerate(etk::UString& _data, int32_t _indent) const { virtual bool iGenerate(std::u32string& _data, int32_t _indent) const {
return true; return true;
}; };
protected: protected:
@ -166,20 +166,20 @@ namespace exml
return m_pos; return m_pos;
}; };
protected: protected:
etk::UString m_value; //!< value of the node (for element this is the name, for text it is the inside text ...) std::u32string m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
public: public:
/** /**
* @brief set the value of the node. * @brief set the value of the node.
* @param[in] _value New value of the node. * @param[in] _value New value of the node.
*/ */
virtual void setValue(etk::UString _value) { virtual void setValue(std::u32string _value) {
m_value = _value; m_value = _value;
}; };
/** /**
* @brief get the current element Value. * @brief get the current element Value.
* @return the reference of the string value. * @return the reference of the string value.
*/ */
virtual const etk::UString& getValue(void) const { virtual const std::u32string& getValue(void) const {
return m_value; return m_value;
}; };
public: public:
@ -196,19 +196,19 @@ namespace exml
* @param[in,out] _data String where the indentation is done. * @param[in,out] _data String where the indentation is done.
* @param[in] _indent Number of tab to add at the string. * @param[in] _indent Number of tab to add at the string.
*/ */
void addIndent(etk::UString& _data, int32_t _indent) const; void addIndent(std::u32string& _data, int32_t _indent) const;
/** /**
* @brief Display the cuurent element that is curently parse. * @brief Display the cuurent element that is curently parse.
* @param[in] _val Char that is parsed. * @param[in] _val Char that is parsed.
* @param[in] _filePos Position of the char in the file. * @param[in] _filePos Position of the char in the file.
*/ */
void drawElementParsed(const etk::UChar& _val, const exml::filePos& _filePos) const; void drawElementParsed(char32_t _val, const exml::filePos& _filePos) const;
/** /**
* @brief check if an element or attribute is availlable (not : !"#$%&'()*+,/;<=>?@[\]^`{|}~ \n\t\r and for first char : not -.0123456789). * @brief check if an element or attribute is availlable (not : !"#$%&'()*+,/;<=>?@[\]^`{|}~ \n\t\r and for first char : not -.0123456789).
* @param[in] _val Value to check the conformity. * @param[in] _val Value to check the conformity.
* @param[in] _firstChar True if the element check is the first char. * @param[in] _firstChar True if the element check is the first char.
*/ */
bool checkAvaillable(const etk::UChar& _val, bool _firstChar) const; bool checkAvaillable(char32_t _val, bool _firstChar) const;
/** /**
* @brief count the number of white char in the string from the specify position (stop at the first element that is not a white char) * @brief count the number of white char in the string from the specify position (stop at the first element that is not a white char)
* @param[in] _data Data to parse. * @param[in] _data Data to parse.
@ -216,7 +216,7 @@ namespace exml
* @param[out] _filePos new poistion of te file to add. * @param[out] _filePos new poistion of te file to add.
* @return number of white element. * @return number of white element.
*/ */
int32_t countWhiteChar(const etk::UString& _data, int32_t _pos, exml::filePos& _filePos) const; int32_t countWhiteChar(const std::u32string& _data, int32_t _pos, exml::filePos& _filePos) const;
public: public:
/** /**
* @brief Cast the element in a Document if it is possible. * @brief Cast the element in a Document if it is possible.

View File

@ -13,7 +13,7 @@
#undef __class__ #undef __class__
#define __class__ "Text" #define __class__ "Text"
bool exml::Text::iGenerate(etk::UString& _data, int32_t _indent) const { bool exml::Text::iGenerate(std::u32string& _data, int32_t _indent) const {
_data += m_value; _data += m_value;
return true; return true;
} }
@ -28,7 +28,7 @@ int32_t exml::Text::countLines(void) const {
return count; return count;
} }
bool exml::Text::iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::Text::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_VERBOSE("start parse : 'text'"); EXML_VERBOSE("start parse : 'text'");
m_pos = _filePos; m_pos = _filePos;
// search end of the comment : // search end of the comment :
@ -44,25 +44,25 @@ bool exml::Text::iParse(const etk::UString& _data, int32_t& _pos, bool _caseSens
// search whitespace : // search whitespace :
int32_t newEnd=iii; int32_t newEnd=iii;
for( int32_t jjj=iii-1; jjj>_pos; jjj--) { for( int32_t jjj=iii-1; jjj>_pos; jjj--) {
if(true == _data[jjj].isWhiteChar()) { if(true == etk::isWhiteChar(_data[jjj])) {
newEnd = jjj; newEnd = jjj;
} else { } else {
break; break;
} }
} }
// find end of value: // find end of value:
m_value = _data.extract(_pos, newEnd); m_value = std::u32string(_data, _pos, newEnd);
EXML_VERBOSE(" find text '" << m_value << "'"); EXML_VERBOSE(" find text '" << m_value << "'");
_pos = iii-1; _pos = iii-1;
return true; return true;
} }
} }
CREATE_ERROR(_doc, _data, _pos, _filePos, "Text got end of file without finding end node"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"Text got end of file without finding end node");
_pos = _data.size(); _pos = _data.size();
return false; return false;
} }
bool exml::TextCDATA::iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::TextCDATA::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_VERBOSE("start parse : 'text::CDATA'"); EXML_VERBOSE("start parse : 'text::CDATA'");
m_pos = _filePos; m_pos = _filePos;
// search end of the comment : // search end of the comment :
@ -78,13 +78,13 @@ bool exml::TextCDATA::iParse(const etk::UString& _data, int32_t& _pos, bool _cas
&& _data[iii+2] == '>') { && _data[iii+2] == '>') {
// find end of value: // find end of value:
_filePos += 2; _filePos += 2;
m_value = _data.extract(_pos, iii); m_value = std::u32string(_data, _pos, iii);
EXML_VERBOSE(" find text CDATA '" << m_value << "'"); EXML_VERBOSE(" find text CDATA '" << m_value << "'");
_pos = iii+2; _pos = iii+2;
return true; return true;
} }
} }
CREATE_ERROR(_doc, _data, _pos, _filePos, "text CDATA got end of file without finding end node"); CREATE_ERROR(_doc, _data, _pos, _filePos, U"text CDATA got end of file without finding end node");
_pos = _data.size(); _pos = _data.size();
return false; return false;
} }

View File

@ -10,7 +10,7 @@
#define __ETK_XML_TEXT_H__ #define __ETK_XML_TEXT_H__
#include <exml/Node.h> #include <exml/Node.h>
#include <etk/Vector.h> #include <vector>
namespace exml { namespace exml {
class Text : public Node { class Text : public Node {
@ -23,7 +23,7 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _data String data of the current Text * @param[in] _data String data of the current Text
*/ */
Text(const etk::UString& _data) : exml::Node(_data) { }; Text(const std::u32string& _data) : exml::Node(_data) { };
/** /**
* @brief Destructor * @brief Destructor
*/ */
@ -37,8 +37,8 @@ namespace exml {
virtual enum nodeType getType(void) const { virtual enum nodeType getType(void) const {
return typeText; return typeText;
}; };
virtual bool iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc); virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(etk::UString& _data, int32_t _indent) const; virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual exml::Text* toText(void) { virtual exml::Text* toText(void) {
return this; return this;
}; };
@ -57,7 +57,7 @@ namespace exml {
*/ */
virtual ~TextCDATA(void) { }; virtual ~TextCDATA(void) { };
public: // herited function: public: // herited function:
virtual bool iParse(const etk::UString& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc); virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
}; };
}; };

View File

@ -8,7 +8,7 @@
#include <exml/test.h> #include <exml/test.h>
#include <exml/debug.h> #include <exml/debug.h>
#include <etk/Vector.h> #include <vector>
#include <exml/debug.h> #include <exml/debug.h>
#undef __class__ #undef __class__
@ -16,241 +16,241 @@
class testCheck { class testCheck {
public: public:
etk::UString m_ref; std::u32string m_ref;
etk::UString m_input; std::u32string m_input;
int32_t m_errorPos; // -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? int32_t m_errorPos; // -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ????
testCheck(void) {}; testCheck(void) {};
void set(const etk::UString& _ref, int32_t _pos, const etk::UString& _input) { void set(const std::u32string& _ref, int32_t _pos, const std::u32string& _input) {
m_ref = _ref; m_ref = _ref;
m_input = _input; m_input = _input;
m_errorPos = _pos; m_errorPos = _pos;
} }
}; };
etk::Vector<testCheck> l_list; std::vector<testCheck> l_list;
void init(void) { void init(void) {
etk::UString reference; std::u32string reference;
etk::UString input; std::u32string input;
testCheck check; testCheck check;
// == ==================================================== // == ====================================================
check.set("test exml::Element", -2, ""); check.set("test exml::Element", -2, "");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
reference = "<exemple/>\n"; reference = "<exemple/>\n";
check.set(reference, check.set(reference,
-1, -1,
"<exemple/>\n"); "<exemple/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
-1, -1,
"< \t\r exemple/>\n"); "< \t\r exemple/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
-1, -1,
"< \t\r exemple \t\r\r\r\n \t\t />\n"); "< \t\r exemple \t\r\r\r\n \t\t />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"< exemple < >\n"); "< exemple < >\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"< exemple / />\n"); "< exemple / />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"< exemple ? />\n"); "< exemple ? />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"< exemple * />\n"); "< exemple * />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"< . exemple < />\n"); "< . exemple < />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"<! exemple < />\n"); "<! exemple < />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"<!- exemple < />\n"); "<!- exemple < />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set(reference, check.set(reference,
1, 1,
"< exemple < />\n"); "< exemple < />\n");
l_list.pushBack(check); l_list.push_back(check);
check.set("<exemple--/>\n", check.set("<exemple--/>\n",
1, 1,
"<exemple-->\n"); "<exemple-->\n");
l_list.pushBack(check); l_list.push_back(check);
check.set("<exemple/>\n", check.set("<exemple/>\n",
1, 1,
"<exemple>\n</exemple sdfgsdfg>\n"); "<exemple>\n</exemple sdfgsdfg>\n");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("test element exml::Attribute ", -2, ""); check.set("test element exml::Attribute ", -2, "");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("<elementtt attr=\"plop\"/>\n", check.set("<elementtt attr=\"plop\"/>\n",
-1, -1,
"<elementtt attr=\"plop\"/>\n"); "<elementtt attr=\"plop\"/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"plop\"/>\n", check.set("<elementtt attr=\"plop\"/>\n",
-1, -1,
"<elementtt attr=plop/>\n"); "<elementtt attr=plop/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"234345@3452345_.'\"/>\n", check.set("<elementtt attr=\"234345@3452345_.'\"/>\n",
-1, -1,
"<elementtt attr=234345@3452345_.' />\n"); "<elementtt attr=234345@3452345_.' />\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"plop\"/>\n", check.set("<elementtt attr=\"plop\"/>\n",
-1, -1,
"<elementtt attr =\"plop\"/>\n"); "<elementtt attr =\"plop\"/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"plop\"/>\n", check.set("<elementtt attr=\"plop\"/>\n",
-1, -1,
"<elementtt attr= \"plop\"/>\n"); "<elementtt attr= \"plop\"/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"plop\"/>\n", check.set("<elementtt attr=\"plop\"/>\n",
-1, -1,
"<elementtt attr\n=\n\"plop\"/>\n"); "<elementtt attr\n=\n\"plop\"/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"plop\"/>\n", check.set("<elementtt attr=\"plop\"/>\n",
-1, -1,
"<elementtt attr=plop/>\n"); "<elementtt attr=plop/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"plop\"/>\n", check.set("<elementtt attr=\"plop\"/>\n",
-1, -1,
"<elementtt attr \n = \n\t plop/>\n"); "<elementtt attr \n = \n\t plop/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"\"/>\n", check.set("<elementtt attr=\"\"/>\n",
-1, -1,
"<elementtt attr=\"\"/>\n"); "<elementtt attr=\"\"/>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<elementtt attr=\"\"/>\n", check.set("<elementtt attr=\"\"/>\n",
-1, -1,
"<elementtt attr=/>\n"); "<elementtt attr=/>\n");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("test exml::Declaration", -2, ""); check.set("test exml::Declaration", -2, "");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("<?testDeclaration?>\n", check.set("<?testDeclaration?>\n",
-1, -1,
"<?testDeclaration?>\n"); "<?testDeclaration?>\n");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("test Declaration exml::Attribute", -2, ""); check.set("test Declaration exml::Attribute", -2, "");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("<?xml attr=\"plop\"?>\n", check.set("<?xml attr=\"plop\"?>\n",
-1, -1,
"<?xml attr=\"plop\"?>\n"); "<?xml attr=\"plop\"?>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<?xml attr=\"plop\"?>\n", check.set("<?xml attr=\"plop\"?>\n",
-1, -1,
"<?xml attr=plop?>\n"); "<?xml attr=plop?>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<?xml attr=\"234345@3452345_.'\"?>\n", check.set("<?xml attr=\"234345@3452345_.'\"?>\n",
-1, -1,
"<?xml attr=234345@3452345_.' ?>\n"); "<?xml attr=234345@3452345_.' ?>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<?xml attr=\"plop\"?>\n", check.set("<?xml attr=\"plop\"?>\n",
-1, -1,
"<?xml attr =\"plop\"?>\n"); "<?xml attr =\"plop\"?>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<?xml attr=\"plop\"?>\n", check.set("<?xml attr=\"plop\"?>\n",
-1, -1,
"<?xml attr= \"plop\"?>\n"); "<?xml attr= \"plop\"?>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<?xml attr=\"plop\"?>\n", check.set("<?xml attr=\"plop\"?>\n",
-1, -1,
"<?xml attr\n=\n\"plop\"?>\n"); "<?xml attr\n=\n\"plop\"?>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<?xml attr=\"plop\"?>\n", check.set("<?xml attr=\"plop\"?>\n",
-1, -1,
"<?xml attr=plop?>\n"); "<?xml attr=plop?>\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<?xml attr=\"plop\"?>\n", check.set("<?xml attr=\"plop\"?>\n",
-1, -1,
"<?xml attr \n = \n\t plop?>\n"); "<?xml attr \n = \n\t plop?>\n");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("test exml::Comment", -2, ""); check.set("test exml::Comment", -2, "");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("<!--exemple-->\n", check.set("<!--exemple-->\n",
-1, -1,
"<!--exemple-->\n"); "<!--exemple-->\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<!--exemple-->\n", check.set("<!--exemple-->\n",
-1, -1,
"<!-- \t \t\t exemple \n\n\n\t-->\n"); "<!-- \t \t\t exemple \n\n\n\t-->\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<!---- exemple-->\n", check.set("<!---- exemple-->\n",
-1, -1,
"<!-- -- exemple -->\n"); "<!-- -- exemple -->\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<!--> exemple-->\n", check.set("<!--> exemple-->\n",
-1, -1,
"<!--> exemple -->\n"); "<!--> exemple -->\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<!--exemple-->\n", check.set("<!--exemple-->\n",
1, 1,
"<!-- ---> exemple -->\n"); "<!-- ---> exemple -->\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<!--exemple-->\n", check.set("<!--exemple-->\n",
1, 1,
"<!-- ssdfgdfg >\n"); "<!-- ssdfgdfg >\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<!---->\n", check.set("<!---->\n",
-1, -1,
"<!---->\n"); "<!---->\n");
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("<!--<.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris>-->\n", check.set("<!--<.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris>-->\n",
-1, -1,
"<!-- <.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris> -->\n"); "<!-- <.:!*%^$0945- '(- &<<< >>> '& ( '( '-' <elementPouris> -->\n");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
check.set("test all", -2, ""); check.set("test all", -2, "");
l_list.pushBack(check); l_list.push_back(check);
// == ==================================================== // == ====================================================
reference= "<exemple>\n" reference= "<exemple>\n"
" <ex2 ploppp-plpl:erer=\"dfsdfsdfsdf\" lkmjmlk=\"156235\" sdfsdf=\"456321\"/>\n" " <ex2 ploppp-plpl:erer=\"dfsdfsdfsdf\" lkmjmlk=\"156235\" sdfsdf=\"456321\"/>\n"
@ -265,7 +265,7 @@ void init(void) {
" </ex2>\n" " </ex2>\n"
"</exemple>\n"; "</exemple>\n";
check.set(reference, -1, input); check.set(reference, -1, input);
l_list.pushBack(check); l_list.push_back(check);
// ------------------------------------------------------ // ------------------------------------------------------
check.set("", 1, check.set("", 1,
"< exemple\n >\n" "< exemple\n >\n"
@ -275,11 +275,11 @@ void init(void) {
" Text example ...\n" " Text example ...\n"
" </ex2>\n" " </ex2>\n"
"</exemple>\n"); "</exemple>\n");
l_list.pushBack(check); l_list.push_back(check);
} }
int main(int argc, const char *argv[]) { int main(int argc, const char *argv[]) {
debug::setGeneralLevel(etk::LOG_LEVEL_VERBOSE); debug::setGeneralLevel(etk::logLevelVerbose);
init(); init();
int32_t countError = 0; int32_t countError = 0;
int32_t countSeparator = 0; int32_t countSeparator = 0;
@ -296,7 +296,7 @@ int main(int argc, const char *argv[]) {
} }
sectionID++; sectionID++;
exml::Document doc; exml::Document doc;
etk::UString out(""); std::u32string out("");
//EXML_DEBUG("parse : \n" << l_list[iii].m_input); //EXML_DEBUG("parse : \n" << l_list[iii].m_input);
if (false == doc.parse(l_list[iii].m_input)) { if (false == doc.parse(l_list[iii].m_input)) {
if (l_list[iii].m_errorPos == 1) { if (l_list[iii].m_errorPos == 1) {