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/notification.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/notification.h')
-rw-r--r-- | src/notification.h | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/src/notification.h b/src/notification.h index b5ecd49..a6dd6f4 100644 --- a/src/notification.h +++ b/src/notification.h | |||
@@ -88,25 +88,69 @@ namespace twitter { | |||
88 | 88 | ||
89 | type getType() const; | 89 | type getType() const; |
90 | 90 | ||
91 | notification() {} | ||
91 | notification(const client& tclient, std::string data); | 92 | notification(const client& tclient, std::string data); |
93 | |||
94 | notification(const notification& other); | ||
92 | notification(notification&& other); | 95 | notification(notification&& other); |
93 | notification& operator=(notification&& other); | 96 | notification& operator=(notification other); |
94 | ~notification(); | 97 | ~notification(); |
95 | 98 | ||
96 | notification(const notification& other) = delete; | 99 | friend void swap(notification& first, notification& second); |
97 | notification& operator=(const notification& other) = delete; | ||
98 | 100 | ||
99 | const tweet& getTweet() const; | 101 | const tweet& getTweet() const; |
102 | tweet& getTweet() | ||
103 | { | ||
104 | return const_cast<tweet&>(static_cast<const notification&>(*this).getTweet()); | ||
105 | } | ||
106 | |||
100 | const user& getUser() const; | 107 | const user& getUser() const; |
108 | user& getUser() | ||
109 | { | ||
110 | return const_cast<user&>(static_cast<const notification&>(*this).getUser()); | ||
111 | } | ||
112 | |||
101 | const list& getList() const; | 113 | const list& getList() const; |
114 | list& getList() | ||
115 | { | ||
116 | return const_cast<list&>(static_cast<const notification&>(*this).getList()); | ||
117 | } | ||
118 | |||
102 | tweet_id getTweetID() const; | 119 | tweet_id getTweetID() const; |
120 | void setTweetID(tweet_id _arg); | ||
121 | |||
103 | user_id getUserID() const; | 122 | user_id getUserID() const; |
123 | void setUserID(user_id _arg); | ||
124 | |||
104 | const std::vector<std::string>& getCountries() const; | 125 | const std::vector<std::string>& getCountries() const; |
126 | std::vector<std::string>& getCountries() | ||
127 | { | ||
128 | return const_cast<std::vector<std::string>&>(static_cast<const notification&>(*this).getCountries()); | ||
129 | } | ||
130 | |||
105 | disconnect_code getDisconnectCode() const; | 131 | disconnect_code getDisconnectCode() const; |
132 | void setDisconnectCode(disconnect_code _arg); | ||
133 | |||
106 | const std::set<user_id>& getFriends() const; | 134 | const std::set<user_id>& getFriends() const; |
135 | std::set<user_id>& getFriends() | ||
136 | { | ||
137 | return const_cast<std::set<user_id>&>(static_cast<const notification&>(*this).getFriends()); | ||
138 | } | ||
139 | |||
107 | const direct_message& getDirectMessage() const; | 140 | const direct_message& getDirectMessage() const; |
141 | direct_message& getDirectMessage() | ||
142 | { | ||
143 | return const_cast<direct_message&>(static_cast<const notification&>(*this).getDirectMessage()); | ||
144 | } | ||
145 | |||
108 | int getLimit() const; | 146 | int getLimit() const; |
147 | void setLimit(int _arg); | ||
148 | |||
109 | const std::string& getWarning() const; | 149 | const std::string& getWarning() const; |
150 | std::string& getWarning() | ||
151 | { | ||
152 | return const_cast<std::string&>(static_cast<const notification&>(*this).getWarning()); | ||
153 | } | ||
110 | 154 | ||
111 | private: | 155 | private: |
112 | union { | 156 | union { |
@@ -140,7 +184,7 @@ namespace twitter { | |||
140 | std::set<user_id> _friends; | 184 | std::set<user_id> _friends; |
141 | direct_message _direct_message; | 185 | direct_message _direct_message; |
142 | }; | 186 | }; |
143 | type _type; | 187 | type _type = type::invalid; |
144 | }; | 188 | }; |
145 | 189 | ||
146 | }; | 190 | }; |