Reformat header files.
This commit is contained in:
parent
63d2497966
commit
8c7493e68e
|
@ -322,7 +322,7 @@ public:
|
|||
*
|
||||
* @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.
|
||||
|
@ -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_type,string_view> _endpoint_map;
|
||||
static const map<endpoint_type, string_view> _endpoint_map;
|
||||
};
|
||||
|
||||
} // namespace mastodonpp
|
||||
|
||||
#endif // MASTODONPP_API_HPP
|
||||
#endif // MASTODONPP_API_HPP
|
||||
|
|
|
@ -40,7 +40,7 @@ using std::vector;
|
|||
*
|
||||
* @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.
|
||||
|
@ -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
|
||||
|
|
|
@ -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 <mutex>
|
||||
#include <string>
|
||||
|
@ -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<CURLWrapper*>(f)->writer_body(data, sz, nmemb);
|
||||
return static_cast<CURLWrapper *>(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<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 ultotal, curl_off_t ulnow)
|
||||
{
|
||||
return static_cast<CURLWrapper*>(f)->progress(clientp, dltotal, dlnow,
|
||||
ultotal, ulnow);
|
||||
return static_cast<CURLWrapper *>(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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -119,4 +119,4 @@
|
|||
namespace mastodonpp
|
||||
{} // namespace mastodonpp
|
||||
|
||||
#endif // MASTODONPP_HPP
|
||||
#endif // MASTODONPP_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<string_view, variant<string_view, vector<string_view>>>;
|
||||
using parametermap = map<string_view,
|
||||
variant<string_view, vector<string_view>>>;
|
||||
|
||||
/*!
|
||||
* @brief A single parameter of a parametermap.
|
||||
*
|
||||
* @since 0.1.0
|
||||
*/
|
||||
using parameterpair =
|
||||
pair<string_view, variant<string_view, vector<string_view>>>;
|
||||
using parameterpair = pair<string_view,
|
||||
variant<string_view, vector<string_view>>>;
|
||||
|
||||
/*!
|
||||
* @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
|
||||
|
|
12
src/log.hpp
12
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user