diff --git a/ejson/Array.cpp b/ejson/Array.cpp index e28f603..b0fc8cd 100644 --- a/ejson/Array.cpp +++ b/ejson/Array.cpp @@ -110,7 +110,7 @@ template class ejson::iterator; // Not implemented ==> force link error ... /* template<> -std::string ejson::iterator::getKey() const noexcept { +etk::String ejson::iterator::getKey() const noexcept { return m_data.getKey(m_id); } */ \ No newline at end of file diff --git a/ejson/Document.cpp b/ejson/Document.cpp index 5fb9ad6..2f6971a 100644 --- a/ejson/Document.cpp +++ b/ejson/Document.cpp @@ -34,7 +34,7 @@ ejson::Document& ejson::Document::operator= (const ejson::Document& _obj) { return *this; } -bool ejson::Document::parse(const std::string& _data) { +bool ejson::Document::parse(const etk::String& _data) { if (m_data == nullptr) { EJSON_DEBUG("Can not parse (nullptr) ..."); return false; @@ -42,7 +42,7 @@ bool ejson::Document::parse(const std::string& _data) { return static_cast(m_data.get())->parse(_data); } -bool ejson::Document::generate(std::string& _data) { +bool ejson::Document::generate(etk::String& _data) { if (m_data == nullptr) { EJSON_DEBUG("Can not generate (nullptr) ..."); return false; @@ -50,7 +50,7 @@ bool ejson::Document::generate(std::string& _data) { return static_cast(m_data.get())->generate(_data); } -bool ejson::Document::load(const std::string& _file) { +bool ejson::Document::load(const etk::String& _file) { if (m_data == nullptr) { EJSON_DEBUG("Can not load (nullptr) ..."); return false; @@ -58,7 +58,7 @@ bool ejson::Document::load(const std::string& _file) { return static_cast(m_data.get())->load(_file); } -bool ejson::Document::store(const std::string& _file) { +bool ejson::Document::store(const etk::String& _file) { if (m_data == nullptr) { EJSON_DEBUG("Can not store (nullptr) ..."); return false; @@ -66,7 +66,7 @@ bool ejson::Document::store(const std::string& _file) { return static_cast(m_data.get())->store(_file); } -bool ejson::Document::storeSafe(const std::string& _file) { +bool ejson::Document::storeSafe(const etk::String& _file) { if (m_data == nullptr) { EJSON_DEBUG("Can not store (nullptr) ..."); return false; diff --git a/ejson/Document.hpp b/ejson/Document.hpp index 01bef50..2c5977c 100644 --- a/ejson/Document.hpp +++ b/ejson/Document.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include #include @@ -44,35 +44,35 @@ namespace ejson { * @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 Json * @param[out] _data Data where the Json 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 Json * @param[in] _file Filename of the Json (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 Json in the file * @param[in] _file Filename of the Json (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 Store the Json in the file (safe mode mean that the file is store in a second file xxx.tmp and moved in the file xxx (only one mode to be really safe with filesystem ...) * @param[in] _file Filename of the Json (compatible with etk FSNode naming) * @return false : An error occured * @return true : Parsing is OK */ - bool storeSafe(const std::string& _file); + bool storeSafe(const etk::String& _file); /** * @brief Set the display of the error when detected. * @param[in] _value true: display error, false not display error (get it at end) diff --git a/ejson/FilePos.cpp b/ejson/FilePos.cpp index a1f6844..7c74cc4 100644 --- a/ejson/FilePos.cpp +++ b/ejson/FilePos.cpp @@ -83,7 +83,7 @@ size_t ejson::FilePos::getLine() const { return m_line; } -std::ostream& ejson::operator <<(std::ostream& _os, const ejson::FilePos& _obj) { +etk::Stream& ejson::operator <<(etk::Stream& _os, const ejson::FilePos& _obj) { _os << "(l="; _os << _obj.getLine(); _os << ",c="; diff --git a/ejson/FilePos.hpp b/ejson/FilePos.hpp index ae18e13..94b4db4 100644 --- a/ejson/FilePos.hpp +++ b/ejson/FilePos.hpp @@ -87,7 +87,7 @@ namespace ejson { 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/ejson/Object.cpp b/ejson/Object.cpp index dd1993a..5a85a3a 100644 --- a/ejson/Object.cpp +++ b/ejson/Object.cpp @@ -31,7 +31,7 @@ ejson::Object::Object() : m_data = ejson::internal::Object::create(); } -ejson::Object::Object(const std::string& _data) : +ejson::Object::Object(const etk::String& _data) : ejson::Value() { m_data = ejson::internal::Object::create(_data); } @@ -41,7 +41,7 @@ ejson::Object& ejson::Object::operator= (const ejson::Object& _obj) { return *this; } -bool ejson::Object::valueExist(const std::string& _name) const { +bool ejson::Object::valueExist(const etk::String& _name) const { if (m_data == nullptr) { EJSON_DEBUG("Can not exist (nullptr) ..."); return false; @@ -49,7 +49,7 @@ bool ejson::Object::valueExist(const std::string& _name) const { return static_cast(m_data.get())->exist(_name); } -ejson::Value ejson::Object::operator[] (const std::string& _name) { +ejson::Value ejson::Object::operator[] (const etk::String& _name) { if (m_data == nullptr) { EJSON_DEBUG("Can not operator[] (nullptr) ..."); return ejson::Value(nullptr); @@ -57,7 +57,7 @@ ejson::Value ejson::Object::operator[] (const std::string& _name) { return ejson::Value(static_cast(m_data.get())->get(_name)); } -const ejson::Value ejson::Object::operator[] (const std::string& _name) const { +const ejson::Value ejson::Object::operator[] (const etk::String& _name) const { if (m_data == nullptr) { EJSON_DEBUG("Can not operator[] (nullptr) ..."); return ejson::Value(nullptr); @@ -65,10 +65,10 @@ const ejson::Value ejson::Object::operator[] (const std::string& _name) const { return ejson::Value(static_cast(m_data.get())->get(_name)); } -std::vector ejson::Object::getKeys() const { +etk::Vector ejson::Object::getKeys() const { if (m_data == nullptr) { EJSON_DEBUG("Can not getKeys (nullptr) ..."); - return std::vector(); + return etk::Vector(); } return static_cast(m_data.get())->getKeys(); } @@ -97,7 +97,7 @@ const ejson::Value ejson::Object::operator[] (size_t _id) const { return ejson::Value(static_cast(m_data.get())->get(_id)); } -std::string ejson::Object::getKey(size_t _id) const { +etk::String ejson::Object::getKey(size_t _id) const { if (m_data == nullptr) { EJSON_DEBUG("Can not getKey (nullptr) ..."); return ""; @@ -105,7 +105,7 @@ std::string ejson::Object::getKey(size_t _id) const { return static_cast(m_data.get())->getKey(_id); } -bool ejson::Object::add(const std::string& _name, const ejson::Value& _value) { +bool ejson::Object::add(const etk::String& _name, const ejson::Value& _value) { if (m_data == nullptr) { EJSON_DEBUG("Can not add (nullptr) ..."); return false; @@ -113,7 +113,7 @@ bool ejson::Object::add(const std::string& _name, const ejson::Value& _value) { return static_cast(m_data.get())->add(_name, _value.m_data); } -void ejson::Object::remove(const std::string& _name) { +void ejson::Object::remove(const etk::String& _name) { if (m_data == nullptr) { EJSON_DEBUG("Can not remove (nullptr) ..."); return; @@ -160,7 +160,7 @@ const ejson::Object::iterator ejson::Object::end() const { template class ejson::iterator; namespace ejson { template<> - std::string iterator::getKey() const noexcept { + etk::String iterator::getKey() const noexcept { return m_data.getKey(m_id); } } diff --git a/ejson/Object.hpp b/ejson/Object.hpp index 2ac4741..4be613d 100644 --- a/ejson/Object.hpp +++ b/ejson/Object.hpp @@ -35,7 +35,7 @@ namespace ejson { * @brief Constructor * @param[in] _data string data to parse */ - Object(const std::string& _data); + Object(const etk::String& _data); /** * @brief Copy constructor * @param[in] _obj Object to copy @@ -49,25 +49,25 @@ namespace ejson { * @param[in] _name Name of the object. * @return The existance of the element. */ - bool valueExist(const std::string& _name) const; + bool valueExist(const etk::String& _name) const; /** * @brief Cet the sub element with his name (no cast check) * @param[in] _name Name of the object * @return Value on the element requested or a value that does not exist @ref ejson::Value::exist. */ - ejson::Value operator[] (const std::string& _name); + ejson::Value operator[] (const etk::String& _name); /** * @brief Get the const sub element with his name (no cast check) * @param[in] _name Name of the object * @return const Value on the element requested or a value that does not exist @ref ejson::Value::exist. */ - const ejson::Value operator[] (const std::string& _name) const; + const ejson::Value operator[] (const etk::String& _name) const; public: /** * @brief Get all the element name (keys). * @return a vector of all name (key). */ - std::vector getKeys() const; + etk::Vector getKeys() const; /** * @brief get the number of sub element in the current one * @return the Number of stored element @@ -90,7 +90,7 @@ namespace ejson { * @param[in] _id Id of the element. * @return The name (key). */ - std::string getKey(size_t _id) const; + etk::String getKey(size_t _id) const; public: /** * @brief add an element in the Object @@ -98,12 +98,12 @@ namespace ejson { * @param[in] _value Element to add * @return false if an error occured */ - bool add(const std::string& _name, const ejson::Value& _value); + bool add(const etk::String& _name, const ejson::Value& _value); /** * @brief Remove Value with his name * @param[in] _name Name of the object */ - void remove(const std::string& _name); + void remove(const etk::String& _name); /** * @brief Remove Value with his id * @param[in] _id Id of the element. diff --git a/ejson/String.cpp b/ejson/String.cpp index 7d562c4..3d93fc5 100644 --- a/ejson/String.cpp +++ b/ejson/String.cpp @@ -23,7 +23,7 @@ ejson::String::String(const ejson::String& _obj) : } -ejson::String::String(const std::string& _value) : +ejson::String::String(const etk::String& _value) : ejson::Value() { m_data = ejson::internal::String::create(_value); } @@ -33,7 +33,7 @@ ejson::String& ejson::String::operator= (const ejson::String& _obj) { return *this; } -void ejson::String::set(const std::string& _value) { +void ejson::String::set(const etk::String& _value) { if (m_data == nullptr) { EJSON_DEBUG("Can not set (nullptr) ..."); return; @@ -41,7 +41,7 @@ void ejson::String::set(const std::string& _value) { static_cast(m_data.get())->set(_value); } -std::string ejson::String::get(const std::string& _errorValue) const { +etk::String ejson::String::get(const etk::String& _errorValue) const { if (m_data == nullptr) { EJSON_DEBUG("Can not get (nullptr) ..."); return _errorValue; diff --git a/ejson/String.hpp b/ejson/String.hpp index a2ceed7..b908aab 100644 --- a/ejson/String.hpp +++ b/ejson/String.hpp @@ -28,7 +28,7 @@ namespace ejson { * @brief Constructor * @param[in] _value String value to set */ - String(const std::string& _value=""); + String(const etk::String& _value=""); /** * @brief Copy constructor * @param[in] _obj Object to copy @@ -40,13 +40,13 @@ namespace ejson { * @brief set the value of the node. * @param[in] _value New value of the node. */ - void set(const std::string& _value); + void set(const etk::String& _value); /** * @brief get the current element Value. * @param[in] _errorValue The return value if an error occured. * @return the reference of the string value. */ - std::string get(const std::string& _errorValue="") const; + etk::String get(const etk::String& _errorValue="") const; }; } diff --git a/ejson/Value.cpp b/ejson/Value.cpp index 50341d9..a4f8708 100644 --- a/ejson/Value.cpp +++ b/ejson/Value.cpp @@ -15,7 +15,7 @@ ejson::Value ejson::empty() { -std::ostream& ejson::operator <<(std::ostream& _os, const ejson::Value& _obj) { +etk::Stream& ejson::operator <<(etk::Stream& _os, const ejson::Value& _obj) { _os << "{"; _os << "Value JSON: " << _obj.getType(); /* @@ -42,8 +42,8 @@ bool ejson::Value::exist() const { return true; } -std::string ejson::Value::generateHumanString() const { - std::string out; +etk::String ejson::Value::generateHumanString() const { + etk::String out; if (m_data == nullptr) { EJSON_DEBUG("Can not remove (nullptr) ..."); return out; @@ -52,8 +52,8 @@ std::string ejson::Value::generateHumanString() const { return out; } -std::string ejson::Value::generateMachineString() const { - std::string out; +etk::String ejson::Value::generateMachineString() const { + etk::String out; if (m_data == nullptr) { EJSON_DEBUG("Can not remove (nullptr) ..."); return out; diff --git a/ejson/Value.hpp b/ejson/Value.hpp index c96b021..cca2199 100644 --- a/ejson/Value.hpp +++ b/ejson/Value.hpp @@ -192,15 +192,15 @@ namespace ejson { * @brief generate a string that contain the created JSON * @return generated data */ - std::string generateHumanString() const; + etk::String generateHumanString() const; /** * @brief generate a string that contain the created JSON * @return generated data */ - std::string generateMachineString() const; + etk::String generateMachineString() const; }; //! @not_in_doc - std::ostream& operator <<(std::ostream& _os, const ejson::Value& _obj); + etk::Stream& operator <<(etk::Stream& _os, const ejson::Value& _obj); /** * @brief create an empty Value (that does not exist ... * @return empty value (not usable) diff --git a/ejson/details/iterator.hxx b/ejson/details/iterator.hxx index 4c64d99..a8a7b19 100644 --- a/ejson/details/iterator.hxx +++ b/ejson/details/iterator.hxx @@ -9,28 +9,28 @@ template ejson::iterator::iterator(EJSON_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 ejson::iterator::iterator(const EJSON_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 ejson::iterator::iterator(const ejson::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 ejson::iterator& ejson::iterator::operator= (const ejson::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; } @@ -38,7 +38,7 @@ template ejson::iterator& ejson::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; } @@ -53,7 +53,7 @@ template ejson::iterator& ejson::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; } @@ -68,7 +68,7 @@ template ejson::iterator& ejson::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; } @@ -83,7 +83,7 @@ template ejson::iterator& ejson::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/ejson/internal/Array.cpp b/ejson/internal/Array.cpp index 1c146ce..25df22e 100644 --- a/ejson/internal/Array.cpp +++ b/ejson/internal/Array.cpp @@ -22,7 +22,7 @@ void ejson::internal::Array::clear() { m_value.clear(); } -bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { +bool ejson::internal::Array::iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { EJSON_PARSE_ELEMENT("start parse : 'Object' "); for (size_t iii=_pos+1; iii<_data.size(); iii++) { _filePos.check(_data[iii]); @@ -57,7 +57,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.push_back(tmpElement); + m_value.pushBack(tmpElement); } else if ( _data[iii] == '"' || _data[iii] == '\'') { // find a string: @@ -69,7 +69,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.push_back(tmpElement); + m_value.pushBack(tmpElement); } else if (_data[iii] == '[') { // find a list: EJSON_PARSE_ELEMENT("find List"); @@ -80,7 +80,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.push_back(tmpElement); + m_value.pushBack(tmpElement); } else if ( ( _data[iii] == 'f' && iii+4 < _data.size() && _data[iii+1] == 'a' @@ -101,7 +101,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.push_back(tmpElement); + m_value.pushBack(tmpElement); } else if ( _data[iii] == 'n' && iii+3 < _data.size() && _data[iii+1] == 'u' @@ -116,7 +116,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.push_back(tmpElement); + m_value.pushBack(tmpElement); } else if (checkNumber(_data[iii]) == true) { // find number: EJSON_PARSE_ELEMENT("find Number"); @@ -127,7 +127,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso return false; } tmpElement->iParse(_data, iii, _filePos, _doc); - m_value.push_back(tmpElement); + m_value.pushBack(tmpElement); } else if (_data[iii] == ',') { // find Separator : Restart cycle ... // TODO : check if element are separated with ',' @@ -139,7 +139,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso return false; } else { // find an error .... - EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, std::string("Find '") + _data[iii] + "' with no element in the element..."); + EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, etk::String("Find '") + _data[iii] + "' with no element in the element..."); // move the curent index _pos = iii+1; return false; @@ -150,7 +150,7 @@ bool ejson::internal::Array::iParse(const std::string& _data, size_t& _pos, ejso } -bool ejson::internal::Array::iGenerate(std::string& _data, size_t _indent) const { +bool ejson::internal::Array::iGenerate(etk::String& _data, size_t _indent) const { bool oneLine=true; if (m_value.size()>3) { oneLine=false; @@ -206,7 +206,7 @@ bool ejson::internal::Array::iGenerate(std::string& _data, size_t _indent) const return true; } -void ejson::internal::Array::iMachineGenerate(std::string& _data) const { +void ejson::internal::Array::iMachineGenerate(etk::String& _data) const { _data += "["; bool needComa = false; for (size_t iii=0; iii _ele EJSON_ERROR("Request add on an nullptr pointer"); return false; } - m_value.push_back(_element); + m_value.pushBack(_element); return true; } diff --git a/ejson/internal/Array.hpp b/ejson/internal/Array.hpp index ecebcc4..ca11ffd 100644 --- a/ejson/internal/Array.hpp +++ b/ejson/internal/Array.hpp @@ -28,7 +28,7 @@ namespace ejson { */ static ememory::SharedPtr create(); private: - std::vector > m_value; //!< vector of sub elements + etk::Vector > m_value; //!< vector of sub elements public: /** * @brief get the number of sub element in the current one @@ -59,9 +59,9 @@ namespace ejson { */ void remove(size_t _id); public: - bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; - bool iGenerate(std::string& _data, size_t _indent) const override; - void iMachineGenerate(std::string& _data) const override; + bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; + bool iGenerate(etk::String& _data, size_t _indent) const override; + void iMachineGenerate(etk::String& _data) const override; void clear() override; bool transfertIn(ememory::SharedPtr _obj) override; ememory::SharedPtr clone() const override; diff --git a/ejson/internal/Boolean.cpp b/ejson/internal/Boolean.cpp index b7be9d3..e7deedb 100644 --- a/ejson/internal/Boolean.cpp +++ b/ejson/internal/Boolean.cpp @@ -25,7 +25,7 @@ bool ejson::internal::Boolean::get() const { return m_value; } -bool ejson::internal::Boolean::iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { +bool ejson::internal::Boolean::iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { EJSON_PARSE_ELEMENT("start parse : 'Boolean' "); m_value=false; if( _data[_pos] == 't' @@ -54,7 +54,7 @@ bool ejson::internal::Boolean::iParse(const std::string& _data, size_t& _pos, ej } -bool ejson::internal::Boolean::iGenerate(std::string& _data, size_t _indent) const { +bool ejson::internal::Boolean::iGenerate(etk::String& _data, size_t _indent) const { if (m_value == true) { _data += "true"; } else { @@ -63,7 +63,7 @@ bool ejson::internal::Boolean::iGenerate(std::string& _data, size_t _indent) con return true; } -void ejson::internal::Boolean::iMachineGenerate(std::string& _data) const { +void ejson::internal::Boolean::iMachineGenerate(etk::String& _data) const { if (m_value == true) { _data += "true"; } else { diff --git a/ejson/internal/Boolean.hpp b/ejson/internal/Boolean.hpp index 5796ad4..1402df3 100644 --- a/ejson/internal/Boolean.hpp +++ b/ejson/internal/Boolean.hpp @@ -41,9 +41,9 @@ namespace ejson { */ bool get() const; public: - bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; - bool iGenerate(std::string& _data, size_t _indent) const override; - void iMachineGenerate(std::string& _data) const override; + bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; + bool iGenerate(etk::String& _data, size_t _indent) const override; + void iMachineGenerate(etk::String& _data) const override; bool transfertIn(ememory::SharedPtr _obj) override; ememory::SharedPtr clone() const override; }; diff --git a/ejson/internal/Document.cpp b/ejson/internal/Document.cpp index b222a92..1b6b2c4 100644 --- a/ejson/internal/Document.cpp +++ b/ejson/internal/Document.cpp @@ -27,13 +27,13 @@ ejson::internal::Document::Document() : m_type = ejson::valueType::document; } -bool ejson::internal::Document::iGenerate(std::string& _data, size_t _indent) const { +bool ejson::internal::Document::iGenerate(etk::String& _data, size_t _indent) const { ejson::internal::Object::iGenerate(_data, _indent+1); _data += "\n"; return true; } -bool ejson::internal::Document::parse(const std::string& _data) { +bool ejson::internal::Document::parse(const etk::String& _data) { EJSON_VERBOSE("Start parsing document (type: string) size=" << _data.size()); clear(); ejson::FilePos filePos(1,0); @@ -41,12 +41,12 @@ bool ejson::internal::Document::parse(const std::string& _data) { return iParse(_data, parsePos, filePos, *this); } -bool ejson::internal::Document::generate(std::string& _data) { +bool ejson::internal::Document::generate(etk::String& _data) { _data = ""; return iGenerate(_data,0); } -bool ejson::internal::Document::load(const std::string& _file) { +bool ejson::internal::Document::load(const etk::String& _file) { // Start loading the XML : EJSON_VERBOSE("open file (xml) \"" << _file << "\""); clear(); @@ -65,22 +65,22 @@ bool ejson::internal::Document::load(const std::string& _file) { return false; } // allocate data - std::vector fileBuffer; + etk::Vector fileBuffer; fileBuffer.resize(fileSize+5, 0); // load data from the file : tmpFile.fileRead(&fileBuffer[0], 1, fileSize); // close the file: tmpFile.fileClose(); - std::string tmpDataUnicode(&fileBuffer[0]); + etk::String tmpDataUnicode(&fileBuffer[0]); // parse the data : bool ret = parse(tmpDataUnicode); //Display(); return ret; } -bool ejson::internal::Document::store(const std::string& _file) { - std::string createData; +bool ejson::internal::Document::store(const etk::String& _file) { + etk::String createData; if (false == generate(createData)) { EJSON_ERROR("Error while creating the XML : " << _file); return false; @@ -100,8 +100,8 @@ bool ejson::internal::Document::store(const std::string& _file) { } -static std::string createPosPointer(const std::string& _line, size_t _pos) { - std::string out; +static etk::String createPosPointer(const etk::String& _line, size_t _pos) { + etk::String out; size_t iii; for (iii=0; iii<_pos && iii<_line.size(); iii++) { if (_line[iii] == '\t') { @@ -117,7 +117,7 @@ static std::string createPosPointer(const std::string& _line, size_t _pos) { return out; } -bool ejson::internal::Document::iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { +bool ejson::internal::Document::iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { EJSON_PARSE_ELEMENT("start parse : 'Document' "); bool haveMainNode=false; bool nodeParsed=false; @@ -192,10 +192,10 @@ void ejson::internal::Document::displayError() { #endif } -void ejson::internal::Document::createError(const std::string& _data, +void ejson::internal::Document::createError(const etk::String& _data, size_t _pos, const ejson::FilePos& _filePos, - const std::string& _comment) { + const etk::String& _comment) { m_comment = _comment; m_Line = etk::extract_line(_data, _pos); m_filePos = _filePos; diff --git a/ejson/internal/Document.hpp b/ejson/internal/Document.hpp index 169307e..0584dca 100644 --- a/ejson/internal/Document.hpp +++ b/ejson/internal/Document.hpp @@ -6,7 +6,7 @@ #pragma once #include -#include +#include #include #include #include @@ -35,32 +35,32 @@ namespace ejson { * @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); private: bool m_writeErrorWhenDetexted; //!< Flag to know if we need to display error when they are detected - std::string m_comment; //!< Error comment - std::string m_Line; //!< Line with the error + etk::String m_comment; //!< Error comment + etk::String m_Line; //!< Line with the error ejson::FilePos m_filePos; //!< Position in the file of the error public: /** @@ -85,16 +85,16 @@ namespace ejson { * @param[in] _filePos Position in x/y in the file * @param[in] _comment Help coment */ - void createError(const std::string& _data, + void createError(const etk::String& _data, size_t _pos, const ejson::FilePos& _filePos, - const std::string& _comment); + const etk::String& _comment); public: - bool iParse(const std::string& _data, + bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; - bool iGenerate(std::string& _data, size_t _indent) const override; + bool iGenerate(etk::String& _data, size_t _indent) const override; }; } } diff --git a/ejson/internal/Null.cpp b/ejson/internal/Null.cpp index c8865ea..d431bfe 100644 --- a/ejson/internal/Null.cpp +++ b/ejson/internal/Null.cpp @@ -16,7 +16,7 @@ ejson::internal::Null::Null() { m_type = ejson::valueType::null; } -bool ejson::internal::Null::iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { +bool ejson::internal::Null::iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { EJSON_PARSE_ELEMENT("start parse : 'Null' "); if (_pos+3 >= _data.size()){ EJSON_CREATE_ERROR(_doc, _data, _pos, _filePos, "can not parse null !!! "); @@ -35,12 +35,12 @@ bool ejson::internal::Null::iParse(const std::string& _data, size_t& _pos, ejson } -bool ejson::internal::Null::iGenerate(std::string& _data, size_t _indent) const { +bool ejson::internal::Null::iGenerate(etk::String& _data, size_t _indent) const { _data += "null"; return true; } -void ejson::internal::Null::iMachineGenerate(std::string& _data) const { +void ejson::internal::Null::iMachineGenerate(etk::String& _data) const { _data += "null"; } diff --git a/ejson/internal/Null.hpp b/ejson/internal/Null.hpp index f89362a..60320b3 100644 --- a/ejson/internal/Null.hpp +++ b/ejson/internal/Null.hpp @@ -26,9 +26,9 @@ namespace ejson { */ static ememory::SharedPtr create(); public: - bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; - bool iGenerate(std::string& _data, size_t _indent) const override; - void iMachineGenerate(std::string& _data) const override; + bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; + bool iGenerate(etk::String& _data, size_t _indent) const override; + void iMachineGenerate(etk::String& _data) const override; bool transfertIn(ememory::SharedPtr _obj) override; ememory::SharedPtr clone() const override; }; diff --git a/ejson/internal/Number.cpp b/ejson/internal/Number.cpp index c888a78..698ad89 100644 --- a/ejson/internal/Number.cpp +++ b/ejson/internal/Number.cpp @@ -37,9 +37,9 @@ ejson::internal::Number::Number(int64_t _value) : m_type = ejson::valueType::number; } -bool ejson::internal::Number::iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { +bool ejson::internal::Number::iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { EJSON_PARSE_ELEMENT("start parse : 'Number' "); - std::string tmpVal; + etk::String tmpVal; bool isDouble = false; for (size_t iii=_pos; iii<_data.size(); iii++) { _filePos.check(_data[iii]); @@ -76,41 +76,41 @@ bool ejson::internal::Number::iParse(const std::string& _data, size_t& _pos, ejs return false; } -bool ejson::internal::Number::iGenerate(std::string& _data, size_t _indent) const { +bool ejson::internal::Number::iGenerate(etk::String& _data, size_t _indent) const { if (m_typeNumber == ejson::internal::Number::type::tDouble) { // special thing to remove .000000 at the end of perfect number ... int64_t tmpVal = m_value; if (double(tmpVal) == m_value) { - _data += etk::to_string(tmpVal); + _data += etk::toString(tmpVal); } else { - _data += etk::to_string(m_value); + _data += etk::toString(m_value); } return true; } if (m_typeNumber == ejson::internal::Number::type::tInt) { - _data += etk::to_string(m_valueI64); + _data += etk::toString(m_valueI64); return true; } - _data += etk::to_string(m_valueU64); + _data += etk::toString(m_valueU64); return true; } -void ejson::internal::Number::iMachineGenerate(std::string& _data) const { +void ejson::internal::Number::iMachineGenerate(etk::String& _data) const { if (m_typeNumber == ejson::internal::Number::type::tDouble) { // special thing to remove .000000 at the end of perfect number ... int64_t tmpVal = m_value; if (double(tmpVal) == m_value) { - _data += etk::to_string(tmpVal); + _data += etk::toString(tmpVal); } else { - _data += etk::to_string(m_value); + _data += etk::toString(m_value); } return; } if (m_typeNumber == ejson::internal::Number::type::tInt) { - _data += etk::to_string(m_valueI64); + _data += etk::toString(m_valueI64); return; } - _data += etk::to_string(m_valueU64); + _data += etk::toString(m_valueU64); return; } diff --git a/ejson/internal/Number.hpp b/ejson/internal/Number.hpp index 9059b35..7a9bc5e 100644 --- a/ejson/internal/Number.hpp +++ b/ejson/internal/Number.hpp @@ -80,9 +80,9 @@ namespace ejson { */ int64_t getI64() const; public: - bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; - bool iGenerate(std::string& _data, size_t _indent) const override; - void iMachineGenerate(std::string& _data) const override; + bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; + bool iGenerate(etk::String& _data, size_t _indent) const override; + void iMachineGenerate(etk::String& _data) const override; bool transfertIn(ememory::SharedPtr _obj) override; ememory::SharedPtr clone() const override; }; diff --git a/ejson/internal/Object.cpp b/ejson/internal/Object.cpp index da98ee7..afef41c 100644 --- a/ejson/internal/Object.cpp +++ b/ejson/internal/Object.cpp @@ -18,7 +18,7 @@ ememory::SharedPtr ejson::internal::Object::create() { return ememory::SharedPtr(new ejson::internal::Object()); } -ememory::SharedPtr ejson::internal::Object::create(const std::string& _data) { +ememory::SharedPtr ejson::internal::Object::create(const etk::String& _data) { ejson::internal::Document doc; doc.parse(_data); return doc.cloneObj(); @@ -36,9 +36,9 @@ enum statusParsing { parseValue, }; -bool ejson::internal::Object::iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { +bool ejson::internal::Object::iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { enum statusParsing mode = parseName; - std::string currentName; + etk::String currentName; EJSON_PARSE_ELEMENT("start parse : 'Object' "); bool standalone = true; size_t startPos = _pos+1; @@ -198,7 +198,7 @@ bool ejson::internal::Object::iParse(const std::string& _data, size_t& _pos, ejs currentName = ""; } else { // find an error .... - EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, std::string("Find '") + _data[iii] + "' with no element in the element..."); + EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, etk::String("Find '") + _data[iii] + "' with no element in the element..."); // move the curent index _pos = iii+1; return false; @@ -212,7 +212,7 @@ bool ejson::internal::Object::iParse(const std::string& _data, size_t& _pos, ejs } return false; } -bool ejson::internal::Object::iGenerate(std::string& _data, size_t _indent) const { +bool ejson::internal::Object::iGenerate(etk::String& _data, size_t _indent) const { bool oneLine = true; if (m_value.size()>3) { oneLine = false; @@ -272,7 +272,7 @@ bool ejson::internal::Object::iGenerate(std::string& _data, size_t _indent) cons return true; } -void ejson::internal::Object::iMachineGenerate(std::string& _data) const { +void ejson::internal::Object::iMachineGenerate(etk::String& _data) const { _data += "{"; bool needComa = false; for (int32_t iii=0; iii ejson::internal::Object::getKeys() const { +etk::Vector ejson::internal::Object::getKeys() const { return m_value.getKeys(); } @@ -308,25 +308,25 @@ const ememory::SharedPtr ejson::internal::Object::get(si return m_value[_id]; } -ememory::SharedPtr ejson::internal::Object::get(const std::string& _name) { +ememory::SharedPtr ejson::internal::Object::get(const etk::String& _name) { if (m_value.exist(_name) == false) { return ememory::SharedPtr(); } return m_value[_name]; } -const ememory::SharedPtr ejson::internal::Object::get(const std::string& _name) const { +const ememory::SharedPtr ejson::internal::Object::get(const etk::String& _name) const { if (m_value.exist(_name) == false) { return ememory::SharedPtr(); } return m_value[_name]; } -std::string ejson::internal::Object::getKey(size_t _id) const { +etk::String ejson::internal::Object::getKey(size_t _id) const { return m_value.getKey(_id); } -bool ejson::internal::Object::add(const std::string& _name, ememory::SharedPtr _value) { +bool ejson::internal::Object::add(const etk::String& _name, ememory::SharedPtr _value) { if (_value == nullptr) { return false; } @@ -341,7 +341,7 @@ bool ejson::internal::Object::add(const std::string& _name, ememory::SharedPtr ejson::internal::Object::cloneObj() } for (int32_t iii=0; iii val = m_value.getValue(iii); - std::string key = m_value.getKey(iii); + etk::String key = m_value.getKey(iii); if (val == nullptr) { continue; } diff --git a/ejson/internal/Object.hpp b/ejson/internal/Object.hpp index 484e587..50db9da 100644 --- a/ejson/internal/Object.hpp +++ b/ejson/internal/Object.hpp @@ -34,7 +34,7 @@ namespace ejson { * @param[in] _data Json stream to parse and interprete * @return A SharedPtr on the Object value */ - static ememory::SharedPtr create(const std::string& _data); + static ememory::SharedPtr create(const etk::String& _data); protected: // TODO : Change this with a generic methode ... etk::Hash > m_value; //!< value of the node (for element this is the name, for text it is the inside text ...) @@ -44,25 +44,25 @@ namespace ejson { * @param[in] _name name of the object. * @return The existance of the element. */ - bool exist(const std::string& _name) const; + bool exist(const etk::String& _name) const; /** * @brief get the sub element with his name (no cast check) * @param[in] _name name of the object * @return pointer on the element requested or nullptr if it not the corect type or does not existed */ - ememory::SharedPtr get(const std::string& _name); + ememory::SharedPtr get(const etk::String& _name); /** * @brief get the sub element with his name (no cast check) * @param[in] _name name of the object * @return pointer on the element requested or nullptr if it not the corect type or does not existed */ - const ememory::SharedPtr get(const std::string& _name) const; + const ememory::SharedPtr get(const etk::String& _name) const; public: /** * @brief Get all the element name (keys). * @return a vector of all name (key). */ - std::vector getKeys() const; + etk::Vector getKeys() const; /** * @brief get the number of sub element in the current one * @return the Number of stored element @@ -85,7 +85,7 @@ namespace ejson { * @param[in] _id Id of the element. * @return The name (key). */ - std::string getKey(size_t _id) const; + etk::String getKey(size_t _id) const; public: /** * @brief add an element in the Object @@ -93,12 +93,12 @@ namespace ejson { * @param[in] _value Element to add * @return false if an error occured */ - bool add(const std::string& _name, ememory::SharedPtr _value); + bool add(const etk::String& _name, ememory::SharedPtr _value); /** * @brief Remove Value with his name * @param[in] _name Name of the object */ - void remove(const std::string& _name); + void remove(const etk::String& _name); /** * @brief Remove Value with his id * @param[in] _id Id of the element. @@ -116,9 +116,9 @@ namespace ejson { */ ememory::SharedPtr cloneObj() const; public: - bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; - bool iGenerate(std::string& _data, size_t _indent) const override; - void iMachineGenerate(std::string& _data) const override; + bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; + bool iGenerate(etk::String& _data, size_t _indent) const override; + void iMachineGenerate(etk::String& _data) const override; void clear() override; bool transfertIn(ememory::SharedPtr _obj) override; ememory::SharedPtr clone() const override; diff --git a/ejson/internal/String.cpp b/ejson/internal/String.cpp index 8c6a7f7..7122cc6 100644 --- a/ejson/internal/String.cpp +++ b/ejson/internal/String.cpp @@ -11,24 +11,24 @@ #include #include -ememory::SharedPtr ejson::internal::String::create(const std::string& _value) { +ememory::SharedPtr ejson::internal::String::create(const etk::String& _value) { return ememory::SharedPtr(new ejson::internal::String(_value)); } -ejson::internal::String::String(const std::string& _value) : +ejson::internal::String::String(const etk::String& _value) : m_value(_value) { m_type = ejson::valueType::string; } -void ejson::internal::String::set(const std::string& _value) { +void ejson::internal::String::set(const etk::String& _value) { m_value = _value; } -const std::string& ejson::internal::String::get() const { +const etk::String& ejson::internal::String::get() const { return m_value; } -bool ejson::internal::String::iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { +bool ejson::internal::String::iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) { EJSON_PARSE_ELEMENT("start parse : 'String' "); char end = _data[_pos]; bool backslashPrevious = false; @@ -67,7 +67,7 @@ bool ejson::internal::String::iParse(const std::string& _data, size_t& _pos, ejs } -bool ejson::internal::String::iGenerate(std::string& _data, size_t _indent) const { +bool ejson::internal::String::iGenerate(etk::String& _data, size_t _indent) const { _data += "\""; for (auto &it: m_value) { if ( it == '\\' @@ -79,7 +79,7 @@ bool ejson::internal::String::iGenerate(std::string& _data, size_t _indent) cons _data += "\""; return true; } -void ejson::internal::String::iMachineGenerate(std::string& _data) const { +void ejson::internal::String::iMachineGenerate(etk::String& _data) const { _data += "\""; for (auto &it: m_value) { if ( it == '\\' diff --git a/ejson/internal/String.hpp b/ejson/internal/String.hpp index 1cf7d0b..fec684b 100644 --- a/ejson/internal/String.hpp +++ b/ejson/internal/String.hpp @@ -19,31 +19,31 @@ namespace ejson { * @brief basic element of a xml structure * @param[in] _value Value to set on the ejson::Value */ - String(const std::string& _value=""); + String(const etk::String& _value=""); public: /** * @brief Create factory on the ejson::internal::String * @param[in] _value Value to set on the ejson::Value * @return A SharedPtr on the String value */ - static ememory::SharedPtr create(const std::string& _value=""); + static ememory::SharedPtr create(const etk::String& _value=""); 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: /** * @brief set the value of the node. * @param[in] _value New value of the node. */ - void set(const std::string& _value); + void set(const etk::String& _value); /** * @brief get the current element Value. * @return the reference of the string value. */ - const std::string& get() const; + const etk::String& get() const; public: - bool iParse(const std::string& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; - bool iGenerate(std::string& _data, size_t _indent) const override; - void iMachineGenerate(std::string& _data) const override; + bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) override; + bool iGenerate(etk::String& _data, size_t _indent) const override; + void iMachineGenerate(etk::String& _data) const override; bool transfertIn(ememory::SharedPtr _obj) override; ememory::SharedPtr clone() const override; }; diff --git a/ejson/internal/Value.cpp b/ejson/internal/Value.cpp index 28f5ce3..96a8700 100644 --- a/ejson/internal/Value.cpp +++ b/ejson/internal/Value.cpp @@ -27,7 +27,7 @@ bool ejson::internal::Value::isWhiteChar(char32_t _val) { return false; } -void ejson::internal::Value::addIndent(std::string& _data, int32_t _indent) const { +void ejson::internal::Value::addIndent(etk::String& _data, int32_t _indent) const { if (_indent <= 0) { return; } @@ -46,7 +46,7 @@ void ejson::internal::Value::drawElementParsed(char32_t _val, const ejson::FileP } } -int32_t ejson::internal::Value::countWhiteChar(const std::string& _data, size_t _pos, ejson::FilePos& _filePos) const { +int32_t ejson::internal::Value::countWhiteChar(const etk::String& _data, size_t _pos, ejson::FilePos& _filePos) const { _filePos.clear(); size_t white=0; for (size_t iii=_pos; iii<_data.size(); iii++) { @@ -113,7 +113,7 @@ bool ejson::internal::Value::checkNumber(char32_t _val) const { } void ejson::internal::Value::display() const { - std::string tmpp; + etk::String tmpp; iGenerate(tmpp, 0); EJSON_INFO("Generated JSON : \n" << tmpp); } diff --git a/ejson/internal/Value.hpp b/ejson/internal/Value.hpp index e72e87a..7080921 100644 --- a/ejson/internal/Value.hpp +++ b/ejson/internal/Value.hpp @@ -70,7 +70,7 @@ namespace ejson { * @param[in,out] _doc Reference on the main document * @return false if an error occured. */ - virtual bool iParse(const std::string& _data, + virtual bool iParse(const etk::String& _data, size_t& _pos, ejson::FilePos& _filePos, ejson::internal::Document& _doc) = 0; @@ -80,14 +80,14 @@ namespace ejson { * @param[in] _indent current indentation of the file * @return false if an error occured. */ - virtual bool iGenerate(std::string& _data, + virtual bool iGenerate(etk::String& _data, size_t _indent) const = 0; /** * @brief generate a string with the tree of the json (not human readable ==> for computer transfer) * @param[in,out] _data string where to add the elements * @return false if an error occured. */ - virtual void iMachineGenerate(std::string& _data) const = 0; + virtual void iMachineGenerate(etk::String& _data) const = 0; /** * @brief Display the Document on console */ @@ -98,7 +98,7 @@ namespace ejson { * @param[in,out] _data String where the indentation is done. * @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. * @param[in] _val Char that is parsed. @@ -126,7 +126,7 @@ namespace ejson { * @param[out] _filePos new poistion of te file to add. * @return number of white element. */ - int32_t countWhiteChar(const std::string& _data, size_t _pos, ejson::FilePos& _filePos) const; + int32_t countWhiteChar(const etk::String& _data, size_t _pos, ejson::FilePos& _filePos) const; public: /** * @brief clear the Node diff --git a/ejson/iterator.hpp b/ejson/iterator.hpp index 059dc8a..eb90030 100644 --- a/ejson/iterator.hpp +++ b/ejson/iterator.hpp @@ -118,6 +118,6 @@ namespace ejson { * @brief Get Key of an element * @return Key of the Element */ - std::string getKey() const noexcept; + etk::String getKey() const noexcept; }; } diff --git a/ejson/valueType.cpp b/ejson/valueType.cpp index 4ec1cf5..f6b77a2 100644 --- a/ejson/valueType.cpp +++ b/ejson/valueType.cpp @@ -9,7 +9,7 @@ -std::ostream& ejson::operator <<(std::ostream& _os, enum ejson::valueType _obj) { +etk::Stream& ejson::operator <<(etk::Stream& _os, enum ejson::valueType _obj) { switch (_obj) { case ejson::valueType::unknow: _os << "ejson::valueType::unknow"; diff --git a/ejson/valueType.hpp b/ejson/valueType.hpp index ee420c0..0f51979 100644 --- a/ejson/valueType.hpp +++ b/ejson/valueType.hpp @@ -5,7 +5,7 @@ */ #pragma once -#include +#include namespace ejson { /** @@ -23,6 +23,6 @@ namespace ejson { boolean, //!< the element true or false }; //! @not_in_doc - std::ostream& operator <<(std::ostream& _os, enum valueType _obj); + etk::Stream& operator <<(etk::Stream& _os, enum valueType _obj); } diff --git a/sample/main.cpp b/sample/main.cpp index da3857e..a256f8f 100644 --- a/sample/main.cpp +++ b/sample/main.cpp @@ -13,7 +13,7 @@ int main(int argc, const char *argv[]) { // the only one init for etk: etk::init(argc, argv); for (int32_t iii=0; iii -static std::string refOutputBoolean1("{\n\t\"tmpElement\": true\n}\n"); +static etk::String refOutputBoolean1("{\n\t\"tmpElement\": true\n}\n"); TEST(TestBoolean, testBaseTrue) { localTest(refOutputBoolean1, "{ tmpElement:true }\n", -1); } @@ -29,7 +29,7 @@ TEST(TestBoolean, testBaseTrue2) { } -static std::string refOutputBoolean2("{\n\t\"tmpElement\": false\n}\n"); +static etk::String refOutputBoolean2("{\n\t\"tmpElement\": false\n}\n"); TEST(TestBoolean, testBaseFalse) { localTest(refOutputBoolean2, "{ tmpElement:false }\n", -1); } diff --git a/test/testCommon.hpp b/test/testCommon.hpp index 72c2143..c8efb43 100644 --- a/test/testCommon.hpp +++ b/test/testCommon.hpp @@ -12,7 +12,7 @@ #include // _errorPos : -1 : no error , 1 : parsing error, 2 generation error, 3 comparaison error ???? -static void localTest(const std::string& _ref, const std::string& _input, int32_t _errorPos) { +static void localTest(const etk::String& _ref, const etk::String& _input, int32_t _errorPos) { ejson::Document doc; bool retParse = doc.parse(_input); if (_errorPos == 1) { @@ -21,7 +21,7 @@ static void localTest(const std::string& _ref, const std::string& _input, int32_ } else { EXPECT_EQ(retParse, true); } - std::string out(""); + etk::String out(""); bool retGenerate = doc.generate(out); if (_errorPos == 2) { EXPECT_EQ(retGenerate, false); @@ -36,8 +36,8 @@ static void localTest(const std::string& _ref, const std::string& _input, int32_ EXPECT_EQ(_ref, out); /* JSON_ERROR("[TEST] {ERROR } different output"); - std::vector tmpout = etk::split(out, '\n'); - std::vector tmpref = etk::split(_ref, '\n'); + etk::Vector tmpout = etk::split(out, '\n'); + etk::Vector tmpref = etk::split(_ref, '\n'); //JSON_ERROR("generate : \n" << out); //JSON_ERROR("reference : \n" << l_list[iii].m_ref); for (int32_t jjj=0; jjj -static std::string refOutputDocument("{\n}\n"); +static etk::String refOutputDocument("{\n}\n"); TEST(TestDocument, testEmptyDoc) { localTest(refOutputDocument, "{}\n", -1); } diff --git a/test/testNull.hpp b/test/testNull.hpp index aabd4dc..62880ed 100644 --- a/test/testNull.hpp +++ b/test/testNull.hpp @@ -11,7 +11,7 @@ #include -static std::string refOutputNull("{\n\t\"tmpElement\": null\n}\n"); +static etk::String refOutputNull("{\n\t\"tmpElement\": null\n}\n"); TEST(TestNull, testBasicNullElement) { localTest(refOutputNull, "{ tmpElement:null }\n", -1); } diff --git a/test/testNumber.hpp b/test/testNumber.hpp index a519194..2c40163 100644 --- a/test/testNumber.hpp +++ b/test/testNumber.hpp @@ -10,7 +10,7 @@ #include "testCommon.hpp" #include -static std::string refOutputNumber("{\n\t\"tmpElement\": 956256\n}\n"); +static etk::String refOutputNumber("{\n\t\"tmpElement\": 956256\n}\n"); TEST(TestNumber, testBase) { localTest(refOutputNumber, "{ tmpElement:956256 }\n", -1); }