diff options
| author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-08-20 13:56:23 -0400 |
|---|---|---|
| committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2016-08-20 13:56:23 -0400 |
| commit | 69fc8d805396b889b5e8c1c88e8129d93db77d29 (patch) | |
| tree | 6b807bd9332c65b65066e247d4d00fd5e4118d2e /src/notification.h | |
| parent | 442f1ee071152be04c4184473ddfee5040795b76 (diff) | |
| download | libtwittercpp-69fc8d805396b889b5e8c1c88e8129d93db77d29.tar.gz libtwittercpp-69fc8d805396b889b5e8c1c88e8129d93db77d29.tar.bz2 libtwittercpp-69fc8d805396b889b5e8c1c88e8129d93db77d29.zip | |
Updated API to use exceptions and make tweet/user objects more helpful
Diffstat (limited to 'src/notification.h')
| -rw-r--r-- | src/notification.h | 213 |
1 files changed, 108 insertions, 105 deletions
| diff --git a/src/notification.h b/src/notification.h index da83b0f..b5ecd49 100644 --- a/src/notification.h +++ b/src/notification.h | |||
| @@ -11,7 +11,10 @@ | |||
| 11 | 11 | ||
| 12 | namespace twitter { | 12 | namespace twitter { |
| 13 | 13 | ||
| 14 | enum class disconnect_code { | 14 | class client; |
| 15 | |||
| 16 | enum class disconnect_code | ||
| 17 | { | ||
| 15 | shutdown, | 18 | shutdown, |
| 16 | duplicate, | 19 | duplicate, |
| 17 | stall, | 20 | stall, |
| @@ -26,118 +29,118 @@ namespace twitter { | |||
| 26 | }; | 29 | }; |
| 27 | 30 | ||
| 28 | class notification { | 31 | class notification { |
| 29 | public: | 32 | public: |
| 30 | enum class type { | 33 | enum class type { |
| 31 | // Tweet object | 34 | // Tweet object |
| 32 | tweet, | 35 | tweet, |
| 33 | 36 | ||
| 34 | // User object | 37 | // User object |
| 35 | update_user, | 38 | update_user, |
| 36 | block, | 39 | block, |
| 37 | unblock, | 40 | unblock, |
| 38 | follow, | 41 | follow, |
| 39 | followed, | 42 | followed, |
| 40 | unfollow, | 43 | unfollow, |
| 41 | 44 | ||
| 42 | // User and tweet | 45 | // User and tweet |
| 43 | favorite, | 46 | favorite, |
| 44 | favorited, | 47 | favorited, |
| 45 | unfavorite, | 48 | unfavorite, |
| 46 | unfavorited, | 49 | unfavorited, |
| 47 | quoted, | 50 | quoted, |
| 48 | |||
| 49 | // List | ||
| 50 | list_created, | ||
| 51 | list_destroyed, | ||
| 52 | list_updated, | ||
| 53 | |||
| 54 | // User and list | ||
| 55 | list_add, | ||
| 56 | list_added, | ||
| 57 | list_remove, | ||
| 58 | list_removed, | ||
| 59 | list_subscribe, | ||
| 60 | list_subscribed, | ||
| 61 | list_unsubscribe, | ||
| 62 | list_unsubscribed, | ||
| 63 | |||
| 64 | // Warning | ||
| 65 | stall, | ||
| 66 | follow_limit, | ||
| 67 | unknown_warning, | ||
| 68 | |||
| 69 | // User ID and tweet ID | ||
| 70 | deletion, | ||
| 71 | scrub_location, | ||
| 72 | |||
| 73 | // Special | ||
| 74 | limit, | ||
| 75 | withhold_status, | ||
| 76 | withhold_user, | ||
| 77 | disconnect, | ||
| 78 | friends, | ||
| 79 | direct, | ||
| 80 | |||
| 81 | // Nothing | ||
| 82 | unknown, | ||
| 83 | invalid | ||
| 84 | }; | ||
| 85 | 51 | ||
| 86 | type getType() const; | 52 | // List |
| 53 | list_created, | ||
| 54 | list_destroyed, | ||
| 55 | list_updated, | ||
| 87 | 56 | ||
| 88 | notification(); | 57 | // User and list |
| 89 | notification(std::string data, const user& current_user); | 58 | list_add, |
| 90 | notification(const notification& other); | 59 | list_added, |
| 91 | notification& operator=(const notification& other); | 60 | list_remove, |
| 92 | ~notification(); | 61 | list_removed, |
| 62 | list_subscribe, | ||
| 63 | list_subscribed, | ||
| 64 | list_unsubscribe, | ||
| 65 | list_unsubscribed, | ||
| 93 | 66 | ||
| 94 | tweet getTweet() const; | 67 | // Warning |
| 95 | user getUser() const; | 68 | stall, |
| 96 | list getList() const; | 69 | follow_limit, |
| 97 | tweet_id getTweetID() const; | 70 | unknown_warning, |
| 98 | user_id getUserID() const; | ||
| 99 | std::vector<std::string> getCountries() const; | ||
| 100 | disconnect_code getDisconnectCode() const; | ||
| 101 | std::set<user_id> getFriends() const; | ||
| 102 | direct_message getDirectMessage() const; | ||
| 103 | int getLimit() const; | ||
| 104 | std::string getWarning() const; | ||
| 105 | 71 | ||
| 106 | operator bool() const; | 72 | // User ID and tweet ID |
| 73 | deletion, | ||
| 74 | scrub_location, | ||
| 107 | 75 | ||
| 108 | private: | 76 | // Special |
| 109 | union { | 77 | limit, |
| 78 | withhold_status, | ||
| 79 | withhold_user, | ||
| 80 | disconnect, | ||
| 81 | friends, | ||
| 82 | direct, | ||
| 83 | |||
| 84 | // Nothing | ||
| 85 | unknown, | ||
| 86 | invalid | ||
| 87 | }; | ||
| 88 | |||
| 89 | type getType() const; | ||
| 90 | |||
| 91 | notification(const client& tclient, std::string data); | ||
| 92 | notification(notification&& other); | ||
| 93 | notification& operator=(notification&& other); | ||
| 94 | ~notification(); | ||
| 95 | |||
| 96 | notification(const notification& other) = delete; | ||
| 97 | notification& operator=(const notification& other) = delete; | ||
| 98 | |||
| 99 | const tweet& getTweet() const; | ||
| 100 | const user& getUser() const; | ||
| 101 | const list& getList() const; | ||
| 102 | tweet_id getTweetID() const; | ||
| 103 | user_id getUserID() const; | ||
| 104 | const std::vector<std::string>& getCountries() const; | ||
| 105 | disconnect_code getDisconnectCode() const; | ||
| 106 | const std::set<user_id>& getFriends() const; | ||
| 107 | const direct_message& getDirectMessage() const; | ||
| 108 | int getLimit() const; | ||
| 109 | const std::string& getWarning() const; | ||
| 110 | |||
| 111 | private: | ||
| 112 | union { | ||
| 113 | tweet _tweet; | ||
| 114 | user _user; | ||
| 115 | list _list; | ||
| 116 | struct { | ||
| 117 | user _user; | ||
| 110 | tweet _tweet; | 118 | tweet _tweet; |
| 119 | } _user_and_tweet; | ||
| 120 | struct { | ||
| 111 | user _user; | 121 | user _user; |
| 112 | list _list; | 122 | list _list; |
| 113 | struct { | 123 | } _user_and_list; |
| 114 | user _user; | 124 | std::string _warning; |
| 115 | tweet _tweet; | 125 | struct { |
| 116 | } _user_and_tweet; | 126 | user_id _user_id; |
| 117 | struct { | 127 | tweet_id _tweet_id; |
| 118 | user _user; | 128 | } _user_id_and_tweet_id; |
| 119 | list _list; | 129 | int _limit; |
| 120 | } _user_and_list; | 130 | struct { |
| 121 | std::string _warning; | 131 | user_id _user_id; |
| 122 | struct { | 132 | tweet_id _tweet_id; |
| 123 | user_id _user_id; | 133 | std::vector<std::string> _countries; |
| 124 | tweet_id _tweet_id; | 134 | } _withhold_status; |
| 125 | } _user_id_and_tweet_id; | 135 | struct { |
| 126 | int _limit; | 136 | user_id _user_id; |
| 127 | struct { | 137 | std::vector<std::string> _countries; |
| 128 | user_id _user_id; | 138 | } _withhold_user; |
| 129 | tweet_id _tweet_id; | 139 | disconnect_code _disconnect; |
| 130 | std::vector<std::string> _countries; | 140 | std::set<user_id> _friends; |
| 131 | } _withhold_status; | 141 | direct_message _direct_message; |
| 132 | struct { | 142 | }; |
| 133 | user_id _user_id; | 143 | type _type; |
| 134 | std::vector<std::string> _countries; | ||
| 135 | } _withhold_user; | ||
| 136 | disconnect_code _disconnect; | ||
| 137 | std::set<user_id> _friends; | ||
| 138 | direct_message _direct_message; | ||
| 139 | }; | ||
| 140 | type _type; | ||
| 141 | }; | 144 | }; |
| 142 | 145 | ||
| 143 | }; | 146 | }; |
