mtx::client::utils namespace

Utility namespace.

Classes

struct MxcUrl
Representation of Matrix Content (MXC) URIs.

Functions

template<class T>
auto deserialize(std::string_view data) -> T
deserialize a type or string from json.
template<class T>
auto serialize(const T& obj) -> std::string
serialize a type or string to json.
auto parse_mxc_url(const std::string& url) -> MxcUrl
Parse a matrix content URI into its server & media_id components.
auto is_number(const std::string& s) -> bool
Check if the given string represents a number.
auto random_token(uint8_t len = 12, bool with_symbols = true) -> std::string noexcept
Generates a random string of the given size.
auto query_params(const std::map<std::string, std::string>& params) -> std::string noexcept
Construct query string from the given parameter pairs.
auto url_encode(std::string_view s) -> std::string noexcept
URL-encode the input string.

Function documentation

template<class T>
T mtx::client::utils::deserialize(std::string_view data)

deserialize a type or string from json.

Used internally to deserialize the response types for the various http methods.

template<class T>
std::string mtx::client::utils::serialize(const T& obj)

serialize a type or string to json.

Used internally to serialize the request types for the various http methods.

MxcUrl mtx::client::utils::parse_mxc_url(const std::string& url)

Parse a matrix content URI into its server & media_id components.

bool mtx::client::utils::is_number(const std::string& s)

Check if the given string represents a number.

std::string mtx::client::utils::random_token(uint8_t len = 12, bool with_symbols = true) noexcept

Generates a random string of the given size.

std::string mtx::client::utils::query_params(const std::map<std::string, std::string>& params) noexcept

Construct query string from the given parameter pairs.

std::string mtx::client::utils::url_encode(std::string_view s) noexcept

URL-encode the input string.