2020-01-03 10:24:31 +01:00
|
|
|
/* This file is part of mastodonpp.
|
|
|
|
* Copyright © 2020 tastytea <tastytea@tastytea.de>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Affero General Public License as published by
|
|
|
|
* the Free Software Foundation, version 3.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Affero General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MASTODONPP_RETURN_TYPES_HPP
|
|
|
|
#define MASTODONPP_RETURN_TYPES_HPP
|
|
|
|
|
|
|
|
#include <cstdint>
|
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
namespace mastodonpp
|
|
|
|
{
|
|
|
|
|
|
|
|
using std::uint8_t;
|
|
|
|
using std::uint16_t;
|
|
|
|
using std::string;
|
|
|
|
using std::string_view;
|
|
|
|
|
2020-01-03 10:59:04 +01:00
|
|
|
/*!
|
2020-01-03 13:05:00 +01:00
|
|
|
* @brief Return type for Request%s.
|
2020-01-03 10:59:04 +01:00
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*
|
|
|
|
* @section error Error codes
|
|
|
|
* | Code | Explanation |
|
|
|
|
* | --------: |:-------------------------------------------------------------|
|
|
|
|
* | 0 | No error. |
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
struct answer
|
|
|
|
{
|
2020-01-03 10:59:04 +01:00
|
|
|
/*!
|
|
|
|
* @brief @ref error "Error code".
|
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
uint8_t error_code;
|
2020-01-03 10:59:04 +01:00
|
|
|
/*!
|
|
|
|
* @brief The error message.
|
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
string error_message;
|
2020-01-03 10:59:04 +01:00
|
|
|
/*!
|
|
|
|
* @brief HTTP status code.
|
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
uint16_t http_status;
|
2020-01-03 10:59:04 +01:00
|
|
|
/*!
|
|
|
|
* @brief The response from the server, usually JSON.
|
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
string body;
|
|
|
|
|
2020-01-03 10:59:04 +01:00
|
|
|
/*!
|
2020-01-03 13:05:00 +01:00
|
|
|
* @brief Returns true if #error_code is 0, false otherwise.
|
2020-01-03 10:59:04 +01:00
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
explicit operator bool() const;
|
2020-01-03 10:59:04 +01:00
|
|
|
|
|
|
|
/*!
|
2020-01-03 13:05:00 +01:00
|
|
|
* @brief Returns #body as `std::string_view`.
|
2020-01-03 10:59:04 +01:00
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
explicit operator string_view() const;
|
2020-01-03 10:59:04 +01:00
|
|
|
|
|
|
|
/*!
|
2020-01-03 13:05:00 +01:00
|
|
|
* @brief Returns #body as `std::ostream`.
|
2020-01-03 10:59:04 +01:00
|
|
|
*
|
|
|
|
* @since 0.1.0
|
|
|
|
*/
|
2020-01-03 10:24:31 +01:00
|
|
|
friend std::ostream &operator <<(std::ostream &out, const answer &answer);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mastodonpp
|
|
|
|
|
|
|
|
#endif // MASTODONPP_RETURN_TYPES_HPP
|