mastodon-cpp  0.110.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 Affero 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 Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero 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 #include "types.hpp"
23 
24 using std::uint8_t;
25 using std::uint16_t;
26 using std::string;
27 
28 namespace Mastodon
29 {
35  typedef struct return_base
36  {
42  uint8_t error_code = 0;
43 
49  string error_message;
50 
56  uint16_t http_error_code = 0;
57 
63  operator bool() const;
64 
70  operator uint8_t() const;
71  } return_base;
72 
93  typedef struct return_call : return_base
94  {
100  string answer;
101 
102  return_call();
103 
114  return_call(const uint8_t ec, const string &em,
115  const uint16_t hec, const string &a);
116 
127  return_call(const error ec, const string &em,
128  const uint16_t hec, const string &a);
129 
135  operator const string() const;
136 
142  friend std::ostream &operator <<(std::ostream &out,
143  const return_call &ret);
144  } return_call;
145 }
146 
147 #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:93
string answer
The response from the server.
Definition: return_types.hpp:100
struct Mastodon::return_base return_base
Basis for return types.
uint8_t error_code
Error code.
Definition: return_types.hpp:42
uint16_t http_error_code
HTTP error code.
Definition: return_types.hpp:56
Collection of things to interface with server software that implements the Mastodon API.
Definition: mastodon-cpp.hpp:47
string error_message
The error message, or "".
Definition: return_types.hpp:49
friend std::ostream & operator<<(std::ostream &out, const return_call &ret)
Same es return_call::answer.
Definition: return_types.cpp:43
Basis for return types.
Definition: return_types.hpp:35