[DEV] modify interface
This commit is contained in:
parent
dd2c3b15e9
commit
5e0c804a56
@ -471,8 +471,24 @@ bool ejson::Object::transfertIn(std::shared_ptr<ejson::Value> _obj) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ejson::Object::cloneIn(const std::shared_ptr<ejson::Object>& _obj) const {
|
||||||
|
if (_obj == nullptr) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
_obj->clear();
|
||||||
|
for (int32_t iii=0; iii<m_value.size(); ++iii) {
|
||||||
|
_obj->add(m_value.getKey(iii), m_value[iii]->clone());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO : Manage error ...
|
// TODO : Manage error ...
|
||||||
std::shared_ptr<ejson::Value> ejson::Object::clone() const {
|
std::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();
|
std::shared_ptr<ejson::Object> output = ejson::Object::create();
|
||||||
if (output == nullptr) {
|
if (output == nullptr) {
|
||||||
JSON_ERROR("Allocation error ...");
|
JSON_ERROR("Allocation error ...");
|
||||||
|
@ -210,7 +210,9 @@ namespace ejson {
|
|||||||
virtual bool iGenerate(std::string& _data, size_t _indent) const;
|
virtual bool iGenerate(std::string& _data, size_t _indent) const;
|
||||||
virtual void clear();
|
virtual void clear();
|
||||||
virtual bool transfertIn(std::shared_ptr<ejson::Value> _obj);
|
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::Value> clone() const;
|
||||||
|
virtual std::shared_ptr<ejson::Object> cloneObj() const;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -163,4 +163,11 @@ std::shared_ptr<ejson::Null> ejson::Value::toNull() {
|
|||||||
};
|
};
|
||||||
const std::shared_ptr<const ejson::Null> ejson::Value::toNull() const{
|
const std::shared_ptr<const ejson::Null> ejson::Value::toNull() const{
|
||||||
return std::dynamic_pointer_cast<const ejson::Null>(shared_from_this());
|
return std::dynamic_pointer_cast<const ejson::Null>(shared_from_this());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
void ejson::Value::display() const {
|
||||||
|
std::string tmpp;
|
||||||
|
iGenerate(tmpp, 0);
|
||||||
|
JSON_INFO("Generated JSON : \n" << tmpp);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -132,6 +132,10 @@ namespace ejson {
|
|||||||
* @return false if an error occured.
|
* @return false if an error occured.
|
||||||
*/
|
*/
|
||||||
virtual bool iGenerate(std::string& _data, size_t _indent) const = 0;
|
virtual bool iGenerate(std::string& _data, size_t _indent) const = 0;
|
||||||
|
/**
|
||||||
|
* @brief Display the Document on console
|
||||||
|
*/
|
||||||
|
void display() const;
|
||||||
protected:
|
protected:
|
||||||
/**
|
/**
|
||||||
* @brief add indentation of the string input.
|
* @brief add indentation of the string input.
|
||||||
|
@ -109,11 +109,6 @@ bool ejson::Document::store(const std::string& _file) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ejson::Document::display() {
|
|
||||||
std::string tmpp;
|
|
||||||
iGenerate(tmpp, 0);
|
|
||||||
JSON_INFO("Generated JSON : \n" << tmpp);
|
|
||||||
}
|
|
||||||
|
|
||||||
static std::string createPosPointer(const std::string& _line, size_t _pos) {
|
static std::string createPosPointer(const std::string& _line, size_t _pos) {
|
||||||
std::string out;
|
std::string out;
|
||||||
|
@ -57,10 +57,6 @@ namespace ejson {
|
|||||||
* @return true : Parsing is OK
|
* @return true : Parsing is OK
|
||||||
*/
|
*/
|
||||||
bool store(const std::string& _file);
|
bool store(const std::string& _file);
|
||||||
/**
|
|
||||||
* @brief Display the Document on console
|
|
||||||
*/
|
|
||||||
void display();
|
|
||||||
private:
|
private:
|
||||||
bool m_writeErrorWhenDetexted;
|
bool m_writeErrorWhenDetexted;
|
||||||
std::string m_comment;
|
std::string m_comment;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user