From 8c7493e68e185caefa6db48f4d1d764258e86fb8 Mon Sep 17 00:00:00 2001 From: tastytea Date: Fri, 13 Nov 2020 13:45:59 +0100 Subject: [PATCH] Reformat header files. --- include/api.hpp | 9 +++---- include/connection.hpp | 53 +++++++++++++++++----------------------- include/curl_wrapper.hpp | 44 +++++++++++++++------------------ include/exceptions.hpp | 7 +++--- include/helpers.hpp | 5 ++-- include/instance.hpp | 32 ++++++++++-------------- include/mastodonpp.hpp | 2 +- include/types.hpp | 30 ++++++++++------------- src/log.hpp | 12 ++++----- 9 files changed, 84 insertions(+), 110 deletions(-) diff --git a/include/api.hpp b/include/api.hpp index 5d0cbe1..024547f 100644 --- a/include/api.hpp +++ b/include/api.hpp @@ -322,7 +322,7 @@ public: * * @since 0.1.0 */ - using endpoint_type = variant; + using endpoint_type = variant; /*! * @brief Constructs an API object. You should never need this. @@ -339,17 +339,16 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - inline string_view to_string_view() const + [[nodiscard]] inline string_view to_string_view() const { return _endpoint_map.at(_endpoint); } private: const endpoint_type _endpoint; - static const map _endpoint_map; + static const map _endpoint_map; }; } // namespace mastodonpp -#endif // MASTODONPP_API_HPP +#endif // MASTODONPP_API_HPP diff --git a/include/connection.hpp b/include/connection.hpp index 67bc6f1..9917987 100644 --- a/include/connection.hpp +++ b/include/connection.hpp @@ -40,7 +40,7 @@ using std::vector; * * @since 0.1.0 */ -using endpoint_variant = variant; +using endpoint_variant = variant; /*! * @brief A stream event. @@ -106,10 +106,10 @@ public: ~Connection() noexcept override = default; //! Copy assignment operator - Connection& operator=(const Connection &other) = delete; + Connection &operator=(const Connection &other) = delete; //! Move assignment operator - Connection& operator=(Connection &&other) noexcept = delete; + Connection &operator=(Connection &&other) noexcept = delete; /*! * @brief Make a HTTP GET call with parameters. @@ -129,9 +129,8 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - answer_type get(const endpoint_variant &endpoint, - const parametermap ¶meters); + [[nodiscard]] answer_type get(const endpoint_variant &endpoint, + const parametermap ¶meters); /*! * @brief Make a HTTP GET call. @@ -145,8 +144,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - inline answer_type get(const endpoint_variant &endpoint) + [[nodiscard]] inline answer_type get(const endpoint_variant &endpoint) { return get(endpoint, {}); } @@ -171,9 +169,8 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - answer_type post(const endpoint_variant &endpoint, - const parametermap ¶meters); + [[nodiscard]] answer_type post(const endpoint_variant &endpoint, + const parametermap ¶meters); /*! * @brief Make a HTTP POST call. @@ -182,8 +179,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - inline answer_type post(const endpoint_variant &endpoint) + [[nodiscard]] inline answer_type post(const endpoint_variant &endpoint) { return post(endpoint, {}); } @@ -197,9 +193,8 @@ public: * * @since 0.2.0 */ - [[nodiscard]] - answer_type patch(const endpoint_variant &endpoint, - const parametermap ¶meters); + [[nodiscard]] answer_type patch(const endpoint_variant &endpoint, + const parametermap ¶meters); /*! * @brief Make a HTTP PATCH call. @@ -208,8 +203,7 @@ public: * * @since 0.2.0 */ - [[nodiscard]] - inline answer_type patch(const endpoint_variant &endpoint) + [[nodiscard]] inline answer_type patch(const endpoint_variant &endpoint) { return patch(endpoint, {}); } @@ -223,9 +217,8 @@ public: * * @since 0.2.0 */ - [[nodiscard]] - answer_type put(const endpoint_variant &endpoint, - const parametermap ¶meters); + [[nodiscard]] answer_type put(const endpoint_variant &endpoint, + const parametermap ¶meters); /*! * @brief Make a HTTP PUT call. @@ -234,8 +227,7 @@ public: * * @since 0.2.0 */ - [[nodiscard]] - inline answer_type put(const endpoint_variant &endpoint) + [[nodiscard]] inline answer_type put(const endpoint_variant &endpoint) { return put(endpoint, {}); } @@ -249,9 +241,8 @@ public: * * @since 0.2.0 */ - [[nodiscard]] - answer_type del(const endpoint_variant &endpoint, - const parametermap ¶meters); + [[nodiscard]] answer_type del(const endpoint_variant &endpoint, + const parametermap ¶meters); /*! * @brief Make a HTTP DELETE call. @@ -260,8 +251,7 @@ public: * * @since 0.2.0 */ - [[nodiscard]] - inline answer_type del(const endpoint_variant &endpoint) + [[nodiscard]] inline answer_type del(const endpoint_variant &endpoint) { return del(endpoint, {}); } @@ -291,14 +281,15 @@ public: { CURLWrapper::cancel_stream(); } + private: const Instance &_instance; const string_view _baseuri; - [[nodiscard]] - string endpoint_to_uri(const endpoint_variant &endpoint) const; + [[nodiscard]] string + endpoint_to_uri(const endpoint_variant &endpoint) const; }; } // namespace mastodonpp -#endif // MASTODONPP_CONNECTION_HPP +#endif // MASTODONPP_CONNECTION_HPP diff --git a/include/curl_wrapper.hpp b/include/curl_wrapper.hpp index 52af3b2..37c8d4b 100644 --- a/include/curl_wrapper.hpp +++ b/include/curl_wrapper.hpp @@ -17,9 +17,8 @@ #ifndef MASTODONPP_CURL_WRAPPER_HPP #define MASTODONPP_CURL_WRAPPER_HPP -#include "types.hpp" - #include "curl/curl.h" +#include "types.hpp" #include #include @@ -39,11 +38,11 @@ using std::string_view; */ enum class http_method { - GET, // NOLINT(readability-identifier-naming) - POST, // NOLINT(readability-identifier-naming) - PATCH, // NOLINT(readability-identifier-naming) - PUT, // NOLINT(readability-identifier-naming) - DELETE // NOLINT(readability-identifier-naming) + GET, // NOLINT(readability-identifier-naming) + POST, // NOLINT(readability-identifier-naming) + PATCH, // NOLINT(readability-identifier-naming) + PUT, // NOLINT(readability-identifier-naming) + DELETE // NOLINT(readability-identifier-naming) }; /*! @@ -92,10 +91,10 @@ public: virtual ~CURLWrapper() noexcept; //! Copy assignment operator - CURLWrapper& operator=(const CURLWrapper &other) = delete; + CURLWrapper &operator=(const CURLWrapper &other) = delete; //! Move assignment operator - CURLWrapper& operator=(CURLWrapper &&other) noexcept = delete; + CURLWrapper &operator=(CURLWrapper &&other) noexcept = delete; /*! * @brief Returns pointer to the CURL easy handle. @@ -162,8 +161,7 @@ public: */ void setup_connection_properties(string_view proxy, string_view access_token, - string_view cainfo, - string_view useragent); + string_view cainfo, string_view useragent); protected: /*! @@ -185,17 +183,16 @@ protected: * * @since 0.1.0 */ - [[nodiscard]] - answer_type make_request(const http_method &method, string uri, - const parametermap ¶meters); + [[nodiscard]] answer_type make_request(const http_method &method, + string uri, + const parametermap ¶meters); /*! * @brief Returns a reference to the buffer libcurl writes into. * * @since 0.1.0 */ - [[nodiscard]] - inline string &get_buffer() + [[nodiscard]] inline string &get_buffer() { return _curl_buffer_body; } @@ -233,7 +230,6 @@ protected: */ void set_access_token(string_view access_token); - /*! * @brief Set path to Certificate Authority (CA) bundle. * @@ -280,7 +276,7 @@ private: static inline size_t writer_body_wrapper(char *data, size_t sz, size_t nmemb, void *f) { - return static_cast(f)->writer_body(data, sz, nmemb); + return static_cast(f)->writer_body(data, sz, nmemb); } //! @copydoc writer_body @@ -290,7 +286,7 @@ private: static inline size_t writer_header_wrapper(char *data, size_t sz, size_t nmemb, void *f) { - return static_cast(f)->writer_header(data, sz, nmemb); + return static_cast(f)->writer_header(data, sz, nmemb); } /*! @@ -308,8 +304,8 @@ private: curl_off_t dltotal, curl_off_t dlnow, curl_off_t ultotal, curl_off_t ulnow) { - return static_cast(f)->progress(clientp, dltotal, dlnow, - ultotal, ulnow); + return static_cast(f)->progress(clientp, dltotal, dlnow, + ultotal, ulnow); } /*! @@ -352,8 +348,8 @@ private: * * @since 0.2.0 */ - static void add_mime_part(curl_mime *mime, - string_view name, string_view data); + static void add_mime_part(curl_mime *mime, string_view name, + string_view data); /*! * @brief Convert parametermap to `*curl_mime`. @@ -375,4 +371,4 @@ private: } // namespace mastodonpp -#endif // MASTODONPP_CURL_WRAPPER_HPP +#endif // MASTODONPP_CURL_WRAPPER_HPP diff --git a/include/exceptions.hpp b/include/exceptions.hpp index 5cbad42..07ba4e2 100644 --- a/include/exceptions.hpp +++ b/include/exceptions.hpp @@ -26,9 +26,9 @@ namespace mastodonpp { -using std::uint16_t; using std::exception; using std::string; +using std::uint16_t; /*! * @brief Exception for libcurl errors. @@ -77,8 +77,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - const char *what() const noexcept override; + [[nodiscard]] const char *what() const noexcept override; private: const string _message; @@ -87,4 +86,4 @@ private: } // namespace mastodonpp -#endif // MASTODONPP_EXCEPTIONS_HPP +#endif // MASTODONPP_EXCEPTIONS_HPP diff --git a/include/helpers.hpp b/include/helpers.hpp index 898b66f..d806347 100644 --- a/include/helpers.hpp +++ b/include/helpers.hpp @@ -42,9 +42,8 @@ using std::string; * * @since 0.4.0 */ -[[nodiscard]] -string unescape_html(string html); +[[nodiscard]] string unescape_html(string html); } // namespace mastodonpp -#endif // MASTODONPP_HELPERS_HPP +#endif // MASTODONPP_HELPERS_HPP diff --git a/include/instance.hpp b/include/instance.hpp index 3bcbaa3..de691f0 100644 --- a/include/instance.hpp +++ b/include/instance.hpp @@ -29,9 +29,9 @@ namespace mastodonpp { -using std::uint64_t; using std::string; using std::string_view; +using std::uint64_t; using std::vector; /*! @@ -72,10 +72,10 @@ public: ~Instance() noexcept override = default; //! Copy assignment operator - Instance& operator=(const Instance &other) = delete; + Instance &operator=(const Instance &other) = delete; //! Move assignment operator - Instance& operator=(Instance &&other) noexcept = delete; + Instance &operator=(Instance &&other) noexcept = delete; /*! * @brief Set the properties of the connection of the calling class up. @@ -98,8 +98,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - inline string_view get_hostname() const noexcept + [[nodiscard]] inline string_view get_hostname() const noexcept { return _hostname; } @@ -111,8 +110,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - inline string_view get_baseuri() const noexcept + [[nodiscard]] inline string_view get_baseuri() const noexcept { return _baseuri; } @@ -122,8 +120,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - inline string_view get_access_token() const noexcept + [[nodiscard]] inline string_view get_access_token() const noexcept { return _access_token; } @@ -153,8 +150,7 @@ public: * * @since 0.1.0 */ - [[nodiscard]] - uint64_t get_max_chars() noexcept; + [[nodiscard]] uint64_t get_max_chars() noexcept; /*! @copydoc CURLWrapper::set_proxy(string_view) * @@ -176,8 +172,7 @@ public: * * @since 0.3.0 */ - [[nodiscard]] - answer_type get_nodeinfo(); + [[nodiscard]] answer_type get_nodeinfo(); /*! * @brief Returns the allowed mime types for statuses. @@ -284,9 +279,9 @@ public: * * @since 0.3.0 */ - [[nodiscard]] - answer_type step_1(string_view client_name, string_view scopes, - string_view website); + [[nodiscard]] answer_type step_1(string_view client_name, + string_view scopes, + string_view website); /*! * @brief Creates a token via `/oauth/token`. @@ -303,8 +298,7 @@ public: * * @since 0.3.0 */ - [[nodiscard]] - answer_type step_2(string_view code); + [[nodiscard]] answer_type step_2(string_view code); private: Instance &_instance; @@ -327,4 +321,4 @@ private: } // namespace mastodonpp -#endif // MASTODONPP_INSTANCE_HPP +#endif // MASTODONPP_INSTANCE_HPP diff --git a/include/mastodonpp.hpp b/include/mastodonpp.hpp index 98733d6..e3b3952 100644 --- a/include/mastodonpp.hpp +++ b/include/mastodonpp.hpp @@ -119,4 +119,4 @@ namespace mastodonpp {} // namespace mastodonpp -#endif // MASTODONPP_HPP +#endif // MASTODONPP_HPP diff --git a/include/types.hpp b/include/types.hpp index aebb25d..3db0992 100644 --- a/include/types.hpp +++ b/include/types.hpp @@ -31,13 +31,13 @@ namespace mastodonpp { -using std::uint8_t; -using std::uint16_t; using std::map; using std::ostream; +using std::pair; using std::string; using std::string_view; -using std::pair; +using std::uint16_t; +using std::uint8_t; using std::variant; using std::vector; @@ -60,16 +60,16 @@ using std::vector; * * @since 0.1.0 */ -using parametermap = - map>>; +using parametermap = map>>; /*! * @brief A single parameter of a parametermap. * * @since 0.1.0 */ -using parameterpair = - pair>>; +using parameterpair = pair>>; /*! * @brief Return type for Request%s. @@ -138,7 +138,7 @@ struct answer_type * * @since 0.1.0 */ - friend ostream &operator <<(ostream &out, const answer_type &answer); + friend ostream &operator<<(ostream &out, const answer_type &answer); /*! * @brief Returns the value of a header field. @@ -149,8 +149,7 @@ struct answer_type * * @since 0.1.0 */ - [[nodiscard]] - string_view get_header(string_view field) const; + [[nodiscard]] string_view get_header(string_view field) const; /*! * @brief Returns the parameters needed for the next entries. @@ -159,8 +158,7 @@ struct answer_type * * @since 0.3.0 */ - [[nodiscard]] - inline parametermap next() const + [[nodiscard]] inline parametermap next() const { return parse_pagination(true); } @@ -173,8 +171,7 @@ struct answer_type * * @since 0.3.0 */ - [[nodiscard]] - inline parametermap prev() const + [[nodiscard]] inline parametermap prev() const { return parse_pagination(false); } @@ -188,10 +185,9 @@ private: * * @since 0.3.0 */ - [[nodiscard]] - parametermap parse_pagination(bool next) const; + [[nodiscard]] parametermap parse_pagination(bool next) const; }; } // namespace mastodonpp -#endif // MASTODONPP_TYPES_HPP +#endif // MASTODONPP_TYPES_HPP diff --git a/src/log.hpp b/src/log.hpp index 8f74847..9b5a09d 100644 --- a/src/log.hpp +++ b/src/log.hpp @@ -23,7 +23,7 @@ namespace mastodonpp { -using std::cerr; // NOLINT(misc-unused-using-decls) +using std::cerr; // NOLINT(misc-unused-using-decls) using std::string_view; //! @private @@ -41,17 +41,17 @@ constexpr auto shorten_filename(const string_view &filename) } // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define commonlog cerr << '[' << shorten_filename(__FILE__) \ - << ':' << __LINE__ << ']' +#define commonlog \ + cerr << '[' << shorten_filename(__FILE__) << ':' << __LINE__ << ']' #ifndef NDEBUG // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) -#define debuglog commonlog << " DEBUG: " +# define debuglog commonlog << " DEBUG: " #else - #define debuglog false && cerr +# define debuglog false && cerr #endif // NOLINTNEXTLINE(cppcoreguidelines-macro-usage) #define errorlog commonlog << " ERROR: " } // namespace mastodonpp -#endif // MASTODONPP_LOG_HPP +#endif // MASTODONPP_LOG_HPP