From 7c44fd17bb6be54a2ea4b60761e91053ca988977 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 29 Nov 2016 16:18:25 -0500 Subject: Made tweets, users, and notifications into copyable objects Notifications are now also mutable. Users and tweets no longer have helper methods for interacting with the client. Fixed a bug (possibly introduced by a change to the Twitter API) that caused non-reply tweets to be marked as unknown notifications. --- src/tweet.h | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'src/tweet.h') diff --git a/src/tweet.h b/src/tweet.h index e21d689..ae1c916 100644 --- a/src/tweet.h +++ b/src/tweet.h @@ -18,57 +18,65 @@ namespace twitter { class tweet { public: - tweet(const client& tclient, std::string data); + tweet() {} + tweet(std::string data); - tweet(const tweet& other) = delete; - tweet& operator=(const tweet& other) = delete; + tweet(const tweet& other); + tweet(tweet&& other); - tweet(tweet&& other) = default; - tweet& operator=(tweet&& other) = default; + tweet& operator=(tweet other); + + friend void swap(tweet& first, tweet& second); tweet_id getID() const { + assert(_valid); + return _id; } std::string getText() const { + assert(_valid); + return _text; } const user& getAuthor() const { + assert(_valid); + return *_author; } bool isRetweet() const { + assert(_valid); + return _is_retweet; } const tweet& getRetweet() const { - assert(_is_retweet); + assert(_valid && _is_retweet); return *_retweeted_status; } const std::vector>& getMentions() const { + assert(_valid); + return _mentions; } - std::string generateReplyPrefill() const; - - tweet reply(std::string message, std::list media_ids = {}) const; - - bool isMyTweet() const; + std::string generateReplyPrefill(const user& me) const; std::string getURL() const; private: - const client& _client; + bool _valid = false; tweet_id _id; std::string _text; std::unique_ptr _author; -- cgit 1.4.1