[DEV] WORK on a port for BOOST
This commit is contained in:
parent
1028c4aad4
commit
45ec7abcdd
116
ejson/Array.cpp
116
ejson/Array.cpp
@ -20,8 +20,8 @@
|
||||
#define __class__ "Array"
|
||||
|
||||
|
||||
std::shared_ptr<ejson::Array> ejson::Array::create() {
|
||||
return std::shared_ptr<ejson::Array>(new ejson::Array());
|
||||
std11::shared_ptr<ejson::Array> ejson::Array::create() {
|
||||
return std11::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");
|
||||
std::shared_ptr<ejson::Object> tmpElement = ejson::Object::create();
|
||||
std11::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");
|
||||
std::shared_ptr<ejson::String> tmpElement = ejson::String::create();
|
||||
std11::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");
|
||||
std::shared_ptr<ejson::Array> tmpElement = ejson::Array::create();
|
||||
std11::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");
|
||||
std::shared_ptr<ejson::Boolean> tmpElement = ejson::Boolean::create();
|
||||
std11::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");
|
||||
std::shared_ptr<ejson::Null> tmpElement = ejson::Null::create();
|
||||
std11::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");
|
||||
std::shared_ptr<ejson::Number> tmpElement = ejson::Number::create();
|
||||
std11::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++) {
|
||||
std::shared_ptr<const ejson::Value> tmp = m_value[iii];
|
||||
std11::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()) {
|
||||
std::shared_ptr<const ejson::String> tmp2 = tmp->toString();
|
||||
std11::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(std::shared_ptr<ejson::Value> _element) {
|
||||
bool ejson::Array::add(std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
bool ejson::Array::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
|
||||
if (_obj == nullptr) {
|
||||
JSON_ERROR("Request transfer on an nullptr pointer");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<ejson::Array> other = _obj->toArray();
|
||||
std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
}
|
||||
|
||||
// TODO : Manage error ...
|
||||
std::shared_ptr<ejson::Value> ejson::Array::clone() const {
|
||||
std::shared_ptr<ejson::Array> output = ejson::Array::create();
|
||||
std11::shared_ptr<ejson::Value> ejson::Array::clone() const {
|
||||
std11::shared_ptr<ejson::Array> output = ejson::Array::create();
|
||||
if (output == nullptr) {
|
||||
JSON_ERROR("Allocation error ...");
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Value>();
|
||||
}
|
||||
for (size_t iii=0; iii<m_value.size(); ++iii) {
|
||||
std::shared_ptr<const ejson::Value> val = m_value[iii];
|
||||
std11::shared_ptr<const ejson::Value> val = m_value[iii];
|
||||
if (val == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@ -256,103 +256,103 @@ std::shared_ptr<ejson::Value> ejson::Array::clone() const {
|
||||
return output;
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Object> ejson::Array::getObject(size_t _id) {
|
||||
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
std11::shared_ptr<ejson::Object> ejson::Array::getObject(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Object>();
|
||||
}
|
||||
return tmpElement->toObject();
|
||||
}
|
||||
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];
|
||||
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];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Object>();
|
||||
}
|
||||
return tmpElement->toObject();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::String> ejson::Array::getString(size_t _id) {
|
||||
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
std11::shared_ptr<ejson::String> ejson::Array::getString(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::String>();
|
||||
}
|
||||
return tmpElement->toString();
|
||||
}
|
||||
|
||||
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];
|
||||
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];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::String>();
|
||||
}
|
||||
return tmpElement->toString();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Array> ejson::Array::getArray(size_t _id) {
|
||||
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
std11::shared_ptr<ejson::Array> ejson::Array::getArray(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Array>();
|
||||
}
|
||||
return tmpElement->toArray();
|
||||
}
|
||||
|
||||
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];
|
||||
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];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Array>();
|
||||
}
|
||||
return tmpElement->toArray();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Null> ejson::Array::getNull(size_t _id) {
|
||||
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
std11::shared_ptr<ejson::Null> ejson::Array::getNull(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Null>();
|
||||
}
|
||||
return tmpElement->toNull();
|
||||
}
|
||||
|
||||
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];
|
||||
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];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Null>();
|
||||
}
|
||||
return tmpElement->toNull();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Number> ejson::Array::getNumber(size_t _id) {
|
||||
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
std11::shared_ptr<ejson::Number> ejson::Array::getNumber(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Number>();
|
||||
}
|
||||
return tmpElement->toNumber();
|
||||
}
|
||||
|
||||
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];
|
||||
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];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Number>();
|
||||
}
|
||||
return tmpElement->toNumber();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Boolean> ejson::Array::getBoolean(size_t _id) {
|
||||
std::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
std11::shared_ptr<ejson::Boolean> ejson::Array::getBoolean(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> tmpElement = m_value[_id];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Boolean>();
|
||||
}
|
||||
return tmpElement->toBoolean();
|
||||
}
|
||||
|
||||
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];
|
||||
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];
|
||||
if (tmpElement == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Boolean>();
|
||||
}
|
||||
return tmpElement->toBoolean();
|
||||
}
|
||||
|
||||
std::string ejson::Array::getStringValue(size_t _id) {
|
||||
std::shared_ptr<ejson::String> tmpElement = getString(_id);
|
||||
std11::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 std::shared_ptr<const ejson::String> tmpElement = getString(_id);
|
||||
const std11::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 std::shared_ptr<const ejson::String> tmpElement = getString(_id);
|
||||
const std11::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 std::shared_ptr<const ejson::Number> tmpElement = getNumber(_id);
|
||||
const std11::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 std::shared_ptr<const ejson::Boolean> tmpElement = getBoolean(_id);
|
||||
const std11::shared_ptr<const ejson::Boolean> tmpElement = getBoolean(_id);
|
||||
if (tmpElement == nullptr) {
|
||||
return _errorValue;
|
||||
}
|
||||
|
@ -20,13 +20,13 @@ namespace ejson {
|
||||
*/
|
||||
Array() { };
|
||||
public:
|
||||
static std::shared_ptr<Array> create();
|
||||
static std11::shared_ptr<Array> create();
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
virtual ~Array() { };
|
||||
private:
|
||||
std::vector<std::shared_ptr<ejson::Value>> m_value; //!< vector of sub elements
|
||||
std::vector<std11::shared_ptr<ejson::Value> > m_value; //!< vector of sub elements
|
||||
public:
|
||||
/**
|
||||
* @brief get the number of sub element in the current one
|
||||
@ -40,19 +40,19 @@ namespace ejson {
|
||||
* @param[in] _id Id of the element.
|
||||
* @return nullptr if the element does not exist.
|
||||
*/
|
||||
std::shared_ptr<ejson::Value> get(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> get(size_t _id) {
|
||||
return m_value[_id];
|
||||
};
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Value> get(size_t _id) const{
|
||||
const std11::shared_ptr<const ejson::Value> get(size_t _id) const{
|
||||
return m_value[_id];
|
||||
};
|
||||
//! @previous
|
||||
std::shared_ptr<ejson::Value> operator[] (size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> operator[] (size_t _id) {
|
||||
return m_value[_id];
|
||||
}
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
|
||||
const std11::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
|
||||
return m_value[_id];
|
||||
}
|
||||
/**
|
||||
@ -60,17 +60,17 @@ namespace ejson {
|
||||
* @param[in] _id Id of the element.
|
||||
* @return nullptr if the element does not exist.
|
||||
*/
|
||||
std::shared_ptr<ejson::Object> getObject(size_t _id);
|
||||
std11::shared_ptr<ejson::Object> getObject(size_t _id);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Object> getObject(size_t _id) const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::String> getString(size_t _id);
|
||||
std11::shared_ptr<ejson::String> getString(size_t _id);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::String> getString(size_t _id) const;
|
||||
const std11::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.
|
||||
@ -91,25 +91,25 @@ namespace ejson {
|
||||
* @param[in] _id Id of the element.
|
||||
* @return nullptr if the element does not exist.
|
||||
*/
|
||||
std::shared_ptr<ejson::Array> getArray(size_t _id);
|
||||
std11::shared_ptr<ejson::Array> getArray(size_t _id);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Array> getArray(size_t _id) const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Null> getNull(size_t _id);
|
||||
std11::shared_ptr<ejson::Null> getNull(size_t _id);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Null> getNull(size_t _id) const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Number> getNumber(size_t _id);
|
||||
std11::shared_ptr<ejson::Number> getNumber(size_t _id);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Number> getNumber(size_t _id) const;
|
||||
const std11::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.
|
||||
@ -122,9 +122,9 @@ namespace ejson {
|
||||
* @param[in] _id Id of the element.
|
||||
* @return nullptr if the element does not exist.
|
||||
*/
|
||||
std::shared_ptr<ejson::Boolean> getBoolean(size_t _id);
|
||||
std11::shared_ptr<ejson::Boolean> getBoolean(size_t _id);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Boolean> getBoolean(size_t _id) const;
|
||||
const std11::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.
|
||||
@ -137,7 +137,7 @@ namespace ejson {
|
||||
* @param[in] _element element to add.
|
||||
* @return false if an error occured.
|
||||
*/
|
||||
bool add(std::shared_ptr<ejson::Value> _element);
|
||||
bool add(std11::shared_ptr<ejson::Value> _element);
|
||||
/**
|
||||
* @brief add a string element in the Object (automatic creation)
|
||||
* @param[in] _value string value to add
|
||||
@ -166,8 +166,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(std::shared_ptr<ejson::Value> _obj);
|
||||
virtual std::shared_ptr<ejson::Value> clone() const;
|
||||
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
|
||||
virtual std11::shared_ptr<ejson::Value> clone() const;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
#undef __class__
|
||||
#define __class__ "Boolean"
|
||||
|
||||
std::shared_ptr<ejson::Boolean> ejson::Boolean::create(bool _value) {
|
||||
return std::shared_ptr<ejson::Boolean>(new ejson::Boolean(_value));
|
||||
std11::shared_ptr<ejson::Boolean> ejson::Boolean::create(bool _value) {
|
||||
return std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
bool ejson::Boolean::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
|
||||
if (_obj == nullptr) {
|
||||
JSON_ERROR("Request transfer on an NULL pointer");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<ejson::Boolean> other = _obj->toBoolean();
|
||||
std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Value> ejson::Boolean::clone() const {
|
||||
std::shared_ptr<ejson::Boolean> output = ejson::Boolean::create(m_value);
|
||||
std11::shared_ptr<ejson::Value> ejson::Boolean::clone() const {
|
||||
std11::shared_ptr<ejson::Boolean> output = ejson::Boolean::create(m_value);
|
||||
if (output == nullptr) {
|
||||
JSON_ERROR("Allocation error ...");
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Value>();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace ejson {
|
||||
|
||||
};
|
||||
public:
|
||||
static std::shared_ptr<Boolean> create(bool _value=false);
|
||||
static std11::shared_ptr<Boolean> create(bool _value=false);
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
@ -50,8 +50,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(std::shared_ptr<ejson::Value> _obj);
|
||||
virtual std::shared_ptr<ejson::Value> clone() const;
|
||||
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
|
||||
virtual std11::shared_ptr<ejson::Value> clone() const;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#undef __class__
|
||||
#define __class__ "Null"
|
||||
|
||||
std::shared_ptr<ejson::Null> ejson::Null::create() {
|
||||
return std::shared_ptr<ejson::Null>(new ejson::Null());
|
||||
std11::shared_ptr<ejson::Null> ejson::Null::create() {
|
||||
return std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
bool ejson::Null::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
|
||||
if (_obj == nullptr) {
|
||||
JSON_ERROR("Request transfer on an nullptr pointer");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<ejson::Null> other = _obj->toNull();
|
||||
std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Value> ejson::Null::clone() const {
|
||||
std::shared_ptr<ejson::Null> output = ejson::Null::create();
|
||||
std11::shared_ptr<ejson::Value> ejson::Null::clone() const {
|
||||
std11::shared_ptr<ejson::Null> output = ejson::Null::create();
|
||||
if (output == nullptr) {
|
||||
JSON_ERROR("Allocation error ...");
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Value>();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ namespace ejson {
|
||||
*/
|
||||
Null() { };
|
||||
public:
|
||||
static std::shared_ptr<Null> create();
|
||||
static std11::shared_ptr<Null> create();
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
@ -28,8 +28,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(std::shared_ptr<ejson::Value> _obj);
|
||||
virtual std::shared_ptr<ejson::Value> clone() const;
|
||||
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
|
||||
virtual std11::shared_ptr<ejson::Value> clone() const;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -14,8 +14,8 @@
|
||||
#undef __class__
|
||||
#define __class__ "Number"
|
||||
|
||||
std::shared_ptr<ejson::Number> ejson::Number::create(double _value) {
|
||||
return std::shared_ptr<ejson::Number>(new ejson::Number(_value));
|
||||
std11::shared_ptr<ejson::Number> ejson::Number::create(double _value) {
|
||||
return std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
bool ejson::Number::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
|
||||
if (_obj == nullptr) {
|
||||
JSON_ERROR("Request transfer on an nullptr pointer");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<ejson::Number> other = _obj->toNumber();
|
||||
std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Value> ejson::Number::clone() const {
|
||||
std::shared_ptr<ejson::Number> output = ejson::Number::create(m_value);
|
||||
std11::shared_ptr<ejson::Value> ejson::Number::clone() const {
|
||||
std11::shared_ptr<ejson::Number> output = ejson::Number::create(m_value);
|
||||
if (output == nullptr) {
|
||||
JSON_ERROR("Allocation error ...");
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Value>();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace ejson {
|
||||
|
||||
};
|
||||
public:
|
||||
static std::shared_ptr<Number> create(double _value=0.0);
|
||||
static std11::shared_ptr<Number> create(double _value=0.0);
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
@ -62,8 +62,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(std::shared_ptr<ejson::Value> _obj);
|
||||
virtual std::shared_ptr<ejson::Value> clone() const;
|
||||
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
|
||||
virtual std11::shared_ptr<ejson::Value> clone() const;
|
||||
};
|
||||
};
|
||||
|
||||
|
142
ejson/Object.cpp
142
ejson/Object.cpp
@ -21,8 +21,8 @@
|
||||
|
||||
|
||||
|
||||
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() {
|
||||
return std11::shared_ptr<ejson::Object>(new ejson::Object());
|
||||
}
|
||||
|
||||
void ejson::Object::clear() {
|
||||
@ -121,7 +121,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");
|
||||
std::shared_ptr<ejson::Object> tmpElement = ejson::Object::create();
|
||||
std11::shared_ptr<ejson::Object> tmpElement = ejson::Object::create();
|
||||
if (tmpElement == nullptr) {
|
||||
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in object");
|
||||
_pos=iii;
|
||||
@ -134,7 +134,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");
|
||||
std::shared_ptr<ejson::String> tmpElement = ejson::String::create();
|
||||
std11::shared_ptr<ejson::String> tmpElement = ejson::String::create();
|
||||
if (tmpElement == nullptr) {
|
||||
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in String");
|
||||
_pos=iii;
|
||||
@ -146,7 +146,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");
|
||||
std::shared_ptr<ejson::Array> tmpElement = ejson::Array::create();
|
||||
std11::shared_ptr<ejson::Array> tmpElement = ejson::Array::create();
|
||||
if (tmpElement == nullptr) {
|
||||
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Array");
|
||||
_pos=iii;
|
||||
@ -159,7 +159,7 @@ bool ejson::Object::iParse(const std::string& _data, size_t& _pos, ejson::filePo
|
||||
|| _data[iii] == 't' ) {
|
||||
// find boolean:
|
||||
JSON_PARSE_ELEMENT("find Boolean");
|
||||
std::shared_ptr<ejson::Boolean> tmpElement = ejson::Boolean::create();
|
||||
std11::shared_ptr<ejson::Boolean> tmpElement = ejson::Boolean::create();
|
||||
if (tmpElement == nullptr) {
|
||||
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
|
||||
_pos=iii;
|
||||
@ -171,7 +171,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");
|
||||
std::shared_ptr<ejson::Null> tmpElement = ejson::Null::create();
|
||||
std11::shared_ptr<ejson::Null> tmpElement = ejson::Null::create();
|
||||
if (tmpElement == nullptr) {
|
||||
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
|
||||
_pos=iii;
|
||||
@ -183,7 +183,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");
|
||||
std::shared_ptr<ejson::Number> tmpElement = ejson::Number::create();
|
||||
std11::shared_ptr<ejson::Number> tmpElement = ejson::Number::create();
|
||||
if (tmpElement == nullptr) {
|
||||
EJSON_CREATE_ERROR(_doc, _data, iii, _filePos, "Allocation error in Boolean");
|
||||
_pos=iii;
|
||||
@ -220,7 +220,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++) {
|
||||
std::shared_ptr<ejson::Value> tmp = m_value[iii];
|
||||
std11::shared_ptr<ejson::Value> tmp = m_value[iii];
|
||||
if (tmp == nullptr) {
|
||||
continue;
|
||||
}
|
||||
@ -233,7 +233,7 @@ bool ejson::Object::iGenerate(std::string& _data, size_t _indent) const {
|
||||
break;
|
||||
}
|
||||
if (tmp->isString() == true) {
|
||||
std::shared_ptr<ejson::String> tmp2 = tmp->toString();
|
||||
std11::shared_ptr<ejson::String> tmp2 = tmp->toString();
|
||||
if (tmp2 != nullptr) {
|
||||
if( tmp2->get().size()>25
|
||||
|| m_value.getKey(iii).size()>25) {
|
||||
@ -277,87 +277,87 @@ bool ejson::Object::exist(const std::string& _name) const {
|
||||
return m_value.exist(_name);
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Value> ejson::Object::get(const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> ejson::Object::get(const std::string& _name) {
|
||||
if (false == m_value.exist(_name)) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Value>();
|
||||
}
|
||||
return m_value[_name];
|
||||
}
|
||||
|
||||
const std::shared_ptr<const ejson::Value> ejson::Object::get(const std::string& _name) const {
|
||||
const std11::shared_ptr<const ejson::Value> ejson::Object::get(const std::string& _name) const {
|
||||
if (false == m_value.exist(_name)) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Value>();
|
||||
}
|
||||
return m_value[_name];
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Object> ejson::Object::getObject(const std::string& _name) {
|
||||
std::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
std11::shared_ptr<ejson::Object> ejson::Object::getObject(const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Object>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<ejson::Object>(tmp);
|
||||
return std11::dynamic_pointer_cast<ejson::Object>(tmp);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Object>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<const ejson::Object>(tmp);
|
||||
return std11::dynamic_pointer_cast<const ejson::Object>(tmp);
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Array> ejson::Object::getArray(const std::string& _name) {
|
||||
std::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
std11::shared_ptr<ejson::Array> ejson::Object::getArray(const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Array>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<ejson::Array>(tmp);
|
||||
return std11::dynamic_pointer_cast<ejson::Array>(tmp);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Array>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<const ejson::Array>(tmp);
|
||||
return std11::dynamic_pointer_cast<const ejson::Array>(tmp);
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Null> ejson::Object::getNull(const std::string& _name) {
|
||||
std::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
std11::shared_ptr<ejson::Null> ejson::Object::getNull(const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Null>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<ejson::Null>(tmp);
|
||||
return std11::dynamic_pointer_cast<ejson::Null>(tmp);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Null>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<const ejson::Null>(tmp);
|
||||
return std11::dynamic_pointer_cast<const ejson::Null>(tmp);
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::String> ejson::Object::getString(const std::string& _name) {
|
||||
std::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
std11::shared_ptr<ejson::String> ejson::Object::getString(const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::String>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<ejson::String>(tmp);
|
||||
return std11::dynamic_pointer_cast<ejson::String>(tmp);
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::String>();
|
||||
}
|
||||
return std::dynamic_pointer_cast<const ejson::String>(tmp);
|
||||
return std11::dynamic_pointer_cast<const ejson::String>(tmp);
|
||||
}
|
||||
|
||||
const std::string& ejson::Object::getStringValue(const std::string& _name) const {
|
||||
static const std::string errorString("");
|
||||
const std::shared_ptr<const ejson::String> tmpp = getString(_name);
|
||||
const std11::shared_ptr<const ejson::String> tmpp = getString(_name);
|
||||
if (tmpp == nullptr) {
|
||||
return errorString;
|
||||
}
|
||||
@ -365,55 +365,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 std::shared_ptr<const ejson::String> tmpp = getString(_name);
|
||||
const std11::shared_ptr<const ejson::String> tmpp = getString(_name);
|
||||
if (tmpp == nullptr) {
|
||||
return _errorValue;
|
||||
}
|
||||
return tmpp->get();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Boolean> ejson::Object::getBoolean(const std::string& _name) {
|
||||
std::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
std11::shared_ptr<ejson::Boolean> ejson::Object::getBoolean(const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Boolean>();
|
||||
}
|
||||
return tmp->toBoolean();
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Boolean>();
|
||||
}
|
||||
return tmp->toBoolean();
|
||||
}
|
||||
|
||||
bool ejson::Object::getBooleanValue(const std::string& _name, bool _errorValue) const {
|
||||
const std::shared_ptr<const ejson::Boolean> tmpp = getBoolean(_name);
|
||||
const std11::shared_ptr<const ejson::Boolean> tmpp = getBoolean(_name);
|
||||
if (tmpp == nullptr) {
|
||||
return _errorValue;
|
||||
}
|
||||
return tmpp->get();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Number> ejson::Object::getNumber(const std::string& _name) {
|
||||
std::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
std11::shared_ptr<ejson::Number> ejson::Object::getNumber(const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> tmp = get(_name);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Number>();
|
||||
}
|
||||
return tmp->toNumber();
|
||||
}
|
||||
|
||||
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);
|
||||
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);
|
||||
if (tmp == nullptr) {
|
||||
return nullptr;
|
||||
return std11::shared_ptr<const ejson::Number>();
|
||||
}
|
||||
return tmp->toNumber();
|
||||
}
|
||||
|
||||
double ejson::Object::getNumberValue(const std::string& _name, double _errorValue) const {
|
||||
const std::shared_ptr<const ejson::Number> tmpp = getNumber(_name);
|
||||
const std11::shared_ptr<const ejson::Number> tmpp = getNumber(_name);
|
||||
if (tmpp == nullptr) {
|
||||
return _errorValue;
|
||||
}
|
||||
@ -421,7 +421,7 @@ double ejson::Object::getNumberValue(const std::string& _name, double _errorValu
|
||||
}
|
||||
|
||||
|
||||
bool ejson::Object::add(const std::string& _name, std::shared_ptr<ejson::Value> _value) {
|
||||
bool ejson::Object::add(const std::string& _name, std11::shared_ptr<ejson::Value> _value) {
|
||||
if (_value == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -452,12 +452,12 @@ bool ejson::Object::addNumber(const std::string& _name, double _value) {
|
||||
return add(_name, ejson::Number::create(_value));
|
||||
}
|
||||
|
||||
bool ejson::Object::transfertIn(std::shared_ptr<ejson::Value> _obj) {
|
||||
bool ejson::Object::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
|
||||
if (_obj == nullptr) {
|
||||
JSON_ERROR("Request transfer on an nullptr pointer");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<ejson::Object> other = _obj->toObject();
|
||||
std11::shared_ptr<ejson::Object> other = _obj->toObject();
|
||||
if (other == nullptr) {
|
||||
JSON_ERROR("Request transfer on an element that is not an object");
|
||||
return false;
|
||||
@ -471,7 +471,7 @@ bool ejson::Object::transfertIn(std::shared_ptr<ejson::Value> _obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ejson::Object::cloneIn(const std::shared_ptr<ejson::Object>& _obj) const {
|
||||
bool ejson::Object::cloneIn(const std11::shared_ptr<ejson::Object>& _obj) const {
|
||||
if (_obj == nullptr) {
|
||||
return false;
|
||||
}
|
||||
@ -484,18 +484,18 @@ bool ejson::Object::cloneIn(const std::shared_ptr<ejson::Object>& _obj) const {
|
||||
|
||||
|
||||
// TODO : Manage error ...
|
||||
std::shared_ptr<ejson::Value> ejson::Object::clone() const {
|
||||
std11::shared_ptr<ejson::Value> ejson::Object::clone() const {
|
||||
return cloneObj();
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Object> ejson::Object::cloneObj() const {
|
||||
std::shared_ptr<ejson::Object> output = ejson::Object::create();
|
||||
std11::shared_ptr<ejson::Object> ejson::Object::cloneObj() const {
|
||||
std11::shared_ptr<ejson::Object> output = ejson::Object::create();
|
||||
if (output == nullptr) {
|
||||
JSON_ERROR("Allocation error ...");
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Object>();
|
||||
}
|
||||
for (int32_t iii=0; iii<m_value.size(); ++iii) {
|
||||
std::shared_ptr<ejson::Value> val = m_value.getValue(iii);
|
||||
std11::shared_ptr<ejson::Value> val = m_value.getValue(iii);
|
||||
std::string key = m_value.getKey(iii);
|
||||
if (val == nullptr) {
|
||||
continue;
|
||||
|
@ -22,13 +22,13 @@ namespace ejson {
|
||||
*/
|
||||
Object() { };
|
||||
public:
|
||||
static std::shared_ptr<Object> create();
|
||||
static std11::shared_ptr<Object> create();
|
||||
/**
|
||||
* @brief destructor
|
||||
*/
|
||||
virtual ~Object() { };
|
||||
protected:
|
||||
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 ...)
|
||||
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 ...)
|
||||
public:
|
||||
/**
|
||||
* @brief check if an element exist.
|
||||
@ -41,15 +41,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
|
||||
*/
|
||||
std::shared_ptr<ejson::Value> get(const std::string& _name);
|
||||
std11::shared_ptr<ejson::Value> get(const std::string& _name);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Value> get(const std::string& _name) const;
|
||||
const std11::shared_ptr<const ejson::Value> get(const std::string& _name) const;
|
||||
//! @previous
|
||||
std::shared_ptr<ejson::Value> operator[] (const std::string& _name) {
|
||||
std11::shared_ptr<ejson::Value> operator[] (const std::string& _name) {
|
||||
return get(_name);
|
||||
}
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Value> operator[] (const std::string& _name) const {
|
||||
const std11::shared_ptr<const ejson::Value> operator[] (const std::string& _name) const {
|
||||
return get(_name);
|
||||
}
|
||||
public:
|
||||
@ -72,19 +72,19 @@ namespace ejson {
|
||||
* @param[in] _id Id of the element.
|
||||
* @return nullptr if the element does not exist.
|
||||
*/
|
||||
std::shared_ptr<ejson::Value> get(size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> get(size_t _id) {
|
||||
return m_value[_id];
|
||||
};
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Value> get(size_t _id) const{
|
||||
const std11::shared_ptr<const ejson::Value> get(size_t _id) const{
|
||||
return m_value[_id];
|
||||
};
|
||||
//! @previous
|
||||
std::shared_ptr<ejson::Value> operator[] (size_t _id) {
|
||||
std11::shared_ptr<ejson::Value> operator[] (size_t _id) {
|
||||
return m_value[_id];
|
||||
}
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
|
||||
const std11::shared_ptr<const ejson::Value> operator[] (size_t _id) const {
|
||||
return m_value[_id];
|
||||
}
|
||||
/**
|
||||
@ -100,33 +100,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
|
||||
*/
|
||||
std::shared_ptr<ejson::Object> getObject(const std::string& _name);
|
||||
std11::shared_ptr<ejson::Object> getObject(const std::string& _name);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Object> getObject(const std::string& _name) const;
|
||||
const std11::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
|
||||
*/
|
||||
std::shared_ptr<ejson::Array> getArray(const std::string& _name);
|
||||
std11::shared_ptr<ejson::Array> getArray(const std::string& _name);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Array> getArray(const std::string& _name) const;
|
||||
const std11::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
|
||||
*/
|
||||
std::shared_ptr<ejson::Null> getNull(const std::string& _name);
|
||||
std11::shared_ptr<ejson::Null> getNull(const std::string& _name);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Null> getNull(const std::string& _name) const;
|
||||
const std11::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
|
||||
*/
|
||||
std::shared_ptr<ejson::String> getString(const std::string& _name);
|
||||
std11::shared_ptr<ejson::String> getString(const std::string& _name);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::String> getString(const std::string& _name) const;
|
||||
const std11::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
|
||||
@ -145,9 +145,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
|
||||
*/
|
||||
std::shared_ptr<ejson::Boolean> getBoolean(const std::string& _name);
|
||||
std11::shared_ptr<ejson::Boolean> getBoolean(const std::string& _name);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Boolean> getBoolean(const std::string& _name) const;
|
||||
const std11::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.
|
||||
@ -160,9 +160,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
|
||||
*/
|
||||
std::shared_ptr<ejson::Number> getNumber(const std::string& _name);
|
||||
std11::shared_ptr<ejson::Number> getNumber(const std::string& _name);
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Number> getNumber(const std::string& _name) const;
|
||||
const std11::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.
|
||||
@ -177,7 +177,7 @@ namespace ejson {
|
||||
* @param[in] _value Element to add
|
||||
* @return false if an error occured
|
||||
*/
|
||||
bool add(const std::string& _name, std::shared_ptr<ejson::Value> _value);
|
||||
bool add(const std::string& _name, std11::shared_ptr<ejson::Value> _value);
|
||||
/**
|
||||
* @brief add a string element in the Object (automatic creation)
|
||||
* @param[in] _name name of the object
|
||||
@ -209,10 +209,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(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;
|
||||
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;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -17,8 +17,8 @@
|
||||
#define __class__ "String"
|
||||
|
||||
|
||||
std::shared_ptr<ejson::String> ejson::String::create(const std::string& _value) {
|
||||
return std::shared_ptr<ejson::String>(new ejson::String(_value));
|
||||
std11::shared_ptr<ejson::String> ejson::String::create(const std::string& _value) {
|
||||
return std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
bool ejson::String::transfertIn(std11::shared_ptr<ejson::Value> _obj) {
|
||||
if (_obj == nullptr) {
|
||||
JSON_ERROR("Request transfer on an nullptr pointer");
|
||||
return false;
|
||||
}
|
||||
std::shared_ptr<ejson::String> other = _obj->toString();
|
||||
std11::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(std::shared_ptr<ejson::Value> _obj) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::shared_ptr<ejson::Value> ejson::String::clone() const {
|
||||
std::shared_ptr<ejson::String> output = ejson::String::create(m_value);
|
||||
std11::shared_ptr<ejson::Value> ejson::String::clone() const {
|
||||
std11::shared_ptr<ejson::String> output = ejson::String::create(m_value);
|
||||
if (output == nullptr) {
|
||||
JSON_ERROR("Allocation error ...");
|
||||
return nullptr;
|
||||
return std11::shared_ptr<ejson::Value>();
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ namespace ejson {
|
||||
|
||||
};
|
||||
public:
|
||||
static std::shared_ptr<String> create(const std::string& _value="");
|
||||
static std11::shared_ptr<String> create(const std::string& _value="");
|
||||
/**
|
||||
* @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(std::shared_ptr<ejson::Value> _obj);
|
||||
virtual std::shared_ptr<ejson::Value> clone() const;
|
||||
virtual bool transfertIn(std11::shared_ptr<ejson::Value> _obj);
|
||||
virtual std11::shared_ptr<ejson::Value> clone() const;
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -121,48 +121,53 @@ bool ejson::Value::checkNumber(char32_t _val) const {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
std::shared_ptr<ejson::Document> ejson::Value::toDocument() {
|
||||
return std::dynamic_pointer_cast<ejson::Document>(shared_from_this());
|
||||
std11::shared_ptr<ejson::Value> ejson::Value::toValue() {
|
||||
return 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());
|
||||
const std11::shared_ptr<const ejson::Value> ejson::Value::toValue() const {
|
||||
return shared_from_this();
|
||||
};
|
||||
std::shared_ptr<ejson::Array> ejson::Value::toArray() {
|
||||
return std::dynamic_pointer_cast<ejson::Array>(shared_from_this());
|
||||
std11::shared_ptr<ejson::Document> ejson::Value::toDocument() {
|
||||
return std11::dynamic_pointer_cast<ejson::Document>(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());
|
||||
const std11::shared_ptr<const ejson::Document> ejson::Value::toDocument() const {
|
||||
return std11::dynamic_pointer_cast<const ejson::Document>(shared_from_this());
|
||||
};
|
||||
std::shared_ptr<ejson::Object> ejson::Value::toObject() {
|
||||
return std::dynamic_pointer_cast<ejson::Object>(shared_from_this());
|
||||
std11::shared_ptr<ejson::Array> ejson::Value::toArray() {
|
||||
return std11::dynamic_pointer_cast<ejson::Array>(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());
|
||||
const std11::shared_ptr<const ejson::Array> ejson::Value::toArray() const{
|
||||
return std11::dynamic_pointer_cast<const ejson::Array>(shared_from_this());
|
||||
};
|
||||
std::shared_ptr<ejson::String> ejson::Value::toString() {
|
||||
return std::dynamic_pointer_cast<ejson::String>(shared_from_this());
|
||||
std11::shared_ptr<ejson::Object> ejson::Value::toObject() {
|
||||
return std11::dynamic_pointer_cast<ejson::Object>(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());
|
||||
const std11::shared_ptr<const ejson::Object> ejson::Value::toObject() const{
|
||||
return std11::dynamic_pointer_cast<const ejson::Object>(shared_from_this());
|
||||
};
|
||||
std::shared_ptr<ejson::Number> ejson::Value::toNumber() {
|
||||
return std::dynamic_pointer_cast<ejson::Number>(shared_from_this());
|
||||
std11::shared_ptr<ejson::String> ejson::Value::toString() {
|
||||
return std11::dynamic_pointer_cast<ejson::String>(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());
|
||||
const std11::shared_ptr<const ejson::String> ejson::Value::toString() const{
|
||||
return std11::dynamic_pointer_cast<const ejson::String>(shared_from_this());
|
||||
};
|
||||
std::shared_ptr<ejson::Boolean> ejson::Value::toBoolean() {
|
||||
return std::dynamic_pointer_cast<ejson::Boolean>(shared_from_this());
|
||||
std11::shared_ptr<ejson::Number> ejson::Value::toNumber() {
|
||||
return std11::dynamic_pointer_cast<ejson::Number>(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());
|
||||
const std11::shared_ptr<const ejson::Number> ejson::Value::toNumber() const{
|
||||
return std11::dynamic_pointer_cast<const ejson::Number>(shared_from_this());
|
||||
};
|
||||
std::shared_ptr<ejson::Null> ejson::Value::toNull() {
|
||||
return std::dynamic_pointer_cast<ejson::Null>(shared_from_this());
|
||||
std11::shared_ptr<ejson::Boolean> ejson::Value::toBoolean() {
|
||||
return std11::dynamic_pointer_cast<ejson::Boolean>(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());
|
||||
const std11::shared_ptr<const ejson::Boolean> ejson::Value::toBoolean() const{
|
||||
return std11::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());
|
||||
};
|
||||
const std11::shared_ptr<const ejson::Null> ejson::Value::toNull() const{
|
||||
return std11::dynamic_pointer_cast<const ejson::Null>(shared_from_this());
|
||||
};
|
||||
|
||||
void ejson::Value::display() const {
|
||||
|
@ -10,7 +10,12 @@
|
||||
#define __ETK_JSON_VALUE_H__
|
||||
|
||||
#include <etk/types.h>
|
||||
#include <memory>
|
||||
#if __cplusplus >= 201103L
|
||||
#include <memory>
|
||||
#else
|
||||
#include <etk/memory.h>
|
||||
#endif
|
||||
|
||||
|
||||
namespace ejson {
|
||||
//#define ENABLE_DISPLAY_PARSED_ELEMENT
|
||||
@ -105,7 +110,7 @@ namespace ejson {
|
||||
};
|
||||
std::ostream& operator <<(std::ostream& _os, const filePos& _obj);
|
||||
|
||||
class Value : public std::enable_shared_from_this<Value> {
|
||||
class Value : public std11::enable_shared_from_this<Value> {
|
||||
protected:
|
||||
/**
|
||||
* @brief basic element of a xml structure
|
||||
@ -172,62 +177,58 @@ namespace ejson {
|
||||
* @brief Cast the element in a Value if it is possible.
|
||||
* @return pointer on the class or nullptr.
|
||||
*/
|
||||
std::shared_ptr<ejson::Value> toValue() {
|
||||
return shared_from_this();
|
||||
};
|
||||
std11::shared_ptr<ejson::Value> toValue();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Value> toValue() const {
|
||||
return shared_from_this();
|
||||
};
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Document> toDocument();
|
||||
std11::shared_ptr<ejson::Document> toDocument();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Document> toDocument() const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Array> toArray();
|
||||
std11::shared_ptr<ejson::Array> toArray();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Array> toArray() const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Object> toObject();
|
||||
std11::shared_ptr<ejson::Object> toObject();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Object> toObject() const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::String> toString();
|
||||
std11::shared_ptr<ejson::String> toString();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::String> toString() const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Number> toNumber();
|
||||
std11::shared_ptr<ejson::Number> toNumber();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Number> toNumber() const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Boolean> toBoolean();
|
||||
std11::shared_ptr<ejson::Boolean> toBoolean();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Boolean> toBoolean() const;
|
||||
const std11::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.
|
||||
*/
|
||||
std::shared_ptr<ejson::Null> toNull();
|
||||
std11::shared_ptr<ejson::Null> toNull();
|
||||
//! @previous
|
||||
const std::shared_ptr<const ejson::Null> toNull() const;
|
||||
const std11::shared_ptr<const ejson::Null> toNull() const;
|
||||
|
||||
/**
|
||||
* @brief check if the node is a ejson::Document
|
||||
@ -289,15 +290,15 @@ namespace ejson {
|
||||
* @return true if transfer is done corectly
|
||||
* @note all element is remove from the curent element.
|
||||
*/
|
||||
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj) {
|
||||
virtual bool transfertIn(std11::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 std::shared_ptr<ejson::Value> clone() const {
|
||||
return nullptr;
|
||||
virtual std11::shared_ptr<ejson::Value> clone() const {
|
||||
return std11::shared_ptr<ejson::Value>();
|
||||
};
|
||||
protected:
|
||||
/**
|
||||
|
@ -21,8 +21,8 @@
|
||||
#define __class__ "Document"
|
||||
|
||||
|
||||
std::shared_ptr<ejson::Document> ejson::Document::create() {
|
||||
return std::shared_ptr<ejson::Document>(new ejson::Document());
|
||||
std11::shared_ptr<ejson::Document> ejson::Document::create() {
|
||||
return std11::shared_ptr<ejson::Document>(new ejson::Document());
|
||||
}
|
||||
|
||||
ejson::Document::Document() :
|
||||
|
@ -23,7 +23,7 @@ namespace ejson {
|
||||
* @brief Constructor
|
||||
*/
|
||||
Document();
|
||||
static std::shared_ptr<Document> create();
|
||||
static std11::shared_ptr<Document> create();
|
||||
/**
|
||||
* @brief Destructor
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user