mastodon-cpp  0.106.0
return_types.hpp
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2019 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODON_CPP_RETURN_TYPES_HPP
18 #define MASTODON_CPP_RETURN_TYPES_HPP
19 
20 #include <cstdint>
21 #include <string>
22 
23 using std::uint8_t;
24 using std::uint16_t;
25 using std::string;
26 
27 namespace Mastodon
28 {
34  typedef struct return_base
35  {
41  uint8_t error_code = 0;
42 
48  string error_message;
49 
55  uint16_t http_error_code = 0;
56 
62  operator bool() const;
63 
69  operator uint8_t() const;
70  } return_base;
71 
92  typedef struct return_call : return_base
93  {
99  string answer;
100 
101  return_call();
102 
113  return_call(const uint8_t ec, const string &em,
114  const uint16_t hec, const string &a);
115 
121  operator const string() const;
122 
128  friend std::ostream &operator <<(std::ostream &out,
129  const return_call &ret);
130  } return_call;
131 }
132 
133 #endif // MASTODON_CPP_RETURN_TYPES_HPP
Mastodon::return_call return_call
Return type for API calls.
Return type for API calls.
Definition: return_types.hpp:92
string answer
The response from the server.
Definition: return_types.hpp:99
struct Mastodon::return_base return_base
Basis for return types.
uint8_t error_code
Error code.
Definition: return_types.hpp:41
uint16_t http_error_code
HTTP error code.
Definition: return_types.hpp:55
Collection of things to interface with server software that implements the Mastodon API...
Definition: mastodon-cpp.hpp:46
string error_message
The error message, or "".
Definition: return_types.hpp:48
std::ostream & operator<<(std::ostream &out, const return_call &ret)
Definition: return_types.cpp:43
Basis for return types.
Definition: return_types.hpp:34