From 69740568e0a2ca32ac1518d34ce09ba77375e5fa Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 30 Mar 2018 20:16:31 +0200 Subject: [PATCH] Added constructors for empty Entities --- src/easy/account.cpp | 6 +++++- src/easy/account.hpp | 5 +++++ src/easy/attachment.cpp | 4 ++++ src/easy/attachment.hpp | 5 +++++ src/easy/card.cpp | 8 +++++--- src/easy/card.hpp | 5 +++++ src/easy/emoji.cpp | 8 +++++--- src/easy/emoji.hpp | 13 +++++++++---- src/easy/instance.cpp | 2 +- 9 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/easy/account.cpp b/src/easy/account.cpp index 1b8d675..229188a 100644 --- a/src/easy/account.cpp +++ b/src/easy/account.cpp @@ -32,6 +32,10 @@ Account::Account(const string &json) : Entity(json) {} +Account::Account() +: Entity() +{} + const string Account::acct() const { return get_string("acct"); @@ -105,7 +109,7 @@ const Account Account::moved() const return Account(get("moved").toStyledString()); } - return Account(""); + return Account(); } const string Account::note() const diff --git a/src/easy/account.hpp b/src/easy/account.hpp index f2b9992..fecbc5d 100644 --- a/src/easy/account.hpp +++ b/src/easy/account.hpp @@ -50,6 +50,11 @@ namespace Mastodon */ explicit Account(const string &json); + /*! + * @brief Constructs an empty Account object. + */ + Account(); + /*! * @brief Returns username * diff --git a/src/easy/attachment.cpp b/src/easy/attachment.cpp index 36fbb76..ece9766 100644 --- a/src/easy/attachment.cpp +++ b/src/easy/attachment.cpp @@ -30,6 +30,10 @@ Attachment::Attachment(const string &json) : Entity(json) {} +Attachment::Attachment() +: Entity() +{} + const double Attachment::aspect() const { return get_double("meta.original.aspect"); diff --git a/src/easy/attachment.hpp b/src/easy/attachment.hpp index cf200e5..3f39d1f 100644 --- a/src/easy/attachment.hpp +++ b/src/easy/attachment.hpp @@ -50,6 +50,11 @@ namespace Mastodon */ explicit Attachment(const string &json); + /*! + * @brief Constructs an empty Attachment object. + */ + Attachment(); + /*! * @brief Aspect of original image */ diff --git a/src/easy/card.cpp b/src/easy/card.cpp index 23bdcda..b3418b9 100644 --- a/src/easy/card.cpp +++ b/src/easy/card.cpp @@ -27,9 +27,11 @@ using std::uint64_t; Card::Card(const string &json) : Entity(json) -{ - // -} +{} + +Card::Card() +: Entity() +{} const string Card::author_name() const { diff --git a/src/easy/card.hpp b/src/easy/card.hpp index 88f5d8f..ed0b3a3 100644 --- a/src/easy/card.hpp +++ b/src/easy/card.hpp @@ -48,6 +48,11 @@ namespace Mastodon */ explicit Card(const string &json); + /*! + * @brief Constructs an empty Card object. + */ + Card(); + /*! * @brief Returns the name of the author */ diff --git a/src/easy/emoji.cpp b/src/easy/emoji.cpp index 60e7e6d..ea91df9 100644 --- a/src/easy/emoji.cpp +++ b/src/easy/emoji.cpp @@ -27,9 +27,11 @@ using std::uint64_t; Emoji::Emoji(const string &json) : Entity(json) -{ - // -} +{} + +Emoji::Emoji() +: Entity() +{} const string Emoji::shortcode() const { diff --git a/src/easy/emoji.hpp b/src/easy/emoji.hpp index 168b182..cf5d793 100644 --- a/src/easy/emoji.hpp +++ b/src/easy/emoji.hpp @@ -14,8 +14,8 @@ * along with this program. If not, see . */ -#ifndef MASTODON_CPP_EASY_CARD_HPP -#define MASTODON_CPP_EASY_CARD_HPP +#ifndef MASTODON_CPP_EASY_EMOJI_HPP +#define MASTODON_CPP_EASY_EMOJI_HPP #include @@ -39,12 +39,17 @@ namespace Mastodon { public: /*! - * @brief Constructs a Emoji object from a JSON string. + * @brief Constructs an Emoji object from a JSON string. * * @param json JSON string */ explicit Emoji(const string &json); + /*! + * @brief Constructs an empty Emoji object. + */ + Emoji(); + /*! * @brief Returns the shortcode of the emoji */ @@ -62,4 +67,4 @@ namespace Mastodon }; } -#endif // MASTODON_CPP_EASY_CARD_HPP +#endif // MASTODON_CPP_EASY_EMOJI_HPP diff --git a/src/easy/instance.cpp b/src/easy/instance.cpp index 1bd7e9c..f269a71 100644 --- a/src/easy/instance.cpp +++ b/src/easy/instance.cpp @@ -44,7 +44,7 @@ const Easy::Account Instance::contact_account() const } ttdebug << "Could not get data: contact_account\n"; - return Easy::Account(""); + return Easy::Account(); } const string Instance::description() const