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.h55
1 files changed, 32 insertions, 23 deletions
diff --git a/src/tweet.h b/src/tweet.h index ae1c916..71a27bd 100644 --- a/src/tweet.h +++ b/src/tweet.h
@@ -7,84 +7,93 @@
7#include <cassert> 7#include <cassert>
8#include <list> 8#include <list>
9#include <memory> 9#include <memory>
10#include <ctime>
10#include "user.h" 11#include "user.h"
11 12
12namespace twitter { 13namespace twitter {
13 14
14 class client; 15 class client;
15 16
16 typedef unsigned long long tweet_id; 17 typedef unsigned long long tweet_id;
17 18
18 class tweet { 19 class tweet {
19 public: 20 public:
20 21
21 tweet() {} 22 tweet() {}
22 tweet(std::string data); 23 tweet(std::string data);
23 24
24 tweet(const tweet& other); 25 tweet(const tweet& other);
25 tweet(tweet&& other); 26 tweet(tweet&& other);
26 27
27 tweet& operator=(tweet other); 28 tweet& operator=(tweet other);
28 29
29 friend void swap(tweet& first, tweet& second); 30 friend void swap(tweet& first, tweet& second);
30 31
31 tweet_id getID() const 32 tweet_id getID() const
32 { 33 {
33 assert(_valid); 34 assert(_valid);
34 35
35 return _id; 36 return _id;
36 } 37 }
37 38
38 std::string getText() const 39 std::string getText() const
39 { 40 {
40 assert(_valid); 41 assert(_valid);
41 42
42 return _text; 43 return _text;
43 } 44 }
44 45
45 const user& getAuthor() const 46 const user& getAuthor() const
46 { 47 {
47 assert(_valid); 48 assert(_valid);
48 49
49 return *_author; 50 return *_author;
50 } 51 }
51 52
53 const std::time_t& getCreatedAt() const
54 {
55 assert(_valid);
56
57 return _created_at;
58 }
59
52 bool isRetweet() const 60 bool isRetweet() const
53 { 61 {
54 assert(_valid); 62 assert(_valid);
55 63
56 return _is_retweet; 64 return _is_retweet;
57 } 65 }
58 66
59 const tweet& getRetweet() const 67 const tweet& getRetweet() const
60 { 68 {
61 assert(_valid && _is_retweet); 69 assert(_valid && _is_retweet);
62 70
63 return *_retweeted_status; 71 return *_retweeted_status;
64 } 72 }
65 73
66 const std::vector<std::pair<user_id, std::string>>& getMentions() const 74 const std::vector<std::pair<user_id, std::string>>& getMentions() const
67 { 75 {
68 assert(_valid); 76 assert(_valid);
69 77
70 return _mentions; 78 return _mentions;
71 } 79 }
72 80
73 std::string generateReplyPrefill(const user& me) const; 81 std::string generateReplyPrefill(const user& me) const;
74 82
75 std::string getURL() const; 83 std::string getURL() const;
76 84
77 private: 85 private:
78 86
79 bool _valid = false; 87 bool _valid = false;
80 tweet_id _id; 88 tweet_id _id;
81 std::string _text; 89 std::string _text;
82 std::unique_ptr<user> _author; 90 std::unique_ptr<user> _author;
91 std::time_t _created_at;
83 bool _is_retweet = false; 92 bool _is_retweet = false;
84 std::unique_ptr<tweet> _retweeted_status; 93 std::unique_ptr<tweet> _retweeted_status;
85 std::vector<std::pair<user_id, std::string>> _mentions; 94 std::vector<std::pair<user_id, std::string>> _mentions;
86 }; 95 };
87 96
88}; 97};
89 98
90#endif /* end of include guard: TWEET_H_CE980721 */ 99#endif /* end of include guard: TWEET_H_CE980721 */