From f77bf5d8add60048f76e1242729a70bf36a48489 Mon Sep 17 00:00:00 2001 From: Edouard DUPIN Date: Mon, 28 Aug 2017 00:05:54 +0200 Subject: [PATCH] [DEV] continue removing stl --- exml/Attribute.cpp | 14 ++++----- exml/Attribute.hpp | 10 +++--- exml/AttributeList.cpp | 14 ++++----- exml/AttributeList.hpp | 10 +++--- exml/Comment.cpp | 2 +- exml/Comment.hpp | 4 +-- exml/Declaration.cpp | 4 +-- exml/Declaration.hpp | 4 +-- exml/Document.cpp | 8 ++--- exml/Document.hpp | 10 +++--- exml/Element.cpp | 10 +++--- exml/Element.hpp | 12 +++---- exml/FilePos.cpp | 2 +- exml/FilePos.hpp | 2 +- exml/Node.cpp | 8 ++--- exml/Node.hpp | 6 ++-- exml/Text.cpp | 2 +- exml/Text.hpp | 4 +-- exml/details/iterator.hxx | 16 +++++----- exml/internal/Attribute.cpp | 14 ++++----- exml/internal/Attribute.hpp | 16 +++++----- exml/internal/AttributeList.cpp | 22 ++++++------- exml/internal/AttributeList.hpp | 18 +++++------ exml/internal/Comment.cpp | 8 ++--- exml/internal/Comment.hpp | 10 +++--- exml/internal/Declaration.cpp | 12 +++---- exml/internal/Declaration.hpp | 12 +++---- exml/internal/Document.cpp | 24 +++++++------- exml/internal/Document.hpp | 18 +++++------ exml/internal/Element.cpp | 56 ++++++++++++++++----------------- exml/internal/Element.hpp | 22 ++++++------- exml/internal/Node.cpp | 12 +++---- exml/internal/Node.hpp | 16 +++++----- exml/internal/Text.cpp | 55 +++++++++++++------------------- exml/internal/Text.hpp | 14 ++++----- exml/nodeType.cpp | 2 +- exml/nodeType.hpp | 4 +-- sample/main.cpp | 2 +- sample/read.cpp | 16 +++++----- sample/write.cpp | 2 +- test/exmlTestCommon.cpp | 6 ++-- test/exmlTestCommon.hpp | 4 +-- test/exmlTestParseElement.cpp | 2 +- test/main.cpp | 2 +- 44 files changed, 249 insertions(+), 262 deletions(-) diff --git a/exml/Attribute.cpp b/exml/Attribute.cpp index ede1ed8..8d415ed 100644 --- a/exml/Attribute.cpp +++ b/exml/Attribute.cpp @@ -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() { m_data = exml::internal::Attribute::create(_name, _value); } @@ -39,7 +39,7 @@ exml::Attribute& exml::Attribute::operator= (const exml::Attribute& _obj) { return *this; } -void exml::Attribute::setName(const std::string& _name){ +void exml::Attribute::setName(const etk::String& _name){ if (m_data == nullptr) { EXML_DEBUG(" can not setName (nullptr) ..."); return; @@ -47,9 +47,9 @@ void exml::Attribute::setName(const std::string& _name){ static_cast(m_data.get())->setName(_name); } -const std::string& exml::Attribute::getName() const { +const etk::String& exml::Attribute::getName() const { if (m_data == nullptr) { - static std::string errorValue = ""; + static etk::String errorValue = ""; EXML_DEBUG(" can not setName (nullptr) ..."); return errorValue; } @@ -64,12 +64,12 @@ void exml::Attribute::clear() { static_cast(m_data.get())->clear(); } -std::pair exml::Attribute::getPair() const { +etk::Pair exml::Attribute::getPair() const { if (m_data == nullptr) { EXML_DEBUG(" can not setName (nullptr) ..."); - return std::pair("",""); + return etk::Pair("",""); } - return std::pair(static_cast(m_data.get())->getName(), + return etk::Pair(static_cast(m_data.get())->getName(), static_cast(m_data.get())->getValue()); } diff --git a/exml/Attribute.hpp b/exml/Attribute.hpp index 4debc16..56707a0 100644 --- a/exml/Attribute.hpp +++ b/exml/Attribute.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace exml { namespace internal { @@ -38,7 +38,7 @@ namespace exml { * @param[in] _name Name of the attribute. * @param[in] _value Value of the attribute. */ - Attribute(const std::string& _name="", const std::string& _value=""); + Attribute(const etk::String& _name="", const etk::String& _value=""); /** * @brief Copy constructor * @param[in] _obj Object to copy @@ -50,17 +50,17 @@ namespace exml { * @brief set the 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 * @return String of the attribute */ - virtual const std::string& getName() const; + virtual const etk::String& getName() const; /** * @brief get attribute name and value * @return Name and value of the attribute */ - std::pair getPair() const; + etk::Pair getPair() const; public: void clear() override; friend class exml::AttributeListData; diff --git a/exml/AttributeList.cpp b/exml/AttributeList.cpp index 217d090..7344466 100644 --- a/exml/AttributeList.cpp +++ b/exml/AttributeList.cpp @@ -51,10 +51,10 @@ const exml::Attribute exml::AttributeListData::operator[] (int32_t _id) const { return exml::Attribute(static_cast(m_data->m_data.get())->getAttr(_id)); } -std::pair exml::AttributeListData::getPair(int32_t _id) const { +etk::Pair exml::AttributeListData::getPair(int32_t _id) const { if (m_data->m_data == nullptr) { EXML_DEBUG(" can not getAttrPair (nullptr) ..."); - return std::pair("",""); + return etk::Pair("",""); } return static_cast(m_data->m_data.get())->getAttrPair(_id); } @@ -67,16 +67,16 @@ void exml::AttributeListData::add(exml::Attribute _attr) { static_cast(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) { EXML_DEBUG(" can not getAttribute (nullptr) ..."); - static std::string errorValue(""); + static etk::String errorValue(""); return errorValue; } return static_cast(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) { EXML_DEBUG(" can not getAttribute (nullptr) ..."); return false; @@ -84,7 +84,7 @@ bool exml::AttributeListData::exist(const std::string& _name) const { return static_cast(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) { EXML_DEBUG(" can not removeAttribute (nullptr) ..."); return false; @@ -92,7 +92,7 @@ bool exml::AttributeListData::remove(const std::string& _name) { return static_cast(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) { EXML_DEBUG(" can not setAttribute (nullptr) ..."); return; diff --git a/exml/AttributeList.hpp b/exml/AttributeList.hpp index 2a0a6bb..d1a1e2a 100644 --- a/exml/AttributeList.hpp +++ b/exml/AttributeList.hpp @@ -40,7 +40,7 @@ namespace exml { * @return true The attribute has been removed * @return false An error occured. */ - bool remove(const std::string& _name); + bool remove(const etk::String& _name); /** * @brief get attribute whith his ID * @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() * @return Name and value of the attribute */ - std::pair getPair(int32_t _id) const; + etk::Pair getPair(int32_t _id) const; /** * @brief get the attribute value with searching in the List with his name * @param[in] _name Attribute Name. * @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. * @param[in] _name Attribute Name. * @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 * @param[in] _name Name 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: using iterator = exml::iterator; //!< Specify iterator of the element methode /** diff --git a/exml/Comment.cpp b/exml/Comment.cpp index 885632c..ea2595d 100644 --- a/exml/Comment.cpp +++ b/exml/Comment.cpp @@ -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() { m_data = exml::internal::Comment::create(_value); } diff --git a/exml/Comment.hpp b/exml/Comment.hpp index 49fd146..adbe8dc 100644 --- a/exml/Comment.hpp +++ b/exml/Comment.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace exml { /** @@ -28,7 +28,7 @@ namespace exml { * @brief Constructor * @param[in] _value comment value */ - Comment(const std::string& _value=""); + Comment(const etk::String& _value=""); /** * @brief Copy constructor * @param[in] _obj Object to copy diff --git a/exml/Declaration.cpp b/exml/Declaration.cpp index 2c58a33..72ec36b 100644 --- a/exml/Declaration.cpp +++ b/exml/Declaration.cpp @@ -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() { 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() { m_data = exml::internal::DeclarationXML::create(_version, _format, _standalone); } diff --git a/exml/Declaration.hpp b/exml/Declaration.hpp index cff7969..6925385 100644 --- a/exml/Declaration.hpp +++ b/exml/Declaration.hpp @@ -28,7 +28,7 @@ namespace exml { * @brief Constructor * @param[in] _name name of the declaration (xml, xml:xxxx ...) */ - Declaration(const std::string& _name=""); + Declaration(const etk::String& _name=""); /** * @brief Copy constructor * @param[in] _obj Object to copy @@ -57,7 +57,7 @@ namespace exml { * @param[in] _format charset of the XML * @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 * @param[in] _obj Object to copy diff --git a/exml/Document.cpp b/exml/Document.cpp index 38d0fbc..ac59866 100644 --- a/exml/Document.cpp +++ b/exml/Document.cpp @@ -34,7 +34,7 @@ exml::Document& exml::Document::operator= (const exml::Document& _obj) { return *this; } -bool exml::Document::parse(const std::string& _data) { +bool exml::Document::parse(const etk::String& _data) { if (m_data == nullptr) { EXML_DEBUG("Can not parse (nullptr) ..."); return false; @@ -42,7 +42,7 @@ bool exml::Document::parse(const std::string& _data) { return static_cast(m_data.get())->parse(_data); } -bool exml::Document::generate(std::string& _data) { +bool exml::Document::generate(etk::String& _data) { if (m_data == nullptr) { EXML_DEBUG("Can not generate (nullptr) ..."); return false; @@ -50,7 +50,7 @@ bool exml::Document::generate(std::string& _data) { return static_cast(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) { EXML_DEBUG("Can not load (nullptr) ..."); return false; @@ -58,7 +58,7 @@ bool exml::Document::load(const std::string& _file) { return static_cast(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) { EXML_DEBUG("Can not store (nullptr) ..."); return false; diff --git a/exml/Document.hpp b/exml/Document.hpp index 05aceef..fb6fdb7 100644 --- a/exml/Document.hpp +++ b/exml/Document.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace exml { /** @@ -51,28 +51,28 @@ namespace exml { * @return false : An error occured * @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 * @param[out] _data Data where the xml is stored * @return false : An error occured * @return true : Parsing is OK */ - bool generate(std::string& _data); + bool generate(etk::String& _data); /** * @brief Load the file that might contain the xml * @param[in] _file Filename of the xml (compatible with etk FSNode naming) * @return false : An error occured * @return true : Parsing is OK */ - bool load(const std::string& _file); + bool load(const etk::String& _file); /** * @brief Store the Xml in the file * @param[in] _file Filename of the xml (compatible with etk FSNode naming) * @return false : An error occured * @return true : Parsing is OK */ - bool store(const std::string& _file); + bool store(const etk::String& _file); /** * @brief Display the Document on console */ diff --git a/exml/Element.cpp b/exml/Element.cpp index 0343e97..b22fc34 100644 --- a/exml/Element.cpp +++ b/exml/Element.cpp @@ -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(), nodes(this) { 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(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) { EXML_DEBUG(" can not get type ..."); return exml::Element(); @@ -100,7 +100,7 @@ exml::Element exml::ElementData::operator[](const std::string& _name) { return exml::Element(static_cast(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) { EXML_DEBUG(" can not get type ..."); return exml::Element(); @@ -116,7 +116,7 @@ void exml::ElementData::add(const exml::Node& _node) { static_cast(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) { EXML_DEBUG(" can not APPEND on null element ..."); return; @@ -124,7 +124,7 @@ void exml::ElementData::remove(const std::string& _nodeName) { static_cast(m_data->m_data.get())->remove(_nodeName); } -std::string exml::Element::getText() const { +etk::String exml::Element::getText() const { if (m_data == nullptr) { EXML_DEBUG(" can not APPEND on null element ..."); return ""; diff --git a/exml/Element.hpp b/exml/Element.hpp index 3db0cda..f0dbec9 100644 --- a/exml/Element.hpp +++ b/exml/Element.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include @@ -41,7 +41,7 @@ namespace exml { * @brief Remove a node with his name. * @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. * @param[in] _id Id of the element. @@ -65,13 +65,13 @@ namespace exml { * @param[in] _name Name of the element that is requested * @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) * @param[in] _name Name of the element that is requested * @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: using iterator = exml::iterator; //!< Specify iterator of the element methode /** @@ -116,7 +116,7 @@ namespace exml { * @brief Constructor * @param[in] _value Element name; */ - Element(const std::string& _value=""); + Element(const etk::String& _value=""); /** * @brief Copy constructor * @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 * @return the curent data string. if Only one text node, then we get the parssed data (no & ...) if more than one node, then we transform &,",',<,> in xml normal text... */ - std::string getText() const; + etk::String getText() const; public: void clear() override; }; diff --git a/exml/FilePos.cpp b/exml/FilePos.cpp index cf59e77..a7e5517 100644 --- a/exml/FilePos.cpp +++ b/exml/FilePos.cpp @@ -82,7 +82,7 @@ size_t exml::FilePos::getLine() const { 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 << _obj.getLine(); _os << ",c="; diff --git a/exml/FilePos.hpp b/exml/FilePos.hpp index 478f8cf..86ffb37 100644 --- a/exml/FilePos.hpp +++ b/exml/FilePos.hpp @@ -87,7 +87,7 @@ namespace exml { size_t getLine() const; }; //! @not-in-doc - std::ostream& operator <<(std::ostream& _os, const FilePos& _obj); + etk::Stream& operator <<(etk::Stream& _os, const FilePos& _obj); } diff --git a/exml/Node.cpp b/exml/Node.cpp index a6cb4ab..9b8d5de 100644 --- a/exml/Node.cpp +++ b/exml/Node.cpp @@ -14,7 +14,7 @@ #include #include -std::ostream& exml::operator <<(std::ostream& _os, const exml::Node& _obj) { +etk::Stream& exml::operator <<(etk::Stream& _os, const exml::Node& _obj) { _os << "{"; _os << "Node XML: " << _obj.getType(); if (_obj.isElement() == true) { @@ -49,7 +49,7 @@ exml::FilePos exml::Node::getPos() const { return m_data->getPos(); } -void exml::Node::setValue(std::string _value) { +void exml::Node::setValue(etk::String _value) { if (m_data == nullptr) { EXML_ERROR(" can not set value: '" << _value << "'"); return; @@ -57,9 +57,9 @@ void exml::Node::setValue(std::string _value) { m_data->setValue(_value); } -const std::string& exml::Node::getValue() const { +const etk::String& exml::Node::getValue() const { if (m_data == nullptr) { - static std::string errorString = ""; + static etk::String errorString = ""; EXML_DEBUG(" can not get value ..."); return errorString; } diff --git a/exml/Node.hpp b/exml/Node.hpp index 84a61b6..75311ef 100644 --- a/exml/Node.hpp +++ b/exml/Node.hpp @@ -64,12 +64,12 @@ namespace exml { * @brief set the 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. * @return the reference of the string value. */ - const std::string& getValue() const; + const etk::String& getValue() const; /** * @brief get the node type. * @return the type of the Node. @@ -171,5 +171,5 @@ namespace exml { virtual void clear(); }; //! @not_in_doc - std::ostream& operator <<(std::ostream& _os, const exml::Node& _obj); + etk::Stream& operator <<(etk::Stream& _os, const exml::Node& _obj); } diff --git a/exml/Text.cpp b/exml/Text.cpp index 99aee23..3bea660 100644 --- a/exml/Text.cpp +++ b/exml/Text.cpp @@ -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() { m_data = exml::internal::Text::create(_data); } diff --git a/exml/Text.hpp b/exml/Text.hpp index ebbaa5b..8a4c47a 100644 --- a/exml/Text.hpp +++ b/exml/Text.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace exml { /** @@ -28,7 +28,7 @@ namespace exml { * @brief Constructor * @param[in] _data String data of the current Text */ - Text(const std::string& _data=""); + Text(const etk::String& _data=""); /** * @brief Copy constructor * @param[in] _obj Object to copy diff --git a/exml/details/iterator.hxx b/exml/details/iterator.hxx index da77676..aba20a3 100644 --- a/exml/details/iterator.hxx +++ b/exml/details/iterator.hxx @@ -11,28 +11,28 @@ template exml::iterator::iterator(EXML_BASE_T& _obj, size_t _pos) : m_data(_obj), 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 exml::iterator::iterator(const EXML_BASE_T& _obj, size_t _pos) : m_data(const_cast(_obj)), 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 exml::iterator::iterator(const exml::iterator& _obj) : m_data(_obj.m_data), 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 exml::iterator& exml::iterator::operator= (const exml::iterator& _obj) { m_data = _obj.m_data; 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; } @@ -40,7 +40,7 @@ template exml::iterator& exml::iterator::operator+= (int32_t _val) { 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; } @@ -55,7 +55,7 @@ template exml::iterator& exml::iterator::operator-= (int32_t _val) { 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; } @@ -70,7 +70,7 @@ template exml::iterator& exml::iterator::operator++() { int64_t val = m_id; ++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; } @@ -85,7 +85,7 @@ template exml::iterator& exml::iterator::operator--() { int64_t val = m_id; --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; } diff --git a/exml/internal/Attribute.cpp b/exml/internal/Attribute.cpp index 11ec7a3..0cf7450 100644 --- a/exml/internal/Attribute.cpp +++ b/exml/internal/Attribute.cpp @@ -8,17 +8,17 @@ #include #include -ememory::SharedPtr exml::internal::Attribute::create(const std::string& _name, const std::string& _value) { +ememory::SharedPtr exml::internal::Attribute::create(const etk::String& _name, const etk::String& _value) { return ememory::SharedPtr(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), 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'"); m_pos = _filePos; // search end of the comment : @@ -34,7 +34,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos, break; } } - m_name = std::string(_data, _pos, lastElementName+1-(_pos)); + m_name = etk::String(_data, _pos, lastElementName+1-(_pos)); if (_caseSensitive == true) { m_name = etk::tolower(m_name); } @@ -83,7 +83,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos, 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 << "\""); @@ -103,7 +103,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos, 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 << "\""); @@ -111,7 +111,7 @@ bool exml::internal::Attribute::iParse(const std::string& _data, int32_t& _pos, 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 += m_name; _data += "=\""; diff --git a/exml/internal/Attribute.hpp b/exml/internal/Attribute.hpp index 6e905db..4bf7cbc 100644 --- a/exml/internal/Attribute.hpp +++ b/exml/internal/Attribute.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include namespace exml { namespace internal { @@ -20,7 +20,7 @@ namespace exml { * @param[in] _name Name of the attribute. * @param[in] _value Value of the attribute. */ - Attribute(const std::string& _name="", const std::string& _value=""); + Attribute(const etk::String& _name="", const etk::String& _value=""); public: /** * @brief defined factory @@ -28,30 +28,30 @@ namespace exml { * @param[in] _value Value of the attribute * @return Shared pointer on the Attribute element */ - static ememory::SharedPtr create(const std::string& _name="", const std::string& _value=""); + static ememory::SharedPtr create(const etk::String& _name="", const etk::String& _value=""); protected: - std::string m_name; //!< Name of the attribute + etk::String m_name; //!< Name of the attribute public: /** * @brief set the 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; }; /** * @brief get the current name of the Attribute * @return String of the attribute */ - virtual const std::string& getName() const { + virtual const etk::String& getName() const { return m_name; }; public: enum nodeType getType() const override { return exml::nodeType::attribute; }; - bool iParse(const std::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 iParse(const etk::String& _data, int32_t& _pos, bool _caseSensitive, exml::FilePos& _filePos, exml::internal::Document& _doc) override; + bool iGenerate(etk::String& _data, int32_t _indent) const override; ememory::SharedPtr toAttribute() override { return ememory::staticPointerCast(sharedFromThis()); }; diff --git a/exml/internal/AttributeList.cpp b/exml/internal/AttributeList.cpp index 2c4ed18..55bd137 100644 --- a/exml/internal/AttributeList.cpp +++ b/exml/internal/AttributeList.cpp @@ -23,12 +23,12 @@ ememory::SharedPtr exml::internal::AttributeLis return m_listAttribute[_id]; } -std::pair exml::internal::AttributeList::getAttrPair(int32_t _id) const { +etk::Pair exml::internal::AttributeList::getAttrPair(int32_t _id) const { ememory::SharedPtr att = getAttr(_id); if (att == nullptr) { - return std::make_pair("",""); + return etk::makePair("",""); } - 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::SharedPtriGenerate(_data, _indent); diff --git a/exml/internal/AttributeList.hpp b/exml/internal/AttributeList.hpp index 5b84fef..735aacd 100644 --- a/exml/internal/AttributeList.hpp +++ b/exml/internal/AttributeList.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include @@ -21,12 +21,12 @@ namespace exml { * @brief Constructor * @param[in] _value Node value; */ - AttributeList(const std::string& _value="") : + AttributeList(const etk::String& _value="") : exml::internal::Node(_value) { }; protected: - std::vector> m_listAttribute; //!< list of all attribute + etk::Vector> m_listAttribute; //!< list of all attribute public: /** * @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() * @return Name and value of the attribute */ - std::pair getAttrPair(int32_t _id) const; + etk::Pair getAttrPair(int32_t _id) const; /** * @brief get the attribute value with searching in the List with his name * @param[in] _name Attribute Name. * @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. * @param[in] _name Attribute Name. * @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 * @param[in] _name Name of the attribute * @param[in] _value Value of the attribute */ - void setAttribute(const std::string& _name, const std::string& _value); + void setAttribute(const etk::String& _name, const etk::String& _value); /** * @brief Remove an attribute form the list * @param[in] _name Name of the attribute * @return true The attribute has been removed * @return false An error occured. */ - bool removeAttribute(const std::string& _name); + bool removeAttribute(const etk::String& _name); public: - bool iGenerate(std::string& _data, int32_t _indent) const override; + bool iGenerate(etk::String& _data, int32_t _indent) const override; void clear() override; }; } diff --git a/exml/internal/Comment.cpp b/exml/internal/Comment.cpp index 9620b9a..152a334 100644 --- a/exml/internal/Comment.cpp +++ b/exml/internal/Comment.cpp @@ -18,11 +18,11 @@ static bool isWhiteChar(char32_t _val) { return false; } -ememory::SharedPtr exml::internal::Comment::create(const std::string& _value) { +ememory::SharedPtr exml::internal::Comment::create(const etk::String& _value) { return ememory::SharedPtr(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'"); m_pos = _filePos; exml::FilePos tmpPos; @@ -50,7 +50,7 @@ bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bo } } // 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 << "'"); _pos = iii+2; return true; @@ -61,7 +61,7 @@ bool exml::internal::Comment::iParse(const std::string& _data, int32_t& _pos, bo 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); _data += "" "coucou"; bool retParse = doc.parse(stream); @@ -42,7 +42,7 @@ static void readFromString2() { exml::Document doc; TEST_INFO("parse"); //! [exml_sample_read_stream2] - std::string stream = "" + etk::String stream = "" "" "coucou"; bool retParse = doc.parse(stream); @@ -90,7 +90,7 @@ static void readFull() { TEST_INFO(" list of attribute:"); //! [exml_sample_read_folow_attributes] for (const auto itElem: element.attributes) { - std::string value = itElem.getValue(); + etk::String value = itElem.getValue(); TEST_INFO(" '" << value << "'"); } TEST_INFO(" list of attribute in C:"); @@ -98,12 +98,12 @@ static void readFull() { //! [exml_sample_read_folow_attributes_c] for (size_t iii=0; iii // _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? -void exmlLocalTest(const std::string& _ref, - const std::string& _input, +void exmlLocalTest(const etk::String& _ref, + const etk::String& _input, int32_t _errorPos, bool _caseInSensitive=false); diff --git a/test/exmlTestParseElement.cpp b/test/exmlTestParseElement.cpp index 033a372..00607bf 100644 --- a/test/exmlTestParseElement.cpp +++ b/test/exmlTestParseElement.cpp @@ -8,7 +8,7 @@ #include -static std::string refOutputElement("\n"); +static etk::String refOutputElement("\n"); TEST(TestParseElement, testBase) { exmlLocalTest(refOutputElement, "\n", -1); diff --git a/test/main.cpp b/test/main.cpp index 829959f..01af8b2 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -15,7 +15,7 @@ int main(int argc, const char *argv[]) { // the only one init for etk: etk::init(argc, argv); for (int32_t iii=0; iii