mastodonpp/include/api.hpp

96 lines
2.1 KiB
C++
Raw Normal View History

2020-01-03 12:45:55 +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_API_HPP
#define MASTODONPP_API_HPP
2020-01-04 09:12:54 +01:00
#include <map>
2020-01-05 10:35:38 +01:00
#include <string_view>
2020-01-04 09:12:54 +01:00
#include <variant>
namespace mastodonpp
2020-01-03 12:45:55 +01:00
{
2020-01-05 10:35:38 +01:00
using std::string_view;
2020-01-04 09:12:54 +01:00
using std::variant;
2020-01-03 12:45:55 +01:00
/*!
2020-01-04 09:12:54 +01:00
* @brief Holds API endpoints.
2020-01-03 12:45:55 +01:00
*
* @since 0.1.0
2020-01-04 12:04:47 +01:00
*
* @headerfile api.hpp mastodonpp/api.hpp
2020-01-03 12:45:55 +01:00
*/
2020-01-04 09:12:54 +01:00
class API
2020-01-03 12:45:55 +01:00
{
2020-01-04 09:12:54 +01:00
public:
/*!
2020-01-04 12:04:47 +01:00
* @brief An enumeration of all v1 %API endpoints.
2020-01-04 09:12:54 +01:00
*
* The original `/` are substituted with `_`.
*
* @since 0.1.0
*/
enum class v1
{
instance
};
/*!
2020-01-04 12:04:47 +01:00
* @brief An enumeration of all v2 %API endpoints.
2020-01-04 09:12:54 +01:00
*
* The original `/` are substituted with `_`.
*
* @since 0.1.0
*/
enum class v2
{
search
};
/*!
* @brief Type for endpoints. Either API::v1 or API::v2.
*
* @since 0.1.0
*/
using endpoint_type = variant<v1,v2>;
/*!
* @brief Constructs an API object. You should never need this.
*
* This constructor exists to hide away the class members, which are used
* internally.
*
* @since 0.1.0
*/
2020-01-05 10:35:38 +01:00
explicit API(const endpoint_type &endpoint);
2020-01-04 09:12:54 +01:00
/*!
2020-01-05 10:35:38 +01:00
* @brief Convert #endpoint_type to `std::string_view`.
2020-01-04 09:12:54 +01:00
*
* @since 0.1.0
*/
2020-01-04 13:31:22 +01:00
[[nodiscard]]
2020-01-05 10:35:38 +01:00
string_view to_string_view() const;
2020-01-04 09:12:54 +01:00
private:
const endpoint_type _endpoint;
2020-01-03 12:45:55 +01:00
};
2020-01-04 09:12:54 +01:00
} // namespace mastodonpp
2020-01-03 12:45:55 +01:00
#endif // MASTODONPP_API_HPP