[DEV] change idea std::u32string to std::string

This commit is contained in:
Edouard DUPIN 2013-11-12 21:58:13 +01:00
parent 2325808997
commit 4d02dd677e
17 changed files with 295 additions and 156 deletions

View File

@ -11,15 +11,27 @@
#include <exml/Document.h>
#undef __class__
#define __class__ "Attribute"
#define __class__ "Attribute"
exml::Attribute::Attribute(const std::u32string& _name, const std::u32string& _value) :
exml::Attribute::Attribute(const std::string& _name, const std::string& _value) :
exml::Node(_value),
m_name(_name) {
}
bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
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) {
EXML_VERBOSE("start parse : 'attribute'");
m_pos = _filePos;
// search end of the comment :
@ -35,7 +47,7 @@ bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _c
break;
}
}
m_name = std::u32string(_data, _pos, lastElementName+1);
m_name = std::string(_data, _pos, lastElementName+1);
if (true == _caseSensitive) {
m_name = to_lower(m_name);
}
@ -44,18 +56,18 @@ bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _c
int32_t white = countWhiteChar(_data, lastElementName+1, tmpPos);
_filePos += tmpPos;
if (lastElementName+white+1 >= _data.size()) {
CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, U" parse an xml end with an attribute parsing...");
CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, " parse an xml end with an attribute parsing...");
return false;
}
if (_data[lastElementName+white+1] != '=') {
CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, U" error attribute parsing == > missing '=' ...");
CREATE_ERROR(_doc, _data, lastElementName+white+1, _filePos, " error attribute parsing == > missing '=' ...");
return false;
}
white += countWhiteChar(_data, lastElementName+white+2, tmpPos);
_filePos += tmpPos;
if (lastElementName+white+2>=_data.size()) {
CREATE_ERROR(_doc, _data, lastElementName+white+2, _filePos, U" parse an xml end with an attribute parsing...");
CREATE_ERROR(_doc, _data, lastElementName+white+2, _filePos, " parse an xml end with an attribute parsing...");
return false;
}
if (_data[lastElementName+white+2] != '"') {
@ -67,7 +79,7 @@ bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _c
drawElementParsed(_data[iii], _filePos);
#endif
if (_filePos.check(_data[iii]) == true) {
CREATE_ERROR(_doc, _data, iii, _filePos, U"unexpected '\\n' in an attribute parsing");
CREATE_ERROR(_doc, _data, iii, _filePos, "unexpected '\\n' in an attribute parsing");
return false;
}
if( _data[iii] != ' '
@ -79,7 +91,7 @@ bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _c
break;
}
}
m_value = std::u32string(_data, lastElementName+white+2, lastAttributePos);
m_value = std::string(_data, lastElementName+white+2, lastAttributePos);
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -98,7 +110,7 @@ bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _c
break;
}
}
m_value = std::u32string(_data, lastElementName+white+3, lastAttributePos);
m_value = std::string(_data, lastElementName+white+3, lastAttributePos);
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -106,16 +118,16 @@ bool exml::Attribute::iParse(const std::u32string& _data, int32_t& _pos, bool _c
return true;
}
bool exml::Attribute::iGenerate(std::u32string& _data, int32_t _indent) const {
_data += U" ";
bool exml::Attribute::iGenerate(std::string& _data, int32_t _indent) const {
_data += " ";
_data += m_name;
_data += U"=\"";
_data += "=\"";
_data += m_value;
_data += U"\"";
_data += "\"";
return true;
}
void exml::Attribute::clear(void) {
m_name = U"";
m_name = "";
}

View File

@ -24,34 +24,37 @@ namespace exml {
* @param[in] _name Name of the attribute.
* @param[in] _value Value of the attribute.
*/
Attribute(const std::string& _name, const std::string& _value);
Attribute(const std::u32string& _name, const std::u32string& _value);
/**
* @brief Destructor
*/
virtual ~Attribute(void) { };
protected:
std::u32string m_name;
std::string m_name;
public:
/**
* @brief set the name of the attribute
* @param[in] _name New name of the attribute
*/
virtual void setName(std::u32string _name) {
virtual void setName(const std::string& _name) {
m_name = _name;
};
virtual void setName(const std::u32string& _name);
/**
* @brief get the current name of the Attribute
* @return String of the attribute
*/
virtual const std::u32string& getName(void) const {
virtual const std::string& getName(void) const {
return m_name;
};
virtual std::u32string getUName(void) const;
public: // herited function:
virtual enum nodeType getType(void) const {
return exml::typeAttribute;
};
virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(std::string& _data, int32_t _indent) const;
virtual exml::Attribute* toAttribute(void) {
return this;
};

View File

@ -10,7 +10,7 @@
#include <exml/debug.h>
#undef __class__
#define __class__ "AttributeList"
#define __class__ "AttributeList"
exml::AttributeList::~AttributeList(void) {
for (int32_t iii=0; iii<m_listAttribute.size(); iii++) {
@ -50,8 +50,8 @@ void exml::AttributeList::appendAttribute(exml::Attribute* _attr) {
m_listAttribute.push_back(_attr);
}
const std::u32string& exml::AttributeList::getAttribute(const std::u32string& _name) const {
static const std::u32string errorReturn(U"");
const std::string& exml::AttributeList::getAttribute(const std::string& _name) const {
static const std::string errorReturn("");
if (_name.size() == 0) {
return errorReturn;
}
@ -64,7 +64,21 @@ const std::u32string& exml::AttributeList::getAttribute(const std::u32string& _n
return errorReturn;
}
bool exml::AttributeList::existAttribute(const std::u32string& _name) const {
std::u32string exml::AttributeList::getAttribute(const std::u32string& _name) const {
static const std::u32string errorReturn(U"");
if (_name.size() == 0) {
return errorReturn;
}
for (int32_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 {
if (_name.size() == 0) {
return false;
}
@ -77,7 +91,20 @@ bool exml::AttributeList::existAttribute(const std::u32string& _name) const {
return false;
}
void exml::AttributeList::setAttribute(const std::u32string& _name, const std::u32string& _value) {
bool exml::AttributeList::existAttribute(const std::u32string& _name) const {
if (_name.size() == 0) {
return false;
}
for (int32_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) {
// check if attribute already det :
for (int32_t iii=0; iii<m_listAttribute.size(); iii++) {
if( NULL != m_listAttribute[iii]
@ -94,7 +121,24 @@ void exml::AttributeList::setAttribute(const std::u32string& _name, const std::u
m_listAttribute.push_back(attr);
}
bool exml::AttributeList::iGenerate(std::u32string& _data, int32_t _indent) const {
void exml::AttributeList::setAttribute(const std::u32string& _name, const std::u32string& _value) {
// check if attribute already det :
for (int32_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 {
for (int32_t iii=0; iii<m_listAttribute.size(); iii++) {
if (NULL!=m_listAttribute[iii]) {
m_listAttribute[iii]->iGenerate(_data, _indent);

View File

@ -24,6 +24,10 @@ namespace exml {
* @brief Constructor
* @param[in] _value Node value;
*/
AttributeList(const std::string& _value) :
exml::Node(_value) {
};
AttributeList(const std::u32string& _value) :
exml::Node(_value) {
@ -59,21 +63,24 @@ namespace exml {
* @param[in] _name Attribute Name.
* @return Value of the attribute or no data in the string
*/
const std::u32string& getAttribute(const std::u32string& _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.
* @param[in] _name Attribute Name.
* @return true if the attribute exist or False
*/
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
* @param[in] _name Name of the attribute
* @param[in] _value Value of the attribute
*/
void setAttribute(const std::string& _name, const std::string& _value);
void setAttribute(const std::u32string& _name, const std::u32string& _value);
public: // herited function:
bool iGenerate(std::u32string& _data, int32_t _indent) const;
bool iGenerate(std::string& _data, int32_t _indent) const;
virtual void clear(void);
};
};

View File

@ -11,9 +11,9 @@
#include <exml/Document.h>
#undef __class__
#define __class__ "Comment"
#define __class__ "Comment"
bool exml::Comment::iParse(const std::u32string& _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'");
m_pos = _filePos;
exml::filePos tmpPos;
@ -41,21 +41,21 @@ bool exml::Comment::iParse(const std::u32string& _data, int32_t& _pos, bool _cas
}
}
// find end of value:
m_value = std::u32string(_data, _pos+white, newEnd);
m_value = std::string(_data, _pos+white, newEnd);
EXML_VERBOSE(" find comment '" << m_value << "'");
_pos = iii+2;
return true;
}
}
_pos = _data.size();
CREATE_ERROR(_doc, _data, _pos, _filePos, U"comment got end of file without finding end node");
CREATE_ERROR(_doc, _data, _pos, _filePos, "comment got end of file without finding end node");
return false;
}
bool exml::Comment::iGenerate(std::u32string& _data, int32_t _indent) const {
bool exml::Comment::iGenerate(std::string& _data, int32_t _indent) const {
addIndent(_data, _indent);
_data += U"<!--";
_data += "<!--";
_data += m_value;
_data += U"-->\n";
_data += "-->\n";
return true;
}

View File

@ -23,6 +23,10 @@ namespace exml {
* @brief Constructor
* @param[in] _value comment value
*/
Comment(const std::string& _value) :
exml::Node(_value) {
};
Comment(const std::u32string& _value) :
exml::Node(_value) {
@ -35,8 +39,8 @@ namespace exml {
virtual enum nodeType getType(void) const {
return typeAttribute;
};
virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(std::string& _data, int32_t _indent) const;
virtual exml::Comment* toComment(void) {
return this;
};

View File

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

View File

@ -23,6 +23,10 @@ namespace exml {
* @brief Constructor
* @param[in] _name name of the declaration (xml, xml:xxxx ...)
*/
Declaration(const std::string& _name) :
exml::AttributeList(_name) {
};
Declaration(const std::u32string& _name) :
exml::AttributeList(_name) {
@ -35,8 +39,8 @@ namespace exml {
virtual enum nodeType getType(void) const {
return typeAttribute;
};
virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(std::string& _data, int32_t _indent) const;
virtual bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual exml::Declaration* toDeclaration(void) {
return this;
};
@ -52,6 +56,7 @@ namespace exml {
* @param[in] _format charset of the XML
* @param[in] _standalone this document is standalone
*/
DeclarationXML(const std::string& _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

View File

@ -11,20 +11,20 @@
#include <etk/os/FSNode.h>
#undef __class__
#define __class__ "Document"
#define __class__ "Document"
exml::Document::Document(void) :
m_charset(unicode::charsetUTF8),
m_caseSensitive(false),
m_writeErrorWhenDetexted(true),
m_comment(U""),
m_Line(U""),
m_comment(""),
m_Line(""),
m_filePos(0,0) {
}
bool exml::Document::iGenerate(std::u32string& _data, int32_t _indent) const {
bool exml::Document::iGenerate(std::string& _data, int32_t _indent) const {
for (int32_t iii=0; iii<m_listSub.size(); iii++) {
if (NULL!=m_listSub[iii]) {
m_listSub[iii]->iGenerate(_data, _indent);
@ -34,6 +34,9 @@ bool exml::Document::iGenerate(std::u32string& _data, int32_t _indent) const {
}
bool exml::Document::parse(const std::u32string& _data) {
return parse(to_u8string(_data));
}
bool exml::Document::parse(const std::string& _data) {
EXML_VERBOSE("Start parsing document (type: string) size=" << _data.size());
clear();
// came from char == > force in utf8 ...
@ -45,11 +48,20 @@ bool exml::Document::parse(const std::u32string& _data) {
}
bool exml::Document::generate(std::u32string& _data) {
_data = U"";
std::string data;
bool ret = generate(data);
_data = to_u32string(data);
return ret;
}
bool exml::Document::generate(std::string& _data) {
_data = "";
return iGenerate(_data,0);
}
bool exml::Document::load(const std::u32string& _file) {
bool exml::Document::load(const std::u32string& _data) {
return load(to_u8string(_data));
}
bool exml::Document::load(const std::string& _file) {
// Start loading the XML :
EXML_VERBOSE("open file (xml) \"" << _file << "\"");
clear();
@ -81,7 +93,7 @@ bool exml::Document::load(const std::u32string& _file) {
tmpFile.fileClose();
// convert in UTF8 :
std::u32string tmpDataUnicode(to_u32string(fileBuffer));
std::string tmpDataUnicode(fileBuffer);
// remove temporary buffer:
delete(fileBuffer);
// parse the data :
@ -90,8 +102,11 @@ bool exml::Document::load(const std::u32string& _file) {
return ret;
}
bool exml::Document::store(const std::u32string& _file) {
std::u32string createData;
bool exml::Document::store(const std::u32string& _data) {
return store(to_u8string(_data));
}
bool exml::Document::store(const std::string& _file) {
std::string createData;
if (false == generate(createData)) {
EXML_ERROR("Error while creating the XML : " << _file);
return false;
@ -101,8 +116,7 @@ bool exml::Document::store(const std::u32string& _file) {
EXML_ERROR("Can not open (w) the file : " << _file);
return false;
}
std::string endTable = to_u8string(createData);
if (tmpFile.fileWrite((char*)endTable.c_str(), sizeof(char), endTable.size()) != endTable.size()) {
if (tmpFile.fileWrite((char*)createData.c_str(), sizeof(char), createData.size()) != createData.size()) {
EXML_ERROR("Error while writing output XML file : " << _file);
tmpFile.fileClose();
return false;
@ -112,25 +126,25 @@ bool exml::Document::store(const std::u32string& _file) {
}
void exml::Document::display(void) {
std::u32string tmpp;
std::string tmpp;
iGenerate(tmpp, 0);
EXML_INFO("Generated XML : \n" << tmpp);
}
std::u32string createPosPointer(const std::u32string& _line, int32_t _pos) {
std::u32string out;
std::string createPosPointer(const std::string& _line, int32_t _pos) {
std::string out;
int32_t iii;
for (iii=0; iii<_pos && iii<_line.size(); iii++) {
if (_line[iii] == '\t') {
out += U"\t";
out += "\t";
} else {
out += U" ";
out += " ";
}
}
for (; iii<_pos; iii++) {
out += U" ";
out += " ";
}
out += U"^";
out += "^";
return out;
}
@ -147,7 +161,7 @@ void exml::Document::displayError(void) {
#endif
}
void exml::Document::createError(const std::u32string& _data, int32_t _pos, const exml::filePos& _filePos, const std::u32string& _comment) {
void exml::Document::createError(const std::string& _data, int32_t _pos, const exml::filePos& _filePos, const std::string& _comment) {
m_comment = _comment;
m_Line = extract_line(_data, _pos);
m_filePos = _filePos;

View File

@ -65,6 +65,7 @@ namespace exml {
* @return false : An error occured
* @return true : Parsing is OK
*/
bool parse(const std::string& _data);
bool parse(const std::u32string& _data);
/**
* @brief generate a string that contain the created XML
@ -72,6 +73,7 @@ namespace exml {
* @return false : An error occured
* @return true : Parsing is OK
*/
bool generate(std::string& _data);
bool generate(std::u32string& _data);
/**
* @brief Load the file that might contain the xml
@ -79,6 +81,7 @@ namespace exml {
* @return false : An error occured
* @return true : Parsing is OK
*/
bool load(const std::string& _file);
bool load(const std::u32string& _file);
/**
* @brief Store the Xml in the file
@ -86,6 +89,7 @@ namespace exml {
* @return false : An error occured
* @return true : Parsing is OK
*/
bool store(const std::string& _file);
bool store(const std::u32string& _file);
/**
* @brief Display the Document on console
@ -93,8 +97,8 @@ namespace exml {
void display(void);
private:
bool m_writeErrorWhenDetexted;
std::u32string m_comment;
std::u32string m_Line;
std::string m_comment;
std::string m_Line;
exml::filePos m_filePos;
public:
void displayErrorWhenDetected(void) {
@ -104,13 +108,13 @@ namespace exml {
m_writeErrorWhenDetexted = false;
};
void createError(const std::u32string& _data, int32_t _pos, const exml::filePos& _filePos, const std::u32string& _comment);
void createError(const std::string& _data, int32_t _pos, const exml::filePos& _filePos, const std::string& _comment);
void displayError(void);
public: // herited function:
virtual enum nodeType getType(void) const {
return typeDocument;
};
bool iGenerate(std::u32string& _data, int32_t _indent) const;
bool iGenerate(std::string& _data, int32_t _indent) const;
virtual exml::Document* toDocument(void) {
return this;
};

View File

@ -15,7 +15,7 @@
#include <exml/Document.h>
#undef __class__
#define __class__ "Element"
#define __class__ "Element"
exml::Element::~Element(void) {
@ -74,7 +74,7 @@ const exml::Element* exml::Element::getElement(int32_t _id) const {
return tmpp->toElement();
}
exml::Element* exml::Element::getNamed(const std::u32string& _name) {
exml::Element* exml::Element::getNamed(const std::string& _name) {
if (_name.size() == 0) {
return NULL;
}
@ -90,8 +90,11 @@ exml::Element* exml::Element::getNamed(const std::u32string& _name) {
}
return NULL;
}
exml::Element* exml::Element::getNamed(const std::u32string& _name) {
return getNamed(to_u8string(_name));
}
const exml::Element* exml::Element::getNamed(const std::u32string& _name) const {
const exml::Element* exml::Element::getNamed(const std::string& _name) const {
if (_name.size() == 0) {
return NULL;
}
@ -107,6 +110,9 @@ const exml::Element* exml::Element::getNamed(const std::u32string& _name) const
}
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) {
if (_node == NULL) {
@ -126,9 +132,9 @@ void exml::Element::append(exml::Node* _node) {
m_listSub.push_back(_node);
}
std::u32string exml::Element::getText(void) {
std::string exml::Element::getText(void) {
// TODO : add more capabilities ...
std::u32string res;
std::string res;
for (int32_t iii=0; iii<m_listSub.size(); iii++) {
if (NULL!=m_listSub[iii]) {
m_listSub[iii]->iGenerate(res, 0);
@ -137,9 +143,9 @@ std::u32string exml::Element::getText(void) {
return res;
}
bool exml::Element::iGenerate(std::u32string& _data, int32_t _indent) const {
bool exml::Element::iGenerate(std::string& _data, int32_t _indent) const {
addIndent(_data, _indent);
_data += U"<";
_data += "<";
_data += m_value;
exml::AttributeList::iGenerate(_data, _indent);
@ -148,10 +154,10 @@ bool exml::Element::iGenerate(std::u32string& _data, int32_t _indent) const {
&& m_listSub[0] != NULL
&& m_listSub[0]->getType() == exml::typeText
&& static_cast<exml::Text*>(m_listSub[0])->countLines() == 1) {
_data += U">";
_data += ">";
m_listSub[0]->iGenerate(_data,0);
} else {
_data += U">\n";
_data += ">\n";
for (int32_t iii=0; iii<m_listSub.size(); iii++) {
if (NULL!=m_listSub[iii]) {
@ -160,17 +166,17 @@ bool exml::Element::iGenerate(std::u32string& _data, int32_t _indent) const {
}
addIndent(_data, _indent);
}
_data += U"</";
_data += "</";
_data += m_value;
_data += U">\n";
_data += ">\n";
} else {
_data += U"/>\n";
_data += "/>\n";
}
return true;
}
bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode) {
bool exml::Element::subParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode) {
EXML_PARSE_ELEMENT(" start subParse ... " << _pos << " " << _filePos);
for (int32_t iii=_pos; iii<_data.size(); iii++) {
_filePos.check(_data[iii]);
@ -182,14 +188,14 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
int32_t white = countWhiteChar(_data, iii+1, tmpPos);
if (iii+white+1>=_data.size()) {
_filePos+=tmpPos;
CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<' char == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<' char == > invalide XML");
_pos = iii+white;
return false;
}
// Detect type of the element:
if(_data[iii+white+1] == '>') {
_filePos+=tmpPos;
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find '>' with no element in the element...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find '>' with no element in the element...");
_pos = iii+white+1;
return false;
}
@ -197,7 +203,7 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
++tmpPos;
// TODO : white space ...
if( false == checkAvaillable(_data[iii+white+2], true) ) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find unavaillable name in the Declaration node...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find unavaillable name in the Declaration node...");
_pos = iii+white+1;
return false;
}
@ -213,14 +219,14 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
}
tmpPos.check(_data[jjj]);
}
std::u32string tmpname = std::u32string(_data, iii+white+2, endPosName+1);
std::string tmpname = std::string(_data, iii+white+2, endPosName+1);
if (true == _caseSensitive) {
tmpname = to_lower(tmpname);
}
// Find declaration balise
exml::Declaration* declaration = new exml::Declaration(tmpname);
if (NULL == declaration) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation Error...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation Error...");
return false;
}
_filePos += tmpPos;
@ -237,24 +243,24 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
++tmpPos;
// Find special block element
if (iii+white+2>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<!' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<!' chars == > invalide XML");
return false;
}
if(_data[iii+white+2] == '-') {
++tmpPos;
if (iii+white+3>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<!-' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<!-' chars == > invalide XML");
return false;
}
if(_data[iii+white+3] != '-') {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Element parse with '<!-") + _data[iii+3] + U"' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Element parse with '<!-") + _data[iii+3] + "' chars == > invalide XML");
return false;
}
++tmpPos;
// find comment:
exml::Comment* comment = new exml::Comment();
if (NULL == comment) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
_pos = iii+white+4;
@ -268,7 +274,7 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
} else if (_data[iii+white+2] == '[') {
++tmpPos;
if (iii+white+8>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"End file with '<![' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, "End file with '<![' chars == > invalide XML");
return false;
}
if( _data[iii+white+3] != 'C'
@ -277,14 +283,14 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
|| _data[iii+white+6] != 'T'
|| _data[iii+white+7] != 'A'
|| _data[iii+white+8] != '[') {
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");
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("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");
return false;
}
tmpPos+=6;
// find text:
exml::TextCDATA* text = new exml::TextCDATA();
if (NULL == text) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
_pos = iii+9+white;
@ -296,7 +302,7 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
iii = _pos;
m_listSub.push_back(text);
} else {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"End file with '<!") + _data[iii+white+2] + U"' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("End file with '<!") + _data[iii+white+2] + "' chars == > invalide XML");
return false;
}
@ -316,7 +322,7 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
}
tmpPos.check(_data[jjj]);
}
std::u32string tmpname = std::u32string(_data, iii+white+2, endPosName+1);
std::string tmpname = std::string(_data, iii+white+2, endPosName+1);
if (true == _caseSensitive) {
tmpname = to_lower(tmpname);
}
@ -338,18 +344,18 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
&& _data[jjj] != ' '
&& _data[jjj] != '\t') {
_filePos += tmpPos;
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"'");
CREATE_ERROR(_doc, _data, jjj, _filePos, std::string("End node error : have data inside end node other than [ \\n\\t\\r] ") + m_value + "'");
return false;
}
}
} else {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"End node error : '") + tmpname + U"' != '" + m_value + U"'");
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("End node error : '") + tmpname + "' != '" + m_value + "'");
return false;
}
}
if (_data[iii+white+1] == '>') {
// end of something == > this is really bad
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find '>' chars == > invalide XML");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find '>' chars == > invalide XML");
return false;
}
@ -367,7 +373,7 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
}
tmpPos.check(_data[jjj]);
}
std::u32string tmpname = std::u32string(_data, iii+white+1, endPosName+1);
std::string tmpname = std::string(_data, iii+white+1, endPosName+1);
if (true == _caseSensitive) {
to_lower(tmpname);
}
@ -375,7 +381,7 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
// find text:
exml::Element* element = new exml::Element(tmpname);
if (NULL == element) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
_pos = endPosName+1;
@ -390,11 +396,11 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
}
_filePos+=tmpPos;
// here we have an error :
CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Find an ununderstanding element : '") + _data[iii+white+1] + U"'");
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Find an ununderstanding element : '") + _data[iii+white+1] + "'");
return false;
} else {
if (_data[iii] == '>') {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find elemement '>' == > no reason to be here ...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find elemement '>' == > no reason to be here ...");
return false;
}
// might to be data text ...
@ -407,7 +413,7 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
// find data == > parse it...
exml::Text* text = new exml::Text();
if (NULL == text) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
_pos = iii;
@ -424,11 +430,11 @@ bool exml::Element::subParse(const std::u32string& _data, int32_t& _pos, bool _c
if (_mainNode == true) {
return true;
}
CREATE_ERROR(_doc, _data, _pos, _filePos, std::u32string(U"Did not find end of the exml::Element : '") + m_value + U"'");
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Did not find end of the exml::Element : '") + m_value + "'");
return false;
}
bool exml::Element::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
bool exml::Element::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
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
m_pos=_filePos;
@ -446,7 +452,7 @@ bool exml::Element::iParse(const std::u32string& _data, int32_t& _pos, bool _cas
if (_data[iii] == '/') {
// standalone node or error...
if (iii+1>=_data.size()) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find end of files ... == > bad case");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find end of files ... == > bad case");
return false;
}
// TODO : Can have white spaces ....
@ -455,14 +461,14 @@ bool exml::Element::iParse(const std::u32string& _data, int32_t& _pos, bool _cas
return true;
}
// error
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Find / without > char ...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Find / without > char ...");
return false;
}
if (true == checkAvaillable(_data[iii], true)) {
// we find an attibute == > create a new and parse it :
exml::Attribute* attribute = new exml::Attribute();
if (NULL == attribute) {
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Allocation error ...");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Allocation error ...");
return false;
}
_pos = iii;
@ -475,11 +481,11 @@ bool exml::Element::iParse(const std::u32string& _data, int32_t& _pos, bool _cas
continue;
}
if (false == etk::isWhiteChar(_data[iii])) {
CREATE_ERROR(_doc, _data, iii, _filePos, std::u32string(U"Find an unknow element : '") + _data[iii] + U"'");
CREATE_ERROR(_doc, _data, iii, _filePos, std::string("Find an unknow element : '") + _data[iii] + "'");
return false;
}
}
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");
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Unexpecting end of parsing exml::Element : '") + m_value + "' == > check if the '/>' is set or the end of element");
return false;
}

View File

@ -24,6 +24,10 @@ namespace exml {
* @brief Constructor
* @param[in] _value Element name;
*/
Element(const std::string& _value) :
exml::AttributeList(_value) {
};
Element(const std::u32string& _value) :
exml::AttributeList(_value) {
@ -73,21 +77,23 @@ namespace exml {
* @param[in] _name Name of the element that is requested
* @return Pointer on the element or NULL.
*/
Element* getNamed(const std::string& _name);
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[...]]>
* @return the curent data string.
*/
std::u32string getText(void);
std::string getText(void);
protected:
bool subParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode=false);
bool subParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc, bool _mainNode=false);
public: // herited function:
virtual enum nodeType getType(void) const {
return typeElement;
};
virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(std::u32string& _data, int32_t _indent) const;
virtual bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc);
virtual bool iGenerate(std::string& _data, int32_t _indent) const;
virtual exml::Element* toElement(void) {
return this;
};

View File

@ -14,23 +14,28 @@
etk::CCout& exml::operator <<(etk::CCout& _os, const exml::filePos& _obj) {
_os << U"(l=";
_os << "(l=";
_os << _obj.getLine();
_os << U",c=";
_os << ",c=";
_os << _obj.getCol();
_os << U")";
_os << ")";
return _os;
}
exml::Node::Node(const std::u32string& _value) :
exml::Node::Node(const std::string& _value) :
m_pos(0,0),
m_value(_value) {
// nothing to do.
}
exml::Node::Node(const std::u32string& _value) :
m_pos(0,0) {
m_value = to_u8string(_value);
}
void exml::Node::addIndent(std::u32string& _data, int32_t _indent) const {
void exml::Node::addIndent(std::string& _data, int32_t _indent) const {
for (int32_t iii=0; iii<_indent; iii++) {
_data += U"\t";
_data += "\t";
}
}
@ -91,7 +96,7 @@ bool exml::Node::checkAvaillable(char32_t _val, bool _firstChar) const {
}
int32_t exml::Node::countWhiteChar(const std::u32string& _data, int32_t _pos, exml::filePos& _filePos) const {
int32_t exml::Node::countWhiteChar(const std::string& _data, int32_t _pos, exml::filePos& _filePos) const {
_filePos.clear();
int32_t white=0;
for (int32_t iii=_pos; iii<_data.size(); iii++) {
@ -107,6 +112,14 @@ int32_t exml::Node::countWhiteChar(const std::u32string& _data, int32_t _pos, ex
}
void exml::Node::clear(void) {
m_value = U"";
m_value = "";
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

@ -132,6 +132,7 @@ namespace exml
* @brief basic element of a xml structure
* @param[in] value of the node
*/
Node(const std::string& _value);
Node(const std::u32string& _value);
/**
* @brief destructor
@ -146,14 +147,14 @@ namespace exml
* @param[in,out] file parsing position (line x col x)
* @return false if an error occured.
*/
virtual bool iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) = 0;
virtual bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) = 0;
/**
* @brief generate a string with the tree of the xml
* @param[in,out] _data string where to add the elements
* @param[in] current indentation of the file
* @return false if an error occured.
*/
virtual bool iGenerate(std::u32string& _data, int32_t _indent) const {
virtual bool iGenerate(std::string& _data, int32_t _indent) const {
return true;
};
protected:
@ -166,22 +167,24 @@ namespace exml
return m_pos;
};
protected:
std::u32string m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
std::string m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
public:
/**
* @brief set the value of the node.
* @param[in] _value New value of the node.
*/
virtual void setValue(std::u32string _value) {
virtual void setValue(std::string _value) {
m_value = _value;
};
virtual void setValue(std::u32string _value);
/**
* @brief get the current element Value.
* @return the reference of the string value.
*/
virtual const std::u32string& getValue(void) const {
virtual const std::string& getValue(void) const {
return m_value;
};
virtual std::u32string getUValue(void) const;
public:
/**
* @brief get the node type.
@ -196,7 +199,7 @@ namespace exml
* @param[in,out] _data String where the indentation is done.
* @param[in] _indent Number of tab to add at the string.
*/
void addIndent(std::u32string& _data, int32_t _indent) const;
void addIndent(std::string& _data, int32_t _indent) const;
/**
* @brief Display the cuurent element that is curently parse.
* @param[in] _val Char that is parsed.
@ -216,7 +219,7 @@ namespace exml
* @param[out] _filePos new poistion of te file to add.
* @return number of white element.
*/
int32_t countWhiteChar(const std::u32string& _data, int32_t _pos, exml::filePos& _filePos) const;
int32_t countWhiteChar(const std::string& _data, int32_t _pos, exml::filePos& _filePos) const;
public:
/**
* @brief Cast the element in a Document if it is possible.

View File

@ -11,9 +11,9 @@
#include <exml/Document.h>
#undef __class__
#define __class__ "Text"
#define __class__ "Text"
bool exml::Text::iGenerate(std::u32string& _data, int32_t _indent) const {
bool exml::Text::iGenerate(std::string& _data, int32_t _indent) const {
_data += m_value;
return true;
}
@ -28,7 +28,7 @@ int32_t exml::Text::countLines(void) const {
return count;
}
bool exml::Text::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
bool exml::Text::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_VERBOSE("start parse : 'text'");
m_pos = _filePos;
// search end of the comment :
@ -51,18 +51,18 @@ bool exml::Text::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSe
}
}
// find end of value:
m_value = std::u32string(_data, _pos, newEnd);
m_value = std::string(_data, _pos, newEnd);
EXML_VERBOSE(" find text '" << m_value << "'");
_pos = iii-1;
return true;
}
}
CREATE_ERROR(_doc, _data, _pos, _filePos, U"Text got end of file without finding end node");
CREATE_ERROR(_doc, _data, _pos, _filePos, "Text got end of file without finding end node");
_pos = _data.size();
return false;
}
bool exml::TextCDATA::iParse(const std::u32string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
bool exml::TextCDATA::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::filePos& _filePos, exml::Document& _doc) {
EXML_VERBOSE("start parse : 'text::CDATA'");
m_pos = _filePos;
// search end of the comment :
@ -78,13 +78,13 @@ bool exml::TextCDATA::iParse(const std::u32string& _data, int32_t& _pos, bool _c
&& _data[iii+2] == '>') {
// find end of value:
_filePos += 2;
m_value = std::u32string(_data, _pos, iii);
m_value = std::string(_data, _pos, iii);
EXML_VERBOSE(" find text CDATA '" << m_value << "'");
_pos = iii+2;
return true;
}
}
CREATE_ERROR(_doc, _data, _pos, _filePos, U"text CDATA got end of file without finding end node");
CREATE_ERROR(_doc, _data, _pos, _filePos, "text CDATA got end of file without finding end node");
_pos = _data.size();
return false;
}

View File

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

View File

@ -16,11 +16,11 @@
class testCheck {
public:
std::u32string m_ref;
std::u32string m_input;
std::string m_ref;
std::string m_input;
int32_t m_errorPos; // -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ????
testCheck(void) {};
void set(const std::u32string& _ref, int32_t _pos, const std::u32string& _input) {
void set(const std::string& _ref, int32_t _pos, const std::string& _input) {
m_ref = _ref;
m_input = _input;
m_errorPos = _pos;
@ -30,8 +30,8 @@ class testCheck {
std::vector<testCheck> l_list;
void init(void) {
std::u32string reference;
std::u32string input;
std::string reference;
std::string input;
testCheck check;
// == ====================================================
@ -296,7 +296,7 @@ int main(int argc, const char *argv[]) {
}
sectionID++;
exml::Document doc;
std::u32string out("");
std::string out("");
//EXML_DEBUG("parse : \n" << l_list[iii].m_input);
if (false == doc.parse(l_list[iii].m_input)) {
if (l_list[iii].m_errorPos == 1) {