blob: 72ca3f74afcb31e398d5ed4525e5e85727c3786e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
/* 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
#include <map>
#include <string_view>
#include <variant>
namespace mastodonpp
{
using std::string_view;
using std::variant;
/*!
* @brief Holds API endpoints.
*
* @since 0.1.0
*
* @headerfile api.hpp mastodonpp/api.hpp
*/
class API
{
public:
/*!
* @brief An enumeration of all v1 %API endpoints.
*
* The original `/` are substituted with `_`.
*
* @since 0.1.0
*/
enum class v1
{
instance
};
/*!
* @brief An enumeration of all v2 %API endpoints.
*
* 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
*/
explicit API(const endpoint_type &endpoint);
/*!
* @brief Convert #endpoint_type to `std::string_view`.
*
* @since 0.1.0
*/
[[nodiscard]]
string_view to_string_view() const;
private:
const endpoint_type _endpoint;
};
} // namespace mastodonpp
#endif // MASTODONPP_API_HPP
|