mastodonpp  0.0.0
api.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_API_HPP
18 #define MASTODONPP_API_HPP
19 
20 #include <map>
21 #include <string_view>
22 #include <variant>
23 
24 namespace mastodonpp
25 {
26 
27 using std::string_view;
28 using std::variant;
29 
37 class API
38 {
39 public:
47  enum class v1
48  {
49  instance
50  };
51 
59  enum class v2
60  {
61  search
62  };
63 
69  using endpoint_type = variant<v1,v2>;
70 
79  explicit API(const endpoint_type &endpoint);
80 
86  [[nodiscard]]
87  string_view to_string_view() const;
88 
89 private:
90  const endpoint_type _endpoint;
91 };
92 
93 } // namespace mastodonpp
94 
95 #endif // MASTODONPP_API_HPP
mastodonpp::API::v2
v2
An enumeration of all v2 API endpoints.
Definition: api.hpp:59
mastodonpp::API::to_string_view
string_view to_string_view() const
Convert endpoint_type to std::string_view.
Definition: api.cpp:31
mastodonpp
C++ wrapper for the Mastodon API.
Definition: api.cpp:21
mastodonpp::API
Holds API endpoints.
Definition: api.hpp:37
mastodonpp::API::v1
v1
An enumeration of all v1 API endpoints.
Definition: api.hpp:47
mastodonpp::API::API
API(const endpoint_type &endpoint)
Constructs an API object. You should never need this.
Definition: api.cpp:27
mastodonpp::API::endpoint_type
variant< v1, v2 > endpoint_type
Type for endpoints. Either API::v1 or API::v2.
Definition: api.hpp:69