diff --git a/README.adoc b/README.adoc index 5460a9e..9e1405c 100644 --- a/README.adoc +++ b/README.adoc @@ -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 diff --git a/cmake/debug_flags.cmake b/cmake/debug_flags.cmake index 0009039..6f177d9 100644 --- a/cmake/debug_flags.cmake +++ b/cmake/debug_flags.cmake @@ -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") diff --git a/include/connection.hpp b/include/connection.hpp index 957483a..1d3a273 100644 --- a/include/connection.hpp +++ b/include/connection.hpp @@ -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 diff --git a/include/curl_wrapper.hpp b/include/curl_wrapper.hpp index 4c6b1ef..0088197 100644 --- a/include/curl_wrapper.hpp +++ b/include/curl_wrapper.hpp @@ -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(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(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; diff --git a/include/instance.hpp b/include/instance.hpp index 5b578fa..225f106 100644 --- a/include/instance.hpp +++ b/include/instance.hpp @@ -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. * diff --git a/src/connection.cpp b/src/connection.cpp index 77e7ad0..1b19833 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -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;