mastodon-cpp  0.110.0
poll.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_POLL_HPP
18 #define MASTODON_CPP_EASY_POLL_HPP
19 
20 #include <string>
21 #include <cstdint>
22 #include <vector>
23 
24 #include "../../mastodon-cpp.hpp"
25 #include "../entity.hpp"
26 
27 using std::string;
28 using std::uint64_t;
29 
30 namespace Mastodon
31 {
32 namespace Easy
33 {
39  class Poll : public Entity
40  {
41  public:
42  using Entity::Entity;
43 
44  virtual bool valid() const override;
45 
51  const string id() const;
52 
58  const Easy::time_type expires_at() const;
59 
65  bool expired() const;
66 
72  bool multiple() const;
73 
79  uint64_t votes_count() const;
80 
86  const vector<poll_options_type> options() const;
87 
93  bool voted() const;
94  };
95 }
96 }
97 
98 #endif // MASTODON_CPP_EASY_POLL_HPP
const vector< poll_options_type > options() const
Returns poll options and their votes count.
Definition: poll.cpp:61
Entity()
Constructs an empty Entity object.
Definition: entity.cpp:43
Class to hold polls.
Definition: poll.hpp:39
virtual bool valid() const override
Returns true if the Entity holds valid data.
Definition: poll.cpp:23
bool multiple() const
Returns true or false.
Definition: poll.cpp:51
Type for time. Converts to time_point and string.
Definition: types_easy.hpp:150
uint64_t votes_count() const
Returns the number of votes.
Definition: poll.cpp:56
bool voted() const
Returns whether you voted or not.
Definition: poll.cpp:83
Collection of things to interface with server software that implements the Mastodon API.
Definition: mastodon-cpp.hpp:47
Base class for all entities.
Definition: entity.hpp:36
const Easy::time_type expires_at() const
Returns time when the poll expires.
Definition: poll.cpp:41
bool expired() const
Returns true if poll has expired.
Definition: poll.cpp:46
const string id() const
Returns poll ID.
Definition: poll.cpp:36