[DEV] update of external of elog and ethread

This commit is contained in:
Edouard DUPIN 2016-03-08 21:29:34 +01:00
parent e786cd605c
commit 934660ad8a
18 changed files with 275 additions and 275 deletions

View File

@ -20,8 +20,8 @@
#define __class__ "Array"
std11::shared_ptr<ejson::Array> ejson::Array::create() {
return std11::shared_ptr<ejson::Array>(new ejson::Array());
std::shared_ptr<ejson::Array> ejson::Array::create() {
return std::shared_ptr<ejson::Array>(new ejson::Array());
}
void ejson::Array::clear() {
@ -56,7 +56,7 @@ bool ejson::Array::iParse(const std::string& _data, size_t& _pos, ejson::filePos
} else if (_data[iii] == '{') {
// find an object:
JSON_PARSE_ELEMENT("find Object");
std11::shared_ptr<ejson::Object> tmpElement = ejson::Object::create();
std::shared_ptr<ejson::Object> tmpElement = ejson::Object::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in object");
_pos=iii;
@ -68,7 +68,7 @@ bool ejson::Array::iParse(const std::string& _data, size_t& _pos, ejson::filePos
|| _data[iii] == '\'') {
// find a string:
JSON_PARSE_ELEMENT("find String quoted");
std11::shared_ptr<ejson::String> tmpElement = ejson::String::create();
std::shared_ptr<ejson::String> tmpElement = ejson::String::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in String");
_pos=iii;
@ -79,7 +79,7 @@ bool ejson::Array::iParse(const std::string& _data, size_t& _pos, ejson::filePos
} else if (_data[iii] == '[') {
// find a list:
JSON_PARSE_ELEMENT("find List");
std11::shared_ptr<ejson::Array> tmpElement = ejson::Array::create();
std::shared_ptr<ejson::Array> tmpElement = ejson::Array::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Array");
_pos=iii;
@ -91,7 +91,7 @@ bool ejson::Array::iParse(const std::string& _data, size_t& _pos, ejson::filePos
|| _data[iii] == 't' ) {
// find boolean:
JSON_PARSE_ELEMENT("find Boolean");
std11::shared_ptr<ejson::Boolean> tmpElement = ejson::Boolean::create();
std::shared_ptr<ejson::Boolean> tmpElement = ejson::Boolean::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
@ -102,7 +102,7 @@ bool ejson::Array::iParse(const std::string& _data, size_t& _pos, ejson::filePos
} else if( _data[iii] == 'n') {
// find null:
JSON_PARSE_ELEMENT("find Null");
std11::shared_ptr<ejson::Null> tmpElement = ejson::Null::create();
std::shared_ptr<ejson::Null> tmpElement = ejson::Null::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
@ -113,7 +113,7 @@ bool ejson::Array::iParse(const std::string& _data, size_t& _pos, ejson::filePos
} else if(true == checkNumber(_data[iii])) {
// find number:
JSON_PARSE_ELEMENT("find Number");
std11::shared_ptr<ejson::Number> tmpElement = ejson::Number::create();
std::shared_ptr<ejson::Number> tmpElement = ejson::Number::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
@ -143,7 +143,7 @@ bool ejson::Array::iGenerate(std::string& _data, size_t _indent) const {
oneLine=false;
} else {
for (size_t iii=0; iii<m_value.size() ; iii++) {
std11::shared_ptr<const ejson::Value> tmp = m_value[iii];
std::shared_ptr<const ejson::Value> tmp = m_value[iii];
if (tmp == nullptr) {
continue;
}
@ -156,7 +156,7 @@ bool ejson::Array::iGenerate(std::string& _data, size_t _indent) const {
break;
}
if (true == tmp->isString()) {
std11::shared_ptr<const ejson::String> tmp2 = tmp->toString();
std::shared_ptr<const ejson::String> tmp2 = tmp->toString();
if (tmp2 != nullptr) {
if(tmp2->get().size()>40) {
oneLine=false;
@ -194,7 +194,7 @@ bool ejson::Array::iGenerate(std::string& _data, size_t _indent) const {
return true;
}
bool ejson::Array::add(std11::shared_ptr<ejson::Value> _element) {
bool ejson::Array::add(std::shared_ptr<ejson::Value> _element) {
if (_element == nullptr) {
JSON_ERROR("Request add on an nullptr pointer");
return false;
@ -220,12 +220,12 @@ bool ejson::Array::addNumber(double _value) {
}
bool ejson::Array::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
bool ejson::Array::transfertIn(std::shared_ptr<ejson::Value> _obj) {
if (_obj == nullptr) {
JSON_ERROR("Request transfer on an nullptr pointer");
return false;
}
std11::shared_ptr<ejson::Array> other = _obj->toArray();
std::shared_ptr<ejson::Array> other = _obj->toArray();
if (other == nullptr) {
JSON_ERROR("Request transfer on an element that is not an array");
return false;
@ -240,14 +240,14 @@ bool ejson::Array::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
}
// TODO : Manage error ...
std11::shared_ptr<ejson::Value> ejson::Array::clone() const {
std11::shared_ptr<ejson::Array> output = ejson::Array::create();
std::shared_ptr<ejson::Value> ejson::Array::clone() const {
std::shared_ptr<ejson::Array> output = ejson::Array::create();
if (output == nullptr) {
JSON_ERROR("Allocation error ...");
return std11::shared_ptr<ejson::Value>();
return std::shared_ptr<ejson::Value>();
}
for (size_t iii=0; iii<m_value.size(); ++iii) {
std11::shared_ptr<const ejson::Value> val = m_value[iii];
std::shared_ptr<const ejson::Value> val = m_value[iii];
if (val == nullptr) {
continue;
}
@ -256,103 +256,103 @@ std11::shared_ptr<ejson::Value> ejson::Array::clone() const {
return output;
}
std11::shared_ptr<ejson::Object> ejson::Array::getObject(size_t _id) {
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
std::shared_ptr<ejson::Object> ejson::Array::getObject(size_t _id) {
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<ejson::Object>();
return std::shared_ptr<ejson::Object>();
}
return tmpElement->toObject();
}
const std11::shared_ptr<const ejson::Object> ejson::Array::getObject(size_t _id) const {
const std11::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
const std::shared_ptr<const ejson::Object> ejson::Array::getObject(size_t _id) const {
const std::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<const ejson::Object>();
return std::shared_ptr<const ejson::Object>();
}
return tmpElement->toObject();
}
std11::shared_ptr<ejson::String> ejson::Array::getString(size_t _id) {
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
std::shared_ptr<ejson::String> ejson::Array::getString(size_t _id) {
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<ejson::String>();
return std::shared_ptr<ejson::String>();
}
return tmpElement->toString();
}
const std11::shared_ptr<const ejson::String> ejson::Array::getString(size_t _id) const {
const std11::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
const std::shared_ptr<const ejson::String> ejson::Array::getString(size_t _id) const {
const std::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<const ejson::String>();
return std::shared_ptr<const ejson::String>();
}
return tmpElement->toString();
}
std11::shared_ptr<ejson::Array> ejson::Array::getArray(size_t _id) {
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
std::shared_ptr<ejson::Array> ejson::Array::getArray(size_t _id) {
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<ejson::Array>();
return std::shared_ptr<ejson::Array>();
}
return tmpElement->toArray();
}
const std11::shared_ptr<const ejson::Array> ejson::Array::getArray(size_t _id) const {
const std11::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
const std::shared_ptr<const ejson::Array> ejson::Array::getArray(size_t _id) const {
const std::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<const ejson::Array>();
return std::shared_ptr<const ejson::Array>();
}
return tmpElement->toArray();
}
std11::shared_ptr<ejson::Null> ejson::Array::getNull(size_t _id) {
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
std::shared_ptr<ejson::Null> ejson::Array::getNull(size_t _id) {
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<ejson::Null>();
return std::shared_ptr<ejson::Null>();
}
return tmpElement->toNull();
}
const std11::shared_ptr<const ejson::Null> ejson::Array::getNull(size_t _id) const {
const std11::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
const std::shared_ptr<const ejson::Null> ejson::Array::getNull(size_t _id) const {
const std::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<const ejson::Null>();
return std::shared_ptr<const ejson::Null>();
}
return tmpElement->toNull();
}
std11::shared_ptr<ejson::Number> ejson::Array::getNumber(size_t _id) {
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
std::shared_ptr<ejson::Number> ejson::Array::getNumber(size_t _id) {
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<ejson::Number>();
return std::shared_ptr<ejson::Number>();
}
return tmpElement->toNumber();
}
const std11::shared_ptr<const ejson::Number> ejson::Array::getNumber(size_t _id) const {
const std11::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
const std::shared_ptr<const ejson::Number> ejson::Array::getNumber(size_t _id) const {
const std::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<const ejson::Number>();
return std::shared_ptr<const ejson::Number>();
}
return tmpElement->toNumber();
}
std11::shared_ptr<ejson::Boolean> ejson::Array::getBoolean(size_t _id) {
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
std::shared_ptr<ejson::Boolean> ejson::Array::getBoolean(size_t _id) {
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<ejson::Boolean>();
return std::shared_ptr<ejson::Boolean>();
}
return tmpElement->toBoolean();
}
const std11::shared_ptr<const ejson::Boolean> ejson::Array::getBoolean(size_t _id) const {
const std11::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
const std::shared_ptr<const ejson::Boolean> ejson::Array::getBoolean(size_t _id) const {
const std::shared_ptr<const ejson::Value> tmpElement = m_value[_id];
if (tmpElement == nullptr) {
return std11::shared_ptr<const ejson::Boolean>();
return std::shared_ptr<const ejson::Boolean>();
}
return tmpElement->toBoolean();
}
std::string ejson::Array::getStringValue(size_t _id) {
std11::shared_ptr<ejson::String> tmpElement = getString(_id);
std::shared_ptr<ejson::String> tmpElement = getString(_id);
if (tmpElement == nullptr) {
return "";
}
@ -361,7 +361,7 @@ std::string ejson::Array::getStringValue(size_t _id) {
const std::string& ejson::Array::getStringValue(size_t _id) const {
static const std::string errorValue("");
const std11::shared_ptr<const ejson::String> tmpElement = getString(_id);
const std::shared_ptr<const ejson::String> tmpElement = getString(_id);
if (tmpElement == nullptr) {
return errorValue;
}
@ -369,7 +369,7 @@ const std::string& ejson::Array::getStringValue(size_t _id) const {
}
std::string ejson::Array::getStringValue(size_t _id, const std::string& _errorValue) const {
const std11::shared_ptr<const ejson::String> tmpElement = getString(_id);
const std::shared_ptr<const ejson::String> tmpElement = getString(_id);
if (tmpElement == nullptr) {
return _errorValue;
}
@ -377,7 +377,7 @@ std::string ejson::Array::getStringValue(size_t _id, const std::string& _errorVa
}
double ejson::Array::getNumberValue(size_t _id, double _errorValue) const {
const std11::shared_ptr<const ejson::Number> tmpElement = getNumber(_id);
const std::shared_ptr<const ejson::Number> tmpElement = getNumber(_id);
if (tmpElement == nullptr) {
return _errorValue;
}
@ -385,7 +385,7 @@ double ejson::Array::getNumberValue(size_t _id, double _errorValue) const {
}
bool ejson::Array::getBooleanValue(size_t _id, bool _errorValue) const {
const std11::shared_ptr<const ejson::Boolean> tmpElement = getBoolean(_id);
const std::shared_ptr<const ejson::Boolean> tmpElement = getBoolean(_id);
if (tmpElement == nullptr) {
return _errorValue;
}

View File

@ -18,13 +18,13 @@ namespace ejson {
*/
Array() { };
public:
static std11::shared_ptr<Array> create();
static std::shared_ptr<Array> create();
/**
* @brief destructor
*/
virtual ~Array() { };
private:
std::vector<std11::shared_ptr<ejson::Value> > m_value; //!< vector of sub elements
std::vector<std::shared_ptr<ejson::Value> > m_value; //!< vector of sub elements
public:
/**
* @brief get the number of sub element in the current one
@ -38,19 +38,19 @@ namespace ejson {
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::Value> get(size_t _id) {
std::shared_ptr<ejson::Value> get(size_t _id) {
return m_value[_id];
};
//! @previous
const std11::shared_ptr<const ejson::Value> get(size_t _id) const{
const std::shared_ptr<const ejson::Value> get(size_t _id) const{
return m_value[_id];
};
//! @previous
std11::shared_ptr<ejson::Value> operator[] (size_t _id) {
std::shared_ptr<ejson::Value> operator[] (size_t _id) {
return m_value[_id];
}
//! @previous
const std11::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
const std::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
return m_value[_id];
}
/**
@ -58,17 +58,17 @@ namespace ejson {
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::Object> getObject(size_t _id);
std::shared_ptr<ejson::Object> getObject(size_t _id);
//! @previous
const std11::shared_ptr<const ejson::Object> getObject(size_t _id) const;
const std::shared_ptr<const ejson::Object> getObject(size_t _id) const;
/**
* @brief get the pointer on an element reference with his ID (casted in String if it is an String).
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::String> getString(size_t _id);
std::shared_ptr<ejson::String> getString(size_t _id);
//! @previous
const std11::shared_ptr<const ejson::String> getString(size_t _id) const;
const std::shared_ptr<const ejson::String> getString(size_t _id) const;
/**
* @brief get the value of the string element (if not a string return "")
* @param[in] _id Id of the element.
@ -89,25 +89,25 @@ namespace ejson {
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::Array> getArray(size_t _id);
std::shared_ptr<ejson::Array> getArray(size_t _id);
//! @previous
const std11::shared_ptr<const ejson::Array> getArray(size_t _id) const;
const std::shared_ptr<const ejson::Array> getArray(size_t _id) const;
/**
* @brief get the pointer on an element reference with his ID (casted in Null if it is an Null).
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::Null> getNull(size_t _id);
std::shared_ptr<ejson::Null> getNull(size_t _id);
//! @previous
const std11::shared_ptr<const ejson::Null> getNull(size_t _id) const;
const std::shared_ptr<const ejson::Null> getNull(size_t _id) const;
/**
* @brief get the pointer on an element reference with his ID (casted in Number if it is an Number).
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::Number> getNumber(size_t _id);
std::shared_ptr<ejson::Number> getNumber(size_t _id);
//! @previous
const std11::shared_ptr<const ejson::Number> getNumber(size_t _id) const;
const std::shared_ptr<const ejson::Number> getNumber(size_t _id) const;
/**
* @brief get the value of the Number element
* @param[in] _id Id of the element.
@ -120,9 +120,9 @@ namespace ejson {
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::Boolean> getBoolean(size_t _id);
std::shared_ptr<ejson::Boolean> getBoolean(size_t _id);
//! @previous
const std11::shared_ptr<const ejson::Boolean> getBoolean(size_t _id) const;
const std::shared_ptr<const ejson::Boolean> getBoolean(size_t _id) const;
/**
* @brief get the value of the Boolean element
* @param[in] _id Id of the element.
@ -135,7 +135,7 @@ namespace ejson {
* @param[in] _element element to add.
* @return false if an error occured.
*/
bool add(std11::shared_ptr<ejson::Value> _element);
bool add(std::shared_ptr<ejson::Value> _element);
/**
* @brief add a string element in the Object (automatic creation)
* @param[in] _value string value to add
@ -164,8 +164,8 @@ namespace ejson {
virtual bool iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc);
virtual bool iGenerate(std::string& _data, size_t _indent) const;
virtual void clear();
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
virtual std11::shared_ptr<ejson::Value> clone() const;
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj);
virtual std::shared_ptr<ejson::Value> clone() const;
};
}

View File

@ -13,8 +13,8 @@
#undef __class__
#define __class__ "Boolean"
std11::shared_ptr<ejson::Boolean> ejson::Boolean::create(bool _value) {
return std11::shared_ptr<ejson::Boolean>(new ejson::Boolean(_value));
std::shared_ptr<ejson::Boolean> ejson::Boolean::create(bool _value) {
return std::shared_ptr<ejson::Boolean>(new ejson::Boolean(_value));
}
@ -57,12 +57,12 @@ bool ejson::Boolean::iGenerate(std::string& _data, size_t _indent) const {
}
bool ejson::Boolean::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
bool ejson::Boolean::transfertIn(std::shared_ptr<ejson::Value> _obj) {
if (_obj == nullptr) {
JSON_ERROR("Request transfer on an NULL pointer");
return false;
}
std11::shared_ptr<ejson::Boolean> other = _obj->toBoolean();
std::shared_ptr<ejson::Boolean> other = _obj->toBoolean();
if (other == nullptr) {
JSON_ERROR("Request transfer on an element that is not an Boolean");
return false;
@ -73,11 +73,11 @@ bool ejson::Boolean::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
return true;
}
std11::shared_ptr<ejson::Value> ejson::Boolean::clone() const {
std11::shared_ptr<ejson::Boolean> output = ejson::Boolean::create(m_value);
std::shared_ptr<ejson::Value> ejson::Boolean::clone() const {
std::shared_ptr<ejson::Boolean> output = ejson::Boolean::create(m_value);
if (output == nullptr) {
JSON_ERROR("Allocation error ...");
return std11::shared_ptr<ejson::Value>();
return std::shared_ptr<ejson::Value>();
}
return output;
}

View File

@ -21,7 +21,7 @@ namespace ejson {
};
public:
static std11::shared_ptr<Boolean> create(bool _value=false);
static std::shared_ptr<Boolean> create(bool _value=false);
/**
* @brief destructor
*/
@ -48,8 +48,8 @@ namespace ejson {
public: // herited function :
virtual bool iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc);
virtual bool iGenerate(std::string& _data, size_t _indent) const;
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
virtual std11::shared_ptr<ejson::Value> clone() const;
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj);
virtual std::shared_ptr<ejson::Value> clone() const;
};
}

View File

@ -14,8 +14,8 @@
#undef __class__
#define __class__ "Null"
std11::shared_ptr<ejson::Null> ejson::Null::create() {
return std11::shared_ptr<ejson::Null>(new ejson::Null());
std::shared_ptr<ejson::Null> ejson::Null::create() {
return std::shared_ptr<ejson::Null>(new ejson::Null());
}
@ -44,12 +44,12 @@ bool ejson::Null::iGenerate(std::string& _data, size_t _indent) const {
}
bool ejson::Null::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
bool ejson::Null::transfertIn(std::shared_ptr<ejson::Value> _obj) {
if (_obj == nullptr) {
JSON_ERROR("Request transfer on an nullptr pointer");
return false;
}
std11::shared_ptr<ejson::Null> other = _obj->toNull();
std::shared_ptr<ejson::Null> other = _obj->toNull();
if (other == nullptr) {
JSON_ERROR("Request transfer on an element that is not an Null");
return false;
@ -57,11 +57,11 @@ bool ejson::Null::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
return true;
}
std11::shared_ptr<ejson::Value> ejson::Null::clone() const {
std11::shared_ptr<ejson::Null> output = ejson::Null::create();
std::shared_ptr<ejson::Value> ejson::Null::clone() const {
std::shared_ptr<ejson::Null> output = ejson::Null::create();
if (output == nullptr) {
JSON_ERROR("Allocation error ...");
return std11::shared_ptr<ejson::Value>();
return std::shared_ptr<ejson::Value>();
}
return output;
}

View File

@ -18,7 +18,7 @@ namespace ejson {
*/
Null() { };
public:
static std11::shared_ptr<Null> create();
static std::shared_ptr<Null> create();
/**
* @brief destructor
*/
@ -26,8 +26,8 @@ namespace ejson {
public: // herited function :
virtual bool iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc);
virtual bool iGenerate(std::string& _data, size_t _indent) const;
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
virtual std11::shared_ptr<ejson::Value> clone() const;
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj);
virtual std::shared_ptr<ejson::Value> clone() const;
};
}

View File

@ -14,8 +14,8 @@
#undef __class__
#define __class__ "Number"
std11::shared_ptr<ejson::Number> ejson::Number::create(double _value) {
return std11::shared_ptr<ejson::Number>(new ejson::Number(_value));
std::shared_ptr<ejson::Number> ejson::Number::create(double _value) {
return std::shared_ptr<ejson::Number>(new ejson::Number(_value));
}
bool ejson::Number::iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
@ -53,12 +53,12 @@ bool ejson::Number::iGenerate(std::string& _data, size_t _indent) const {
}
bool ejson::Number::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
bool ejson::Number::transfertIn(std::shared_ptr<ejson::Value> _obj) {
if (_obj == nullptr) {
JSON_ERROR("Request transfer on an nullptr pointer");
return false;
}
std11::shared_ptr<ejson::Number> other = _obj->toNumber();
std::shared_ptr<ejson::Number> other = _obj->toNumber();
if (other == nullptr) {
JSON_ERROR("Request transfer on an element that is not an Number");
return false;
@ -69,11 +69,11 @@ bool ejson::Number::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
return true;
}
std11::shared_ptr<ejson::Value> ejson::Number::clone() const {
std11::shared_ptr<ejson::Number> output = ejson::Number::create(m_value);
std::shared_ptr<ejson::Value> ejson::Number::clone() const {
std::shared_ptr<ejson::Number> output = ejson::Number::create(m_value);
if (output == nullptr) {
JSON_ERROR("Allocation error ...");
return std11::shared_ptr<ejson::Value>();
return std::shared_ptr<ejson::Value>();
}
return output;
}

View File

@ -21,7 +21,7 @@ namespace ejson {
};
public:
static std11::shared_ptr<Number> create(double _value=0.0);
static std::shared_ptr<Number> create(double _value=0.0);
/**
* @brief destructor
*/
@ -60,8 +60,8 @@ namespace ejson {
public: // herited function :
virtual bool iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc);
virtual bool iGenerate(std::string& _data, size_t _indent) const;
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
virtual std11::shared_ptr<ejson::Value> clone() const;
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj);
virtual std::shared_ptr<ejson::Value> clone() const;
};
}

View File

@ -21,10 +21,10 @@
std11::shared_ptr<ejson::Object> ejson::Object::create() {
return std11::shared_ptr<ejson::Object>(new ejson::Object());
std::shared_ptr<ejson::Object> ejson::Object::create() {
return std::shared_ptr<ejson::Object>(new ejson::Object());
}
std11::shared_ptr<ejson::Object> ejson::Object::create(const std::string& _data) {
std::shared_ptr<ejson::Object> ejson::Object::create(const std::string& _data) {
ejson::Document doc;
doc.parse(_data);
return doc.cloneObj();
@ -127,7 +127,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
if (_data[iii] == '{') {
// find an object:
JSON_PARSE_ELEMENT("find Object");
std11::shared_ptr<ejson::Object> tmpElement = ejson::Object::create();
std::shared_ptr<ejson::Object> tmpElement = ejson::Object::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in object");
_pos=iii;
@ -140,7 +140,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
|| _data[iii] == '\'') {
// find a string:
JSON_PARSE_ELEMENT("find String quoted");
std11::shared_ptr<ejson::String> tmpElement = ejson::String::create();
std::shared_ptr<ejson::String> tmpElement = ejson::String::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in String");
_pos=iii;
@ -152,7 +152,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
} else if (_data[iii] == '[') {
// find a list:
JSON_PARSE_ELEMENT("find List");
std11::shared_ptr<ejson::Array> tmpElement = ejson::Array::create();
std::shared_ptr<ejson::Array> tmpElement = ejson::Array::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Array");
_pos=iii;
@ -165,7 +165,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
|| _data[iii] == 't' ) {
// find boolean:
JSON_PARSE_ELEMENT("find Boolean");
std11::shared_ptr<ejson::Boolean> tmpElement = ejson::Boolean::create();
std::shared_ptr<ejson::Boolean> tmpElement = ejson::Boolean::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
@ -177,7 +177,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
} else if( _data[iii] == 'n') {
// find null:
JSON_PARSE_ELEMENT("find Null");
std11::shared_ptr<ejson::Null> tmpElement = ejson::Null::create();
std::shared_ptr<ejson::Null> tmpElement = ejson::Null::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
@ -189,7 +189,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
} else if(true == checkNumber(_data[iii])) {
// find number:
JSON_PARSE_ELEMENT("find Number");
std11::shared_ptr<ejson::Number> tmpElement = ejson::Number::create();
std::shared_ptr<ejson::Number> tmpElement = ejson::Number::create();
if (tmpElement == nullptr) {
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
_pos=iii;
@ -226,7 +226,7 @@ bool ejson::Object::iGenerate(std::string& _data, size_t _indent) const {
oneLine=false;
} else {
for (int32_t iii=0; iii<m_value.size() ; iii++) {
std11::shared_ptr<ejson::Value> tmp = m_value[iii];
std::shared_ptr<ejson::Value> tmp = m_value[iii];
if (tmp == nullptr) {
continue;
}
@ -239,7 +239,7 @@ bool ejson::Object::iGenerate(std::string& _data, size_t _indent) const {
break;
}
if (tmp->isString() == true) {
std11::shared_ptr<ejson::String> tmp2 = tmp->toString();
std::shared_ptr<ejson::String> tmp2 = tmp->toString();
if (tmp2 != nullptr) {
if( tmp2->get().size()>25
|| m_value.getKey(iii).size()>25) {
@ -283,87 +283,87 @@ bool ejson::Object::exist(const std::string& _name) const {
return m_value.exist(_name);
}
std11::shared_ptr<ejson::Value> ejson::Object::get(const std::string& _name) {
std::shared_ptr<ejson::Value> ejson::Object::get(const std::string& _name) {
if (false == m_value.exist(_name)) {
return std11::shared_ptr<ejson::Value>();
return std::shared_ptr<ejson::Value>();
}
return m_value[_name];
}
const std11::shared_ptr<const ejson::Value> ejson::Object::get(const std::string& _name) const {
const std::shared_ptr<const ejson::Value> ejson::Object::get(const std::string& _name) const {
if (false == m_value.exist(_name)) {
return std11::shared_ptr<const ejson::Value>();
return std::shared_ptr<const ejson::Value>();
}
return m_value[_name];
}
std11::shared_ptr<ejson::Object> ejson::Object::getObject(const std::string& _name) {
std11::shared_ptr<ejson::Value> tmp = get(_name);
std::shared_ptr<ejson::Object> ejson::Object::getObject(const std::string& _name) {
std::shared_ptr<ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<ejson::Object>();
return std::shared_ptr<ejson::Object>();
}
return std11::dynamic_pointer_cast<ejson::Object>(tmp);
return std::dynamic_pointer_cast<ejson::Object>(tmp);
}
const std11::shared_ptr<const ejson::Object> ejson::Object::getObject(const std::string& _name) const {
const std11::shared_ptr<const ejson::Value> tmp = get(_name);
const std::shared_ptr<const ejson::Object> ejson::Object::getObject(const std::string& _name) const {
const std::shared_ptr<const ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<const ejson::Object>();
return std::shared_ptr<const ejson::Object>();
}
return std11::dynamic_pointer_cast<const ejson::Object>(tmp);
return std::dynamic_pointer_cast<const ejson::Object>(tmp);
}
std11::shared_ptr<ejson::Array> ejson::Object::getArray(const std::string& _name) {
std11::shared_ptr<ejson::Value> tmp = get(_name);
std::shared_ptr<ejson::Array> ejson::Object::getArray(const std::string& _name) {
std::shared_ptr<ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<ejson::Array>();
return std::shared_ptr<ejson::Array>();
}
return std11::dynamic_pointer_cast<ejson::Array>(tmp);
return std::dynamic_pointer_cast<ejson::Array>(tmp);
}
const std11::shared_ptr<const ejson::Array> ejson::Object::getArray(const std::string& _name) const {
const std11::shared_ptr<const ejson::Value> tmp = get(_name);
const std::shared_ptr<const ejson::Array> ejson::Object::getArray(const std::string& _name) const {
const std::shared_ptr<const ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<const ejson::Array>();
return std::shared_ptr<const ejson::Array>();
}
return std11::dynamic_pointer_cast<const ejson::Array>(tmp);
return std::dynamic_pointer_cast<const ejson::Array>(tmp);
}
std11::shared_ptr<ejson::Null> ejson::Object::getNull(const std::string& _name) {
std11::shared_ptr<ejson::Value> tmp = get(_name);
std::shared_ptr<ejson::Null> ejson::Object::getNull(const std::string& _name) {
std::shared_ptr<ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<ejson::Null>();
return std::shared_ptr<ejson::Null>();
}
return std11::dynamic_pointer_cast<ejson::Null>(tmp);
return std::dynamic_pointer_cast<ejson::Null>(tmp);
}
const std11::shared_ptr<const ejson::Null> ejson::Object::getNull(const std::string& _name) const {
const std11::shared_ptr<const ejson::Value> tmp = get(_name);
const std::shared_ptr<const ejson::Null> ejson::Object::getNull(const std::string& _name) const {
const std::shared_ptr<const ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<const ejson::Null>();
return std::shared_ptr<const ejson::Null>();
}
return std11::dynamic_pointer_cast<const ejson::Null>(tmp);
return std::dynamic_pointer_cast<const ejson::Null>(tmp);
}
std11::shared_ptr<ejson::String> ejson::Object::getString(const std::string& _name) {
std11::shared_ptr<ejson::Value> tmp = get(_name);
std::shared_ptr<ejson::String> ejson::Object::getString(const std::string& _name) {
std::shared_ptr<ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<ejson::String>();
return std::shared_ptr<ejson::String>();
}
return std11::dynamic_pointer_cast<ejson::String>(tmp);
return std::dynamic_pointer_cast<ejson::String>(tmp);
}
const std11::shared_ptr<const ejson::String> ejson::Object::getString(const std::string& _name) const {
const std11::shared_ptr<const ejson::Value> tmp = get(_name);
const std::shared_ptr<const ejson::String> ejson::Object::getString(const std::string& _name) const {
const std::shared_ptr<const ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<const ejson::String>();
return std::shared_ptr<const ejson::String>();
}
return std11::dynamic_pointer_cast<const ejson::String>(tmp);
return std::dynamic_pointer_cast<const ejson::String>(tmp);
}
const std::string& ejson::Object::getStringValue(const std::string& _name) const {
static const std::string errorString("");
const std11::shared_ptr<const ejson::String> tmpp = getString(_name);
const std::shared_ptr<const ejson::String> tmpp = getString(_name);
if (tmpp == nullptr) {
return errorString;
}
@ -371,55 +371,55 @@ const std::string& ejson::Object::getStringValue(const std::string& _name) const
}
std::string ejson::Object::getStringValue(const std::string& _name, const std::string& _errorValue) const {
const std11::shared_ptr<const ejson::String> tmpp = getString(_name);
const std::shared_ptr<const ejson::String> tmpp = getString(_name);
if (tmpp == nullptr) {
return _errorValue;
}
return tmpp->get();
}
std11::shared_ptr<ejson::Boolean> ejson::Object::getBoolean(const std::string& _name) {
std11::shared_ptr<ejson::Value> tmp = get(_name);
std::shared_ptr<ejson::Boolean> ejson::Object::getBoolean(const std::string& _name) {
std::shared_ptr<ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<ejson::Boolean>();
return std::shared_ptr<ejson::Boolean>();
}
return tmp->toBoolean();
}
const std11::shared_ptr<const ejson::Boolean> ejson::Object::getBoolean(const std::string& _name) const {
const std11::shared_ptr<const ejson::Value> tmp = get(_name);
const std::shared_ptr<const ejson::Boolean> ejson::Object::getBoolean(const std::string& _name) const {
const std::shared_ptr<const ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<const ejson::Boolean>();
return std::shared_ptr<const ejson::Boolean>();
}
return tmp->toBoolean();
}
bool ejson::Object::getBooleanValue(const std::string& _name, bool _errorValue) const {
const std11::shared_ptr<const ejson::Boolean> tmpp = getBoolean(_name);
const std::shared_ptr<const ejson::Boolean> tmpp = getBoolean(_name);
if (tmpp == nullptr) {
return _errorValue;
}
return tmpp->get();
}
std11::shared_ptr<ejson::Number> ejson::Object::getNumber(const std::string& _name) {
std11::shared_ptr<ejson::Value> tmp = get(_name);
std::shared_ptr<ejson::Number> ejson::Object::getNumber(const std::string& _name) {
std::shared_ptr<ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<ejson::Number>();
return std::shared_ptr<ejson::Number>();
}
return tmp->toNumber();
}
const std11::shared_ptr<const ejson::Number> ejson::Object::getNumber(const std::string& _name) const {
const std11::shared_ptr<const ejson::Value> tmp = get(_name);
const std::shared_ptr<const ejson::Number> ejson::Object::getNumber(const std::string& _name) const {
const std::shared_ptr<const ejson::Value> tmp = get(_name);
if (tmp == nullptr) {
return std11::shared_ptr<const ejson::Number>();
return std::shared_ptr<const ejson::Number>();
}
return tmp->toNumber();
}
double ejson::Object::getNumberValue(const std::string& _name, double _errorValue) const {
const std11::shared_ptr<const ejson::Number> tmpp = getNumber(_name);
const std::shared_ptr<const ejson::Number> tmpp = getNumber(_name);
if (tmpp == nullptr) {
return _errorValue;
}
@ -427,7 +427,7 @@ double ejson::Object::getNumberValue(const std::string& _name, double _errorValu
}
bool ejson::Object::add(const std::string& _name, std11::shared_ptr<ejson::Value> _value) {
bool ejson::Object::add(const std::string& _name, std::shared_ptr<ejson::Value> _value) {
if (_value == nullptr) {
return false;
}
@ -458,12 +458,12 @@ bool ejson::Object::addNumber(const std::string& _name, double _value) {
return add(_name, ejson::Number::create(_value));
}
bool ejson::Object::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
bool ejson::Object::transfertIn(std::shared_ptr<ejson::Value> _obj) {
if (_obj == nullptr) {
JSON_ERROR("Request transfer on an nullptr pointer");
return false;
}
std11::shared_ptr<ejson::Object> other = _obj->toObject();
std::shared_ptr<ejson::Object> other = _obj->toObject();
if (other == nullptr) {
JSON_ERROR("Request transfer on an element that is not an object");
return false;
@ -477,7 +477,7 @@ bool ejson::Object::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
return true;
}
bool ejson::Object::cloneIn(const std11::shared_ptr<ejson::Object>& _obj) const {
bool ejson::Object::cloneIn(const std::shared_ptr<ejson::Object>& _obj) const {
if (_obj == nullptr) {
return false;
}
@ -490,18 +490,18 @@ bool ejson::Object::cloneIn(const std11::shared_ptr<ejson::Object>& _obj) const
// TODO : Manage error ...
std11::shared_ptr<ejson::Value> ejson::Object::clone() const {
std::shared_ptr<ejson::Value> ejson::Object::clone() const {
return cloneObj();
}
std11::shared_ptr<ejson::Object> ejson::Object::cloneObj() const {
std11::shared_ptr<ejson::Object> output = ejson::Object::create();
std::shared_ptr<ejson::Object> ejson::Object::cloneObj() const {
std::shared_ptr<ejson::Object> output = ejson::Object::create();
if (output == nullptr) {
JSON_ERROR("Allocation error ...");
return std11::shared_ptr<ejson::Object>();
return std::shared_ptr<ejson::Object>();
}
for (int32_t iii=0; iii<m_value.size(); ++iii) {
std11::shared_ptr<ejson::Value> val = m_value.getValue(iii);
std::shared_ptr<ejson::Value> val = m_value.getValue(iii);
std::string key = m_value.getKey(iii);
if (val == nullptr) {
continue;

View File

@ -20,14 +20,14 @@ namespace ejson {
*/
Object() { };
public:
static std11::shared_ptr<Object> create();
static std11::shared_ptr<Object> create(const std::string& _data);
static std::shared_ptr<Object> create();
static std::shared_ptr<Object> create(const std::string& _data);
/**
* @brief destructor
*/
virtual ~Object() { };
protected:
etk::Hash<std11::shared_ptr<ejson::Value> > m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
etk::Hash<std::shared_ptr<ejson::Value> > m_value; //!< value of the node (for element this is the name, for text it is the inside text ...)
public:
/**
* @brief check if an element exist.
@ -40,15 +40,15 @@ namespace ejson {
* @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
*/
std11::shared_ptr<ejson::Value> get(const std::string& _name);
std::shared_ptr<ejson::Value> get(const std::string& _name);
//! @previous
const std11::shared_ptr<const ejson::Value> get(const std::string& _name) const;
const std::shared_ptr<const ejson::Value> get(const std::string& _name) const;
//! @previous
std11::shared_ptr<ejson::Value> operator[] (const std::string& _name) {
std::shared_ptr<ejson::Value> operator[] (const std::string& _name) {
return get(_name);
}
//! @previous
const std11::shared_ptr<const ejson::Value> operator[] (const std::string& _name) const {
const std::shared_ptr<const ejson::Value> operator[] (const std::string& _name) const {
return get(_name);
}
public:
@ -71,19 +71,19 @@ namespace ejson {
* @param[in] _id Id of the element.
* @return nullptr if the element does not exist.
*/
std11::shared_ptr<ejson::Value> get(size_t _id) {
std::shared_ptr<ejson::Value> get(size_t _id) {
return m_value[_id];
};
//! @previous
const std11::shared_ptr<const ejson::Value> get(size_t _id) const{
const std::shared_ptr<const ejson::Value> get(size_t _id) const{
return m_value[_id];
};
//! @previous
std11::shared_ptr<ejson::Value> operator[] (size_t _id) {
std::shared_ptr<ejson::Value> operator[] (size_t _id) {
return m_value[_id];
}
//! @previous
const std11::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
const std::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
return m_value[_id];
}
/**
@ -99,33 +99,33 @@ namespace ejson {
* @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
*/
std11::shared_ptr<ejson::Object> getObject(const std::string& _name);
std::shared_ptr<ejson::Object> getObject(const std::string& _name);
//! @previous
const std11::shared_ptr<const ejson::Object> getObject(const std::string& _name) const;
const std::shared_ptr<const ejson::Object> getObject(const std::string& _name) const;
/**
* @brief get the sub element with his name (Casted as Array if it is possible)
* @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
*/
std11::shared_ptr<ejson::Array> getArray(const std::string& _name);
std::shared_ptr<ejson::Array> getArray(const std::string& _name);
//! @previous
const std11::shared_ptr<const ejson::Array> getArray(const std::string& _name) const;
const std::shared_ptr<const ejson::Array> getArray(const std::string& _name) const;
/**
* @brief get the sub element with his name (Casted as Null if it is possible)
* @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
*/
std11::shared_ptr<ejson::Null> getNull(const std::string& _name);
std::shared_ptr<ejson::Null> getNull(const std::string& _name);
//! @previous
const std11::shared_ptr<const ejson::Null> getNull(const std::string& _name) const;
const std::shared_ptr<const ejson::Null> getNull(const std::string& _name) const;
/**
* @brief get the sub element with his name (Casted as String if it is possible)
* @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
*/
std11::shared_ptr<ejson::String> getString(const std::string& _name);
std::shared_ptr<ejson::String> getString(const std::string& _name);
//! @previous
const std11::shared_ptr<const ejson::String> getString(const std::string& _name) const;
const std::shared_ptr<const ejson::String> getString(const std::string& _name) const;
/**
* @brief get the sub string value of the requested element
* @param[in] _name name of the object
@ -144,9 +144,9 @@ namespace ejson {
* @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
*/
std11::shared_ptr<ejson::Boolean> getBoolean(const std::string& _name);
std::shared_ptr<ejson::Boolean> getBoolean(const std::string& _name);
//! @previous
const std11::shared_ptr<const ejson::Boolean> getBoolean(const std::string& _name) const;
const std::shared_ptr<const ejson::Boolean> getBoolean(const std::string& _name) const;
/**
* @brief get the sub boolean value of the requested element.
* @param[in] _name name of the object.
@ -159,9 +159,9 @@ namespace ejson {
* @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
*/
std11::shared_ptr<ejson::Number> getNumber(const std::string& _name);
std::shared_ptr<ejson::Number> getNumber(const std::string& _name);
//! @previous
const std11::shared_ptr<const ejson::Number> getNumber(const std::string& _name) const;
const std::shared_ptr<const ejson::Number> getNumber(const std::string& _name) const;
/**
* @brief get the sub Number value of the requested element.
* @param[in] _name name of the object.
@ -176,7 +176,7 @@ namespace ejson {
* @param[in] _value Element to add
* @return false if an error occured
*/
bool add(const std::string& _name, std11::shared_ptr<ejson::Value> _value);
bool add(const std::string& _name, std::shared_ptr<ejson::Value> _value);
/**
* @brief add a string element in the Object (automatic creation)
* @param[in] _name name of the object
@ -208,10 +208,10 @@ namespace ejson {
virtual bool iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc);
virtual bool iGenerate(std::string& _data, size_t _indent) const;
virtual void clear();
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
virtual bool cloneIn(const std11::shared_ptr<ejson::Object>& _obj) const;
virtual std11::shared_ptr<ejson::Value> clone() const;
virtual std11::shared_ptr<ejson::Object> cloneObj() const;
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj);
virtual bool cloneIn(const std::shared_ptr<ejson::Object>& _obj) const;
virtual std::shared_ptr<ejson::Value> clone() const;
virtual std::shared_ptr<ejson::Object> cloneObj() const;
};
}

View File

@ -17,8 +17,8 @@
#define __class__ "String"
std11::shared_ptr<ejson::String> ejson::String::create(const std::string& _value) {
return std11::shared_ptr<ejson::String>(new ejson::String(_value));
std::shared_ptr<ejson::String> ejson::String::create(const std::string& _value) {
return std::shared_ptr<ejson::String>(new ejson::String(_value));
}
bool ejson::String::iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc) {
@ -52,12 +52,12 @@ bool ejson::String::iGenerate(std::string& _data, size_t _indent) const {
}
bool ejson::String::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
bool ejson::String::transfertIn(std::shared_ptr<ejson::Value> _obj) {
if (_obj == nullptr) {
JSON_ERROR("Request transfer on an nullptr pointer");
return false;
}
std11::shared_ptr<ejson::String> other = _obj->toString();
std::shared_ptr<ejson::String> other = _obj->toString();
if (other == nullptr) {
JSON_ERROR("Request transfer on an element that is not an String");
return false;
@ -67,11 +67,11 @@ bool ejson::String::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
return true;
}
std11::shared_ptr<ejson::Value> ejson::String::clone() const {
std11::shared_ptr<ejson::String> output = ejson::String::create(m_value);
std::shared_ptr<ejson::Value> ejson::String::clone() const {
std::shared_ptr<ejson::String> output = ejson::String::create(m_value);
if (output == nullptr) {
JSON_ERROR("Allocation error ...");
return std11::shared_ptr<ejson::Value>();
return std::shared_ptr<ejson::Value>();
}
return output;
}

View File

@ -21,7 +21,7 @@ namespace ejson {
};
public:
static std11::shared_ptr<String> create(const std::string& _value="");
static std::shared_ptr<String> create(const std::string& _value="");
/**
* @brief destructor
*/
@ -46,8 +46,8 @@ namespace ejson {
public: // herited function :
virtual bool iParse(const std::string& _data, size_t& _pos, ejson::filePos& _filePos, ejson::Document& _doc);
virtual bool iGenerate(std::string& _data, size_t _indent) const;
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
virtual std11::shared_ptr<ejson::Value> clone() const;
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj);
virtual std::shared_ptr<ejson::Value> clone() const;
};
}

View File

@ -121,53 +121,53 @@ bool ejson::Value::checkNumber(char32_t _val) const {
return false;
}
std11::shared_ptr<ejson::Value> ejson::Value::toValue() {
std::shared_ptr<ejson::Value> ejson::Value::toValue() {
return shared_from_this();
};
const std11::shared_ptr<const ejson::Value> ejson::Value::toValue() const {
const std::shared_ptr<const ejson::Value> ejson::Value::toValue() const {
return shared_from_this();
};
std11::shared_ptr<ejson::Document> ejson::Value::toDocument() {
return std11::dynamic_pointer_cast<ejson::Document>(shared_from_this());
std::shared_ptr<ejson::Document> ejson::Value::toDocument() {
return std::dynamic_pointer_cast<ejson::Document>(shared_from_this());
};
const std11::shared_ptr<const ejson::Document> ejson::Value::toDocument() const {
return std11::dynamic_pointer_cast<const ejson::Document>(shared_from_this());
const std::shared_ptr<const ejson::Document> ejson::Value::toDocument() const {
return std::dynamic_pointer_cast<const ejson::Document>(shared_from_this());
};
std11::shared_ptr<ejson::Array> ejson::Value::toArray() {
return std11::dynamic_pointer_cast<ejson::Array>(shared_from_this());
std::shared_ptr<ejson::Array> ejson::Value::toArray() {
return std::dynamic_pointer_cast<ejson::Array>(shared_from_this());
};
const std11::shared_ptr<const ejson::Array> ejson::Value::toArray() const{
return std11::dynamic_pointer_cast<const ejson::Array>(shared_from_this());
const std::shared_ptr<const ejson::Array> ejson::Value::toArray() const{
return std::dynamic_pointer_cast<const ejson::Array>(shared_from_this());
};
std11::shared_ptr<ejson::Object> ejson::Value::toObject() {
return std11::dynamic_pointer_cast<ejson::Object>(shared_from_this());
std::shared_ptr<ejson::Object> ejson::Value::toObject() {
return std::dynamic_pointer_cast<ejson::Object>(shared_from_this());
};
const std11::shared_ptr<const ejson::Object> ejson::Value::toObject() const{
return std11::dynamic_pointer_cast<const ejson::Object>(shared_from_this());
const std::shared_ptr<const ejson::Object> ejson::Value::toObject() const{
return std::dynamic_pointer_cast<const ejson::Object>(shared_from_this());
};
std11::shared_ptr<ejson::String> ejson::Value::toString() {
return std11::dynamic_pointer_cast<ejson::String>(shared_from_this());
std::shared_ptr<ejson::String> ejson::Value::toString() {
return std::dynamic_pointer_cast<ejson::String>(shared_from_this());
};
const std11::shared_ptr<const ejson::String> ejson::Value::toString() const{
return std11::dynamic_pointer_cast<const ejson::String>(shared_from_this());
const std::shared_ptr<const ejson::String> ejson::Value::toString() const{
return std::dynamic_pointer_cast<const ejson::String>(shared_from_this());
};
std11::shared_ptr<ejson::Number> ejson::Value::toNumber() {
return std11::dynamic_pointer_cast<ejson::Number>(shared_from_this());
std::shared_ptr<ejson::Number> ejson::Value::toNumber() {
return std::dynamic_pointer_cast<ejson::Number>(shared_from_this());
};
const std11::shared_ptr<const ejson::Number> ejson::Value::toNumber() const{
return std11::dynamic_pointer_cast<const ejson::Number>(shared_from_this());
const std::shared_ptr<const ejson::Number> ejson::Value::toNumber() const{
return std::dynamic_pointer_cast<const ejson::Number>(shared_from_this());
};
std11::shared_ptr<ejson::Boolean> ejson::Value::toBoolean() {
return std11::dynamic_pointer_cast<ejson::Boolean>(shared_from_this());
std::shared_ptr<ejson::Boolean> ejson::Value::toBoolean() {
return std::dynamic_pointer_cast<ejson::Boolean>(shared_from_this());
};
const std11::shared_ptr<const ejson::Boolean> ejson::Value::toBoolean() const{
return std11::dynamic_pointer_cast<const ejson::Boolean>(shared_from_this());
const std::shared_ptr<const ejson::Boolean> ejson::Value::toBoolean() const{
return std::dynamic_pointer_cast<const ejson::Boolean>(shared_from_this());
};
std11::shared_ptr<ejson::Null> ejson::Value::toNull() {
return std11::dynamic_pointer_cast<ejson::Null>(shared_from_this());
std::shared_ptr<ejson::Null> ejson::Value::toNull() {
return std::dynamic_pointer_cast<ejson::Null>(shared_from_this());
};
const std11::shared_ptr<const ejson::Null> ejson::Value::toNull() const{
return std11::dynamic_pointer_cast<const ejson::Null>(shared_from_this());
const std::shared_ptr<const ejson::Null> ejson::Value::toNull() const{
return std::dynamic_pointer_cast<const ejson::Null>(shared_from_this());
};
void ejson::Value::display() const {

View File

@ -104,7 +104,7 @@ namespace ejson {
};
std::ostream& operator <<(std::ostream& _os, const filePos& _obj);
class Value : public std11::enable_shared_from_this<Value> {
class Value : public std::enable_shared_from_this<Value> {
protected:
/**
* @brief basic element of a xml structure
@ -171,58 +171,58 @@ namespace ejson {
* @brief Cast the element in a Value if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::Value> toValue();
std::shared_ptr<ejson::Value> toValue();
//! @previous
const std11::shared_ptr<const ejson::Value> toValue() const;
const std::shared_ptr<const ejson::Value> toValue() const;
/**
* @brief Cast the element in a Document if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::Document> toDocument();
std::shared_ptr<ejson::Document> toDocument();
//! @previous
const std11::shared_ptr<const ejson::Document> toDocument() const;
const std::shared_ptr<const ejson::Document> toDocument() const;
/**
* @brief Cast the element in a Array if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::Array> toArray();
std::shared_ptr<ejson::Array> toArray();
//! @previous
const std11::shared_ptr<const ejson::Array> toArray() const;
const std::shared_ptr<const ejson::Array> toArray() const;
/**
* @brief Cast the element in a Object if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::Object> toObject();
std::shared_ptr<ejson::Object> toObject();
//! @previous
const std11::shared_ptr<const ejson::Object> toObject() const;
const std::shared_ptr<const ejson::Object> toObject() const;
/**
* @brief Cast the element in a String if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::String> toString();
std::shared_ptr<ejson::String> toString();
//! @previous
const std11::shared_ptr<const ejson::String> toString() const;
const std::shared_ptr<const ejson::String> toString() const;
/**
* @brief Cast the element in a Number if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::Number> toNumber();
std::shared_ptr<ejson::Number> toNumber();
//! @previous
const std11::shared_ptr<const ejson::Number> toNumber() const;
const std::shared_ptr<const ejson::Number> toNumber() const;
/**
* @brief Cast the element in a Boolean if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::Boolean> toBoolean();
std::shared_ptr<ejson::Boolean> toBoolean();
//! @previous
const std11::shared_ptr<const ejson::Boolean> toBoolean() const;
const std::shared_ptr<const ejson::Boolean> toBoolean() const;
/**
* @brief Cast the element in a Null if it is possible.
* @return pointer on the class or nullptr.
*/
std11::shared_ptr<ejson::Null> toNull();
std::shared_ptr<ejson::Null> toNull();
//! @previous
const std11::shared_ptr<const ejson::Null> toNull() const;
const std::shared_ptr<const ejson::Null> toNull() const;
/**
* @brief check if the node is a ejson::Document
@ -284,15 +284,15 @@ namespace ejson {
* @return true if transfer is done corectly
* @note all element is remove from the curent element.
*/
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj) {
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj) {
return false;
};
/**
* @brief Copy the curent node and all the child in the curent one.
* @return nullptr in an error occured, the pointer on the element otherwise
*/
virtual std11::shared_ptr<ejson::Value> clone() const {
return std11::shared_ptr<ejson::Value>();
virtual std::shared_ptr<ejson::Value> clone() const {
return std::shared_ptr<ejson::Value>();
};
protected:
/**

View File

@ -9,7 +9,7 @@
#include <ejson/debug.h>
int32_t ejson::getLogId() {
static int32_t g_val = etk::log::registerInstance("ejson");
static int32_t g_val = elog::registerInstance("ejson");
return g_val;
}

View File

@ -7,12 +7,12 @@
*/
#pragma once
#include <etk/log.h>
#include <elog/log.h>
namespace ejson {
int32_t getLogId();
};
#define JSON_BASE(info,data) TK_LOG_BASE(ejson::getLogId(),info,data)
#define JSON_BASE(info,data) ELOG_BASE(ejson::getLogId(),info,data)
#define JSON_CRITICAL(data) JSON_BASE(1, data)
#define JSON_ERROR(data) JSON_BASE(2, data)

View File

@ -21,8 +21,8 @@
#define __class__ "Document"
std11::shared_ptr<ejson::Document> ejson::Document::create() {
return std11::shared_ptr<ejson::Document>(new ejson::Document());
std::shared_ptr<ejson::Document> ejson::Document::create() {
return std::shared_ptr<ejson::Document>(new ejson::Document());
}
ejson::Document::Document() :

View File

@ -21,7 +21,7 @@ namespace ejson {
* @brief Constructor
*/
Document();
static std11::shared_ptr<Document> create();
static std::shared_ptr<Document> create();
/**
* @brief Destructor
*/