Added virtual destructors to API and Easy::Entity.
the build failed Details

This commit is contained in:
tastytea 2019-02-25 14:36:49 +01:00
parent 7bdeaeb236
commit 25628e1d5d
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
4 changed files with 54 additions and 16 deletions

View File

@ -340,11 +340,11 @@ public:
Entity();
/*!
* @brief Constructs an Entity object from a JSON object.
* @brief Destroys the object.
*
* @param generic The generic
* @since 0.100.0
*/
Entity(const Json::Value &object);
virtual ~Entity();
/*!
* @brief Replaces the Entity with a new one from a JSON string.
@ -355,6 +355,24 @@ public:
*/
void from_string(const string &json);
/*!
* @brief Returns the JSON object of the Entity
*
* @return JSON object
*
* @since before 0.11.0
*/
const string to_string() const;
/*!
* @brief Replaces the Entity with a new one from a JSON object.
*
* @param object JSON object
*
* @since 0.100.0
*/
void from_object(const Json::Value &object);
/*!
* @brief Returns the JSON object of the Entity
*
@ -520,7 +538,7 @@ protected:
};
/*!
* Return type for simple calls.
* Return type for Easy calls, with an Easy::Entity.
* @since 0.100.0
*/
typedef struct return_entity : return_base
@ -532,6 +550,10 @@ typedef struct return_entity : return_base
const Easy::GenericEntity &ent);
} return_entity;
/*!
* Return type for Easy calls, with a vector of Easy::Entity.
* @since 0.100.0
*/
typedef struct return_entity_vector : return_base
{
vector<Easy::GenericEntity> entities;

View File

@ -33,6 +33,13 @@ Easy::Entity::Entity(const string &json)
from_string(json);
}
Easy::Entity::Entity()
: _was_set(false)
{}
Easy::Entity::~Entity()
{}
void Easy::Entity::from_string(const string &json)
{
std::stringstream ss(json);
@ -57,20 +64,21 @@ void Easy::Entity::from_string(const string &json)
}
}
const string Easy::Entity::to_string() const
{
return _tree.toStyledString();
}
void Easy::Entity::from_object(const Json::Value &object)
{
_tree = object;
}
const Json::Value Easy::Entity::to_object() const
{
return _tree;
}
Easy::Entity::Entity(const Json::Value &object)
: _tree(object)
, _was_set(false)
{}
Easy::Entity::Entity()
: _was_set(false)
{}
bool Easy::Entity::check_valid(const std::vector<string> &attributes) const
{
for (const string &attribute: attributes)

View File

@ -75,9 +75,10 @@ API::API(const string &instance, const string &access_token)
, _exceptions(false)
, _proxy("")
, _proxy_userpw("")
{
//
}
{}
API::~API()
{}
void API::set_useragent(const std::string &useragent)
{

View File

@ -304,6 +304,13 @@ public:
*/
explicit API(const string &instance, const string &access_token);
/*!
* @brief Destroys the object.
*
* @since 0.100.0
*/
virtual ~API();
/*!
* @brief Sets the useragent. Default is mastodon-cpp/version.
*