From 1f36568b20bce6b3184b0725363492af78d161e6 Mon Sep 17 00:00:00 2001 From: tastytea Date: Mon, 11 Mar 2019 20:41:52 +0100 Subject: [PATCH] Added contructor with Json::Value and operator Json::Value() to Entity --- src/easy/easy.hpp | 11 +++++++++++ src/easy/entity.cpp | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/easy/easy.hpp b/src/easy/easy.hpp index 0e14aa7..58cc899 100644 --- a/src/easy/easy.hpp +++ b/src/easy/easy.hpp @@ -333,6 +333,15 @@ public: */ explicit Entity(const string &json); + /*! + * @brief Constructs an Entity object from a JSON object. + * + * @param object JSON object + * + * @since 0.100.0 + */ + explicit Entity(const Json::Value &object); + /*! * @brief Constructs an empty Entity object. * @@ -347,6 +356,8 @@ public: */ virtual ~Entity(); + operator const Json::Value() const; + /*! * @brief Replaces the Entity with a new one from a JSON string. * diff --git a/src/easy/entity.cpp b/src/easy/entity.cpp index 4bd0682..df51565 100644 --- a/src/easy/entity.cpp +++ b/src/easy/entity.cpp @@ -33,6 +33,11 @@ Easy::Entity::Entity(const string &json) from_string(json); } +Easy::Entity::Entity(const Json::Value &object) +: _tree(object) +,_was_set(false) +{} + Easy::Entity::Entity() : _was_set(false) {} @@ -40,6 +45,11 @@ Easy::Entity::Entity() Easy::Entity::~Entity() {} +Easy::Entity::operator const Json::Value() const +{ + return to_object(); +} + void Easy::Entity::from_string(const string &json) { std::stringstream ss(json);