From e4d2b1759e1df504fe221f7b6aadd4e9413a0ccb Mon Sep 17 00:00:00 2001 From: tastytea Date: Sat, 31 Mar 2018 04:37:36 +0200 Subject: [PATCH] Completed most of the incomplete Entitys (Attachment is still incomplete) --- CMakeLists.txt | 2 +- src/easy/all.hpp | 12 ++++++------ src/easy/context.cpp | 35 +++++++++++++++++++++++++++++++++++ src/easy/context.hpp | 18 ++++++++++-------- src/easy/notification.cpp | 15 +++++++++++---- src/easy/notification.hpp | 4 +++- src/easy/results.cpp | 17 +++++++++++++++++ src/easy/results.hpp | 4 +++- 8 files changed, 86 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ffefdd2..a7a786a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastodon-cpp - VERSION 0.7.12 + VERSION 0.7.13 LANGUAGES CXX ) diff --git a/src/easy/all.hpp b/src/easy/all.hpp index 3d5ce14..17d14b0 100644 --- a/src/easy/all.hpp +++ b/src/easy/all.hpp @@ -24,15 +24,15 @@ #include "easy/application.hpp" #include "easy/attachment.hpp" #include "easy/card.hpp" - //#include "easy/context.hpp" + #include "easy/context.hpp" #include "easy/emoji.hpp" #include "easy/instance.hpp" #include "easy/list.hpp" #include "easy/mention.hpp" - //#include "easy/notification.hpp" + #include "easy/notification.hpp" #include "easy/relationship.hpp" #include "easy/report.hpp" - //#include "easy/results.hpp" + #include "easy/results.hpp" #include "easy/status.hpp" #include "easy/tag.hpp" #else @@ -41,15 +41,15 @@ #include #include #include - //#include + #include #include #include #include #include - //#include + #include #include #include - //#include + #include #include #include #endif diff --git a/src/easy/context.cpp b/src/easy/context.cpp index d206c1d..9f521a7 100644 --- a/src/easy/context.cpp +++ b/src/easy/context.cpp @@ -15,6 +15,7 @@ */ #include "context.hpp" +#include "macros.hpp" using namespace Mastodon; using Context = Easy::Context; @@ -26,3 +27,37 @@ Context::Context(const string &json) Context::Context() : Entity() {} + +const std::vector Context::ancestors() const +{ + const Json::Value node = get("ancestors"); + if (node.isArray()) + { + std::vector vec; + for (const Json::Value &value : node) + { + vec.push_back(Easy::Status(value.toStyledString())); + } + return vec; + } + + ttdebug << "Could not get data: ancestors\n"; + return {}; +} + +const std::vector Context::descendants() const +{ + const Json::Value node = get("descendants"); + if (node.isArray()) + { + std::vector vec; + for (const Json::Value &value : node) + { + vec.push_back(Easy::Status(value.toStyledString())); + } + return vec; + } + + ttdebug << "Could not get data: descendants\n"; + return {}; +} diff --git a/src/easy/context.hpp b/src/easy/context.hpp index 466cf42..37fa469 100644 --- a/src/easy/context.hpp +++ b/src/easy/context.hpp @@ -24,9 +24,11 @@ #ifdef MASTODON_CPP #include "mastodon-cpp.hpp" #include "easy.hpp" + #include "status.hpp" #else #include #include + #include #endif using std::string; @@ -51,15 +53,15 @@ namespace Mastodon */ Context(); - // /*! - // * @brief Returns the ancestors of the Status as vector of Statuses - // */ - // const std::vector ancestors() const; + /*! + * @brief Returns the ancestors of the Status as vector of Statuses + */ + const std::vector ancestors() const; - // /*! - // * @brief Returns the descendants of the Status as vector of Statuses - // */ - // const std::vector descendants() const; + /*! + * @brief Returns the descendants of the Status as vector of Statuses + */ + const std::vector descendants() const; }; } diff --git a/src/easy/notification.cpp b/src/easy/notification.cpp index 77dce58..2bd4e24 100644 --- a/src/easy/notification.cpp +++ b/src/easy/notification.cpp @@ -50,10 +50,17 @@ const uint64_t Notification::id() const return get_uint64("id"); } -// const Status Notification::status() const -// { -// // -// } +const Easy::Status Notification::status() const +{ + const Json::Value node = get("restatusblog"); + if (node.isObject()) + { + return Easy::Status(node.toStyledString()); + } + + ttdebug << "Could not get data: status\n"; + return Easy::Status(); +} const Easy::notification_type Notification::type() const { diff --git a/src/easy/notification.hpp b/src/easy/notification.hpp index 2eda6ba..ab5ff44 100644 --- a/src/easy/notification.hpp +++ b/src/easy/notification.hpp @@ -26,10 +26,12 @@ #include "mastodon-cpp.hpp" #include "easy.hpp" #include "account.hpp" + #include "status.hpp" #else #include #include #include + #include #endif using std::string; @@ -75,7 +77,7 @@ namespace Mastodon * @brief Returns the Status associated with the notification, if * applicable */ - // const Status status() const; + const Status status() const; /*! * @brief Returns notification type diff --git a/src/easy/results.cpp b/src/easy/results.cpp index 59c5cea..966231b 100644 --- a/src/easy/results.cpp +++ b/src/easy/results.cpp @@ -46,6 +46,23 @@ const std::vector Results::accounts() const return {}; } +const std::vector Results::statuses() const +{ + const Json::Value node = get("statuses"); + if (node.isArray()) + { + std::vector vec; + for (const Json::Value &value : node) + { + vec.push_back(Easy::Status(value.toStyledString())); + } + return vec; + } + + ttdebug << "Could not get data: statuses\n"; + return {}; +} + const std::vector Results::hashtags() const { return get_vector("hashtags"); diff --git a/src/easy/results.hpp b/src/easy/results.hpp index 7c2b6a0..81859e2 100644 --- a/src/easy/results.hpp +++ b/src/easy/results.hpp @@ -25,10 +25,12 @@ #include "mastodon-cpp.hpp" #include "easy.hpp" #include "account.hpp" + #include "status.hpp" #else #include #include #include + #include #endif using std::string; @@ -61,7 +63,7 @@ namespace Mastodon /*! * @brief Returns an array of matched Statuses */ - // const std::vector statuses() const; + const std::vector statuses() const; /*! * @brief Returns an array of matched hashtags