Reformat header files.

This commit is contained in:
tastytea 2020-11-13 13:45:59 +01:00
parent 63d2497966
commit 8c7493e68e
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
9 changed files with 84 additions and 110 deletions

View File

@ -322,7 +322,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
using endpoint_type = variant<v1,v2,oauth,other,pleroma>; using endpoint_type = variant<v1, v2, oauth, other, pleroma>;
/*! /*!
* @brief Constructs an API object. You should never need this. * @brief Constructs an API object. You should never need this.
@ -339,17 +339,16 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] inline string_view to_string_view() const
inline string_view to_string_view() const
{ {
return _endpoint_map.at(_endpoint); return _endpoint_map.at(_endpoint);
} }
private: private:
const endpoint_type _endpoint; const endpoint_type _endpoint;
static const map<endpoint_type,string_view> _endpoint_map; static const map<endpoint_type, string_view> _endpoint_map;
}; };
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_API_HPP #endif // MASTODONPP_API_HPP

View File

@ -40,7 +40,7 @@ using std::vector;
* *
* @since 0.1.0 * @since 0.1.0
*/ */
using endpoint_variant = variant<API::endpoint_type,string_view>; using endpoint_variant = variant<API::endpoint_type, string_view>;
/*! /*!
* @brief A stream event. * @brief A stream event.
@ -106,10 +106,10 @@ public:
~Connection() noexcept override = default; ~Connection() noexcept override = default;
//! Copy assignment operator //! Copy assignment operator
Connection& operator=(const Connection &other) = delete; Connection &operator=(const Connection &other) = delete;
//! Move assignment operator //! Move assignment operator
Connection& operator=(Connection &&other) noexcept = delete; Connection &operator=(Connection &&other) noexcept = delete;
/*! /*!
* @brief Make a HTTP GET call with parameters. * @brief Make a HTTP GET call with parameters.
@ -129,9 +129,8 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type get(const endpoint_variant &endpoint,
answer_type get(const endpoint_variant &endpoint, const parametermap &parameters);
const parametermap &parameters);
/*! /*!
* @brief Make a HTTP GET call. * @brief Make a HTTP GET call.
@ -145,8 +144,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] inline answer_type get(const endpoint_variant &endpoint)
inline answer_type get(const endpoint_variant &endpoint)
{ {
return get(endpoint, {}); return get(endpoint, {});
} }
@ -171,9 +169,8 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type post(const endpoint_variant &endpoint,
answer_type post(const endpoint_variant &endpoint, const parametermap &parameters);
const parametermap &parameters);
/*! /*!
* @brief Make a HTTP POST call. * @brief Make a HTTP POST call.
@ -182,8 +179,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] inline answer_type post(const endpoint_variant &endpoint)
inline answer_type post(const endpoint_variant &endpoint)
{ {
return post(endpoint, {}); return post(endpoint, {});
} }
@ -197,9 +193,8 @@ public:
* *
* @since 0.2.0 * @since 0.2.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type patch(const endpoint_variant &endpoint,
answer_type patch(const endpoint_variant &endpoint, const parametermap &parameters);
const parametermap &parameters);
/*! /*!
* @brief Make a HTTP PATCH call. * @brief Make a HTTP PATCH call.
@ -208,8 +203,7 @@ public:
* *
* @since 0.2.0 * @since 0.2.0
*/ */
[[nodiscard]] [[nodiscard]] inline answer_type patch(const endpoint_variant &endpoint)
inline answer_type patch(const endpoint_variant &endpoint)
{ {
return patch(endpoint, {}); return patch(endpoint, {});
} }
@ -223,9 +217,8 @@ public:
* *
* @since 0.2.0 * @since 0.2.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type put(const endpoint_variant &endpoint,
answer_type put(const endpoint_variant &endpoint, const parametermap &parameters);
const parametermap &parameters);
/*! /*!
* @brief Make a HTTP PUT call. * @brief Make a HTTP PUT call.
@ -234,8 +227,7 @@ public:
* *
* @since 0.2.0 * @since 0.2.0
*/ */
[[nodiscard]] [[nodiscard]] inline answer_type put(const endpoint_variant &endpoint)
inline answer_type put(const endpoint_variant &endpoint)
{ {
return put(endpoint, {}); return put(endpoint, {});
} }
@ -249,9 +241,8 @@ public:
* *
* @since 0.2.0 * @since 0.2.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type del(const endpoint_variant &endpoint,
answer_type del(const endpoint_variant &endpoint, const parametermap &parameters);
const parametermap &parameters);
/*! /*!
* @brief Make a HTTP DELETE call. * @brief Make a HTTP DELETE call.
@ -260,8 +251,7 @@ public:
* *
* @since 0.2.0 * @since 0.2.0
*/ */
[[nodiscard]] [[nodiscard]] inline answer_type del(const endpoint_variant &endpoint)
inline answer_type del(const endpoint_variant &endpoint)
{ {
return del(endpoint, {}); return del(endpoint, {});
} }
@ -291,14 +281,15 @@ public:
{ {
CURLWrapper::cancel_stream(); CURLWrapper::cancel_stream();
} }
private: private:
const Instance &_instance; const Instance &_instance;
const string_view _baseuri; const string_view _baseuri;
[[nodiscard]] [[nodiscard]] string
string endpoint_to_uri(const endpoint_variant &endpoint) const; endpoint_to_uri(const endpoint_variant &endpoint) const;
}; };
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_CONNECTION_HPP #endif // MASTODONPP_CONNECTION_HPP

View File

@ -17,9 +17,8 @@
#ifndef MASTODONPP_CURL_WRAPPER_HPP #ifndef MASTODONPP_CURL_WRAPPER_HPP
#define MASTODONPP_CURL_WRAPPER_HPP #define MASTODONPP_CURL_WRAPPER_HPP
#include "types.hpp"
#include "curl/curl.h" #include "curl/curl.h"
#include "types.hpp"
#include <mutex> #include <mutex>
#include <string> #include <string>
@ -39,11 +38,11 @@ using std::string_view;
*/ */
enum class http_method enum class http_method
{ {
GET, // NOLINT(readability-identifier-naming) GET, // NOLINT(readability-identifier-naming)
POST, // NOLINT(readability-identifier-naming) POST, // NOLINT(readability-identifier-naming)
PATCH, // NOLINT(readability-identifier-naming) PATCH, // NOLINT(readability-identifier-naming)
PUT, // NOLINT(readability-identifier-naming) PUT, // NOLINT(readability-identifier-naming)
DELETE // NOLINT(readability-identifier-naming) DELETE // NOLINT(readability-identifier-naming)
}; };
/*! /*!
@ -92,10 +91,10 @@ public:
virtual ~CURLWrapper() noexcept; virtual ~CURLWrapper() noexcept;
//! Copy assignment operator //! Copy assignment operator
CURLWrapper& operator=(const CURLWrapper &other) = delete; CURLWrapper &operator=(const CURLWrapper &other) = delete;
//! Move assignment operator //! Move assignment operator
CURLWrapper& operator=(CURLWrapper &&other) noexcept = delete; CURLWrapper &operator=(CURLWrapper &&other) noexcept = delete;
/*! /*!
* @brief Returns pointer to the CURL easy handle. * @brief Returns pointer to the CURL easy handle.
@ -162,8 +161,7 @@ public:
*/ */
void setup_connection_properties(string_view proxy, void setup_connection_properties(string_view proxy,
string_view access_token, string_view access_token,
string_view cainfo, string_view cainfo, string_view useragent);
string_view useragent);
protected: protected:
/*! /*!
@ -185,17 +183,16 @@ protected:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type make_request(const http_method &method,
answer_type make_request(const http_method &method, string uri, string uri,
const parametermap &parameters); const parametermap &parameters);
/*! /*!
* @brief Returns a reference to the buffer libcurl writes into. * @brief Returns a reference to the buffer libcurl writes into.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] inline string &get_buffer()
inline string &get_buffer()
{ {
return _curl_buffer_body; return _curl_buffer_body;
} }
@ -233,7 +230,6 @@ protected:
*/ */
void set_access_token(string_view access_token); void set_access_token(string_view access_token);
/*! /*!
* @brief Set path to Certificate Authority (CA) bundle. * @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, static inline size_t writer_body_wrapper(char *data, size_t sz,
size_t nmemb, void *f) size_t nmemb, void *f)
{ {
return static_cast<CURLWrapper*>(f)->writer_body(data, sz, nmemb); return static_cast<CURLWrapper *>(f)->writer_body(data, sz, nmemb);
} }
//! @copydoc writer_body //! @copydoc writer_body
@ -290,7 +286,7 @@ private:
static inline size_t writer_header_wrapper(char *data, size_t sz, static inline size_t writer_header_wrapper(char *data, size_t sz,
size_t nmemb, void *f) size_t nmemb, void *f)
{ {
return static_cast<CURLWrapper*>(f)->writer_header(data, sz, nmemb); return static_cast<CURLWrapper *>(f)->writer_header(data, sz, nmemb);
} }
/*! /*!
@ -308,8 +304,8 @@ private:
curl_off_t dltotal, curl_off_t dlnow, curl_off_t dltotal, curl_off_t dlnow,
curl_off_t ultotal, curl_off_t ulnow) curl_off_t ultotal, curl_off_t ulnow)
{ {
return static_cast<CURLWrapper*>(f)->progress(clientp, dltotal, dlnow, return static_cast<CURLWrapper *>(f)->progress(clientp, dltotal, dlnow,
ultotal, ulnow); ultotal, ulnow);
} }
/*! /*!
@ -352,8 +348,8 @@ private:
* *
* @since 0.2.0 * @since 0.2.0
*/ */
static void add_mime_part(curl_mime *mime, static void add_mime_part(curl_mime *mime, string_view name,
string_view name, string_view data); string_view data);
/*! /*!
* @brief Convert parametermap to `*curl_mime`. * @brief Convert parametermap to `*curl_mime`.
@ -375,4 +371,4 @@ private:
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_CURL_WRAPPER_HPP #endif // MASTODONPP_CURL_WRAPPER_HPP

View File

@ -26,9 +26,9 @@
namespace mastodonpp namespace mastodonpp
{ {
using std::uint16_t;
using std::exception; using std::exception;
using std::string; using std::string;
using std::uint16_t;
/*! /*!
* @brief Exception for libcurl errors. * @brief Exception for libcurl errors.
@ -77,8 +77,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] const char *what() const noexcept override;
const char *what() const noexcept override;
private: private:
const string _message; const string _message;
@ -87,4 +86,4 @@ private:
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_EXCEPTIONS_HPP #endif // MASTODONPP_EXCEPTIONS_HPP

View File

@ -42,9 +42,8 @@ using std::string;
* *
* @since 0.4.0 * @since 0.4.0
*/ */
[[nodiscard]] [[nodiscard]] string unescape_html(string html);
string unescape_html(string html);
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_HELPERS_HPP #endif // MASTODONPP_HELPERS_HPP

View File

@ -29,9 +29,9 @@
namespace mastodonpp namespace mastodonpp
{ {
using std::uint64_t;
using std::string; using std::string;
using std::string_view; using std::string_view;
using std::uint64_t;
using std::vector; using std::vector;
/*! /*!
@ -72,10 +72,10 @@ public:
~Instance() noexcept override = default; ~Instance() noexcept override = default;
//! Copy assignment operator //! Copy assignment operator
Instance& operator=(const Instance &other) = delete; Instance &operator=(const Instance &other) = delete;
//! Move assignment operator //! 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. * @brief Set the properties of the connection of the calling class up.
@ -98,8 +98,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] inline string_view get_hostname() const noexcept
inline string_view get_hostname() const noexcept
{ {
return _hostname; return _hostname;
} }
@ -111,8 +110,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] inline string_view get_baseuri() const noexcept
inline string_view get_baseuri() const noexcept
{ {
return _baseuri; return _baseuri;
} }
@ -122,8 +120,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] inline string_view get_access_token() const noexcept
inline string_view get_access_token() const noexcept
{ {
return _access_token; return _access_token;
} }
@ -153,8 +150,7 @@ public:
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] uint64_t get_max_chars() noexcept;
uint64_t get_max_chars() noexcept;
/*! @copydoc CURLWrapper::set_proxy(string_view) /*! @copydoc CURLWrapper::set_proxy(string_view)
* *
@ -176,8 +172,7 @@ public:
* *
* @since 0.3.0 * @since 0.3.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type get_nodeinfo();
answer_type get_nodeinfo();
/*! /*!
* @brief Returns the allowed mime types for statuses. * @brief Returns the allowed mime types for statuses.
@ -284,9 +279,9 @@ public:
* *
* @since 0.3.0 * @since 0.3.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type step_1(string_view client_name,
answer_type step_1(string_view client_name, string_view scopes, string_view scopes,
string_view website); string_view website);
/*! /*!
* @brief Creates a token via `/oauth/token`. * @brief Creates a token via `/oauth/token`.
@ -303,8 +298,7 @@ public:
* *
* @since 0.3.0 * @since 0.3.0
*/ */
[[nodiscard]] [[nodiscard]] answer_type step_2(string_view code);
answer_type step_2(string_view code);
private: private:
Instance &_instance; Instance &_instance;
@ -327,4 +321,4 @@ private:
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_INSTANCE_HPP #endif // MASTODONPP_INSTANCE_HPP

View File

@ -119,4 +119,4 @@
namespace mastodonpp namespace mastodonpp
{} // namespace mastodonpp {} // namespace mastodonpp
#endif // MASTODONPP_HPP #endif // MASTODONPP_HPP

View File

@ -31,13 +31,13 @@
namespace mastodonpp namespace mastodonpp
{ {
using std::uint8_t;
using std::uint16_t;
using std::map; using std::map;
using std::ostream; using std::ostream;
using std::pair;
using std::string; using std::string;
using std::string_view; using std::string_view;
using std::pair; using std::uint16_t;
using std::uint8_t;
using std::variant; using std::variant;
using std::vector; using std::vector;
@ -60,16 +60,16 @@ using std::vector;
* *
* @since 0.1.0 * @since 0.1.0
*/ */
using parametermap = using parametermap = map<string_view,
map<string_view, variant<string_view, vector<string_view>>>; variant<string_view, vector<string_view>>>;
/*! /*!
* @brief A single parameter of a parametermap. * @brief A single parameter of a parametermap.
* *
* @since 0.1.0 * @since 0.1.0
*/ */
using parameterpair = using parameterpair = pair<string_view,
pair<string_view, variant<string_view, vector<string_view>>>; variant<string_view, vector<string_view>>>;
/*! /*!
* @brief Return type for Request%s. * @brief Return type for Request%s.
@ -138,7 +138,7 @@ struct answer_type
* *
* @since 0.1.0 * @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. * @brief Returns the value of a header field.
@ -149,8 +149,7 @@ struct answer_type
* *
* @since 0.1.0 * @since 0.1.0
*/ */
[[nodiscard]] [[nodiscard]] string_view get_header(string_view field) const;
string_view get_header(string_view field) const;
/*! /*!
* @brief Returns the parameters needed for the next entries. * @brief Returns the parameters needed for the next entries.
@ -159,8 +158,7 @@ struct answer_type
* *
* @since 0.3.0 * @since 0.3.0
*/ */
[[nodiscard]] [[nodiscard]] inline parametermap next() const
inline parametermap next() const
{ {
return parse_pagination(true); return parse_pagination(true);
} }
@ -173,8 +171,7 @@ struct answer_type
* *
* @since 0.3.0 * @since 0.3.0
*/ */
[[nodiscard]] [[nodiscard]] inline parametermap prev() const
inline parametermap prev() const
{ {
return parse_pagination(false); return parse_pagination(false);
} }
@ -188,10 +185,9 @@ private:
* *
* @since 0.3.0 * @since 0.3.0
*/ */
[[nodiscard]] [[nodiscard]] parametermap parse_pagination(bool next) const;
parametermap parse_pagination(bool next) const;
}; };
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_TYPES_HPP #endif // MASTODONPP_TYPES_HPP

View File

@ -23,7 +23,7 @@
namespace mastodonpp namespace mastodonpp
{ {
using std::cerr; // NOLINT(misc-unused-using-decls) using std::cerr; // NOLINT(misc-unused-using-decls)
using std::string_view; using std::string_view;
//! @private //! @private
@ -41,17 +41,17 @@ constexpr auto shorten_filename(const string_view &filename)
} }
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define commonlog cerr << '[' << shorten_filename(__FILE__) \ #define commonlog \
<< ':' << __LINE__ << ']' cerr << '[' << shorten_filename(__FILE__) << ':' << __LINE__ << ']'
#ifndef NDEBUG #ifndef NDEBUG
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define debuglog commonlog << " DEBUG: " # define debuglog commonlog << " DEBUG: "
#else #else
#define debuglog false && cerr # define debuglog false && cerr
#endif #endif
// NOLINTNEXTLINE(cppcoreguidelines-macro-usage) // NOLINTNEXTLINE(cppcoreguidelines-macro-usage)
#define errorlog commonlog << " ERROR: " #define errorlog commonlog << " ERROR: "
} // namespace mastodonpp } // namespace mastodonpp
#endif // MASTODONPP_LOG_HPP #endif // MASTODONPP_LOG_HPP