mastodonpp  0.0.0
answer.hpp
1 /* This file is part of mastodonpp.
2  * Copyright © 2020 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 MASTODONPP_ANSWER_HPP
18 #define MASTODONPP_ANSWER_HPP
19 
20 #include <cstdint>
21 #include <string>
22 #include <string_view>
23 
24 namespace mastodonpp
25 {
26 
27 using std::uint8_t;
28 using std::uint16_t;
29 using std::string;
30 using std::string_view;
31 
41 {
50  uint8_t curl_error_code{0};
51 
57  string error_message;
58 
64  uint16_t http_status{0};
65 
71  string headers;
72 
78  string body;
79 
86  explicit operator bool() const;
87 
93  explicit operator string_view() const;
94 
100  friend std::ostream &operator <<(std::ostream &out,
101  const answer_type &answer);
102 };
103 
104 } // namespace mastodonpp
105 
106 #endif // MASTODONPP_ANSWER_HPP
mastodonpp::answer_type::headers
string headers
The headers of the response from the server.
Definition: answer.hpp:71
mastodonpp::answer_type::curl_error_code
uint8_t curl_error_code
The error code returned by libcurl.
Definition: answer.hpp:50
mastodonpp
C++ wrapper for the Mastodon API.
Definition: answer.cpp:19
mastodonpp::answer_type::body
string body
The response from the server, usually JSON.
Definition: answer.hpp:78
mastodonpp::answer_type::error_message
string error_message
The error message.
Definition: answer.hpp:57
mastodonpp::answer_type
Return type for Requests.
Definition: answer.hpp:40
mastodonpp::answer_type::operator<<
friend std::ostream & operator<<(std::ostream &out, const answer_type &answer)
Returns body as std::ostream.
Definition: answer.cpp:32
mastodonpp::answer_type::http_status
uint16_t http_status
HTTP status code.
Definition: answer.hpp:64