diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-11-29 16:18:25 -0500 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-11-29 16:18:25 -0500 |
commit | 7c44fd17bb6be54a2ea4b60761e91053ca988977 (patch) | |
tree | 42f08e0db610617fd0629b117610bfa1a365acaf /src/tweet.h | |
parent | d90a1e74c77ba67f25a812609fd49d479bc464dd (diff) | |
download | libtwittercpp-7c44fd17bb6be54a2ea4b60761e91053ca988977.tar.gz libtwittercpp-7c44fd17bb6be54a2ea4b60761e91053ca988977.tar.bz2 libtwittercpp-7c44fd17bb6be54a2ea4b60761e91053ca988977.zip |
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.
Diffstat (limited to 'src/tweet.h')
-rw-r--r-- | src/tweet.h | 32 |
1 files changed, 20 insertions, 12 deletions
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 { | |||
18 | class tweet { | 18 | class tweet { |
19 | public: | 19 | public: |
20 | 20 | ||
21 | tweet(const client& tclient, std::string data); | 21 | tweet() {} |
22 | tweet(std::string data); | ||
22 | 23 | ||
23 | tweet(const tweet& other) = delete; | 24 | tweet(const tweet& other); |
24 | tweet& operator=(const tweet& other) = delete; | 25 | tweet(tweet&& other); |
25 | 26 | ||
26 | tweet(tweet&& other) = default; | 27 | tweet& operator=(tweet other); |
27 | tweet& operator=(tweet&& other) = default; | 28 | |
29 | friend void swap(tweet& first, tweet& second); | ||
28 | 30 | ||
29 | tweet_id getID() const | 31 | tweet_id getID() const |
30 | { | 32 | { |
33 | assert(_valid); | ||
34 | |||
31 | return _id; | 35 | return _id; |
32 | } | 36 | } |
33 | 37 | ||
34 | std::string getText() const | 38 | std::string getText() const |
35 | { | 39 | { |
40 | assert(_valid); | ||
41 | |||
36 | return _text; | 42 | return _text; |
37 | } | 43 | } |
38 | 44 | ||
39 | const user& getAuthor() const | 45 | const user& getAuthor() const |
40 | { | 46 | { |
47 | assert(_valid); | ||
48 | |||
41 | return *_author; | 49 | return *_author; |
42 | } | 50 | } |
43 | 51 | ||
44 | bool isRetweet() const | 52 | bool isRetweet() const |
45 | { | 53 | { |
54 | assert(_valid); | ||
55 | |||
46 | return _is_retweet; | 56 | return _is_retweet; |
47 | } | 57 | } |
48 | 58 | ||
49 | const tweet& getRetweet() const | 59 | const tweet& getRetweet() const |
50 | { | 60 | { |
51 | assert(_is_retweet); | 61 | assert(_valid && _is_retweet); |
52 | 62 | ||
53 | return *_retweeted_status; | 63 | return *_retweeted_status; |
54 | } | 64 | } |
55 | 65 | ||
56 | const std::vector<std::pair<user_id, std::string>>& getMentions() const | 66 | const std::vector<std::pair<user_id, std::string>>& getMentions() const |
57 | { | 67 | { |
68 | assert(_valid); | ||
69 | |||
58 | return _mentions; | 70 | return _mentions; |
59 | } | 71 | } |
60 | 72 | ||
61 | std::string generateReplyPrefill() const; | 73 | std::string generateReplyPrefill(const user& me) const; |
62 | |||
63 | tweet reply(std::string message, std::list<long> media_ids = {}) const; | ||
64 | |||
65 | bool isMyTweet() const; | ||
66 | 74 | ||
67 | std::string getURL() const; | 75 | std::string getURL() const; |
68 | 76 | ||
69 | private: | 77 | private: |
70 | 78 | ||
71 | const client& _client; | 79 | bool _valid = false; |
72 | tweet_id _id; | 80 | tweet_id _id; |
73 | std::string _text; | 81 | std::string _text; |
74 | std::unique_ptr<user> _author; | 82 | std::unique_ptr<user> _author; |