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(string_view hostname, string_view access_token);
54 
60  [[nodiscard]]
61  inline string_view get_hostname() const
62  {
63  return _hostname;
64  }
65 
73  [[nodiscard]]
74  inline string_view get_baseuri() const
75  {
76  return _baseuri;
77  }
78 
84  [[nodiscard]]
85  inline string_view get_access_token() const
86  {
87  return _access_token;
88  }
89 
95  [[nodiscard]]
96  uint64_t get_max_chars();
97 
98 private:
99  const string _hostname;
100  const string _baseuri;
101  string _access_token;
102  uint64_t _max_chars;
103 };
104 
105 } // namespace mastodonpp
106 
107 #endif // MASTODONPP_INSTANCE_HPP
mastodonpp::Instance::get_access_token
string_view get_access_token() const
Returns the access token.
Definition: instance.hpp:85
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::Instance
Instance(string_view hostname, string_view access_token)
Construct a new Instance object.
Definition: instance.cpp:26
mastodonpp::Instance::get_baseuri
string_view get_baseuri() const
Returns the base URI.
Definition: instance.hpp:74
mastodonpp::Instance
Holds the access data of an instance.
Definition: instance.hpp:40
mastodonpp::CURLWrapper
Handles the details of network connections.
Definition: curl_wrapper.hpp:80
mastodonpp::Instance::get_hostname
string_view get_hostname() const
Returns the hostname.
Definition: instance.hpp:61