diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/mastodonpp.hpp | 47 | ||||
-rw-r--r-- | include/return_types.hpp | 47 |
2 files changed, 94 insertions, 0 deletions
diff --git a/include/mastodonpp.hpp b/include/mastodonpp.hpp index 606e61a..080d4b2 100644 --- a/include/mastodonpp.hpp +++ b/include/mastodonpp.hpp @@ -20,14 +20,61 @@ #include "return_types.hpp" #include <string> +/*! + * @mainpage mastodonpp Reference + * + * @section using Using the library + * + * Include mastodonpp.hpp, which then includes all other headers. + * + * @code + * #include <mastodonpp/mastodonpp.hpp> + * @endcode + * + * Use it in your CMake project like this: + * + * @code + * find_package(mastodonpp REQUIRED CONFIG) + * target_link_libraries(MyProject mastodonpp::mastodonpp) + * @endcode + * + * Or compile your code with `g++ $(pkg-config --cflags --libs mastodonpp)`. + * + * @section Example + * + * @code + * mastodonpp::API masto("example.com", ""); + * @endcode + */ + namespace mastodonpp { using std::string; +/*! + * @brief C++ wrapper for the Mastodon API. + * + * All text input is expected to be UTF-8. + * + * @since 0.1.0 + * + */ + class API { public: + /*! + * @brief Construct a new API object. + * + * To register your application, leave access_token blank and call + * API::register_app1() and API::register_app2(). + * + * @param instance The hostname of your instance. + * @param access_token Your access token. + * + * @since 0.1.0 + */ explicit API(string instance, string access_token); private: diff --git a/include/return_types.hpp b/include/return_types.hpp index e9d7db8..7d09519 100644 --- a/include/return_types.hpp +++ b/include/return_types.hpp @@ -29,15 +29,62 @@ using std::uint16_t; using std::string; using std::string_view; +/*! + * @brief Return type for API calls. + * + * @since 0.1.0 + * + * @section error Error codes + * | Code | Explanation | + * | --------: |:-------------------------------------------------------------| + * | 0 | No error. | + */ struct answer { + /*! + * @brief @ref error "Error code". + * + * @since 0.1.0 + */ uint8_t error_code; + /*! + * @brief The error message. + * + * @since 0.1.0 + */ string error_message; + /*! + * @brief HTTP status code. + * + * @since 0.1.0 + */ uint16_t http_status; + /*! + * @brief The response from the server, usually JSON. + * + * @since 0.1.0 + */ string body; + /*! + * @brief Returns true if answer::error_code is 0, false otherwise. + * + * @since 0.1.0 + */ explicit operator bool() const; + + /*! + * @brief Returns answer::body as std::string_view. + * + * @since 0.1.0 + */ explicit operator string_view() const; + + /*! + * @brief Returns answer::body as std::ostream. + * + * @since 0.1.0 + */ friend std::ostream &operator <<(std::ostream &out, const answer &answer); }; |