mastodonpp  0.0.0
instance.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_INSTANCE_HPP
18 #define MASTODONPP_INSTANCE_HPP
19 
20 #include "curl_wrapper.hpp"
21 
22 #include <cstdint>
23 #include <string>
24 #include <string_view>
25 
26 namespace mastodonpp
27 {
28 
29 using std::uint64_t;
30 using std::string;
31 using std::string_view;
32 
40 class Instance : public CURLWrapper
41 {
42 public:
53  explicit Instance(const string_view &hostname,
54  const string_view &access_token);
55 
61  [[nodiscard]]
62  inline string_view get_hostname() const
63  {
64  return _hostname;
65  }
66 
74  [[nodiscard]]
75  inline string_view get_baseuri() const
76  {
77  return _baseuri;
78  }
79 
85  [[nodiscard]]
86  inline string_view get_access_token() const
87  {
88  return _access_token;
89  }
90 
96  [[nodiscard]]
97  uint64_t get_max_chars();
98 
99 private:
100  const string _hostname;
101  const string _baseuri;
102  string _access_token;
103  uint64_t _max_chars;
104 };
105 
106 } // namespace mastodonpp
107 
108 #endif // MASTODONPP_INSTANCE_HPP
mastodonpp::Instance::get_access_token
string_view get_access_token() const
Returns the access token.
Definition: instance.hpp:86
mastodonpp
C++ wrapper for the Mastodon API.
Definition: answer.cpp:19
mastodonpp::Instance::get_max_chars
uint64_t get_max_chars()
Returns the maximum number of characters per post.
Definition: instance.cpp:33
mastodonpp::Instance::get_baseuri
string_view get_baseuri() const
Returns the base URI.
Definition: instance.hpp:75
mastodonpp::Instance
Holds the access data of an instance.
Definition: instance.hpp:40
mastodonpp::Instance::Instance
Instance(const string_view &hostname, const string_view &access_token)
Construct a new Instance object.
Definition: instance.cpp:26
mastodonpp::CURLWrapper
Handles the details of network connections.
Definition: curl_wrapper.hpp:78
mastodonpp::Instance::get_hostname
string_view get_hostname() const
Returns the hostname.
Definition: instance.hpp:62