mastodon-cpp  0.104.0
Public Member Functions | Public Attributes | Friends | List of all members
Mastodon::return_call Struct Reference

Return type for API calls. More...

#include <return_types.hpp>

Inheritance diagram for Mastodon::return_call:
Mastodon::return_base

Public Member Functions

 return_call (const uint8_t ec, const string &em, const uint16_t hec, const string &a)
 Return type for Mastodon::API. More...
 
 operator const string () const
 Same es return_call::answer. More...
 
- Public Member Functions inherited from Mastodon::return_base
 operator bool ()
 true if return_base::error_code is 0, otherwise false. More...
 
 operator uint8_t ()
 Same as return_base::error_code. More...
 

Public Attributes

string answer
 The response from the server. More...
 
- Public Attributes inherited from Mastodon::return_base
uint8_t error_code = 0
 Error code. More...
 
string error_message
 The error message, or "". More...
 
uint16_t http_error_code = 0
 HTTP error code. More...
 

Friends

std::ostream & operator<< (std::ostream &out, const return_call &ret)
 Same es return_call::answer. More...
 

Detailed Description

Return type for API calls.

Example:

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
}
Since
0.100.0
Examples:
example01_get_public_timeline.cpp.

Constructor & Destructor Documentation

◆ return_call()

return_call::return_call ( const uint8_t  ec,
const string &  em,
const uint16_t  hec,
const string &  a 
)

Return type for Mastodon::API.

Parameters
ecError code
emError message
hecHTTP error code
aAnswer
Since
0.100.0
54  : answer(a)
55 {
56  error_code = ec;
57  error_message = em;
58  http_error_code = hec;
59 }
string answer
The response from the server.
Definition: return_types.hpp:99
uint8_t error_code
Error code.
Definition: return_types.hpp:41
uint16_t http_error_code
HTTP error code.
Definition: return_types.hpp:55
string error_message
The error message, or "".
Definition: return_types.hpp:48

Member Function Documentation

◆ operator const string()

return_call::operator const string ( ) const

Same es return_call::answer.

Since
0.100.0
39 {
40  return answer;
41 }
string answer
The response from the server.
Definition: return_types.hpp:99

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  out,
const return_call ret 
)
friend

Same es return_call::answer.

Since
0.100.0

Member Data Documentation

◆ answer

string Mastodon::return_call::answer

The response from the server.

Since
0.100.0
Examples:
example01_get_public_timeline.cpp.

The documentation for this struct was generated from the following files: