From 69fc8d805396b889b5e8c1c88e8129d93db77d29 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 20 Aug 2016 13:56:23 -0400 Subject: Updated API to use exceptions and make tweet/user objects more helpful --- src/notification.h | 213 +++++++++++++++++++++++++++-------------------------- 1 file changed, 108 insertions(+), 105 deletions(-) (limited to 'src/notification.h') 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 @@ namespace twitter { - enum class disconnect_code { + class client; + + enum class disconnect_code + { shutdown, duplicate, stall, @@ -26,118 +29,118 @@ namespace twitter { }; class notification { - public: - enum class type { - // Tweet object - tweet, - - // User object - update_user, - block, - unblock, - follow, - followed, - unfollow, - - // User and tweet - favorite, - favorited, - unfavorite, - unfavorited, - quoted, - - // List - list_created, - list_destroyed, - list_updated, - - // User and list - list_add, - list_added, - list_remove, - list_removed, - list_subscribe, - list_subscribed, - list_unsubscribe, - list_unsubscribed, - - // Warning - stall, - follow_limit, - unknown_warning, - - // User ID and tweet ID - deletion, - scrub_location, - - // Special - limit, - withhold_status, - withhold_user, - disconnect, - friends, - direct, - - // Nothing - unknown, - invalid - }; + public: + enum class type { + // Tweet object + tweet, + + // User object + update_user, + block, + unblock, + follow, + followed, + unfollow, + + // User and tweet + favorite, + favorited, + unfavorite, + unfavorited, + quoted, - type getType() const; + // List + list_created, + list_destroyed, + list_updated, - notification(); - notification(std::string data, const user& current_user); - notification(const notification& other); - notification& operator=(const notification& other); - ~notification(); + // User and list + list_add, + list_added, + list_remove, + list_removed, + list_subscribe, + list_subscribed, + list_unsubscribe, + list_unsubscribed, - tweet getTweet() const; - user getUser() const; - list getList() const; - tweet_id getTweetID() const; - user_id getUserID() const; - std::vector getCountries() const; - disconnect_code getDisconnectCode() const; - std::set getFriends() const; - direct_message getDirectMessage() const; - int getLimit() const; - std::string getWarning() const; + // Warning + stall, + follow_limit, + unknown_warning, - operator bool() const; + // User ID and tweet ID + deletion, + scrub_location, - private: - union { + // Special + limit, + withhold_status, + withhold_user, + disconnect, + friends, + direct, + + // Nothing + unknown, + invalid + }; + + type getType() const; + + notification(const client& tclient, std::string data); + notification(notification&& other); + notification& operator=(notification&& other); + ~notification(); + + notification(const notification& other) = delete; + notification& operator=(const notification& other) = delete; + + const tweet& getTweet() const; + const user& getUser() const; + const list& getList() const; + tweet_id getTweetID() const; + user_id getUserID() const; + const std::vector& getCountries() const; + disconnect_code getDisconnectCode() const; + const std::set& getFriends() const; + const direct_message& getDirectMessage() const; + int getLimit() const; + const std::string& getWarning() const; + + private: + union { + tweet _tweet; + user _user; + list _list; + struct { + user _user; tweet _tweet; + } _user_and_tweet; + struct { user _user; list _list; - struct { - user _user; - tweet _tweet; - } _user_and_tweet; - struct { - user _user; - list _list; - } _user_and_list; - std::string _warning; - struct { - user_id _user_id; - tweet_id _tweet_id; - } _user_id_and_tweet_id; - int _limit; - struct { - user_id _user_id; - tweet_id _tweet_id; - std::vector _countries; - } _withhold_status; - struct { - user_id _user_id; - std::vector _countries; - } _withhold_user; - disconnect_code _disconnect; - std::set _friends; - direct_message _direct_message; - }; - type _type; + } _user_and_list; + std::string _warning; + struct { + user_id _user_id; + tweet_id _tweet_id; + } _user_id_and_tweet_id; + int _limit; + struct { + user_id _user_id; + tweet_id _tweet_id; + std::vector _countries; + } _withhold_status; + struct { + user_id _user_id; + std::vector _countries; + } _withhold_user; + disconnect_code _disconnect; + std::set _friends; + direct_message _direct_message; + }; + type _type; }; }; -- cgit 1.4.1