Added documentation for return_base and return_call.
This commit is contained in:
parent
da1ee09640
commit
c854230f95
|
@ -39,32 +39,93 @@ using std::string;
|
|||
namespace Mastodon
|
||||
{
|
||||
/*!
|
||||
* Base return type.
|
||||
* @since 0.100.0
|
||||
* @brief Basis for return types.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
typedef struct return_base
|
||||
{
|
||||
uint8_t error_code = 0; // NOTE: http://mazack.org/unix/errno.php
|
||||
/*!
|
||||
* @brief @ref error "Error code".
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
uint8_t error_code = 0;
|
||||
|
||||
/*!
|
||||
* @brief The error message, or "".
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
string error_message;
|
||||
|
||||
/*!
|
||||
* @brief true if return_base::error_code is 0, otherwise false.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
operator bool();
|
||||
|
||||
/*!
|
||||
* @brief Same as return_base::error_code.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
operator uint8_t();
|
||||
} return_base;
|
||||
|
||||
/*!
|
||||
* Return type for API calls.
|
||||
* @since 0.100.0
|
||||
* @brief Return type for API calls.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* Mastodon::return_call ret = masto.get(Mastodon::API::v1::instance);
|
||||
* if (!ret) // Or ret.error_code != 0
|
||||
* {
|
||||
* cout << "Error " << std::to_string(ret.error_code);
|
||||
* cout << " (HTTP " << std::to_string(ret.http_error_code) << "): ";
|
||||
* cout << ret.error_message << endl
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* cout << ret << endl; // Or ret.answer
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
typedef struct return_call : return_base
|
||||
{
|
||||
/*!
|
||||
* @brief HTTP error code.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
uint16_t http_error_code = 0;
|
||||
|
||||
/*!
|
||||
* @brief The response from the server.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
string answer;
|
||||
|
||||
return_call();
|
||||
return_call(const uint8_t ec, const string &em,
|
||||
const uint16_t hec, const string &a);
|
||||
|
||||
/*!
|
||||
* @brief Same es return_call::answer.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
operator const string() const;
|
||||
|
||||
/*!
|
||||
* @brief Same es return_call::answer.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
friend std::ostream &operator <<(std::ostream &out,
|
||||
const return_call &ret);
|
||||
} return_call;
|
||||
|
|
Reference in New Issue
Block a user