[DEV] continue removing stl

This commit is contained in:
Edouard DUPIN 2017-08-28 00:03:43 +02:00
parent 132d1a4921
commit 3006c24262
41 changed files with 195 additions and 195 deletions

View File

@ -110,7 +110,7 @@ template class ejson::iterator<ejson::Array>;
// Not implemented ==> force link error ...
/*
template<>
std::string ejson::iterator<ejson::Array>::getKey() const noexcept {
etk::String ejson::iterator<ejson::Array>::getKey() const noexcept {
return m_data.getKey(m_id);
}
*/

View File

@ -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<ejson::internal::Document*>(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<ejson::internal::Document*>(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<ejson::internal::Document*>(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<ejson::internal::Document*>(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;

View File

@ -6,7 +6,7 @@
#pragma once
#include <ejson/Value.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <etk/types.hpp>
#include <ejson/String.hpp>
#include <ejson/Array.hpp>
@ -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)

View File

@ -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=";

View File

@ -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);
}

View File

@ -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<const ejson::internal::Object*>(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<ejson::internal::Object*>(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<const ejson::internal::Object*>(m_data.get())->get(_name));
}
std::vector<std::string> ejson::Object::getKeys() const {
etk::Vector<etk::String> ejson::Object::getKeys() const {
if (m_data == nullptr) {
EJSON_DEBUG("Can not getKeys (nullptr) ...");
return std::vector<std::string>();
return etk::Vector<etk::String>();
}
return static_cast<const ejson::internal::Object*>(m_data.get())->getKeys();
}
@ -97,7 +97,7 @@ const ejson::Value ejson::Object::operator[] (size_t _id) const {
return ejson::Value(static_cast<const ejson::internal::Object*>(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<const ejson::internal::Object*>(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<ejson::internal::Object*>(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<ejson::Object>;
namespace ejson {
template<>
std::string iterator<ejson::Object>::getKey() const noexcept {
etk::String iterator<ejson::Object>::getKey() const noexcept {
return m_data.getKey(m_id);
}
}

View File

@ -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<std::string> getKeys() const;
etk::Vector<etk::String> 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.

View File

@ -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<ejson::internal::String*>(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;

View File

@ -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;
};
}

View File

@ -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;

View File

@ -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)

View File

@ -9,28 +9,28 @@ template<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>::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<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>::iterator(const EJSON_BASE_T& _obj, size_t _pos) :
m_data(const_cast<EJSON_BASE_T&>(_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<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>::iterator(const ejson::iterator<EJSON_BASE_T>& _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<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>& ejson::iterator<EJSON_BASE_T>::operator= (const ejson::iterator<EJSON_BASE_T>& _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<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>& ejson::iterator<EJSON_BASE_T>::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<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>& ejson::iterator<EJSON_BASE_T>::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<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>& ejson::iterator<EJSON_BASE_T>::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<class EJSON_BASE_T>
ejson::iterator<EJSON_BASE_T>& ejson::iterator<EJSON_BASE_T>::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;
}

View File

@ -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<m_value.size() ; iii++) {
@ -239,7 +239,7 @@ bool ejson::internal::Array::add(ememory::SharedPtr<ejson::internal::Value> _ele
EJSON_ERROR("Request add on an nullptr pointer");
return false;
}
m_value.push_back(_element);
m_value.pushBack(_element);
return true;
}

View File

@ -28,7 +28,7 @@ namespace ejson {
*/
static ememory::SharedPtr<Array> create();
private:
std::vector<ememory::SharedPtr<ejson::internal::Value> > m_value; //!< vector of sub elements
etk::Vector<ememory::SharedPtr<ejson::internal::Value> > 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<ejson::internal::Value> _obj) override;
ememory::SharedPtr<ejson::internal::Value> clone() const override;

View File

@ -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 {

View File

@ -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<ejson::internal::Value> _obj) override;
ememory::SharedPtr<ejson::internal::Value> clone() const override;
};

View File

@ -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<char> fileBuffer;
etk::Vector<char> 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;

View File

@ -6,7 +6,7 @@
#pragma once
#include <ejson/internal/Value.hpp>
#include <vector>
#include <etk/Vector.hpp>
#include <etk/types.hpp>
#include <ejson/internal/String.hpp>
#include <ejson/internal/Array.hpp>
@ -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;
};
}
}

View File

@ -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";
}

View File

@ -26,9 +26,9 @@ namespace ejson {
*/
static ememory::SharedPtr<Null> 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<ejson::internal::Value> _obj) override;
ememory::SharedPtr<ejson::internal::Value> clone() const override;
};

View File

@ -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;
}

View File

@ -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<ejson::internal::Value> _obj) override;
ememory::SharedPtr<ejson::internal::Value> clone() const override;
};

View File

@ -18,7 +18,7 @@
ememory::SharedPtr<ejson::internal::Object> ejson::internal::Object::create() {
return ememory::SharedPtr<ejson::internal::Object>(new ejson::internal::Object());
}
ememory::SharedPtr<ejson::internal::Object> ejson::internal::Object::create(const std::string& _data) {
ememory::SharedPtr<ejson::internal::Object> 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<m_value.size(); ++iii) {
@ -288,11 +288,11 @@ void ejson::internal::Object::iMachineGenerate(std::string& _data) const {
_data += "}";
}
bool ejson::internal::Object::exist(const std::string& _name) const {
bool ejson::internal::Object::exist(const etk::String& _name) const {
return m_value.exist(_name);
}
std::vector<std::string> ejson::internal::Object::getKeys() const {
etk::Vector<etk::String> ejson::internal::Object::getKeys() const {
return m_value.getKeys();
}
@ -308,25 +308,25 @@ const ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(si
return m_value[_id];
}
ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(const std::string& _name) {
ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(const etk::String& _name) {
if (m_value.exist(_name) == false) {
return ememory::SharedPtr<ejson::internal::Value>();
}
return m_value[_name];
}
const ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(const std::string& _name) const {
const ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(const etk::String& _name) const {
if (m_value.exist(_name) == false) {
return ememory::SharedPtr<ejson::internal::Value>();
}
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<ejson::internal::Value> _value) {
bool ejson::internal::Object::add(const etk::String& _name, ememory::SharedPtr<ejson::internal::Value> _value) {
if (_value == nullptr) {
return false;
}
@ -341,7 +341,7 @@ bool ejson::internal::Object::add(const std::string& _name, ememory::SharedPtr<e
return true;
}
void ejson::internal::Object::remove(const std::string& _name) {
void ejson::internal::Object::remove(const etk::String& _name) {
m_value.remove(_name);
}
@ -394,7 +394,7 @@ ememory::SharedPtr<ejson::internal::Object> ejson::internal::Object::cloneObj()
}
for (int32_t iii=0; iii<m_value.size(); ++iii) {
ememory::SharedPtr<ejson::internal::Value> val = m_value.getValue(iii);
std::string key = m_value.getKey(iii);
etk::String key = m_value.getKey(iii);
if (val == nullptr) {
continue;
}

View File

@ -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<Object> create(const std::string& _data);
static ememory::SharedPtr<Object> create(const etk::String& _data);
protected:
// TODO : Change this with a generic methode ...
etk::Hash<ememory::SharedPtr<ejson::internal::Value> > 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<ejson::internal::Value> get(const std::string& _name);
ememory::SharedPtr<ejson::internal::Value> 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<ejson::internal::Value> get(const std::string& _name) const;
const ememory::SharedPtr<ejson::internal::Value> get(const etk::String& _name) const;
public:
/**
* @brief Get all the element name (keys).
* @return a vector of all name (key).
*/
std::vector<std::string> getKeys() const;
etk::Vector<etk::String> 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<ejson::internal::Value> _value);
bool add(const etk::String& _name, ememory::SharedPtr<ejson::internal::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.
@ -116,9 +116,9 @@ namespace ejson {
*/
ememory::SharedPtr<ejson::internal::Object> 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<ejson::internal::Value> _obj) override;
ememory::SharedPtr<ejson::internal::Value> clone() const override;

View File

@ -11,24 +11,24 @@
#include <ejson/internal/String.hpp>
#include <ejson/debug.hpp>
ememory::SharedPtr<ejson::internal::String> ejson::internal::String::create(const std::string& _value) {
ememory::SharedPtr<ejson::internal::String> ejson::internal::String::create(const etk::String& _value) {
return ememory::SharedPtr<ejson::internal::String>(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 == '\\'

View File

@ -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<String> create(const std::string& _value="");
static ememory::SharedPtr<String> 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<ejson::internal::Value> _obj) override;
ememory::SharedPtr<ejson::internal::Value> clone() const override;
};

View File

@ -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);
}

View File

@ -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

View File

@ -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;
};
}

View File

@ -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";

View File

@ -5,7 +5,7 @@
*/
#pragma once
#include <ostream>
#include <etk/Stream.hpp>
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);
}

View File

@ -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<argc ; ++iii) {
std::string data = argv[iii];
etk::String data = argv[iii];
if ( data == "-h"
|| data == "--help") {
TEST_PRINT("Help : ");

View File

@ -27,7 +27,7 @@ static void readFromString1() {
ejson::Document doc;
TEST_INFO("parse");
//! [ejson_sample_read_stream1]
std::string stream = "{"
etk::String stream = "{"
" \"object A\":\"bonjour\","
" \"object B\":null,"
" \"object C\":true,"
@ -51,7 +51,7 @@ static void readFromString2() {
ejson::Document doc;
TEST_INFO("parse");
//! [ejson_sample_read_stream2]
std::string stream = "{"
etk::String stream = "{"
" objectA:'bonjour',"
" objectB:null,"
" objectC:true,"
@ -169,7 +169,7 @@ static void readFull() {
//! [ejson_sample_read_convert_string]
ejson::String elem = doc["object A"].toString();
// Get the value:
std::string value = elem.get();
etk::String value = elem.get();
//! [ejson_sample_read_convert_string]
TEST_INFO(" String Value:" << value);
}
@ -177,7 +177,7 @@ static void readFull() {
{
// Get the value:
//! [ejson_sample_read_get_string]
std::string value = doc["object A"].toString().get();
etk::String value = doc["object A"].toString().get();
//! [ejson_sample_read_get_string]
TEST_INFO(" String Value:" << value);
}

View File

@ -34,7 +34,7 @@ static void writeToString() {
doc.add("D", ejson::Array());
TEST_INFO("generate");
//! [ejson_sample_write_stream]
std::string streamOut;
etk::String streamOut;
bool retGenerate = doc.generate(streamOut);
//! [ejson_sample_write_stream]
TEST_INFO("parse ret = " << retGenerate);

View File

@ -6,7 +6,7 @@
* @license MPL v2.0 (see license file)
*/
#include <vector>
#include <etk/Vector.hpp>
#include <etk/etk.hpp>
#include <etk/types.hpp>
#include <etk/archive/Archive.hpp>

View File

@ -11,7 +11,7 @@
#include <gtest/gtest.h>
TEST(TestAll, testBaseObject) {
std::string base = "{\n"
etk::String base = "{\n"
" \"menu\": {\n"
" \"id\": \"file\",\n"
" \"value\": \"File\",\n"
@ -23,7 +23,7 @@ TEST(TestAll, testBaseObject) {
localTest(base, base, -1);
}
static std::string refOutputAll( "{\n"
static etk::String refOutputAll( "{\n"
" \"menu\": {\n"
" \"id\": \"file\",\n"
" \"value\": \"File\",\n"
@ -105,7 +105,7 @@ TEST(TestAll, testIndentedListWithNoBasicObject) {
TEST(TestAll, testGeneric1) {
std::string base = "{\n"
etk::String base = "{\n"
" \"glossary\": {\n"
" \"title\": \"example glossary\",\n"
" \"GlossDiv\": {\n"
@ -131,7 +131,7 @@ TEST(TestAll, testGeneric1) {
}
TEST(TestAll, testGeneric2) {
std::string base = "{\n"
etk::String base = "{\n"
" \"menu\": {\n"
" \"id\": \"file\",\n"
" \"value\": \"File\",\n"
@ -147,7 +147,7 @@ TEST(TestAll, testGeneric2) {
localTest(base, base, -1);
}
TEST(TestAll, testGeneric3) {
std::string base = "{\n"
etk::String base = "{\n"
" \"widget\": {\n"
" \"debug\": \"on\",\n"
" \"window\": {\n"
@ -180,7 +180,7 @@ TEST(TestAll, testGeneric3) {
TEST(TestAll, testGeneric4) {
std::string base = "{\n"
etk::String base = "{\n"
" \"web-app\": {\n"
" \"servlet\": [\n"
" {\n"
@ -276,7 +276,7 @@ TEST(TestAll, testGeneric4) {
TEST(TestAll, testGeneric5) {
std::string base = "{\n"
etk::String base = "{\n"
" \"menu\": {\n"
" \"header\": \"SVG Viewer\",\n"
" \"items\": [\n"

View File

@ -11,7 +11,7 @@
#include <gtest/gtest.h>
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);
}

View File

@ -12,7 +12,7 @@
#include <ejson/ejson.hpp>
// _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<std::string> tmpout = etk::split(out, '\n');
std::vector<std::string> tmpref = etk::split(_ref, '\n');
etk::Vector<etk::String> tmpout = etk::split(out, '\n');
etk::Vector<etk::String> 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<tmpout.size() || jjj<tmpref.size(); ++jjj) {

View File

@ -10,7 +10,7 @@
#include "testCommon.hpp"
#include <gtest/gtest.h>
static std::string refOutputDocument("{\n}\n");
static etk::String refOutputDocument("{\n}\n");
TEST(TestDocument, testEmptyDoc) {
localTest(refOutputDocument, "{}\n", -1);
}

View File

@ -11,7 +11,7 @@
#include <gtest/gtest.h>
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);
}

View File

@ -10,7 +10,7 @@
#include "testCommon.hpp"
#include <gtest/gtest.h>
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);
}