diff options
Diffstat (limited to 'src/tweet.h')
| -rw-r--r-- | src/tweet.h | 70 |
1 files changed, 52 insertions, 18 deletions
| diff --git a/src/tweet.h b/src/tweet.h index 387f73a..3035d51 100644 --- a/src/tweet.h +++ b/src/tweet.h | |||
| @@ -2,41 +2,75 @@ | |||
| 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 | ||
| 9 | namespace twitter { | 11 | namespace 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 | 19 | ||
| 21 | tweet& operator=(tweet other); | 20 | tweet(const client& tclient, std::string data); |
| 22 | friend void swap(tweet& first, tweet& second); | 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 | } | ||
| 23 | 37 | ||
| 24 | tweet_id getID() const; | 38 | const user& getAuthor() const |
| 25 | std::string getText() const; | 39 | { |
| 26 | const user& getAuthor() const; | 40 | return *_author; |
| 27 | bool isRetweet() const; | 41 | } |
| 28 | tweet getRetweet() const; | ||
| 29 | std::vector<std::pair<user_id, std::string>> getMentions() const; | ||
| 30 | 42 | ||
| 31 | operator bool() const; | 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; | ||
| 32 | 65 | ||
| 33 | private: | 66 | private: |
| 34 | bool _valid; | 67 | |
| 68 | const client& _client; | ||
| 35 | tweet_id _id; | 69 | tweet_id _id; |
| 36 | std::string _text; | 70 | std::string _text; |
| 37 | user _author; | 71 | std::unique_ptr<user> _author; |
| 38 | bool _is_retweet = false; | 72 | bool _is_retweet = false; |
| 39 | tweet* _retweeted_status = nullptr; | 73 | std::unique_ptr<tweet> _retweeted_status; |
| 40 | std::vector<std::pair<user_id, std::string>> _mentions; | 74 | std::vector<std::pair<user_id, std::string>> _mentions; |
| 41 | }; | 75 | }; |
| 42 | 76 | ||
