diff --git a/.gitignore b/.gitignore index ecc66e3..57797e0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,4 @@ /build/ /doc/ /update_gh-pages.sh -/src/mastodon-cpp /src/examples/example99* diff --git a/CMakeLists.txt b/CMakeLists.txt index f7d5fa5..4152d6c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,9 @@ configure_file ( "${PROJECT_BINARY_DIR}/version.hpp" ) +# Announce that we are compiling mastodon-cpp (used in easy.hpp and examples) +add_definitions(-DMASTODON_CPP=1) + if(CMAKE_BUILD_TYPE STREQUAL "Debug") add_definitions(-DDEBUG=1) endif() diff --git a/src/easy/easy.hpp b/src/easy/easy.hpp index 3cf06f0..2b3ea39 100644 --- a/src/easy/easy.hpp +++ b/src/easy/easy.hpp @@ -21,10 +21,16 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +// If we are compiling mastodon-cpp, use another include path +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using std::string; using std::uint16_t; +using std::uint64_t; namespace Mastodon { @@ -49,6 +55,17 @@ public: Undefined }; + /*! + * @brief Describes the attachment type + */ + enum class attachment_type + { + image, + video, + gifv, + unknown + }; + /*! * @brief Constructs a new Easy object. * @@ -71,7 +88,7 @@ public: * * @param json JSON string */ - Account(const string &json); + explicit Account(const string &json); /*! * @brief Returns true if the account holds valid data @@ -109,12 +126,12 @@ public: /*! * @brief Returns number of followers */ - const std::uint64_t followers_count() const; + const uint64_t followers_count() const; /*! * @brief Returns number of people this account follows */ - const std::uint64_t following_count() const; + const uint64_t following_count() const; /*! * @brief Returns URL of header image @@ -129,13 +146,24 @@ public: /*! * @brief Returns account-ID */ - const std::uint64_t id() const; + const uint64_t id() const; /*! * @brief Returns true if the account is locked */ const bool locked() const; + /*! + * @brief Returns true if the account has been moved + */ + const bool has_moved() const; + + /*! + * @brief If the owner decided to switch accounts, new account is in + * this attribute + */ + const Account moved() const; + /*! * @brief Returns note */ @@ -159,7 +187,7 @@ public: /*! * @brief Returns number of statuses */ - const std::uint64_t statuses_count() const; + const uint64_t statuses_count() const; /*! * @brief Returns URL of the profile @@ -175,6 +203,37 @@ public: Json::Value _tree; bool _valid; }; + + /*! + * @brief Class to hold attachments + */ + class Attachment + { + public: + /*! + * @brief Constructs an attachment object from a JSON string. + * + * @param json JSON string + */ + explicit Attachment(const string &json); + + /*! + * @brief Returns true if the attachment holds valid data + */ + const bool valid() const; + + const uint64_t id() const; + const attachment_type type() const; + const string url() const; + const string remote_url() const; + const string preview_url() const; + const string text_url() const; + const string description() const; + + private: + Json::Value _tree; + bool _valid; + }; }; } diff --git a/src/examples/example01_dump_json.cpp b/src/examples/example01_dump_json.cpp index 32ffdec..7d29e3a 100644 --- a/src/examples/example01_dump_json.cpp +++ b/src/examples/example01_dump_json.cpp @@ -7,7 +7,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example02_parse_account.cpp b/src/examples/example02_parse_account.cpp index 78d27db..9ecfcc4 100644 --- a/src/examples/example02_parse_account.cpp +++ b/src/examples/example02_parse_account.cpp @@ -8,7 +8,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; using std::cout; diff --git a/src/examples/example03_mastocron.cpp b/src/examples/example03_mastocron.cpp index e2c8108..613114f 100644 --- a/src/examples/example03_mastocron.cpp +++ b/src/examples/example03_mastocron.cpp @@ -11,7 +11,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; using std::cout; diff --git a/src/examples/example04_update_credentials.cpp b/src/examples/example04_update_credentials.cpp index 0ae4991..7278e9a 100644 --- a/src/examples/example04_update_credentials.cpp +++ b/src/examples/example04_update_credentials.cpp @@ -6,7 +6,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example05_follow_unfollow.cpp b/src/examples/example05_follow_unfollow.cpp index 05d7b95..b2d2b95 100644 --- a/src/examples/example05_follow_unfollow.cpp +++ b/src/examples/example05_follow_unfollow.cpp @@ -8,7 +8,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example06_toot_delete-toot.cpp b/src/examples/example06_toot_delete-toot.cpp index 5fda1a1..6361b49 100644 --- a/src/examples/example06_toot_delete-toot.cpp +++ b/src/examples/example06_toot_delete-toot.cpp @@ -8,7 +8,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example07_register_app.cpp b/src/examples/example07_register_app.cpp index 1302900..a96e464 100644 --- a/src/examples/example07_register_app.cpp +++ b/src/examples/example07_register_app.cpp @@ -7,7 +7,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example08_rate_limiting.cpp b/src/examples/example08_rate_limiting.cpp index 2e90d6d..1255ccc 100644 --- a/src/examples/example08_rate_limiting.cpp +++ b/src/examples/example08_rate_limiting.cpp @@ -7,7 +7,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example09_streaming_api.cpp b/src/examples/example09_streaming_api.cpp index 127e38d..13de09e 100644 --- a/src/examples/example09_streaming_api.cpp +++ b/src/examples/example09_streaming_api.cpp @@ -9,7 +9,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example10_simplify.cpp b/src/examples/example10_simplify.cpp index 02b33da..baf4a53 100644 --- a/src/examples/example10_simplify.cpp +++ b/src/examples/example10_simplify.cpp @@ -6,7 +6,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API; diff --git a/src/examples/example11_post_media.cpp b/src/examples/example11_post_media.cpp index f9df024..0948ef3 100644 --- a/src/examples/example11_post_media.cpp +++ b/src/examples/example11_post_media.cpp @@ -8,7 +8,11 @@ #include #include #include -#include "mastodon-cpp/mastodon-cpp.hpp" +#ifdef MASTODON_CPP + #include "mastodon-cpp.hpp" +#else + #include +#endif using Mastodon::API;