about summary refs log tree commit diff stats
path: root/src/tweet.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/tweet.h')
-rw-r--r--src/tweet.h77
1 files changed, 56 insertions, 21 deletions
diff --git a/src/tweet.h b/src/tweet.h index 74d73d2..a29e45c 100644 --- a/src/tweet.h +++ b/src/tweet.h
@@ -2,42 +2,77 @@
2#define TWEET_H_CE980721 2#define TWEET_H_CE980721
3 3
4#include <string> 4#include <string>
5#include "user.h"
6#include <vector> 5#include <vector>
7#include <utility> 6#include <utility>
7#include <cassert>
8#include <list>
9#include "user.h"
8 10
9namespace twitter { 11namespace twitter {
10 12
13 class client;
14
11 typedef unsigned long long tweet_id; 15 typedef unsigned long long tweet_id;
12 16
13 class tweet { 17 class tweet {
14 public: 18 public:
15 tweet();
16 tweet(std::string data);
17 tweet(const tweet& other);
18 tweet(tweet&& other);
19 ~tweet();
20
21 tweet& operator=(tweet other);
22 friend void swap(tweet& first, tweet& second);
23
24 tweet_id getID() const;
25 std::string getText() const;
26 const user& getAuthor() const;
27 bool isRetweet() const;
28 tweet getRetweet() const;
29 std::vector<std::pair<user_id, std::string>> getMentions() const;
30 std::string getURL() const;
31 19
32 operator bool() const; 20 tweet(const client& tclient, std::string data);
21
22 tweet(const tweet& other) = delete;
23 tweet& operator=(const tweet& other) = delete;
24
25 tweet(tweet&& other) = default;
26 tweet& operator=(tweet&& other) = default;
27
28 tweet_id getID() const
29 {
30 return _id;
31 }
32
33 std::string getText() const
34 {
35 return _text;
36 }
37
38 const user& getAuthor() const
39 {
40 return *_author;
41 }
42
43 bool isRetweet() const
44 {
45 return _is_retweet;
46 }
47
48 const tweet& getRetweet() const
49 {
50 assert(_is_retweet);
51
52 return *_retweeted_status;
53 }
54
55 const std::vector<std::pair<user_id, std::string>>& getMentions() const
56 {
57 return _mentions;
58 }
59
60 std::string generateReplyPrefill() const;
61
62 tweet reply(std::string message, std::list<long> media_ids = {}) const;
63
64 bool isMyTweet() const;
65
66 std::string getURL() const;
33 67
34 private: 68 private:
35 bool _valid; 69
70 const client& _client;
36 tweet_id _id; 71 tweet_id _id;
37 std::string _text; 72 std::string _text;
38 user _author; 73 std::unique_ptr<user> _author;
39 bool _is_retweet = false; 74 bool _is_retweet = false;
40 tweet* _retweeted_status = nullptr; 75 std::unique_ptr<tweet> _retweeted_status;
41 std::vector<std::pair<user_id, std::string>> _mentions; 76 std::vector<std::pair<user_id, std::string>> _mentions;
42 }; 77 };
43 78