[DEBUG] ememory ShredPtr update new API
This commit is contained in:
parent
c1e1768cc9
commit
e406ea7a7e
@ -42,7 +42,7 @@ size_t ejson::Array::size() const {
|
|||||||
EJSON_ERROR("Can not size (nullptr) ...");
|
EJSON_ERROR("Can not size (nullptr) ...");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Array*>(m_data.get())->size();
|
return static_cast<const ejson::internal::Array*>(m_data.get())->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
ejson::Value ejson::Array::operator[] (size_t _id) {
|
ejson::Value ejson::Array::operator[] (size_t _id) {
|
||||||
@ -58,7 +58,7 @@ const ejson::Value ejson::Array::operator[] (size_t _id) const {
|
|||||||
EJSON_ERROR("Can not get (nullptr) ...");
|
EJSON_ERROR("Can not get (nullptr) ...");
|
||||||
return ejson::Value(nullptr);;
|
return ejson::Value(nullptr);;
|
||||||
}
|
}
|
||||||
return ejson::Value(static_cast<ejson::internal::Array*>(m_data.get())->get(_id));
|
return ejson::Value(static_cast<const ejson::internal::Array*>(m_data.get())->get(_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ejson::Array::add(const ejson::Value& _element) {
|
bool ejson::Array::add(const ejson::Value& _element) {
|
||||||
|
@ -48,6 +48,6 @@ bool ejson::Boolean::get(bool _errorValue) const {
|
|||||||
EJSON_ERROR("Can not get (nullptr) ...");
|
EJSON_ERROR("Can not get (nullptr) ...");
|
||||||
return _errorValue;
|
return _errorValue;
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Boolean*>(m_data.get())->get();
|
return static_cast<const ejson::internal::Boolean*>(m_data.get())->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ double ejson::Number::get(double _errorValue) const {
|
|||||||
EJSON_ERROR("Can not get (nullptr) ...");
|
EJSON_ERROR("Can not get (nullptr) ...");
|
||||||
return _errorValue;
|
return _errorValue;
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Number*>(m_data.get())->get();
|
return static_cast<const ejson::internal::Number*>(m_data.get())->get();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t ejson::Number::getU64(uint64_t _errorValue) const {
|
uint64_t ejson::Number::getU64(uint64_t _errorValue) const {
|
||||||
@ -71,7 +71,7 @@ uint64_t ejson::Number::getU64(uint64_t _errorValue) const {
|
|||||||
EJSON_ERROR("Can not get (nullptr) ...");
|
EJSON_ERROR("Can not get (nullptr) ...");
|
||||||
return _errorValue;
|
return _errorValue;
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Number*>(m_data.get())->getU64();
|
return static_cast<const ejson::internal::Number*>(m_data.get())->getU64();
|
||||||
}
|
}
|
||||||
|
|
||||||
int64_t ejson::Number::getI64(int64_t _errorValue) const {
|
int64_t ejson::Number::getI64(int64_t _errorValue) const {
|
||||||
@ -79,7 +79,7 @@ int64_t ejson::Number::getI64(int64_t _errorValue) const {
|
|||||||
EJSON_ERROR("Can not get (nullptr) ...");
|
EJSON_ERROR("Can not get (nullptr) ...");
|
||||||
return _errorValue;
|
return _errorValue;
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Number*>(m_data.get())->getI64();
|
return static_cast<const ejson::internal::Number*>(m_data.get())->getI64();
|
||||||
}
|
}
|
||||||
|
|
||||||
ejson::internal::Number::type ejson::Number::getType() const {
|
ejson::internal::Number::type ejson::Number::getType() const {
|
||||||
@ -87,7 +87,7 @@ ejson::internal::Number::type ejson::Number::getType() const {
|
|||||||
EJSON_ERROR("Can not get (nullptr) ...");
|
EJSON_ERROR("Can not get (nullptr) ...");
|
||||||
return ejson::internal::Number::type::tDouble;
|
return ejson::internal::Number::type::tDouble;
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Number*>(m_data.get())->getType();
|
return static_cast<const ejson::internal::Number*>(m_data.get())->getType();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ const ejson::Value ejson::Object::operator[] (const std::string& _name) const {
|
|||||||
EJSON_ERROR("Can not operator[] (nullptr) ...");
|
EJSON_ERROR("Can not operator[] (nullptr) ...");
|
||||||
return ejson::Value(nullptr);
|
return ejson::Value(nullptr);
|
||||||
}
|
}
|
||||||
return ejson::Value(static_cast<ejson::internal::Object*>(m_data.get())->get(_name));
|
return ejson::Value(static_cast<const ejson::internal::Object*>(m_data.get())->get(_name));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> ejson::Object::getKeys() const {
|
std::vector<std::string> ejson::Object::getKeys() const {
|
||||||
@ -70,7 +70,7 @@ std::vector<std::string> ejson::Object::getKeys() const {
|
|||||||
EJSON_ERROR("Can not getKeys (nullptr) ...");
|
EJSON_ERROR("Can not getKeys (nullptr) ...");
|
||||||
return std::vector<std::string>();
|
return std::vector<std::string>();
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Object*>(m_data.get())->getKeys();
|
return static_cast<const ejson::internal::Object*>(m_data.get())->getKeys();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t ejson::Object::size() const {
|
size_t ejson::Object::size() const {
|
||||||
@ -94,7 +94,7 @@ const ejson::Value ejson::Object::operator[] (size_t _id) const {
|
|||||||
EJSON_ERROR("Can not operator[] (nullptr) ...");
|
EJSON_ERROR("Can not operator[] (nullptr) ...");
|
||||||
return ejson::Value(nullptr);
|
return ejson::Value(nullptr);
|
||||||
}
|
}
|
||||||
return ejson::Value(static_cast<ejson::internal::Object*>(m_data.get())->get(_id));
|
return ejson::Value(static_cast<const ejson::internal::Object*>(m_data.get())->get(_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ejson::Object::getKey(size_t _id) const {
|
std::string ejson::Object::getKey(size_t _id) const {
|
||||||
@ -102,7 +102,7 @@ std::string ejson::Object::getKey(size_t _id) const {
|
|||||||
EJSON_ERROR("Can not getKey (nullptr) ...");
|
EJSON_ERROR("Can not getKey (nullptr) ...");
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::Object*>(m_data.get())->getKey(_id);
|
return static_cast<const ejson::internal::Object*>(m_data.get())->getKey(_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ejson::Object::add(const std::string& _name, const ejson::Value& _value) {
|
bool ejson::Object::add(const std::string& _name, const ejson::Value& _value) {
|
||||||
|
@ -46,5 +46,5 @@ std::string ejson::String::get(const std::string& _errorValue) const {
|
|||||||
EJSON_ERROR("Can not get (nullptr) ...");
|
EJSON_ERROR("Can not get (nullptr) ...");
|
||||||
return _errorValue;
|
return _errorValue;
|
||||||
}
|
}
|
||||||
return static_cast<ejson::internal::String*>(m_data.get())->get();
|
return static_cast<const ejson::internal::String*>(m_data.get())->get();
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ std::string ejson::Value::generateHumanString() const {
|
|||||||
EJSON_ERROR("Can not remove (nullptr) ...");
|
EJSON_ERROR("Can not remove (nullptr) ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
static_cast<ejson::internal::Value*>(m_data.get())->iGenerate(out, 0);
|
static_cast<const ejson::internal::Value*>(m_data.get())->iGenerate(out, 0);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ std::string ejson::Value::generateMachineString() const {
|
|||||||
EJSON_ERROR("Can not remove (nullptr) ...");
|
EJSON_ERROR("Can not remove (nullptr) ...");
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
static_cast<ejson::internal::Value*>(m_data.get())->iMachineGenerate(out);
|
static_cast<const ejson::internal::Value*>(m_data.get())->iMachineGenerate(out);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ bool ejson::internal::Array::iGenerate(std::string& _data, size_t _indent) const
|
|||||||
oneLine=false;
|
oneLine=false;
|
||||||
} else {
|
} else {
|
||||||
for (size_t iii=0; iii<m_value.size() ; iii++) {
|
for (size_t iii=0; iii<m_value.size() ; iii++) {
|
||||||
ememory::SharedPtr<const ejson::internal::Value> tmp = m_value[iii];
|
const ememory::SharedPtr<ejson::internal::Value> tmp = m_value[iii];
|
||||||
if (tmp == nullptr) {
|
if (tmp == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -170,7 +170,7 @@ bool ejson::internal::Array::iGenerate(std::string& _data, size_t _indent) const
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tmp->getType() == ejson::valueType::string) {
|
if (tmp->getType() == ejson::valueType::string) {
|
||||||
ememory::SharedPtr<const ejson::internal::String> tmp2 = std::static_pointer_cast<const ejson::internal::String>(tmp);
|
const ememory::SharedPtr<ejson::internal::String> tmp2 = ememory::staticPointerCast<ejson::internal::String>(tmp);
|
||||||
if(tmp2->get().size()>40) {
|
if(tmp2->get().size()>40) {
|
||||||
oneLine=false;
|
oneLine=false;
|
||||||
break;
|
break;
|
||||||
@ -230,7 +230,7 @@ ememory::SharedPtr<ejson::internal::Value> ejson::internal::Array::get(size_t _i
|
|||||||
return m_value[_id];
|
return m_value[_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ememory::SharedPtr<const ejson::internal::Value> ejson::internal::Array::get(size_t _id) const {
|
const ememory::SharedPtr<ejson::internal::Value> ejson::internal::Array::get(size_t _id) const {
|
||||||
return m_value[_id];
|
return m_value[_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ bool ejson::internal::Array::transfertIn(ememory::SharedPtr<ejson::internal::Val
|
|||||||
EJSON_ERROR("Request transfer on an element that is not an Array");
|
EJSON_ERROR("Request transfer on an element that is not an Array");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ejson::internal::Array> other = std::static_pointer_cast<ejson::internal::Array>(_obj);
|
ememory::SharedPtr<ejson::internal::Array> other = ememory::staticPointerCast<ejson::internal::Array>(_obj);
|
||||||
// remove destination elements
|
// remove destination elements
|
||||||
other->clear();
|
other->clear();
|
||||||
// Copy to the destination
|
// Copy to the destination
|
||||||
|
@ -46,7 +46,7 @@ namespace ejson {
|
|||||||
* @param[in] _id Id of the element.
|
* @param[in] _id Id of the element.
|
||||||
* @return nullptr if the element does not exist.
|
* @return nullptr if the element does not exist.
|
||||||
*/
|
*/
|
||||||
const ememory::SharedPtr<const ejson::internal::Value> get(size_t _id) const;
|
const ememory::SharedPtr<ejson::internal::Value> get(size_t _id) const;
|
||||||
/**
|
/**
|
||||||
* @brief add an element on the array.
|
* @brief add an element on the array.
|
||||||
* @param[in] _element element to add.
|
* @param[in] _element element to add.
|
||||||
|
@ -81,7 +81,7 @@ bool ejson::internal::Boolean::transfertIn(ememory::SharedPtr<ejson::internal::V
|
|||||||
EJSON_ERROR("Request transfer on an element that is not an Boolean");
|
EJSON_ERROR("Request transfer on an element that is not an Boolean");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ejson::internal::Boolean> other = std::static_pointer_cast<ejson::internal::Boolean>(_obj);
|
ememory::SharedPtr<ejson::internal::Boolean> other = ememory::staticPointerCast<ejson::internal::Boolean>(_obj);
|
||||||
// remove destination elements
|
// remove destination elements
|
||||||
other->m_value = m_value;
|
other->m_value = m_value;
|
||||||
m_value = false;
|
m_value = false;
|
||||||
|
@ -124,7 +124,7 @@ bool ejson::internal::Number::transfertIn(ememory::SharedPtr<ejson::internal::Va
|
|||||||
EJSON_ERROR("Request transfer on an element that is not an Number");
|
EJSON_ERROR("Request transfer on an element that is not an Number");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ejson::internal::Number> other = std::static_pointer_cast<ejson::internal::Number>(_obj);
|
ememory::SharedPtr<ejson::internal::Number> other = ememory::staticPointerCast<ejson::internal::Number>(_obj);
|
||||||
// remove destination elements
|
// remove destination elements
|
||||||
other->m_typeNumber = m_typeNumber;
|
other->m_typeNumber = m_typeNumber;
|
||||||
m_typeNumber = ejson::internal::Number::type::tUint;
|
m_typeNumber = ejson::internal::Number::type::tUint;
|
||||||
|
@ -220,7 +220,7 @@ bool ejson::internal::Object::iGenerate(std::string& _data, size_t _indent) cons
|
|||||||
oneLine = false;
|
oneLine = false;
|
||||||
} else {
|
} else {
|
||||||
for (int32_t iii=0; iii<m_value.size() ; iii++) {
|
for (int32_t iii=0; iii<m_value.size() ; iii++) {
|
||||||
ememory::SharedPtr<const ejson::internal::Value> tmp = m_value[iii];
|
const ememory::SharedPtr<ejson::internal::Value> tmp = m_value[iii];
|
||||||
if (tmp == nullptr) {
|
if (tmp == nullptr) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -234,7 +234,7 @@ bool ejson::internal::Object::iGenerate(std::string& _data, size_t _indent) cons
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (tmp->getType() == ejson::valueType::string) {
|
if (tmp->getType() == ejson::valueType::string) {
|
||||||
ememory::SharedPtr<const ejson::internal::String> tmp2 = std::static_pointer_cast<const ejson::internal::String>(tmp);
|
const ememory::SharedPtr<ejson::internal::String> tmp2 = ememory::staticPointerCast<ejson::internal::String>(tmp);
|
||||||
if( tmp2->get().size()>25
|
if( tmp2->get().size()>25
|
||||||
|| m_value.getKey(iii).size()>25) {
|
|| m_value.getKey(iii).size()>25) {
|
||||||
oneLine=false;
|
oneLine=false;
|
||||||
@ -304,7 +304,7 @@ ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(size_t _
|
|||||||
return m_value[_id];
|
return m_value[_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ememory::SharedPtr<const ejson::internal::Value> ejson::internal::Object::get(size_t _id) const{
|
const ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(size_t _id) const{
|
||||||
return m_value[_id];
|
return m_value[_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -315,9 +315,9 @@ ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(const st
|
|||||||
return m_value[_name];
|
return m_value[_name];
|
||||||
}
|
}
|
||||||
|
|
||||||
const ememory::SharedPtr<const ejson::internal::Value> ejson::internal::Object::get(const std::string& _name) const {
|
const ememory::SharedPtr<ejson::internal::Value> ejson::internal::Object::get(const std::string& _name) const {
|
||||||
if (m_value.exist(_name) == false) {
|
if (m_value.exist(_name) == false) {
|
||||||
return ememory::SharedPtr<const ejson::internal::Value>();
|
return ememory::SharedPtr<ejson::internal::Value>();
|
||||||
}
|
}
|
||||||
return m_value[_name];
|
return m_value[_name];
|
||||||
}
|
}
|
||||||
@ -359,7 +359,7 @@ bool ejson::internal::Object::transfertIn(ememory::SharedPtr<ejson::internal::Va
|
|||||||
EJSON_ERROR("Request transfer on an element that is not an object");
|
EJSON_ERROR("Request transfer on an element that is not an object");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ejson::internal::Object> other = std::static_pointer_cast<ejson::internal::Object>(_obj);
|
ememory::SharedPtr<ejson::internal::Object> other = ememory::staticPointerCast<ejson::internal::Object>(_obj);
|
||||||
// remove destination elements
|
// remove destination elements
|
||||||
other->clear();
|
other->clear();
|
||||||
// Copy to the destination
|
// Copy to the destination
|
||||||
@ -369,7 +369,7 @@ bool ejson::internal::Object::transfertIn(ememory::SharedPtr<ejson::internal::Va
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ejson::internal::Object::cloneIn(const ememory::SharedPtr<ejson::internal::Object>& _obj) const {
|
bool ejson::internal::Object::cloneIn(ememory::SharedPtr<ejson::internal::Object>& _obj) const {
|
||||||
if (_obj == nullptr) {
|
if (_obj == nullptr) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -56,7 +56,7 @@ namespace ejson {
|
|||||||
* @param[in] _name name of the object
|
* @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
|
* @return pointer on the element requested or nullptr if it not the corect type or does not existed
|
||||||
*/
|
*/
|
||||||
const ememory::SharedPtr<const ejson::internal::Value> get(const std::string& _name) const;
|
const ememory::SharedPtr<ejson::internal::Value> get(const std::string& _name) const;
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Get all the element name (keys).
|
* @brief Get all the element name (keys).
|
||||||
@ -79,7 +79,7 @@ namespace ejson {
|
|||||||
* @param[in] _id Id of the element.
|
* @param[in] _id Id of the element.
|
||||||
* @return nullptr if the element does not exist.
|
* @return nullptr if the element does not exist.
|
||||||
*/
|
*/
|
||||||
const ememory::SharedPtr<const ejson::internal::Value> get(size_t _id) const;
|
const ememory::SharedPtr<ejson::internal::Value> get(size_t _id) const;
|
||||||
/**
|
/**
|
||||||
* @brief Get the element name (key).
|
* @brief Get the element name (key).
|
||||||
* @param[in] _id Id of the element.
|
* @param[in] _id Id of the element.
|
||||||
@ -109,7 +109,7 @@ namespace ejson {
|
|||||||
* @param[in] _obj Other object ot overwride
|
* @param[in] _obj Other object ot overwride
|
||||||
* @return true The clone has been corectly done, false otherwise
|
* @return true The clone has been corectly done, false otherwise
|
||||||
*/
|
*/
|
||||||
bool cloneIn(const ememory::SharedPtr<ejson::internal::Object>& _obj) const;
|
bool cloneIn(ememory::SharedPtr<ejson::internal::Object>& _obj) const;
|
||||||
/**
|
/**
|
||||||
* @brief Clone the current object
|
* @brief Clone the current object
|
||||||
* @return A new object that has been clone
|
* @return A new object that has been clone
|
||||||
|
@ -100,7 +100,7 @@ bool ejson::internal::String::transfertIn(ememory::SharedPtr<ejson::internal::Va
|
|||||||
EJSON_ERROR("Request transfer on an element that is not an String");
|
EJSON_ERROR("Request transfer on an element that is not an String");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
ememory::SharedPtr<ejson::internal::String> other = std::static_pointer_cast<ejson::internal::String>(_obj);
|
ememory::SharedPtr<ejson::internal::String> other = ememory::staticPointerCast<ejson::internal::String>(_obj);
|
||||||
other->m_value = m_value;
|
other->m_value = m_value;
|
||||||
m_value = "";
|
m_value = "";
|
||||||
return true;
|
return true;
|
||||||
|
@ -56,6 +56,7 @@ namespace ejson {
|
|||||||
m_type(ejson::valueType::unknow) {
|
m_type(ejson::valueType::unknow) {
|
||||||
m_type = ejson::valueType::value;
|
m_type = ejson::valueType::value;
|
||||||
};
|
};
|
||||||
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Virtualize destructor
|
* @brief Virtualize destructor
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user