From b7bb942cadfe3d657895af1557b78acc2559947e Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 5 Aug 2018 15:58:14 -0400 Subject: Tweets store their created time C/C++ time handling is awful, pass it on --- src/tweet.h | 55 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 32 insertions(+), 23 deletions(-) (limited to 'src/tweet.h') 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 @@ #include #include #include +#include #include "user.h" namespace twitter { - + class client; - + typedef unsigned long long tweet_id; - + class tweet { public: - + tweet() {} tweet(std::string data); - + tweet(const tweet& other); tweet(tweet&& other); - + 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; } + const std::time_t& getCreatedAt() const + { + assert(_valid); + + return _created_at; + } + bool isRetweet() const { assert(_valid); - + return _is_retweet; } - + const tweet& getRetweet() const { assert(_valid && _is_retweet); - + return *_retweeted_status; } - + const std::vector>& getMentions() const { assert(_valid); - + return _mentions; } - + std::string generateReplyPrefill(const user& me) const; - + std::string getURL() const; - + private: - + bool _valid = false; tweet_id _id; std::string _text; std::unique_ptr _author; + std::time_t _created_at; bool _is_retweet = false; std::unique_ptr _retweeted_status; std::vector> _mentions; }; - + }; #endif /* end of include guard: TWEET_H_CE980721 */ -- cgit 1.4.1