mastodonpp  0.2.0
mastodonpp Reference

Using the library

Include mastodonpp.hpp, which then includes all other headers.

#include <mastodonpp/mastodonpp.hpp>

Use it in your CMake project like this:

find_package(mastodonpp REQUIRED CONFIG)
target_link_libraries(MyProject mastodonpp::mastodonpp)

Or compile your code with g++ $(pkg-config --cflags --libs mastodonpp).

Example

#include <mastodonpp/mastodonpp.hpp>
#include <iostream>
int main()
{
mastodonpp::Instance instance{"example.com", ""};
std::cout << "Maximum characters per post: "
<< instance.get_max_chars() << std::endl;
mastodonpp::Connection connection{instance};
auto answer{connection.get(mastodonpp::API::v1::instance)};
if (answer)
{
std::cout << answer << std::endl;
}
}

Input

  • All text input is expected to be UTF-8.
  • To send a file, use “@file:” followed by the file name as value in the parametermap.

Exceptions

Any unrecoverable libcurl error will be thrown as a mastodonpp::CURLException. Network errors will not be thrown, but reported via the return value.

Thread safety

The first time you construct an Instance or Connection , curl_global_init(3) is called. When the last Instance or Connection is destroyed, curl_global_cleanup(3) is called. Both are not thread safe.

Do not make 2 requests with the same Connection at the same time. You can create as many Connections as you want from one Instance.

If you are using libcurl with OpenSSL before 1.1.0, please read libcurl-thread(3).

mastodonpp::Connection::get
answer_type get(const endpoint_variant &endpoint, const parametermap &parameters)
Make a HTTP GET call with parameters.
Definition: connection.cpp:50
mastodonpp
C++ wrapper for the Mastodon API.
Definition: answer.cpp:22
mastodonpp::Instance::get_max_chars
uint64_t get_max_chars()
Returns the maximum number of characters per post.
Definition: instance.cpp:36
mastodonpp::Instance
Holds the access data of an instance.
Definition: instance.hpp:42
mastodonpp::Connection
Represents a connection to an instance. Used for requests.
Definition: connection.hpp:75