[DEV] update to the etk normalisation

This commit is contained in:
Edouard DUPIN 2013-12-28 14:22:30 +01:00
parent b12dde7668
commit f8526c27e0
16 changed files with 62 additions and 179 deletions

View File

@ -19,18 +19,6 @@ exml::Attribute::Attribute(const std::string& _name, const std::string& _value)
} }
exml::Attribute::Attribute(const std::u32string& _name, const std::u32string& _value) :
exml::Node(_value) {
m_name = to_u8string(_name);
}
void exml::Attribute::setName(const std::u32string& _name) {
m_name = to_u8string(_name);
};
std::u32string exml::Attribute::getUName(void) const {
return to_u32string(m_name);
};
bool exml::Attribute::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::Attribute::iParse(const std::string& _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;
@ -49,7 +37,7 @@ bool exml::Attribute::iParse(const std::string& _data, int32_t& _pos, bool _case
} }
m_name = std::string(_data, _pos, lastElementName+1-(_pos)); m_name = std::string(_data, _pos, lastElementName+1-(_pos));
if (true == _caseSensitive) { if (true == _caseSensitive) {
m_name = to_lower(m_name); m_name = std::tolower(m_name);
} }
// count white space : // count white space :
exml::filePos tmpPos; exml::filePos tmpPos;

View File

@ -13,7 +13,7 @@
#include <vector> #include <vector>
namespace exml { namespace exml {
class Attribute : public Node { class Attribute : public exml::Node {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -25,7 +25,6 @@ namespace exml {
* @param[in] _value Value of the attribute. * @param[in] _value Value of the attribute.
*/ */
Attribute(const std::string& _name, const std::string& _value); Attribute(const std::string& _name, const std::string& _value);
Attribute(const std::u32string& _name, const std::u32string& _value);
/** /**
* @brief Destructor * @brief Destructor
*/ */
@ -40,7 +39,6 @@ namespace exml {
virtual void setName(const std::string& _name) { virtual void setName(const std::string& _name) {
m_name = _name; m_name = _name;
}; };
virtual void setName(const std::u32string& _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
@ -48,7 +46,6 @@ namespace exml {
virtual const std::string& getName(void) const { virtual const std::string& getName(void) const {
return m_name; return m_name;
}; };
virtual std::u32string getUName(void) const;
public: // herited function: public: // herited function:
virtual enum nodeType getType(void) const { virtual enum nodeType getType(void) const {
return exml::typeAttribute; return exml::typeAttribute;

View File

@ -64,19 +64,6 @@ const std::string& exml::AttributeList::getAttribute(const std::string& _name) c
return errorReturn; return errorReturn;
} }
std::u32string exml::AttributeList::getAttribute(const std::u32string& _name) const {
static const std::u32string errorReturn(U"");
if (_name.size() == 0) {
return errorReturn;
}
for (size_t iii=0; iii<m_listAttribute.size(); iii++) {
if( NULL != m_listAttribute[iii]
&& m_listAttribute[iii]->getUName() == _name) {
return m_listAttribute[iii]->getUValue();
}
}
return errorReturn;
}
bool exml::AttributeList::existAttribute(const std::string& _name) const { bool exml::AttributeList::existAttribute(const std::string& _name) const {
if (_name.size() == 0) { if (_name.size() == 0) {
@ -91,19 +78,6 @@ bool exml::AttributeList::existAttribute(const std::string& _name) const {
return false; return false;
} }
bool exml::AttributeList::existAttribute(const std::u32string& _name) const {
if (_name.size() == 0) {
return false;
}
for (size_t iii=0; iii<m_listAttribute.size(); iii++) {
if( NULL != m_listAttribute[iii]
&& m_listAttribute[iii]->getUName() == _name) {
return true;
}
}
return false;
}
void exml::AttributeList::setAttribute(const std::string& _name, const std::string& _value) { void exml::AttributeList::setAttribute(const std::string& _name, const std::string& _value) {
// check if attribute already det : // check if attribute already det :
for (size_t iii=0; iii<m_listAttribute.size(); iii++) { for (size_t iii=0; iii<m_listAttribute.size(); iii++) {
@ -121,23 +95,6 @@ void exml::AttributeList::setAttribute(const std::string& _name, const std::stri
m_listAttribute.push_back(attr); m_listAttribute.push_back(attr);
} }
void exml::AttributeList::setAttribute(const std::u32string& _name, const std::u32string& _value) {
// check if attribute already det :
for (size_t iii=0; iii<m_listAttribute.size(); iii++) {
if( NULL != m_listAttribute[iii]
&& m_listAttribute[iii]->getUName() == _name) {
// update the value :
m_listAttribute[iii]->setValue(_value);
return;
}
}
exml::Attribute* attr = new exml::Attribute(_name, _value);
if (NULL == attr) {
EXML_ERROR("memory allocation error...");
}
m_listAttribute.push_back(attr);
}
bool exml::AttributeList::iGenerate(std::string& _data, int32_t _indent) const { bool exml::AttributeList::iGenerate(std::string& _data, int32_t _indent) const {
for (size_t iii=0; iii<m_listAttribute.size(); iii++) { for (size_t iii=0; iii<m_listAttribute.size(); iii++) {
if (NULL!=m_listAttribute[iii]) { if (NULL!=m_listAttribute[iii]) {

View File

@ -14,7 +14,7 @@
#include <exml/Attribute.h> #include <exml/Attribute.h>
namespace exml { namespace exml {
class AttributeList : public Node { class AttributeList : public exml::Node {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -27,10 +27,6 @@ namespace exml {
AttributeList(const std::string& _value) : AttributeList(const std::string& _value) :
exml::Node(_value) { exml::Node(_value) {
};
AttributeList(const std::u32string& _value) :
exml::Node(_value) {
}; };
/** /**
* @brief Destructor * @brief Destructor
@ -64,21 +60,18 @@ namespace exml {
* @return Value of the attribute or no data in the string * @return Value of the attribute or no data in the string
*/ */
const std::string& getAttribute(const std::string& _name) const; const std::string& getAttribute(const std::string& _name) 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 std::string& _name) const; bool existAttribute(const std::string& _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 std::string& _name, const std::string& _value); void setAttribute(const std::string& _name, const std::string& _value);
void setAttribute(const std::u32string& _name, const std::u32string& _value);
public: // herited function: public: // herited function:
bool iGenerate(std::string& _data, int32_t _indent) const; bool iGenerate(std::string& _data, int32_t _indent) const;
virtual void clear(void); virtual void clear(void);

View File

@ -13,6 +13,19 @@
#undef __class__ #undef __class__
#define __class__ "Comment" #define __class__ "Comment"
static bool isWhiteChar(char32_t _val) {
if( _val == ' '
|| _val == '\t'
|| _val == '\n'
|| _val == '\r') {
return true;
}
return false;
}
bool exml::Comment::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) { bool exml::Comment::iParse(const std::string& _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;
@ -34,7 +47,7 @@ bool exml::Comment::iParse(const std::string& _data, int32_t& _pos, bool _caseSe
// 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 == etk::isWhiteChar(_data[jjj])) { if(true == isWhiteChar(_data[jjj])) {
newEnd = jjj; newEnd = jjj;
} else { } else {
break; break;

View File

@ -13,7 +13,7 @@
#include <vector> #include <vector>
namespace exml { namespace exml {
class Comment : public Node { class Comment : public exml::Node {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -26,10 +26,6 @@ namespace exml {
Comment(const std::string& _value) : Comment(const std::string& _value) :
exml::Node(_value) { exml::Node(_value) {
};
Comment(const std::u32string& _value) :
exml::Node(_value) {
}; };
/** /**
* @brief Destructor * @brief Destructor

View File

@ -20,30 +20,12 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
*/ */
exml::DeclarationXML::DeclarationXML(const std::string& _version, enum unicode::charset _format, bool _standalone) : exml::DeclarationXML::DeclarationXML(const std::string& _version, const std::string& _format, bool _standalone) :
exml::Declaration("xml") { exml::Declaration("xml") {
if (_version.size()!=0) { if (_version.size()!=0) {
setAttribute("version", _version); setAttribute("version", _version);
} }
if (_format!=unicode::charsetUTF8) { if (_format!="UTF-8") {
setAttribute("encoding", "UTF-8");
} else {
EXML_ERROR("Actually does not supported other charset than UTF8");
setAttribute("encoding", "UTF-8");
}
if (_standalone == true) {
setAttribute("standalone", "true");
} else {
setAttribute("standalone", "true");
}
}
exml::DeclarationXML::DeclarationXML(const std::u32string& _version, enum unicode::charset _format, bool _standalone) :
exml::Declaration("xml") {
if (_version.size()!=0) {
setAttribute("version", to_u8string(_version));
}
if (_format!=unicode::charsetUTF8) {
setAttribute("encoding", "UTF-8"); setAttribute("encoding", "UTF-8");
} else { } else {
EXML_ERROR("Actually does not supported other charset than UTF8"); EXML_ERROR("Actually does not supported other charset than UTF8");

View File

@ -10,7 +10,6 @@
#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 {
@ -26,10 +25,6 @@ namespace exml {
Declaration(const std::string& _name) : Declaration(const std::string& _name) :
exml::AttributeList(_name) { exml::AttributeList(_name) {
};
Declaration(const std::u32string& _name) :
exml::AttributeList(_name) {
}; };
/** /**
* @brief Destructor * @brief Destructor
@ -56,8 +51,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 std::string& _version, enum unicode::charset _format=unicode::charsetUTF8, bool _standalone=true); DeclarationXML(const std::string& _version, const std::string& _format = "UTF-8", bool _standalone = true);
DeclarationXML(const std::u32string& _version, enum unicode::charset _format=unicode::charsetUTF8, bool _standalone=true);
/** /**
* @brief Destructor * @brief Destructor
*/ */

View File

@ -14,7 +14,6 @@
#define __class__ "Document" #define __class__ "Document"
exml::Document::Document(void) : exml::Document::Document(void) :
m_charset(unicode::charsetUTF8),
m_caseSensitive(false), m_caseSensitive(false),
m_writeErrorWhenDetexted(true), m_writeErrorWhenDetexted(true),
m_comment(""), m_comment(""),
@ -33,34 +32,21 @@ bool exml::Document::iGenerate(std::string& _data, int32_t _indent) const {
return true; return true;
} }
bool exml::Document::parse(const std::u32string& _data) {
return parse(to_u8string(_data));
}
bool exml::Document::parse(const std::string& _data) { bool exml::Document::parse(const std::string& _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 ...
m_charset = unicode::charsetUTF8;
exml::filePos filePos(1,0); exml::filePos filePos(1,0);
m_pos = filePos; m_pos = filePos;
int32_t parsePos = 0; int32_t parsePos = 0;
return subParse(_data, parsePos, m_caseSensitive, filePos, *this, true); return subParse(_data, parsePos, m_caseSensitive, filePos, *this, true);
} }
bool exml::Document::generate(std::u32string& _data) {
std::string data;
bool ret = generate(data);
_data = to_u32string(data);
return ret;
}
bool exml::Document::generate(std::string& _data) { bool exml::Document::generate(std::string& _data) {
_data = ""; _data = "";
return iGenerate(_data,0); return iGenerate(_data,0);
} }
bool exml::Document::load(const std::u32string& _data) {
return load(to_u8string(_data));
}
bool exml::Document::load(const std::string& _file) { bool exml::Document::load(const std::string& _file) {
// Start loading the XML : // Start loading the XML :
EXML_VERBOSE("open file (xml) \"" << _file << "\""); EXML_VERBOSE("open file (xml) \"" << _file << "\"");
@ -85,7 +71,6 @@ bool exml::Document::load(const std::string& _file) {
EXML_ERROR("Error Memory allocation size=" << fileSize); EXML_ERROR("Error Memory allocation size=" << fileSize);
return false; return false;
} }
// TODO : change this ... get the charset from the Declaration element ...
memset(fileBuffer, 0, (fileSize+5)*sizeof(char)); memset(fileBuffer, 0, (fileSize+5)*sizeof(char));
// load data from the file : // load data from the file :
tmpFile.fileRead(fileBuffer, 1, fileSize); tmpFile.fileRead(fileBuffer, 1, fileSize);
@ -102,9 +87,6 @@ bool exml::Document::load(const std::string& _file) {
return ret; return ret;
} }
bool exml::Document::store(const std::u32string& _data) {
return store(to_u8string(_data));
}
bool exml::Document::store(const std::string& _file) { bool exml::Document::store(const std::string& _file) {
std::string createData; std::string createData;
if (false == generate(createData)) { if (false == generate(createData)) {

View File

@ -10,7 +10,6 @@
#define __ETK_XML_DOCUMENT_H__ #define __ETK_XML_DOCUMENT_H__
#include <exml/Element.h> #include <exml/Element.h>
#include <etk/unicode.h>
#include <vector> #include <vector>
namespace exml { namespace exml {
@ -24,23 +23,6 @@ namespace exml {
* @brief Destructor * @brief Destructor
*/ */
virtual ~Document(void) { }; virtual ~Document(void) { };
private:
enum unicode::charset m_charset;
public:
/**
* @brief get the current charset of the Parsing
* @param[in] _charset The new charset
*/
virtual void setCharset(enum unicode::charset _charset) {
m_charset = _charset;
};
/**
* @brief get the current charset of the Parsing
* @return The current charset
*/
virtual enum unicode::charset getCharset(void) const {
return m_charset;
};
private: private:
bool m_caseSensitive; // check the case sensitive of the nodes and attribute bool m_caseSensitive; // check the case sensitive of the nodes and attribute
public: public:
@ -66,7 +48,6 @@ namespace exml {
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool parse(const std::string& _data); bool parse(const std::string& _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
@ -74,7 +55,6 @@ namespace exml {
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool generate(std::string& _data); bool generate(std::string& _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)
@ -82,7 +62,6 @@ namespace exml {
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool load(const std::string& _file); bool load(const std::string& _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)
@ -90,7 +69,6 @@ namespace exml {
* @return true : Parsing is OK * @return true : Parsing is OK
*/ */
bool store(const std::string& _file); bool store(const std::string& _file);
bool store(const std::u32string& _file);
/** /**
* @brief Display the Document on console * @brief Display the Document on console
*/ */

View File

@ -18,6 +18,16 @@
#define __class__ "Element" #define __class__ "Element"
static bool isWhiteChar(char32_t _val) {
if( _val == ' '
|| _val == '\t'
|| _val == '\n'
|| _val == '\r') {
return true;
}
return false;
}
exml::Element::~Element(void) { exml::Element::~Element(void) {
for (size_t iii=0; iii<m_listSub.size(); iii++) { for (size_t iii=0; iii<m_listSub.size(); iii++) {
if (NULL!=m_listSub[iii]) { if (NULL!=m_listSub[iii]) {
@ -90,9 +100,6 @@ exml::Element* exml::Element::getNamed(const std::string& _name) {
} }
return NULL; return NULL;
} }
exml::Element* exml::Element::getNamed(const std::u32string& _name) {
return getNamed(to_u8string(_name));
}
const exml::Element* exml::Element::getNamed(const std::string& _name) const { const exml::Element* exml::Element::getNamed(const std::string& _name) const {
if (_name.size() == 0) { if (_name.size() == 0) {
@ -110,9 +117,6 @@ const exml::Element* exml::Element::getNamed(const std::string& _name) const {
} }
return NULL; return NULL;
} }
const exml::Element* exml::Element::getNamed(const std::u32string& _name) const {
return getNamed(to_u8string(_name));
}
void exml::Element::append(exml::Node* _node) { void exml::Element::append(exml::Node* _node) {
if (_node == NULL) { if (_node == NULL) {
@ -221,7 +225,7 @@ bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _case
} }
std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2)); std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2));
if (true == _caseSensitive) { if (true == _caseSensitive) {
tmpname = to_lower(tmpname); tmpname = std::tolower(tmpname);
} }
// Find declaration balise // Find declaration balise
exml::Declaration* declaration = new exml::Declaration(tmpname); exml::Declaration* declaration = new exml::Declaration(tmpname);
@ -324,7 +328,7 @@ bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _case
} }
std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2)); std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2));
if (true == _caseSensitive) { if (true == _caseSensitive) {
tmpname = to_lower(tmpname); tmpname = std::tolower(tmpname);
} }
if( tmpname == m_value) { if( tmpname == m_value) {
// find end of node : // find end of node :
@ -375,7 +379,7 @@ bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _case
} }
std::string tmpname = std::string(_data, iii+white+1, endPosName+1-(iii+white+1)); std::string tmpname = std::string(_data, iii+white+1, endPosName+1-(iii+white+1));
if (true == _caseSensitive) { if (true == _caseSensitive) {
to_lower(tmpname); std::tolower(tmpname);
} }
//EXML_INFO("find node named : '" << tmpname << "'"); //EXML_INFO("find node named : '" << tmpname << "'");
// find text: // find text:
@ -480,7 +484,7 @@ bool exml::Element::iParse(const std::string& _data, int32_t& _pos, bool _caseSe
m_listAttribute.push_back(attribute); m_listAttribute.push_back(attribute);
continue; continue;
} }
if (false == etk::isWhiteChar(_data[iii])) { if (false == isWhiteChar(_data[iii])) {
CREATE_ERROR(_doc, _data, iii, _filePos, std::string("Find an unknow element : '") + _data[iii] + "'"); CREATE_ERROR(_doc, _data, iii, _filePos, std::string("Find an unknow element : '") + _data[iii] + "'");
return false; return false;
} }

View File

@ -14,7 +14,7 @@
#include <exml/AttributeList.h> #include <exml/AttributeList.h>
namespace exml { namespace exml {
class Element : public AttributeList { class Element : public exml::AttributeList {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -27,10 +27,6 @@ namespace exml {
Element(const std::string& _value) : Element(const std::string& _value) :
exml::AttributeList(_value) { exml::AttributeList(_value) {
};
Element(const std::u32string& _value) :
exml::AttributeList(_value) {
}; };
/** /**
* @brief Destructor * @brief Destructor
@ -79,8 +75,6 @@ namespace exml {
*/ */
Element* getNamed(const std::string& _name); Element* getNamed(const std::string& _name);
const Element* getNamed(const std::string& _name) const; const Element* getNamed(const std::string& _name) const;
Element* getNamed(const std::u32string& _name);
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.

View File

@ -12,6 +12,15 @@
#undef __class__ #undef __class__
#define __class__ "Node" #define __class__ "Node"
static bool isWhiteChar(char32_t _val) {
if( _val == ' '
|| _val == '\t'
|| _val == '\n'
|| _val == '\r') {
return true;
}
return false;
}
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 << "(l=";
@ -27,10 +36,6 @@ exml::Node::Node(const std::string& _value) :
m_value(_value) { m_value(_value) {
// nothing to do. // nothing to do.
} }
exml::Node::Node(const std::u32string& _value) :
m_pos(0,0) {
m_value = to_u8string(_value);
}
void exml::Node::addIndent(std::string& _data, int32_t _indent) const { void exml::Node::addIndent(std::string& _data, int32_t _indent) const {
@ -101,7 +106,7 @@ int32_t exml::Node::countWhiteChar(const std::string& _data, int32_t _pos, exml:
int32_t white=0; int32_t white=0;
for (size_t iii=_pos; iii<_data.size(); iii++) { for (size_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]); _filePos.check(_data[iii]);
if(true == etk::isWhiteChar(_data[iii])) { if(true == isWhiteChar(_data[iii])) {
white++; white++;
} else { } else {
break; break;
@ -116,10 +121,3 @@ void exml::Node::clear(void) {
m_pos.clear(); m_pos.clear();
} }
void exml::Node::setValue(std::u32string _value) {
m_value = to_u8string(_value);
}
std::u32string exml::Node::getUValue(void) const {
return to_u32string(m_value);
}

View File

@ -10,11 +10,10 @@
#define __ETK_XML_NODE_H__ #define __ETK_XML_NODE_H__
#include <etk/types.h> #include <etk/types.h>
#include <etk/UString.h> #include <etk/types.h>
#include <etk/math/Vector2D.h> #include <etk/math/Vector2D.h>
namespace exml namespace exml {
{
//#define ENABLE_DISPLAY_PARSED_ELEMENT //#define ENABLE_DISPLAY_PARSED_ELEMENT
//#define ENABLE_CRITICAL_WHEN_ERROR //#define ENABLE_CRITICAL_WHEN_ERROR
#if 1 #if 1
@ -133,7 +132,6 @@ namespace exml
* @param[in] value of the node * @param[in] value of the node
*/ */
Node(const std::string& _value); Node(const std::string& _value);
Node(const std::u32string& _value);
/** /**
* @brief destructor * @brief destructor
*/ */
@ -176,7 +174,6 @@ namespace exml
virtual void setValue(std::string _value) { virtual void setValue(std::string _value) {
m_value = _value; m_value = _value;
}; };
virtual void setValue(std::u32string _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.
@ -184,7 +181,6 @@ namespace exml
virtual const std::string& getValue(void) const { virtual const std::string& getValue(void) const {
return m_value; return m_value;
}; };
virtual std::u32string getUValue(void) const;
public: public:
/** /**
* @brief get the node type. * @brief get the node type.

View File

@ -13,6 +13,17 @@
#undef __class__ #undef __class__
#define __class__ "Text" #define __class__ "Text"
static bool isWhiteChar(char32_t _val) {
if( _val == ' '
|| _val == '\t'
|| _val == '\n'
|| _val == '\r') {
return true;
}
return false;
}
bool exml::Text::iGenerate(std::string& _data, int32_t _indent) const { bool exml::Text::iGenerate(std::string& _data, int32_t _indent) const {
_data += m_value; _data += m_value;
return true; return true;
@ -44,7 +55,7 @@ bool exml::Text::iParse(const std::string& _data, int32_t& _pos, bool _caseSensi
// search whitespace : // search whitespace :
size_t newEnd=iii; size_t newEnd=iii;
for (int64_t jjj=(int64_t)iii-1; jjj>(int64_t)_pos; --jjj) { for (int64_t jjj=(int64_t)iii-1; jjj>(int64_t)_pos; --jjj) {
if(true == etk::isWhiteChar(_data[jjj])) { if(true == isWhiteChar(_data[jjj])) {
newEnd = jjj; newEnd = jjj;
} else { } else {
break; break;

View File

@ -13,7 +13,7 @@
#include <vector> #include <vector>
namespace exml { namespace exml {
class Text : public Node { class Text : public exml::Node {
public: public:
/** /**
* @brief Constructor * @brief Constructor
@ -46,7 +46,7 @@ namespace exml {
return this; return this;
}; };
}; };
class TextCDATA : public Text { class TextCDATA : public exml::Text {
public: public:
/** /**
* @brief Constructor * @brief Constructor