[DEV] continue removing stl

This commit is contained in:
Edouard DUPIN 2017-08-28 00:05:54 +02:00
parent badb1f9ea7
commit f77bf5d8ad
44 changed files with 249 additions and 262 deletions

View File

@ -29,7 +29,7 @@ exml::Attribute::Attribute(nullptr) :
} }
*/ */
exml::Attribute::Attribute(const std::string& _name, const std::string& _value) : exml::Attribute::Attribute(const etk::String& _name, const etk::String& _value) :
exml::Node() { exml::Node() {
m_data = exml::internal::Attribute::create(_name, _value); m_data = exml::internal::Attribute::create(_name, _value);
} }
@ -39,7 +39,7 @@ exml::Attribute& exml::Attribute::operator= (const exml::Attribute& _obj) {
return *this; return *this;
} }
void exml::Attribute::setName(const std::string& _name){ void exml::Attribute::setName(const etk::String& _name){
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_DEBUG(" can not setName (nullptr) ..."); EXML_DEBUG(" can not setName (nullptr) ...");
return; return;
@ -47,9 +47,9 @@ void exml::Attribute::setName(const std::string& _name){
static_cast<exml::internal::Attribute*>(m_data.get())->setName(_name); static_cast<exml::internal::Attribute*>(m_data.get())->setName(_name);
} }
const std::string& exml::Attribute::getName() const { const etk::String& exml::Attribute::getName() const {
if (m_data == nullptr) { if (m_data == nullptr) {
static std::string errorValue = ""; static etk::String errorValue = "";
EXML_DEBUG(" can not setName (nullptr) ..."); EXML_DEBUG(" can not setName (nullptr) ...");
return errorValue; return errorValue;
} }
@ -64,12 +64,12 @@ void exml::Attribute::clear() {
static_cast<exml::internal::Attribute*>(m_data.get())->clear(); static_cast<exml::internal::Attribute*>(m_data.get())->clear();
} }
std::pair<std::string, std::string> exml::Attribute::getPair() const { etk::Pair<etk::String, etk::String> exml::Attribute::getPair() const {
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_DEBUG(" can not setName (nullptr) ..."); EXML_DEBUG(" can not setName (nullptr) ...");
return std::pair<std::string, std::string>("",""); return etk::Pair<etk::String, etk::String>("","");
} }
return std::pair<std::string, std::string>(static_cast<const exml::internal::Attribute*>(m_data.get())->getName(), return etk::Pair<etk::String, etk::String>(static_cast<const exml::internal::Attribute*>(m_data.get())->getName(),
static_cast<const exml::internal::Attribute*>(m_data.get())->getValue()); static_cast<const exml::internal::Attribute*>(m_data.get())->getValue());
} }

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/Node.hpp> #include <exml/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
namespace internal { namespace internal {
@ -38,7 +38,7 @@ 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 std::string& _name="", const std::string& _value=""); Attribute(const etk::String& _name="", const etk::String& _value="");
/** /**
* @brief Copy constructor * @brief Copy constructor
* @param[in] _obj Object to copy * @param[in] _obj Object to copy
@ -50,17 +50,17 @@ namespace exml {
* @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(const std::string& _name); virtual void setName(const etk::String& _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 std::string& getName() const; virtual const etk::String& getName() const;
/** /**
* @brief get attribute name and value * @brief get attribute name and value
* @return Name and value of the attribute * @return Name and value of the attribute
*/ */
std::pair<std::string, std::string> getPair() const; etk::Pair<etk::String, etk::String> getPair() const;
public: public:
void clear() override; void clear() override;
friend class exml::AttributeListData; friend class exml::AttributeListData;

View File

@ -51,10 +51,10 @@ const exml::Attribute exml::AttributeListData::operator[] (int32_t _id) const {
return exml::Attribute(static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttr(_id)); return exml::Attribute(static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttr(_id));
} }
std::pair<std::string, std::string> exml::AttributeListData::getPair(int32_t _id) const { etk::Pair<etk::String, etk::String> exml::AttributeListData::getPair(int32_t _id) const {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttrPair (nullptr) ..."); EXML_DEBUG(" can not getAttrPair (nullptr) ...");
return std::pair<std::string, std::string>("",""); return etk::Pair<etk::String, etk::String>("","");
} }
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttrPair(_id); return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttrPair(_id);
} }
@ -67,16 +67,16 @@ void exml::AttributeListData::add(exml::Attribute _attr) {
static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->appendAttribute(_attr.getInternalAttribute()); static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->appendAttribute(_attr.getInternalAttribute());
} }
const std::string& exml::AttributeListData::operator[](const std::string& _name) const { const etk::String& exml::AttributeListData::operator[](const etk::String& _name) const {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttribute (nullptr) ..."); EXML_DEBUG(" can not getAttribute (nullptr) ...");
static std::string errorValue(""); static etk::String errorValue("");
return errorValue; return errorValue;
} }
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttribute(_name); return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->getAttribute(_name);
} }
bool exml::AttributeListData::exist(const std::string& _name) const { bool exml::AttributeListData::exist(const etk::String& _name) const {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not getAttribute (nullptr) ..."); EXML_DEBUG(" can not getAttribute (nullptr) ...");
return false; return false;
@ -84,7 +84,7 @@ bool exml::AttributeListData::exist(const std::string& _name) const {
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->existAttribute(_name); return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->existAttribute(_name);
} }
bool exml::AttributeListData::remove(const std::string& _name) { bool exml::AttributeListData::remove(const etk::String& _name) {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not removeAttribute (nullptr) ..."); EXML_DEBUG(" can not removeAttribute (nullptr) ...");
return false; return false;
@ -92,7 +92,7 @@ bool exml::AttributeListData::remove(const std::string& _name) {
return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->removeAttribute(_name); return static_cast<exml::internal::AttributeList*>(m_data->m_data.get())->removeAttribute(_name);
} }
void exml::AttributeListData::set(const std::string& _name, const std::string& _value) { void exml::AttributeListData::set(const etk::String& _name, const etk::String& _value) {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not setAttribute (nullptr) ..."); EXML_DEBUG(" can not setAttribute (nullptr) ...");
return; return;

View File

@ -40,7 +40,7 @@ namespace exml {
* @return true The attribute has been removed * @return true The attribute has been removed
* @return false An error occured. * @return false An error occured.
*/ */
bool remove(const std::string& _name); bool remove(const etk::String& _name);
/** /**
* @brief get attribute whith his ID * @brief get attribute whith his ID
* @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute() * @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute()
@ -58,25 +58,25 @@ namespace exml {
* @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute() * @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute()
* @return Name and value of the attribute * @return Name and value of the attribute
*/ */
std::pair<std::string, std::string> getPair(int32_t _id) const; etk::Pair<etk::String, etk::String> getPair(int32_t _id) const;
/** /**
* @brief get the attribute value with searching in the List with his name * @brief get the attribute value with searching in the List with his name
* @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 std::string& operator[](const std::string& _name) const; const etk::String& operator[](const etk::String& _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 exist(const std::string& _name) const; bool exist(const etk::String& _name) const;
/** /**
* @brief Set A new attribute or replace data of the previous one * @brief Set 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 set(const std::string& _name, const std::string& _value); void set(const etk::String& _name, const etk::String& _value);
public: public:
using iterator = exml::iterator<exml::AttributeListData, exml::Attribute>; //!< Specify iterator of the element methode using iterator = exml::iterator<exml::AttributeListData, exml::Attribute>; //!< Specify iterator of the element methode
/** /**

View File

@ -24,7 +24,7 @@ exml::Comment::Comment(const exml::Comment& _obj) :
} }
exml::Comment::Comment(const std::string& _value) : exml::Comment::Comment(const etk::String& _value) :
exml::Node() { exml::Node() {
m_data = exml::internal::Comment::create(_value); m_data = exml::internal::Comment::create(_value);
} }

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/Node.hpp> #include <exml/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
/** /**
@ -28,7 +28,7 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _value comment value * @param[in] _value comment value
*/ */
Comment(const std::string& _value=""); Comment(const etk::String& _value="");
/** /**
* @brief Copy constructor * @brief Copy constructor
* @param[in] _obj Object to copy * @param[in] _obj Object to copy

View File

@ -24,7 +24,7 @@ exml::Declaration::Declaration(const exml::Declaration& _obj) :
} }
exml::Declaration::Declaration(const std::string& _name) : exml::Declaration::Declaration(const etk::String& _name) :
exml::AttributeList() { exml::AttributeList() {
m_data = exml::internal::Declaration::create(); m_data = exml::internal::Declaration::create();
} }
@ -54,7 +54,7 @@ exml::DeclarationXML::DeclarationXML(const exml::DeclarationXML& _obj) :
} }
exml::DeclarationXML::DeclarationXML(const std::string& _version, const std::string& _format, bool _standalone) : exml::DeclarationXML::DeclarationXML(const etk::String& _version, const etk::String& _format, bool _standalone) :
exml::Declaration() { exml::Declaration() {
m_data = exml::internal::DeclarationXML::create(_version, _format, _standalone); m_data = exml::internal::DeclarationXML::create(_version, _format, _standalone);
} }

View File

@ -28,7 +28,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 std::string& _name=""); Declaration(const etk::String& _name="");
/** /**
* @brief Copy constructor * @brief Copy constructor
* @param[in] _obj Object to copy * @param[in] _obj Object to copy
@ -57,7 +57,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="0.0", const std::string& _format = "UTF-8", bool _standalone = true); DeclarationXML(const etk::String& _version="0.0", const etk::String& _format = "UTF-8", bool _standalone = true);
/** /**
* @brief Copy constructor * @brief Copy constructor
* @param[in] _obj Object to copy * @param[in] _obj Object to copy

View File

@ -34,7 +34,7 @@ exml::Document& exml::Document::operator= (const exml::Document& _obj) {
return *this; return *this;
} }
bool exml::Document::parse(const std::string& _data) { bool exml::Document::parse(const etk::String& _data) {
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_DEBUG("Can not parse (nullptr) ..."); EXML_DEBUG("Can not parse (nullptr) ...");
return false; return false;
@ -42,7 +42,7 @@ bool exml::Document::parse(const std::string& _data) {
return static_cast<exml::internal::Document*>(m_data.get())->parse(_data); return static_cast<exml::internal::Document*>(m_data.get())->parse(_data);
} }
bool exml::Document::generate(std::string& _data) { bool exml::Document::generate(etk::String& _data) {
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_DEBUG("Can not generate (nullptr) ..."); EXML_DEBUG("Can not generate (nullptr) ...");
return false; return false;
@ -50,7 +50,7 @@ bool exml::Document::generate(std::string& _data) {
return static_cast<exml::internal::Document*>(m_data.get())->generate(_data); return static_cast<exml::internal::Document*>(m_data.get())->generate(_data);
} }
bool exml::Document::load(const std::string& _file) { bool exml::Document::load(const etk::String& _file) {
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_DEBUG("Can not load (nullptr) ..."); EXML_DEBUG("Can not load (nullptr) ...");
return false; return false;
@ -58,7 +58,7 @@ bool exml::Document::load(const std::string& _file) {
return static_cast<exml::internal::Document*>(m_data.get())->load(_file); return static_cast<exml::internal::Document*>(m_data.get())->load(_file);
} }
bool exml::Document::store(const std::string& _file) { bool exml::Document::store(const etk::String& _file) {
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_DEBUG("Can not store (nullptr) ..."); EXML_DEBUG("Can not store (nullptr) ...");
return false; return false;

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/Element.hpp> #include <exml/Element.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
/** /**
@ -51,28 +51,28 @@ 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 std::string& _data); bool parse(const etk::String& _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(std::string& _data); bool generate(etk::String& _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 std::string& _file); bool load(const etk::String& _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 std::string& _file); bool store(const etk::String& _file);
/** /**
* @brief Display the Document on console * @brief Display the Document on console
*/ */

View File

@ -28,7 +28,7 @@ exml::Element::Element(const exml::Element& _obj) :
} }
exml::Element::Element(const std::string& _data) : exml::Element::Element(const etk::String& _data) :
exml::AttributeList(), exml::AttributeList(),
nodes(this) { nodes(this) {
m_data = exml::internal::Element::create(_data); m_data = exml::internal::Element::create(_data);
@ -92,7 +92,7 @@ const exml::Node exml::ElementData::operator[](int32_t _id) const {
return exml::Node(static_cast<const exml::internal::Element*>(m_data->m_data.get())->getNode(_id)); return exml::Node(static_cast<const exml::internal::Element*>(m_data->m_data.get())->getNode(_id));
} }
exml::Element exml::ElementData::operator[](const std::string& _name) { exml::Element exml::ElementData::operator[](const etk::String& _name) {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not get type ..."); EXML_DEBUG(" can not get type ...");
return exml::Element(); return exml::Element();
@ -100,7 +100,7 @@ exml::Element exml::ElementData::operator[](const std::string& _name) {
return exml::Element(static_cast<exml::internal::Element*>(m_data->m_data.get())->getNamed(_name)); return exml::Element(static_cast<exml::internal::Element*>(m_data->m_data.get())->getNamed(_name));
} }
const exml::Element exml::ElementData::operator[] (const std::string& _name) const { const exml::Element exml::ElementData::operator[] (const etk::String& _name) const {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not get type ..."); EXML_DEBUG(" can not get type ...");
return exml::Element(); return exml::Element();
@ -116,7 +116,7 @@ void exml::ElementData::add(const exml::Node& _node) {
static_cast<exml::internal::Element*>(m_data->m_data.get())->append(_node.m_data); static_cast<exml::internal::Element*>(m_data->m_data.get())->append(_node.m_data);
} }
void exml::ElementData::remove(const std::string& _nodeName) { void exml::ElementData::remove(const etk::String& _nodeName) {
if (m_data->m_data == nullptr) { if (m_data->m_data == nullptr) {
EXML_DEBUG(" can not APPEND on null element ..."); EXML_DEBUG(" can not APPEND on null element ...");
return; return;
@ -124,7 +124,7 @@ void exml::ElementData::remove(const std::string& _nodeName) {
static_cast<exml::internal::Element*>(m_data->m_data.get())->remove(_nodeName); static_cast<exml::internal::Element*>(m_data->m_data.get())->remove(_nodeName);
} }
std::string exml::Element::getText() const { etk::String exml::Element::getText() const {
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_DEBUG(" can not APPEND on null element ..."); EXML_DEBUG(" can not APPEND on null element ...");
return ""; return "";

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/Node.hpp> #include <exml/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
#include <exml/AttributeList.hpp> #include <exml/AttributeList.hpp>
#include <exml/iterator.hpp> #include <exml/iterator.hpp>
@ -41,7 +41,7 @@ namespace exml {
* @brief Remove a node with his name. * @brief Remove a node with his name.
* @param[in] _nodeName Name of the node. * @param[in] _nodeName Name of the node.
*/ */
void remove(const std::string& _nodeName); void remove(const etk::String& _nodeName);
/** /**
* @brief get the type of the element id. * @brief get the type of the element id.
* @param[in] _id Id of the element. * @param[in] _id Id of the element.
@ -65,13 +65,13 @@ 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.
*/ */
exml::Element operator[] (const std::string& _name); exml::Element operator[] (const etk::String& _name);
/** /**
* @brief get an element with his name (work only with exml::Element) * @brief get an element with his name (work only with exml::Element)
* @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.
*/ */
const exml::Element operator[] (const std::string& _name) const; const exml::Element operator[] (const etk::String& _name) const;
public: public:
using iterator = exml::iterator<exml::ElementData, exml::Node>; //!< Specify iterator of the element methode using iterator = exml::iterator<exml::ElementData, exml::Node>; //!< Specify iterator of the element methode
/** /**
@ -116,7 +116,7 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _value Element name; * @param[in] _value Element name;
*/ */
Element(const std::string& _value=""); Element(const etk::String& _value="");
/** /**
* @brief Copy constructor * @brief Copy constructor
* @param[in] _obj Object to copy * @param[in] _obj Object to copy
@ -127,7 +127,7 @@ namespace exml {
* @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. if Only one text node, then we get the parssed data (no &amp; ...) if more than one node, then we transform &,",',<,> in xml normal text... * @return the curent data string. if Only one text node, then we get the parssed data (no &amp; ...) if more than one node, then we transform &,",',<,> in xml normal text...
*/ */
std::string getText() const; etk::String getText() const;
public: public:
void clear() override; void clear() override;
}; };

View File

@ -82,7 +82,7 @@ size_t exml::FilePos::getLine() const {
return m_line; return m_line;
} }
std::ostream& exml::operator <<(std::ostream& _os, const exml::FilePos& _obj) { etk::Stream& exml::operator <<(etk::Stream& _os, const exml::FilePos& _obj) {
_os << "(l="; _os << "(l=";
_os << _obj.getLine(); _os << _obj.getLine();
_os << ",c="; _os << ",c=";

View File

@ -87,7 +87,7 @@ namespace exml {
size_t getLine() const; size_t getLine() const;
}; };
//! @not-in-doc //! @not-in-doc
std::ostream& operator <<(std::ostream& _os, const FilePos& _obj); etk::Stream& operator <<(etk::Stream& _os, const FilePos& _obj);
} }

View File

@ -14,7 +14,7 @@
#include <exml/Element.hpp> #include <exml/Element.hpp>
#include <exml/Text.hpp> #include <exml/Text.hpp>
std::ostream& exml::operator <<(std::ostream& _os, const exml::Node& _obj) { etk::Stream& exml::operator <<(etk::Stream& _os, const exml::Node& _obj) {
_os << "{"; _os << "{";
_os << "Node XML: " << _obj.getType(); _os << "Node XML: " << _obj.getType();
if (_obj.isElement() == true) { if (_obj.isElement() == true) {
@ -49,7 +49,7 @@ exml::FilePos exml::Node::getPos() const {
return m_data->getPos(); return m_data->getPos();
} }
void exml::Node::setValue(std::string _value) { void exml::Node::setValue(etk::String _value) {
if (m_data == nullptr) { if (m_data == nullptr) {
EXML_ERROR(" can not set value: '" << _value << "'"); EXML_ERROR(" can not set value: '" << _value << "'");
return; return;
@ -57,9 +57,9 @@ void exml::Node::setValue(std::string _value) {
m_data->setValue(_value); m_data->setValue(_value);
} }
const std::string& exml::Node::getValue() const { const etk::String& exml::Node::getValue() const {
if (m_data == nullptr) { if (m_data == nullptr) {
static std::string errorString = ""; static etk::String errorString = "";
EXML_DEBUG(" can not get value ..."); EXML_DEBUG(" can not get value ...");
return errorString; return errorString;
} }

View File

@ -64,12 +64,12 @@ namespace exml {
* @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(std::string _value); virtual void setValue(etk::String _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.
*/ */
const std::string& getValue() const; const etk::String& getValue() const;
/** /**
* @brief get the node type. * @brief get the node type.
* @return the type of the Node. * @return the type of the Node.
@ -171,5 +171,5 @@ namespace exml {
virtual void clear(); virtual void clear();
}; };
//! @not_in_doc //! @not_in_doc
std::ostream& operator <<(std::ostream& _os, const exml::Node& _obj); etk::Stream& operator <<(etk::Stream& _os, const exml::Node& _obj);
} }

View File

@ -25,7 +25,7 @@ exml::Text::Text(const exml::Text& _obj) :
} }
exml::Text::Text(const std::string& _data) : exml::Text::Text(const etk::String& _data) :
exml::Node() { exml::Node() {
m_data = exml::internal::Text::create(_data); m_data = exml::internal::Text::create(_data);
} }

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/Node.hpp> #include <exml/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
/** /**
@ -28,7 +28,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 std::string& _data=""); Text(const etk::String& _data="");
/** /**
* @brief Copy constructor * @brief Copy constructor
* @param[in] _obj Object to copy * @param[in] _obj Object to copy

View File

@ -11,28 +11,28 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(EXML_BASE_T& _obj, size_t _pos) : exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(EXML_BASE_T& _obj, size_t _pos) :
m_data(_obj), m_data(_obj),
m_id(_pos) { m_id(_pos) {
m_id = std::avg(size_t(0), m_id, m_data.size()); m_id = etk::avg(size_t(0), m_id, m_data.size());
} }
template<class EXML_BASE_T, class EXML_RETURN_T> template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(const EXML_BASE_T& _obj, size_t _pos) : exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(const EXML_BASE_T& _obj, size_t _pos) :
m_data(const_cast<EXML_BASE_T&>(_obj)), m_data(const_cast<EXML_BASE_T&>(_obj)),
m_id(_pos) { m_id(_pos) {
m_id = std::avg(size_t(0), m_id, m_data.size()); m_id = etk::avg(size_t(0), m_id, m_data.size());
} }
template<class EXML_BASE_T, class EXML_RETURN_T> template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(const exml::iterator<EXML_BASE_T,EXML_RETURN_T>& _obj) : exml::iterator<EXML_BASE_T,EXML_RETURN_T>::iterator(const exml::iterator<EXML_BASE_T,EXML_RETURN_T>& _obj) :
m_data(_obj.m_data), m_data(_obj.m_data),
m_id(_obj.m_id) { m_id(_obj.m_id) {
m_id = std::avg(size_t(0), m_id, m_data.size()); m_id = etk::avg(size_t(0), m_id, m_data.size());
} }
template<class EXML_BASE_T, class EXML_RETURN_T> template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator= (const exml::iterator<EXML_BASE_T,EXML_RETURN_T>& _obj) { exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator= (const exml::iterator<EXML_BASE_T,EXML_RETURN_T>& _obj) {
m_data = _obj.m_data; m_data = _obj.m_data;
m_id = _obj.m_id; m_id = _obj.m_id;
m_id = std::avg(size_t(0), m_id, m_data.size()); m_id = etk::avg(size_t(0), m_id, m_data.size());
return *this; return *this;
} }
@ -40,7 +40,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator+= (int32_t _val) { exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator+= (int32_t _val) {
int64_t val = m_id; int64_t val = m_id;
val += _val; val += _val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size())); m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this; return *this;
} }
@ -55,7 +55,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator-= (int32_t _val) { exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator-= (int32_t _val) {
int64_t val = m_id; int64_t val = m_id;
val -= _val; val -= _val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size())); m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this; return *this;
} }
@ -70,7 +70,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator++() { exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator++() {
int64_t val = m_id; int64_t val = m_id;
++val; ++val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size())); m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this; return *this;
} }
@ -85,7 +85,7 @@ template<class EXML_BASE_T, class EXML_RETURN_T>
exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator--() { exml::iterator<EXML_BASE_T,EXML_RETURN_T>& exml::iterator<EXML_BASE_T,EXML_RETURN_T>::operator--() {
int64_t val = m_id; int64_t val = m_id;
--val; --val;
m_id = std::avg(int64_t(0), val, int64_t(m_data.size())); m_id = etk::avg(int64_t(0), val, int64_t(m_data.size()));
return *this; return *this;
} }

View File

@ -8,17 +8,17 @@
#include <exml/debug.hpp> #include <exml/debug.hpp>
#include <exml/internal/Document.hpp> #include <exml/internal/Document.hpp>
ememory::SharedPtr<exml::internal::Attribute> exml::internal::Attribute::create(const std::string& _name, const std::string& _value) { ememory::SharedPtr<exml::internal::Attribute> exml::internal::Attribute::create(const etk::String& _name, const etk::String& _value) {
return ememory::SharedPtr<exml::internal::Attribute>(new exml::internal::Attribute(_name, _value)); return ememory::SharedPtr<exml::internal::Attribute>(new exml::internal::Attribute(_name, _value));
} }
exml::internal::Attribute::Attribute(const std::string& _name, const std::string& _value) : exml::internal::Attribute::Attribute(const etk::String& _name, const etk::String& _value) :
exml::internal::Node(_value), exml::internal::Node(_value),
m_name(_name) { m_name(_name) {
} }
bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) { bool exml::internal::Attribute::iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::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 :
@ -34,7 +34,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
break; break;
} }
} }
m_name = std::string(_data, _pos, lastElementName+1-(_pos)); m_name = etk::String(_data, _pos, lastElementName+1-(_pos));
if (_caseSensitive == true) { if (_caseSensitive == true) {
m_name = etk::tolower(m_name); m_name = etk::tolower(m_name);
} }
@ -83,7 +83,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
break; break;
} }
} }
m_value = std::string(_data, lastElementName+white+2, lastAttributePos-(lastElementName+white+2)); m_value = etk::String(_data, lastElementName+white+2, lastAttributePos-(lastElementName+white+2));
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\""); EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -103,7 +103,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
break; break;
} }
} }
m_value = std::string(_data, lastElementName+white+3, lastAttributePos-(lastElementName+white+3)); m_value = etk::String(_data, lastElementName+white+3, lastAttributePos-(lastElementName+white+3));
EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\""); EXML_PARSE_ATTRIBUTE(m_pos << " attribute : " << m_name << "=\"" << m_value << "\"");
@ -111,7 +111,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos,
return true; return true;
} }
bool exml::internal::Attribute::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::Attribute::iGenerate(etk::String& _data, int32_t _indent) const {
_data += " "; _data += " ";
_data += m_name; _data += m_name;
_data += "=\""; _data += "=\"";

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/internal/Node.hpp> #include <exml/internal/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
namespace internal { namespace internal {
@ -20,7 +20,7 @@ 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 std::string& _name="", const std::string& _value=""); Attribute(const etk::String& _name="", const etk::String& _value="");
public: public:
/** /**
* @brief defined factory * @brief defined factory
@ -28,30 +28,30 @@ namespace exml {
* @param[in] _value Value of the attribute * @param[in] _value Value of the attribute
* @return Shared pointer on the Attribute element * @return Shared pointer on the Attribute element
*/ */
static ememory::SharedPtr<Attribute> create(const std::string& _name="", const std::string& _value=""); static ememory::SharedPtr<Attribute> create(const etk::String& _name="", const etk::String& _value="");
protected: protected:
std::string m_name; //!< Name of the attribute etk::String m_name; //!< Name of the attribute
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(const std::string& _name) { virtual void setName(const etk::String& _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 std::string& getName() const { virtual const etk::String& getName() const {
return m_name; return m_name;
}; };
public: public:
enum nodeType getType() const override { enum nodeType getType() const override {
return exml::nodeType::attribute; return exml::nodeType::attribute;
}; };
bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Attribute> toAttribute() override { ememory::SharedPtr<exml::internal::Attribute> toAttribute() override {
return ememory::staticPointerCast<exml::internal::Attribute>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Attribute>(sharedFromThis());
}; };

View File

@ -23,12 +23,12 @@ ememory::SharedPtr<const exml::internal::Attribute> exml::internal::AttributeLis
return m_listAttribute[_id]; return m_listAttribute[_id];
} }
std::pair<std::string, std::string> exml::internal::AttributeList::getAttrPair(int32_t _id) const { etk::Pair<etk::String, etk::String> exml::internal::AttributeList::getAttrPair(int32_t _id) const {
ememory::SharedPtr<const exml::internal::Attribute> att = getAttr(_id); ememory::SharedPtr<const exml::internal::Attribute> att = getAttr(_id);
if (att == nullptr) { if (att == nullptr) {
return std::make_pair<std::string, std::string>("",""); return etk::makePair<etk::String, etk::String>("","");
} }
return std::make_pair(att->getName(),att->getValue()); return etk::makePair(att->getName(),att->getValue());
} }
@ -43,11 +43,11 @@ void exml::internal::AttributeList::appendAttribute(const ememory::SharedPtr<exm
return; return;
} }
} }
m_listAttribute.push_back(_attr); m_listAttribute.pushBack(_attr);
} }
const std::string& exml::internal::AttributeList::getAttribute(const std::string& _name) const { const etk::String& exml::internal::AttributeList::getAttribute(const etk::String& _name) const {
static const std::string errorReturn(""); static const etk::String errorReturn("");
if (_name.size() == 0) { if (_name.size() == 0) {
return errorReturn; return errorReturn;
} }
@ -61,7 +61,7 @@ const std::string& exml::internal::AttributeList::getAttribute(const std::string
} }
bool exml::internal::AttributeList::existAttribute(const std::string& _name) const { bool exml::internal::AttributeList::existAttribute(const etk::String& _name) const {
if (_name.size() == 0) { if (_name.size() == 0) {
return false; return false;
} }
@ -74,7 +74,7 @@ bool exml::internal::AttributeList::existAttribute(const std::string& _name) con
return false; return false;
} }
bool exml::internal::AttributeList::removeAttribute(const std::string& _name) { bool exml::internal::AttributeList::removeAttribute(const etk::String& _name) {
if (_name.size() == 0) { if (_name.size() == 0) {
return false; return false;
} }
@ -93,7 +93,7 @@ bool exml::internal::AttributeList::removeAttribute(const std::string& _name) {
return false; return false;
} }
void exml::internal::AttributeList::setAttribute(const std::string& _name, const std::string& _value) { void exml::internal::AttributeList::setAttribute(const etk::String& _name, const etk::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) {
if( m_listAttribute[iii] != nullptr if( m_listAttribute[iii] != nullptr
@ -107,10 +107,10 @@ void exml::internal::AttributeList::setAttribute(const std::string& _name, const
if (attr == nullptr) { if (attr == nullptr) {
EXML_ERROR("memory allocation error..."); EXML_ERROR("memory allocation error...");
} }
m_listAttribute.push_back(attr); m_listAttribute.pushBack(attr);
} }
bool exml::internal::AttributeList::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::AttributeList::iGenerate(etk::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 (m_listAttribute[iii] != nullptr) { if (m_listAttribute[iii] != nullptr) {
m_listAttribute[iii]->iGenerate(_data, _indent); m_listAttribute[iii]->iGenerate(_data, _indent);

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/internal/Node.hpp> #include <exml/internal/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
#include <exml/internal/Attribute.hpp> #include <exml/internal/Attribute.hpp>
#include <utility> #include <utility>
@ -21,12 +21,12 @@ namespace exml {
* @brief Constructor * @brief Constructor
* @param[in] _value Node value; * @param[in] _value Node value;
*/ */
AttributeList(const std::string& _value="") : AttributeList(const etk::String& _value="") :
exml::internal::Node(_value) { exml::internal::Node(_value) {
}; };
protected: protected:
std::vector<ememory::SharedPtr<exml::internal::Attribute>> m_listAttribute; //!< list of all attribute etk::Vector<ememory::SharedPtr<exml::internal::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
@ -57,34 +57,34 @@ namespace exml {
* @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute() * @param[in] _id Identifier of the attribute 0<= _id < sizeAttribute()
* @return Name and value of the attribute * @return Name and value of the attribute
*/ */
std::pair<std::string, std::string> getAttrPair(int32_t _id) const; etk::Pair<etk::String, etk::String> getAttrPair(int32_t _id) const;
/** /**
* @brief get the attribute value with searching in the List with his name * @brief get the attribute value with searching in the List with his name
* @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 std::string& getAttribute(const std::string& _name) const; const etk::String& getAttribute(const etk::String& _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 etk::String& _name) const;
/** /**
* @brief Set A new attribute or replace data of the previous one * @brief Set 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 etk::String& _name, const etk::String& _value);
/** /**
* @brief Remove an attribute form the list * @brief Remove an attribute form the list
* @param[in] _name Name of the attribute * @param[in] _name Name of the attribute
* @return true The attribute has been removed * @return true The attribute has been removed
* @return false An error occured. * @return false An error occured.
*/ */
bool removeAttribute(const std::string& _name); bool removeAttribute(const etk::String& _name);
public: public:
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
void clear() override; void clear() override;
}; };
} }

View File

@ -18,11 +18,11 @@ static bool isWhiteChar(char32_t _val) {
return false; return false;
} }
ememory::SharedPtr<exml::internal::Comment> exml::internal::Comment::create(const std::string& _value) { ememory::SharedPtr<exml::internal::Comment> exml::internal::Comment::create(const etk::String& _value) {
return ememory::SharedPtr<exml::internal::Comment>(new exml::internal::Comment(_value)); return ememory::SharedPtr<exml::internal::Comment>(new exml::internal::Comment(_value));
} }
bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) { bool exml::internal::Comment::iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) {
EXML_VERBOSE("start parse : 'comment'"); EXML_VERBOSE("start parse : 'comment'");
m_pos = _filePos; m_pos = _filePos;
exml::FilePos tmpPos; exml::FilePos tmpPos;
@ -50,7 +50,7 @@ bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bo
} }
} }
// find end of value: // find end of value:
m_value = std::string(_data, _pos+white, newEnd-(_pos+white)); m_value = etk::String(_data, _pos+white, newEnd-(_pos+white));
EXML_VERBOSE(" find comment '" << m_value << "'"); EXML_VERBOSE(" find comment '" << m_value << "'");
_pos = iii+2; _pos = iii+2;
return true; return true;
@ -61,7 +61,7 @@ bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bo
return false; return false;
} }
bool exml::internal::Comment::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::Comment::iGenerate(etk::String& _data, int32_t _indent) const {
addIndent(_data, _indent); addIndent(_data, _indent);
_data += "<!--"; _data += "<!--";
_data += m_value; _data += m_value;

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/internal/Node.hpp> #include <exml/internal/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
namespace internal { namespace internal {
@ -20,12 +20,12 @@ namespace exml {
* @return Shared pointer on the Comment element * @return Shared pointer on the Comment element
* @param[in] _value comment value * @param[in] _value comment value
*/ */
static ememory::SharedPtr<exml::internal::Comment> create(const std::string& _value=""); static ememory::SharedPtr<exml::internal::Comment> create(const etk::String& _value="");
/** /**
* @brief Constructor * @brief Constructor
* @param[in] _value comment value * @param[in] _value comment value
*/ */
Comment(const std::string& _value) : Comment(const etk::String& _value) :
exml::internal::Node(_value) { exml::internal::Node(_value) {
} }
@ -33,8 +33,8 @@ namespace exml {
enum nodeType getType() const override { enum nodeType getType() const override {
return nodeType::comment; return nodeType::comment;
} }
bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Comment> toComment() override { ememory::SharedPtr<exml::internal::Comment> toComment() override {
return ememory::staticPointerCast<exml::internal::Comment>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Comment>(sharedFromThis());
} }

View File

@ -15,15 +15,15 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
*/ */
ememory::SharedPtr<exml::internal::Declaration> exml::internal::Declaration::create(const std::string& _name) { ememory::SharedPtr<exml::internal::Declaration> exml::internal::Declaration::create(const etk::String& _name) {
return ememory::SharedPtr<exml::internal::Declaration>(new exml::internal::Declaration(_name)); return ememory::SharedPtr<exml::internal::Declaration>(new exml::internal::Declaration(_name));
} }
ememory::SharedPtr<exml::internal::DeclarationXML> exml::internal::DeclarationXML::create(const std::string& _version, const std::string& _format, bool _standalone) { ememory::SharedPtr<exml::internal::DeclarationXML> exml::internal::DeclarationXML::create(const etk::String& _version, const etk::String& _format, bool _standalone) {
return ememory::SharedPtr<exml::internal::DeclarationXML>(new exml::internal::DeclarationXML(_version, _format, _standalone)); return ememory::SharedPtr<exml::internal::DeclarationXML>(new exml::internal::DeclarationXML(_version, _format, _standalone));
} }
exml::internal::DeclarationXML::DeclarationXML(const std::string& _version, const std::string& _format, bool _standalone) : exml::internal::DeclarationXML::DeclarationXML(const etk::String& _version, const etk::String& _format, bool _standalone) :
exml::internal::Declaration("xml") { exml::internal::Declaration("xml") {
if (_version.size()!=0) { if (_version.size()!=0) {
setAttribute("version", _version); setAttribute("version", _version);
@ -41,7 +41,7 @@ exml::internal::DeclarationXML::DeclarationXML(const std::string& _version, cons
} }
} }
bool exml::internal::Declaration::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::Declaration::iGenerate(etk::String& _data, int32_t _indent) const {
addIndent(_data, _indent); addIndent(_data, _indent);
_data += "<?"; _data += "<?";
_data += m_value; _data += m_value;
@ -50,7 +50,7 @@ bool exml::internal::Declaration::iGenerate(std::string& _data, int32_t _indent)
return true; return true;
} }
bool exml::internal::Declaration::iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) { bool exml::internal::Declaration::iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::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 :
@ -86,7 +86,7 @@ bool exml::internal::Declaration::iParse(const std::string& _data, int32_t& _pos
return false; return false;
} }
iii = _pos; iii = _pos;
m_listAttribute.push_back(attribute); m_listAttribute.pushBack(attribute);
continue; continue;
} }
} }

View File

@ -18,7 +18,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 std::string& _name="") : Declaration(const etk::String& _name="") :
exml::internal::AttributeList(_name) { exml::internal::AttributeList(_name) {
}; };
@ -28,13 +28,13 @@ namespace exml {
* @param[in] _name name of the declaration (xml, xml:xxxx ...) * @param[in] _name name of the declaration (xml, xml:xxxx ...)
* @return a structure declaration * @return a structure declaration
*/ */
static ememory::SharedPtr<Declaration> create(const std::string& _name=""); static ememory::SharedPtr<Declaration> create(const etk::String& _name="");
public: public:
enum nodeType getType() const override{ enum nodeType getType() const override{
return nodeType::declaration; return nodeType::declaration;
}; };
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
ememory::SharedPtr<exml::internal::Declaration> toDeclaration() override { ememory::SharedPtr<exml::internal::Declaration> toDeclaration() override {
return ememory::staticPointerCast<exml::internal::Declaration>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Declaration>(sharedFromThis());
}; };
@ -53,7 +53,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, const std::string& _format = "UTF-8", bool _standalone = true); DeclarationXML(const etk::String& _version, const etk::String& _format = "UTF-8", bool _standalone = true);
public: public:
/** /**
* @brief Factory to create XML declaration * @brief Factory to create XML declaration
@ -62,7 +62,7 @@ namespace exml {
* @param[in] _standalone this document is standalone * @param[in] _standalone this document is standalone
* @return a structure declaration * @return a structure declaration
*/ */
static ememory::SharedPtr<DeclarationXML> create(const std::string& _version, const std::string& _format = "UTF-8", bool _standalone = true); static ememory::SharedPtr<DeclarationXML> create(const etk::String& _version, const etk::String& _format = "UTF-8", bool _standalone = true);
}; };
} }
} }

View File

@ -22,7 +22,7 @@ exml::internal::Document::Document() :
} }
bool exml::internal::Document::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::Document::iGenerate(etk::String& _data, int32_t _indent) const {
for (size_t iii=0; iii<m_listSub.size(); iii++) { for (size_t iii=0; iii<m_listSub.size(); iii++) {
if (m_listSub[iii] != nullptr) { if (m_listSub[iii] != nullptr) {
m_listSub[iii]->iGenerate(_data, _indent); m_listSub[iii]->iGenerate(_data, _indent);
@ -31,7 +31,7 @@ bool exml::internal::Document::iGenerate(std::string& _data, int32_t _indent) co
return true; return true;
} }
bool exml::internal::Document::parse(const std::string& _data) { bool exml::internal::Document::parse(const etk::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 ...
@ -41,12 +41,12 @@ bool exml::internal::Document::parse(const std::string& _data) {
return subParse(_data, parsePos, m_caseSensitive, filePos, *this, true); return subParse(_data, parsePos, m_caseSensitive, filePos, *this, true);
} }
bool exml::internal::Document::generate(std::string& _data) { bool exml::internal::Document::generate(etk::String& _data) {
_data = ""; _data = "";
return iGenerate(_data,0); return iGenerate(_data,0);
} }
bool exml::internal::Document::load(const std::string& _file) { bool exml::internal::Document::load(const etk::String& _file) {
// Start loading the XML : // Start loading the XML :
EXML_VERBOSE("open file (xml) \"" << _file << "\""); EXML_VERBOSE("open file (xml) \"" << _file << "\"");
clear(); clear();
@ -65,7 +65,7 @@ bool exml::internal::Document::load(const std::string& _file) {
return false; return false;
} }
// allocate data // allocate data
std::vector<char> fileBuffer; etk::Vector<char> fileBuffer;
fileBuffer.resize(fileSize+5, 0); fileBuffer.resize(fileSize+5, 0);
// load data from the file : // load data from the file :
tmpFile.fileRead(&fileBuffer[0], 1, fileSize); tmpFile.fileRead(&fileBuffer[0], 1, fileSize);
@ -73,15 +73,15 @@ bool exml::internal::Document::load(const std::string& _file) {
tmpFile.fileClose(); tmpFile.fileClose();
// convert in UTF8 : // convert in UTF8 :
std::string tmpDataUnicode(&fileBuffer[0]); etk::String tmpDataUnicode(&fileBuffer[0]);
// parse the data : // parse the data :
bool ret = parse(tmpDataUnicode); bool ret = parse(tmpDataUnicode);
//Display(); //Display();
return ret; return ret;
} }
bool exml::internal::Document::store(const std::string& _file) { bool exml::internal::Document::store(const etk::String& _file) {
std::string createData; etk::String createData;
if (generate(createData) == false) { if (generate(createData) == false) {
EXML_ERROR("Error while creating the XML : " << _file); EXML_ERROR("Error while creating the XML : " << _file);
return false; return false;
@ -101,13 +101,13 @@ bool exml::internal::Document::store(const std::string& _file) {
} }
void exml::internal::Document::display() { void exml::internal::Document::display() {
std::string tmpp; etk::String tmpp;
iGenerate(tmpp, 0); iGenerate(tmpp, 0);
EXML_INFO("Generated XML : \n" << tmpp); EXML_INFO("Generated XML : \n" << tmpp);
} }
std::string createPosPointer(const std::string& _line, int32_t _pos) { etk::String createPosPointer(const etk::String& _line, int32_t _pos) {
std::string out; etk::String out;
size_t iii; size_t iii;
for (iii=0; (int64_t)iii<_pos && iii<_line.size(); iii++) { for (iii=0; (int64_t)iii<_pos && iii<_line.size(); iii++) {
if (_line[iii] == '\t') { if (_line[iii] == '\t') {
@ -144,7 +144,7 @@ void exml::internal::Document::displayError() {
#endif #endif
} }
void exml::internal::Document::createError(const std::string& _data, int32_t _pos, const exml::FilePos& _filePos, const std::string& _comment) { void exml::internal::Document::createError(const etk::String& _data, int32_t _pos, const exml::FilePos& _filePos, const etk::String& _comment) {
m_comment = _comment; m_comment = _comment;
m_Line = etk::extract_line(_data, _pos); m_Line = etk::extract_line(_data, _pos);
m_filePos = _filePos; m_filePos = _filePos;

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/internal/Element.hpp> #include <exml/internal/Element.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
namespace internal { namespace internal {
@ -49,36 +49,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 std::string& _data); bool parse(const etk::String& _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(std::string& _data); bool generate(etk::String& _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 std::string& _file); bool load(const etk::String& _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 std::string& _file); bool store(const etk::String& _file);
/** /**
* @brief Display the Document on console * @brief Display the Document on console
*/ */
void display(); void display();
private: private:
bool m_writeErrorWhenDetexted; //!< Request print error in parsing just when detected bool m_writeErrorWhenDetexted; //!< Request print error in parsing just when detected
std::string m_comment; //!< Comment on the error etk::String m_comment; //!< Comment on the error
std::string m_Line; //!< Parse line error (copy) etk::String m_Line; //!< Parse line error (copy)
exml::FilePos m_filePos; //!< position of the error exml::FilePos m_filePos; //!< position of the error
public: public:
/** /**
@ -103,12 +103,12 @@ namespace exml {
* @param[in] _filePos human position of the error * @param[in] _filePos human position of the error
* @param[in] _comment Error string to display * @param[in] _comment Error string to display
*/ */
void createError(const std::string& _data, int32_t _pos, const exml::FilePos& _filePos, const std::string& _comment); void createError(const etk::String& _data, int32_t _pos, const exml::FilePos& _filePos, const etk::String& _comment);
public: public:
enum nodeType getType() const override { enum nodeType getType() const override {
return nodeType::document; return nodeType::document;
} }
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Document> toDocument() override { ememory::SharedPtr<exml::internal::Document> toDocument() override {
return ememory::staticPointerCast<exml::internal::Document>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Document>(sharedFromThis());
} }

View File

@ -22,7 +22,7 @@ static bool isWhiteChar(char32_t _val) {
return false; return false;
} }
ememory::SharedPtr<exml::internal::Element> exml::internal::Element::create(const std::string& _value) { ememory::SharedPtr<exml::internal::Element> exml::internal::Element::create(const etk::String& _value) {
return ememory::SharedPtr<exml::internal::Element>(new exml::internal::Element(_value)); return ememory::SharedPtr<exml::internal::Element>(new exml::internal::Element(_value));
} }
@ -67,7 +67,7 @@ const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getEl
return tmpp->toElement(); return tmpp->toElement();
} }
ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const std::string& _name) { ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const etk::String& _name) {
if (_name.size() == 0) { if (_name.size() == 0) {
return nullptr; return nullptr;
} }
@ -84,7 +84,7 @@ ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(co
return nullptr; return nullptr;
} }
const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const std::string& _name) const { const ememory::SharedPtr<exml::internal::Element> exml::internal::Element::getNamed(const etk::String& _name) const {
if (_name.size() == 0) { if (_name.size() == 0) {
return nullptr; return nullptr;
} }
@ -116,10 +116,10 @@ void exml::internal::Element::append(const ememory::SharedPtr<exml::internal::No
return; return;
} }
} }
m_listSub.push_back(_node); m_listSub.pushBack(_node);
} }
void exml::internal::Element::remove(const std::string& _nodeName) { void exml::internal::Element::remove(const etk::String& _nodeName) {
if (_nodeName == "") { if (_nodeName == "") {
return; return;
} }
@ -135,8 +135,8 @@ void exml::internal::Element::remove(const std::string& _nodeName) {
} }
} }
std::string exml::internal::Element::getText() const { etk::String exml::internal::Element::getText() const {
std::string res; etk::String res;
if (m_listSub.size() == 1) { if (m_listSub.size() == 1) {
if (m_listSub[0]->getType() == nodeType::text) { if (m_listSub[0]->getType() == nodeType::text) {
res = m_listSub[0]->getValue(); res = m_listSub[0]->getValue();
@ -153,7 +153,7 @@ std::string exml::internal::Element::getText() const {
return res; return res;
} }
bool exml::internal::Element::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::Element::iGenerate(etk::String& _data, int32_t _indent) const {
addIndent(_data, _indent); addIndent(_data, _indent);
_data += "<"; _data += "<";
_data += m_value; _data += m_value;
@ -187,7 +187,7 @@ bool exml::internal::Element::iGenerate(std::string& _data, int32_t _indent) con
} }
bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc, bool _mainNode) { bool exml::internal::Element::subParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc, bool _mainNode) {
EXML_PARSE_ELEMENT(" start subParse ... " << _pos << " " << _filePos); EXML_PARSE_ELEMENT(" start subParse ... " << _pos << " " << _filePos);
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]);
@ -230,7 +230,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
} }
tmpPos.check(_data[jjj]); tmpPos.check(_data[jjj]);
} }
std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2)); etk::String tmpname = etk::String(_data, iii+white+2, endPosName+1-(iii+white+2));
if (_caseSensitive == true) { if (_caseSensitive == true) {
tmpname = etk::tolower(tmpname); tmpname = etk::tolower(tmpname);
} }
@ -246,7 +246,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.push_back(declaration); m_listSub.pushBack(declaration);
continue; continue;
} }
if(_data[iii+white+1] == '!') { if(_data[iii+white+1] == '!') {
@ -263,7 +263,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false; return false;
} }
if(_data[iii+white+3] != '-') { if(_data[iii+white+3] != '-') {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Element parse with '<!-") + _data[iii+3] + "' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Element parse with '<!-") + _data[iii+3] + "' chars == > invalide XML");
return false; return false;
} }
++tmpPos; ++tmpPos;
@ -279,7 +279,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.push_back(comment); m_listSub.pushBack(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()) {
@ -292,7 +292,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
|| _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, 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"); CREATE_ERROR(_doc, _data, _pos, _filePos, etk::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; return false;
} }
tmpPos+=6; tmpPos+=6;
@ -308,9 +308,9 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.push_back(text); m_listSub.pushBack(text);
} else { } else {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("End file with '<!") + _data[iii+white+2] + "' chars == > invalide XML"); CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("End file with '<!") + _data[iii+white+2] + "' chars == > invalide XML");
return false; return false;
} }
continue; continue;
@ -329,7 +329,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
} }
tmpPos.check(_data[jjj]); tmpPos.check(_data[jjj]);
} }
std::string tmpname = std::string(_data, iii+white+2, endPosName+1-(iii+white+2)); etk::String tmpname = etk::String(_data, iii+white+2, endPosName+1-(iii+white+2));
if (_caseSensitive == true) { if (_caseSensitive == true) {
tmpname = etk::tolower(tmpname); tmpname = etk::tolower(tmpname);
} }
@ -351,12 +351,12 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
&& _data[jjj] != ' ' && _data[jjj] != ' '
&& _data[jjj] != '\t') { && _data[jjj] != '\t') {
_filePos += tmpPos; _filePos += tmpPos;
CREATE_ERROR(_doc, _data, jjj, _filePos, std::string("End node error : have data inside end node other than [ \\n\\t\\r] ") + m_value + "'"); CREATE_ERROR(_doc, _data, jjj, _filePos, etk::String("End node error : have data inside end node other than [ \\n\\t\\r] ") + m_value + "'");
return false; return false;
} }
} }
} else { } else {
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("End node error : '") + tmpname + "' != '" + m_value + "'"); CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("End node error : '") + tmpname + "' != '" + m_value + "'");
return false; return false;
} }
} }
@ -380,7 +380,7 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
} }
tmpPos.check(_data[jjj]); tmpPos.check(_data[jjj]);
} }
std::string tmpname = std::string(_data, iii+white+1, endPosName+1-(iii+white+1)); etk::String tmpname = etk::String(_data, iii+white+1, endPosName+1-(iii+white+1));
if (_caseSensitive == true) { if (_caseSensitive == true) {
etk::tolower(tmpname); etk::tolower(tmpname);
} }
@ -397,12 +397,12 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.push_back(element); m_listSub.pushBack(element);
continue; continue;
} }
_filePos+=tmpPos; _filePos+=tmpPos;
// here we have an error : // here we have an error :
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Find an ununderstanding element : '") + _data[iii+white+1] + "'"); CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Find an ununderstanding element : '") + _data[iii+white+1] + "'");
return false; return false;
} else { } else {
if (_data[iii] == '>') { if (_data[iii] == '>') {
@ -428,18 +428,18 @@ bool exml::internal::Element::subParse(const std::string& _data, int32_t& _pos,
return false; return false;
} }
iii = _pos; iii = _pos;
m_listSub.push_back(text); m_listSub.pushBack(text);
} }
} }
} }
if (_mainNode == true) { if (_mainNode == true) {
return true; return true;
} }
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Did not find end of the exml::internal::Element : '") + m_value + "'"); CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Did not find end of the exml::internal::Element : '") + m_value + "'");
return false; return false;
} }
bool exml::internal::Element::iParse(const std::string& _data, bool exml::internal::Element::iParse(const etk::String& _data,
int32_t& _pos, int32_t& _pos,
bool _caseSensitive, bool _caseSensitive,
exml::FilePos& _filePos, exml::FilePos& _filePos,
@ -485,15 +485,15 @@ bool exml::internal::Element::iParse(const std::string& _data,
return false; return false;
} }
iii = _pos; iii = _pos;
m_listAttribute.push_back(attribute); m_listAttribute.pushBack(attribute);
continue; continue;
} }
if (isWhiteChar(_data[iii]) == false) { if (isWhiteChar(_data[iii]) == false) {
CREATE_ERROR(_doc, _data, iii, _filePos, std::string("Find an unknow element : '") + _data[iii] + "'"); CREATE_ERROR(_doc, _data, iii, _filePos, etk::String("Find an unknow element : '") + _data[iii] + "'");
return false; return false;
} }
} }
CREATE_ERROR(_doc, _data, _pos, _filePos, std::string("Unexpecting end of parsing exml::internal::Element : '") + m_value + "' == > check if the '/>' is set or the end of element"); CREATE_ERROR(_doc, _data, _pos, _filePos, etk::String("Unexpecting end of parsing exml::internal::Element : '") + m_value + "' == > check if the '/>' is set or the end of element");
return false; return false;
} }

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/internal/Node.hpp> #include <exml/internal/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
#include <exml/internal/AttributeList.hpp> #include <exml/internal/AttributeList.hpp>
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 std::string& _value) : Element(const etk::String& _value) :
exml::internal::AttributeList(_value) { exml::internal::AttributeList(_value) {
}; };
@ -34,9 +34,9 @@ namespace exml {
* @param[in] _value Name of the node. * @param[in] _value Name of the node.
* @return Shared pointer on the Element * @return Shared pointer on the Element
*/ */
static ememory::SharedPtr<Element> create(const std::string& _value=""); static ememory::SharedPtr<Element> create(const etk::String& _value="");
protected: protected:
std::vector<ememory::SharedPtr<exml::internal::Node>> m_listSub; //!< List of subNodes etk::Vector<ememory::SharedPtr<exml::internal::Node>> m_listSub; //!< List of subNodes
public: public:
/** /**
* @brief get the number of sub element in the node (can be exml::internal::Comment ; exml::internal::Element ; exml::internal::Text :exml::internal::Declaration). * @brief get the number of sub element in the node (can be exml::internal::Comment ; exml::internal::Element ; exml::internal::Text :exml::internal::Declaration).
@ -54,7 +54,7 @@ namespace exml {
* @brief Remove all element with this name * @brief Remove all element with this name
* @param[in] _nodeName Name of nodes to remove. * @param[in] _nodeName Name of nodes to remove.
*/ */
void remove(const std::string& _nodeName); void remove(const etk::String& _nodeName);
/** /**
* @brief get the type of the element id. * @brief get the type of the element id.
* @param[in] _id Id of the element. * @param[in] _id Id of the element.
@ -90,18 +90,18 @@ 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.
*/ */
ememory::SharedPtr<Element> getNamed(const std::string& _name); ememory::SharedPtr<Element> getNamed(const etk::String& _name);
/** /**
* @brief get an element with his name (work only with exml::internal::Element) * @brief get an element with his name (work only with exml::internal::Element)
* @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.
*/ */
const ememory::SharedPtr<Element> getNamed(const std::string& _name) const; const ememory::SharedPtr<Element> getNamed(const etk::String& _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. if Only one text node, then we get the parssed data (no &amp; ...) if more than one node, then we transform &,",',<,> in xml normal text... * @return the curent data string. if Only one text node, then we get the parssed data (no &amp; ...) if more than one node, then we transform &,",',<,> in xml normal text...
*/ */
std::string getText() const; etk::String getText() const;
protected: protected:
/** /**
* @brief Parse sub node string * @brief Parse sub node string
@ -114,7 +114,7 @@ namespace exml {
* @return true parsing is done OK * @return true parsing is done OK
* @return false An error appear in the parsing * @return false An error appear in the parsing
*/ */
bool subParse(const std::string& _data, bool subParse(const etk::String& _data,
int32_t& _pos, int32_t& _pos,
bool _caseSensitive, bool _caseSensitive,
exml::FilePos& _filePos, exml::FilePos& _filePos,
@ -124,8 +124,8 @@ namespace exml {
enum nodeType getType() const override { enum nodeType getType() const override {
return nodeType::element; return nodeType::element;
} }
bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override;
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Element> toElement() override; ememory::SharedPtr<exml::internal::Element> toElement() override;
const ememory::SharedPtr<exml::internal::Element> toElement() const override; const ememory::SharedPtr<exml::internal::Element> toElement() const override;
void clear() override; void clear() override;

View File

@ -23,14 +23,14 @@ static bool isWhiteChar(char32_t _val) {
return false; return false;
} }
exml::internal::Node::Node(const std::string& _value) : exml::internal::Node::Node(const etk::String& _value) :
m_pos(0,0), m_pos(0,0),
m_value(_value) { m_value(_value) {
// nothing to do. // nothing to do.
} }
void exml::internal::Node::addIndent(std::string& _data, int32_t _indent) const { void exml::internal::Node::addIndent(etk::String& _data, int32_t _indent) const {
for (int32_t iii=0; iii<_indent; iii++) { for (int32_t iii=0; iii<_indent; iii++) {
_data += "\t"; _data += "\t";
} }
@ -93,7 +93,7 @@ bool exml::internal::Node::checkAvaillable(char32_t _val, bool _firstChar) const
} }
int32_t exml::internal::Node::countWhiteChar(const std::string& _data, int32_t _pos, exml::FilePos& _filePos) const { int32_t exml::internal::Node::countWhiteChar(const etk::String& _data, int32_t _pos, exml::FilePos& _filePos) const {
_filePos.clear(); _filePos.clear();
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++) {
@ -108,7 +108,7 @@ int32_t exml::internal::Node::countWhiteChar(const std::string& _data, int32_t _
return white; return white;
} }
bool exml::internal::Node::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::Node::iGenerate(etk::String& _data, int32_t _indent) const {
return true; return true;
} }
@ -121,11 +121,11 @@ void exml::internal::Node::clear() {
m_pos.clear(); m_pos.clear();
} }
void exml::internal::Node::setValue(std::string _value) { void exml::internal::Node::setValue(etk::String _value) {
m_value = _value; m_value = _value;
} }
const std::string& exml::internal::Node::getValue() const { const etk::String& exml::internal::Node::getValue() const {
return m_value; return m_value;
} }

View File

@ -53,7 +53,7 @@ namespace exml {
* @brief basic element of a xml structure * @brief basic element of a xml structure
* @param[in] _value value of the node * @param[in] _value value of the node
*/ */
Node(const std::string& _value); Node(const etk::String& _value);
public: public:
/** /**
* @brief Virtualize destructor * @brief Virtualize destructor
@ -69,14 +69,14 @@ namespace exml {
* @param[in,out] _doc Base document reference * @param[in,out] _doc Base document reference
* @return false if an error occured. * @return false if an error occured.
*/ */
virtual bool iParse(const std::string& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) = 0; virtual bool iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::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] _indent current indentation of the file * @param[in] _indent current indentation of the file
* @return false if an error occured. * @return false if an error occured.
*/ */
virtual bool iGenerate(std::string& _data, int32_t _indent) const; virtual bool iGenerate(etk::String& _data, int32_t _indent) const;
protected: protected:
exml::FilePos m_pos; //!< position in the readed file == > not correct when the file is generated exml::FilePos m_pos; //!< position in the readed file == > not correct when the file is generated
public: public:
@ -86,18 +86,18 @@ namespace exml {
*/ */
const exml::FilePos& getPos() const; const exml::FilePos& getPos() const;
protected: protected:
std::string m_value; //!< value of the node (for element this is the name, for text it is the inside text ...) etk::String 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(std::string _value); virtual void setValue(etk::String _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 std::string& getValue() const; virtual const etk::String& getValue() const;
public: public:
/** /**
* @brief get the node type. * @brief get the node type.
@ -110,7 +110,7 @@ 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(std::string& _data, int32_t _indent) const; void addIndent(etk::String& _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.
@ -132,7 +132,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 std::string& _data, int32_t _pos, exml::FilePos& _filePos) const; int32_t countWhiteChar(const etk::String& _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

@ -7,7 +7,6 @@
#include <exml/internal/Text.hpp> #include <exml/internal/Text.hpp>
#include <exml/debug.hpp> #include <exml/debug.hpp>
#include <exml/internal/Document.hpp> #include <exml/internal/Document.hpp>
#include <regex>
// transform the Text with : // transform the Text with :
// "&lt;" == "<" // "&lt;" == "<"
@ -15,35 +14,23 @@
// "&amp;" == "&" // "&amp;" == "&"
// "&apos;" == "'" // "&apos;" == "'"
// "&quot;" == """ // "&quot;" == """
static std::string replaceSpecialChar(const std::string& _inval) { static etk::String replaceSpecialChar(const etk::String& _inval) {
std::string out; etk::String out = _inval;
static std::regex regexLT("&lt;"); out.replace("&lt;", "<");
static std::regex regexGT("&gt;"); out.replace("&gt;", ">");
static std::regex regexAPOS("&apos;"); out.replace("&apos;", "'");
static std::regex regexQUOT("&quot;"); out.replace("&quot;", "\"");
static std::regex regexAMP("&amp;"); out.replace("&amp;", "&");
out = std::regex_replace(_inval, regexLT, std::string("<"));
out = std::regex_replace(out, regexGT, std::string(">"));
out = std::regex_replace(out, regexAPOS, std::string("'"));
out = std::regex_replace(out, regexQUOT, std::string("\""));
out = std::regex_replace(out, regexAMP, std::string("&"));
//EXML_ERROR("INNN '"<< _inval << "' => '" << out << "'"); //EXML_ERROR("INNN '"<< _inval << "' => '" << out << "'");
return out; return out;
} }
static std::string replaceSpecialCharOut(const std::string& _inval) { static etk::String replaceSpecialCharOut(const etk::String& _inval) {
std::string out; etk::String out = _inval;
static std::regex regexLT("<"); out.replace("<", "&lt;");
static std::regex regexGT(">;"); out.replace(">", "&gt;");
static std::regex regexAMP("&"); out.replace("'", "&apos;");
static std::regex regexAPOS("'"); out.replace("\"", "&quot;");
static std::regex regexQUOT("\""); out.replace("&", "&amp;");
out = std::regex_replace(_inval, regexAMP, std::string("&amp;"));
out = std::regex_replace(out, regexQUOT, std::string("&quot;"));
out = std::regex_replace(out, regexAPOS, std::string("&apos;"));
out = std::regex_replace(out, regexGT, std::string("&gt;"));
out = std::regex_replace(out, regexLT, std::string("&lt;"));
//EXML_ERROR("OUTTT '"<< _inval << "' => '" << out << "'"); //EXML_ERROR("OUTTT '"<< _inval << "' => '" << out << "'");
return out; return out;
} }
@ -58,11 +45,11 @@ static bool isWhiteChar(char32_t _val) {
return false; return false;
} }
ememory::SharedPtr<exml::internal::Text> exml::internal::Text::create(const std::string& _data) { ememory::SharedPtr<exml::internal::Text> exml::internal::Text::create(const etk::String& _data) {
return ememory::SharedPtr<exml::internal::Text>(new exml::internal::Text(_data)); return ememory::SharedPtr<exml::internal::Text>(new exml::internal::Text(_data));
} }
bool exml::internal::Text::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::Text::iGenerate(etk::String& _data, int32_t _indent) const {
_data += replaceSpecialCharOut(m_value); _data += replaceSpecialCharOut(m_value);
return true; return true;
} }
@ -77,7 +64,7 @@ int32_t exml::internal::Text::countLines() const {
return count; return count;
} }
bool exml::internal::Text::iParse(const std::string& _data, bool exml::internal::Text::iParse(const etk::String& _data,
int32_t& _pos, int32_t& _pos,
bool _caseSensitive, bool _caseSensitive,
exml::FilePos& _filePos, exml::FilePos& _filePos,
@ -104,7 +91,7 @@ bool exml::internal::Text::iParse(const std::string& _data,
} }
} }
// find end of value: // find end of value:
m_value = std::string(_data, _pos, newEnd-(_pos)); m_value = etk::String(_data, _pos, newEnd-(_pos));
EXML_VERBOSE(" find text '" << m_value << "'"); EXML_VERBOSE(" find text '" << m_value << "'");
_pos = iii-1; _pos = iii-1;
m_value = replaceSpecialChar(m_value); m_value = replaceSpecialChar(m_value);
@ -121,12 +108,12 @@ ememory::SharedPtr<exml::internal::TextCDATA> exml::internal::TextCDATA::create(
return ememory::SharedPtr<exml::internal::TextCDATA>(new exml::internal::TextCDATA()); return ememory::SharedPtr<exml::internal::TextCDATA>(new exml::internal::TextCDATA());
} }
bool exml::internal::TextCDATA::iGenerate(std::string& _data, int32_t _indent) const { bool exml::internal::TextCDATA::iGenerate(etk::String& _data, int32_t _indent) const {
_data += "<![CDATA[" + m_value +"]]>"; _data += "<![CDATA[" + m_value +"]]>";
return true; return true;
} }
bool exml::internal::TextCDATA::iParse(const std::string& _data, bool exml::internal::TextCDATA::iParse(const etk::String& _data,
int32_t& _pos, int32_t& _pos,
bool _caseSensitive, bool _caseSensitive,
exml::FilePos& _filePos, exml::FilePos& _filePos,
@ -146,7 +133,7 @@ bool exml::internal::TextCDATA::iParse(const std::string& _data,
&& _data[iii+2] == '>') { && _data[iii+2] == '>') {
// find end of value: // find end of value:
_filePos += 2; _filePos += 2;
m_value = std::string(_data, _pos, iii-(_pos)); m_value = etk::String(_data, _pos, iii-(_pos));
EXML_VERBOSE(" find text CDATA '" << m_value << "'"); EXML_VERBOSE(" find text CDATA '" << m_value << "'");
_pos = iii+2; _pos = iii+2;
return true; return true;

View File

@ -6,7 +6,7 @@
#pragma once #pragma once
#include <exml/internal/Node.hpp> #include <exml/internal/Node.hpp>
#include <vector> #include <etk/Vector.hpp>
namespace exml { namespace exml {
namespace internal { namespace internal {
@ -23,14 +23,14 @@ 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 std::string& _data) : exml::internal::Node(_data) { }; Text(const etk::String& _data) : exml::internal::Node(_data) { };
public: public:
/** /**
* @brief defined factory * @brief defined factory
* @param[in] _data Data in the Text area * @param[in] _data Data in the Text area
* @return Shared pointer on the Text element * @return Shared pointer on the Text element
*/ */
static ememory::SharedPtr<exml::internal::Text> create(const std::string& _data=""); static ememory::SharedPtr<exml::internal::Text> create(const etk::String& _data="");
/** /**
* @brief count the number of line in the current text * @brief count the number of line in the current text
* @return The number of lines * @return The number of lines
@ -40,12 +40,12 @@ namespace exml {
enum nodeType getType() const override{ enum nodeType getType() const override{
return nodeType::text; return nodeType::text;
}; };
bool iParse(const std::string& _data, bool iParse(const etk::String& _data,
int32_t& _pos, int32_t& _pos,
bool _caseSensitive, bool _caseSensitive,
exml::FilePos& _filePos, exml::FilePos& _filePos,
exml::internal::Document& _doc) override; exml::internal::Document& _doc) override;
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
ememory::SharedPtr<exml::internal::Text> toText() override { ememory::SharedPtr<exml::internal::Text> toText() override {
return ememory::staticPointerCast<exml::internal::Text>(sharedFromThis()); return ememory::staticPointerCast<exml::internal::Text>(sharedFromThis());
}; };
@ -69,12 +69,12 @@ namespace exml {
*/ */
static ememory::SharedPtr<TextCDATA> create(); static ememory::SharedPtr<TextCDATA> create();
public: public:
bool iParse(const std::string& _data, bool iParse(const etk::String& _data,
int32_t& _pos, int32_t& _pos,
bool _caseSensitive, bool _caseSensitive,
exml::FilePos& _filePos, exml::FilePos& _filePos,
exml::internal::Document& _doc) override; exml::internal::Document& _doc) override;
bool iGenerate(std::string& _data, int32_t _indent) const override; bool iGenerate(etk::String& _data, int32_t _indent) const override;
}; };
} }
} }

View File

@ -9,7 +9,7 @@
std::ostream& exml::operator <<(std::ostream& _os, enum exml::nodeType _obj) { etk::Stream& exml::operator <<(etk::Stream& _os, enum exml::nodeType _obj) {
switch (_obj) { switch (_obj) {
case nodeType::unknow: case nodeType::unknow:
_os << "exml::nodeType::unknow"; _os << "exml::nodeType::unknow";

View File

@ -5,7 +5,7 @@
*/ */
#pragma once #pragma once
#include <ostream> #include <etk/Stream.hpp>
/** /**
* @brief exml namespace containing all function for XML interpretor * @brief exml namespace containing all function for XML interpretor
@ -25,6 +25,6 @@ namespace exml {
text, //!< &lt;XXX&gt; InsideText &lt;/XXX&gt; text, //!< &lt;XXX&gt; InsideText &lt;/XXX&gt;
}; };
//! @not_in_doc //! @not_in_doc
std::ostream& operator <<(std::ostream& _os, enum nodeType _obj); etk::Stream& operator <<(etk::Stream& _os, enum nodeType _obj);
} }

View File

@ -13,7 +13,7 @@ int main(int argc, const char *argv[]) {
// the only one init for etk: // the only one init for etk:
etk::init(argc, argv); etk::init(argc, argv);
for (int32_t iii=0; iii<argc ; ++iii) { for (int32_t iii=0; iii<argc ; ++iii) {
std::string data = argv[iii]; etk::String data = argv[iii];
if ( data == "-h" if ( data == "-h"
|| data == "--help") { || data == "--help") {
TEST_PRINT("Help : "); TEST_PRINT("Help : ");

View File

@ -28,7 +28,7 @@ static void readFromString1() {
exml::Document doc; exml::Document doc;
TEST_INFO("parse"); TEST_INFO("parse");
//! [exml_sample_read_stream1] //! [exml_sample_read_stream1]
std::string stream = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>" etk::String stream = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"true\"?>"
"<!-- my comment -->" "<!-- my comment -->"
"<exml attributeExample=\"my data attribute\">coucou</exml>"; "<exml attributeExample=\"my data attribute\">coucou</exml>";
bool retParse = doc.parse(stream); bool retParse = doc.parse(stream);
@ -42,7 +42,7 @@ static void readFromString2() {
exml::Document doc; exml::Document doc;
TEST_INFO("parse"); TEST_INFO("parse");
//! [exml_sample_read_stream2] //! [exml_sample_read_stream2]
std::string stream = "<?xml version='1.0' encoding='UTF-8' standalone='true'?>" etk::String stream = "<?xml version='1.0' encoding='UTF-8' standalone='true'?>"
"<!-- my comment -->" "<!-- my comment -->"
"<exml attributeExample='my data attribute'>coucou</exml>"; "<exml attributeExample='my data attribute'>coucou</exml>";
bool retParse = doc.parse(stream); bool retParse = doc.parse(stream);
@ -90,7 +90,7 @@ static void readFull() {
TEST_INFO(" list of attribute:"); TEST_INFO(" list of attribute:");
//! [exml_sample_read_folow_attributes] //! [exml_sample_read_folow_attributes]
for (const auto itElem: element.attributes) { for (const auto itElem: element.attributes) {
std::string value = itElem.getValue(); etk::String value = itElem.getValue();
TEST_INFO(" '" << value << "'"); TEST_INFO(" '" << value << "'");
} }
TEST_INFO(" list of attribute in C:"); TEST_INFO(" list of attribute in C:");
@ -98,12 +98,12 @@ static void readFull() {
//! [exml_sample_read_folow_attributes_c] //! [exml_sample_read_folow_attributes_c]
for (size_t iii=0; iii<element.attributes.size(); ++iii) { for (size_t iii=0; iii<element.attributes.size(); ++iii) {
const exml::Attribute attr = element.attributes[iii]; const exml::Attribute attr = element.attributes[iii];
std::string value = attr.getValue(); etk::String value = attr.getValue();
TEST_INFO(" '" << value << "'"); TEST_INFO(" '" << value << "'");
} }
//! [exml_sample_read_folow_attributes_c] //! [exml_sample_read_folow_attributes_c]
//! [exml_sample_read_get_direct_attribute] //! [exml_sample_read_get_direct_attribute]
std::string attributeValue = element.attributes["attributeExample"]; etk::String attributeValue = element.attributes["attributeExample"];
TEST_INFO(" direct get: '" << attributeValue << "'"); TEST_INFO(" direct get: '" << attributeValue << "'");
//! [exml_sample_read_get_direct_attribute] //! [exml_sample_read_get_direct_attribute]
TEST_INFO(" list of sub-node:"); TEST_INFO(" list of sub-node:");
@ -111,7 +111,7 @@ static void readFull() {
for (const auto itElem: element.nodes) { for (const auto itElem: element.nodes) {
if (itElem.isElement() == true) { if (itElem.isElement() == true) {
// get the <XXXX ... name // get the <XXXX ... name
std::string value = itElem.toElement().getValue(); etk::String value = itElem.toElement().getValue();
TEST_INFO(" '" << value << "'"); TEST_INFO(" '" << value << "'");
} else { } else {
// simple debug for other type: // simple debug for other type:
@ -125,7 +125,7 @@ static void readFull() {
const exml::Node node = element.nodes[iii]; const exml::Node node = element.nodes[iii];
if (node.isElement() == true) { if (node.isElement() == true) {
// get the <XXXX ... name // get the <XXXX ... name
std::string value = node.toElement().getValue(); etk::String value = node.toElement().getValue();
TEST_INFO(" '" << value << "'"); TEST_INFO(" '" << value << "'");
} else { } else {
// simple debug for other type: // simple debug for other type:
@ -134,7 +134,7 @@ static void readFull() {
} }
//! [exml_sample_read_folow_nodes_c] //! [exml_sample_read_folow_nodes_c]
//! [exml_sample_read_get_all_under_string] //! [exml_sample_read_get_all_under_string]
std::string internalData = element.getText(); etk::String internalData = element.getText();
//! [exml_sample_read_get_all_under_string] //! [exml_sample_read_get_all_under_string]
} }

View File

@ -33,7 +33,7 @@ static void writeToString() {
doc.nodes.add(exml::Comment("basic comment")); doc.nodes.add(exml::Comment("basic comment"));
TEST_INFO("generate"); TEST_INFO("generate");
//! [exml_sample_write_stream] //! [exml_sample_write_stream]
std::string streamOut; etk::String streamOut;
bool retGenerate = doc.generate(streamOut); bool retGenerate = doc.generate(streamOut);
//! [exml_sample_write_stream] //! [exml_sample_write_stream]
TEST_INFO("parse ret = " << retGenerate); TEST_INFO("parse ret = " << retGenerate);

View File

@ -10,8 +10,8 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
// _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? // _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ????
void exmlLocalTest(const std::string& _ref, void exmlLocalTest(const etk::String& _ref,
const std::string& _input, const etk::String& _input,
int32_t _errorPos, int32_t _errorPos,
bool _caseInSensitive=false) { bool _caseInSensitive=false) {
exml::Document doc; exml::Document doc;
@ -24,7 +24,7 @@ void exmlLocalTest(const std::string& _ref,
} else { } else {
EXPECT_EQ(retParse, true); EXPECT_EQ(retParse, true);
} }
std::string out(""); etk::String out("");
bool retGenerate = doc.generate(out); bool retGenerate = doc.generate(out);
if (_errorPos == 2) { if (_errorPos == 2) {
EXPECT_EQ(retGenerate, false); EXPECT_EQ(retGenerate, false);

View File

@ -8,8 +8,8 @@
#include <etk/types.hpp> #include <etk/types.hpp>
// _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? // _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ????
void exmlLocalTest(const std::string& _ref, void exmlLocalTest(const etk::String& _ref,
const std::string& _input, const etk::String& _input,
int32_t _errorPos, int32_t _errorPos,
bool _caseInSensitive=false); bool _caseInSensitive=false);

View File

@ -8,7 +8,7 @@
#include <gtest/gtest.h> #include <gtest/gtest.h>
static std::string refOutputElement("<exemple/>\n"); static etk::String refOutputElement("<exemple/>\n");
TEST(TestParseElement, testBase) { TEST(TestParseElement, testBase) {
exmlLocalTest(refOutputElement, "<exemple/>\n", -1); exmlLocalTest(refOutputElement, "<exemple/>\n", -1);

View File

@ -15,7 +15,7 @@ int main(int argc, const char *argv[]) {
// the only one init for etk: // the only one init for etk:
etk::init(argc, argv); etk::init(argc, argv);
for (int32_t iii=0; iii<argc ; ++iii) { for (int32_t iii=0; iii<argc ; ++iii) {
std::string data = argv[iii]; etk::String data = argv[iii];
if ( data == "-h" if ( data == "-h"
|| data == "--help") { || data == "--help") {
TEST_PRINT("Help : "); TEST_PRINT("Help : ");