mastodon-cpp  0.110.0
types_easy.hpp
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2019 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 MASTODON_CPP_EASY_TYPES_EASY_HPP
18 #define MASTODON_CPP_EASY_TYPES_EASY_HPP
19 
20 #include <string>
21 #include <utility>
22 #include <chrono>
23 #include <cstdint>
24 
25 using std::string;
26 using std::chrono::system_clock;
27 using std::uint64_t;
28 
29 namespace Mastodon
30 {
31 namespace Easy
32 {
38  enum class event_type
39  {
40  Update,
42  Delete,
43  Error,
44  Filters_changed,
45  Undefined
46  };
47 
53  // TODO: What about instance-only?
54  enum class visibility_type
55  {
56  Direct,
57  Private,
58  Unlisted,
59  Public,
60  Undefined
61  };
62 
68  // TODO: Look up what Pleroma returns.
69  enum class attachment_type
70  {
71  Image,
72  Video,
73  Gifv,
74  Unknown,
75  Undefined
76  };
77 
83  enum class card_type
84  {
85  Link,
86  Photo,
87  Video,
88  Rich,
89  Undefined
90  };
91 
97  enum class notification_type
98  {
99  Mention,
100  Reblog,
101  Favourite,
102  Follow,
103  Undefined
104  };
105 
111  enum class context_type
112  {
113  Home,
114  Notifications,
115  Public,
116  Thread,
117  Undefined
118  };
119 
125  typedef struct stream_event_type
126  {
127  event_type type = event_type::Undefined;
128  string data;
130 
131  [[deprecated("Replaced by Mastodon::Easy::stream_event_type")]]
133 
139  typedef struct alert_type
140  {
141  Easy::notification_type type = Easy::notification_type::Undefined;
142  bool pushreq = false;
143  } alert_type;
144 
150  struct time_type
151  {
152  system_clock::time_point timepoint = system_clock::time_point();
153 
154  operator const system_clock::time_point() const;
155 
161  operator const string() const;
162 
168  friend std::ostream &operator <<(std::ostream &out,
169  const Easy::time_type &t);
170 
190  const string strtime(const string &format,
191  const bool &local = true) const;
192  };
193 
194  [[deprecated("Replaced by Mastodon::Easy::time_type")]]
195  typedef time_type time;
196 
202  typedef struct account_field_type
203  {
204  const string name;
205  const string value;
206  Easy::time_type verified_at;
208 
214  typedef struct urls_type
215  {
216  string streaming_api;
217  } urls_type;
218 
222  typedef struct stats_type
223  {
224  uint64_t user_count = 0;
225  uint64_t status_count = 0;
226  uint64_t domain_count = 0;
227  } stats_type;
228 
232  typedef struct poll_options_type
233  {
234  string title;
235  uint64_t votes_count = 0;
237 }
238 }
239 #endif // MASTODON_CPP_EASY_TYPES_EASY_HPP
Class to hold notifications.
Definition: notification.hpp:40
Type for time. Converts to time_point and string.
Definition: types_easy.hpp:150
Class to hold mentions.
Definition: mention.hpp:39
Statistics returned by Instance::stats().
Definition: types_easy.hpp:222
Used for stream events.
Definition: types_easy.hpp:125
struct Mastodon::Easy::urls_type urls_type
URLs returned by Instance::urls().
Describes an account-field.
Definition: types_easy.hpp:202
struct Mastodon::Easy::alert_type alert_type
Type of notification and 'push is requested or not'.
Collection of things to interface with server software that implements the Mastodon API.
Definition: mastodon-cpp.hpp:47
struct Mastodon::Easy::poll_options_type poll_options_type
Poll options returned by Poll::options().
context_type
Describes the context.
Definition: types_easy.hpp:111
struct Mastodon::Easy::account_field_type account_field_type
Describes an account-field.
notification_type
Describes the notification type.
Definition: types_easy.hpp:97
URLs returned by Instance::urls().
Definition: types_easy.hpp:214
struct Mastodon::Easy::stats_type stats_type
Statistics returned by Instance::stats().
const string strtime(const string &format, const bool &local=true) const
Converts time to a string.
Definition: types_easy.cpp:33
struct Mastodon::Easy::stream_event_type stream_event_type
Used for stream events.
card_type
Describes the card type.
Definition: types_easy.hpp:83
Type of notification and 'push is requested or not'.
Definition: types_easy.hpp:139
Poll options returned by Poll::options().
Definition: types_easy.hpp:232
friend std::ostream & operator<<(std::ostream &out, const Easy::time_type &t)
Returns local time as string in ISO 8601 format (FTTz).
Definition: types_easy.cpp:53
event_type
Describes the event type returned in streams.
Definition: types_easy.hpp:38
visibility_type
Describes visibility of posts.
Definition: types_easy.hpp:54
attachment_type
Describes the attachment type.
Definition: types_easy.hpp:69