Merge branch 'develop' into main
continuous-integration/drone/push Build is passing Details

This commit is contained in:
tastytea 2020-01-25 03:47:05 +01:00
commit e6c2db91fd
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
6 changed files with 25 additions and 16 deletions

View File

@ -19,8 +19,8 @@
link:{uri-mastodon-cpp}[mastodon-cpp].
We aim to create a library that is comfortable, yet minimal. All API endpoints
from Mastodon and Pleroma are stored in ``enum class``es, to counteract typos and
make your life easier. The network-facing code is built on
from Mastodon and Pleroma are stored in ``enum class``es, to counteract typos
and make your life easier. The network-facing code is built on
link:{uri-libcurl}[libcurl], a mature and stable library that is available on
virtually every operating system. The library does not parse the responses
itself, but returns to you the raw data, because we know everyone has their

View File

@ -23,7 +23,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang"
"-Wformat=2"
"-ftrapv"
"-fsanitize=undefined"
"-g"
"-Og"
"-fno-omit-frame-pointer")
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")

View File

@ -68,6 +68,9 @@ struct event_type
/*!
* @brief Represents a connection to an instance. Used for requests.
*
* Do not make 2 requests with the same Connection at the same time. You can
* create as many Connection%s as you want from one Instance.
*
* @since 0.1.0
*
* @headerfile connection.hpp mastodonpp/connection.hpp

View File

@ -79,7 +79,7 @@ public:
/*!
* @brief Cleans up curl and connection.
*
* Calls `curl_global_cleanup`, which is not thread-safe. For more
* May call `curl_global_cleanup`, which is not thread-safe. For more
* information consult [curl_global_cleanup(3)]
* (https://curl.haxx.se/libcurl/c/curl_global_cleanup.html).
*
@ -124,7 +124,7 @@ public:
{
char *cbuf{curl_easy_escape(_connection, url.data(),
static_cast<int>(url.size()))};
string sbuf{cbuf};
const string sbuf{cbuf};
curl_free(cbuf);
return sbuf;
}
@ -146,7 +146,7 @@ public:
{
char *cbuf{curl_easy_unescape(_connection, url.data(),
static_cast<int>(url.size()), nullptr)};
string sbuf{cbuf};
const string sbuf{cbuf};
curl_free(cbuf);
return sbuf;
}
@ -193,7 +193,7 @@ protected:
* @since 0.1.0
*/
[[nodiscard]]
string &get_buffer()
inline string &get_buffer()
{
return _curl_buffer_body;
}
@ -222,7 +222,7 @@ protected:
*
* @since 0.1.0
*/
void set_proxy(string_view proxy);
virtual void set_proxy(string_view proxy);
/*!
* @brief Set OAuth 2.0 Bearer Access Token.
@ -237,14 +237,14 @@ protected:
*
* @since 0.3.0
*/
void set_cainfo(string_view path);
virtual void set_cainfo(string_view path);
/*!
* @brief Sets the User-Agent.
*
* @since 0.3.0
*/
void set_useragent(string_view useragent);
virtual void set_useragent(string_view useragent);
private:
CURL *_connection;

View File

@ -38,6 +38,10 @@ using std::vector;
/*!
* @brief Holds the access data of an instance.
*
* Instance%s are needed to initialize Connection%s. All properties you set
* here (with set_proxy(), set_useragent() and so on) are copied to every
* Connection you initialize afterwards.
*
* @since 0.1.0
*
* @headerfile instance.hpp mastodonpp/instance.hpp
@ -144,7 +148,7 @@ public:
* Sets also the proxy for all Connection%s that are initialized with this
* Instance afterwards.
*/
void set_proxy(const string_view proxy)
void set_proxy(const string_view proxy) override
{
_proxy = proxy;
CURLWrapper::set_proxy(proxy);
@ -183,7 +187,7 @@ public:
*
* @since 0.3.0
*/
void set_cainfo(string_view path)
void set_cainfo(string_view path) override
{
_cainfo = path;
CURLWrapper::set_cainfo(path);
@ -197,7 +201,7 @@ public:
*
* @since 0.3.0
*/
void set_useragent(const string_view useragent)
void set_useragent(const string_view useragent) override
{
_useragent = useragent;
CURLWrapper::set_useragent(useragent);
@ -206,7 +210,7 @@ public:
/*!
* @brief Simplifies obtaining an OAuth 2.0 Bearer Access Token.
*
* * Create an Instance() and initialize this class with it.
* * Create an Instance and initialize this class with it.
* * Call step_1() to get the URI your user has to visit.
* * Get the authorization code from your user.
* * Call step_2() with the code.
@ -230,6 +234,8 @@ public:
* @endcode
*
* @since 0.3.0
*
* @headerfile instance.hpp mastodonpp/instance.hpp
*/
class ObtainToken : public CURLWrapper
{
@ -272,7 +278,8 @@ public:
* The `body` of the returned @link answer_type answer @endlink
* contains only the access token, not the whole JSON response.
*
* The access token will be set in the parent Instance.
* The access token will be set in the Instance you initialized
* this ObtainToken with.
*
* @param code The authorization code you got from the user.
*

View File

@ -70,7 +70,7 @@ string Connection::get_new_stream_contents()
{
buffer_mutex.lock();
auto &buffer{get_buffer()};
auto buffer_copy{buffer};
const string buffer_copy{buffer};
buffer.clear();
buffer_mutex.unlock();
return buffer_copy;