about summary refs log tree commit diff stats
path: root/src/notification.cpp
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2018-08-05 11:14:39 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2018-08-05 11:14:39 -0400
commit38203b745ae1903ba0804ed5532b78d255bea635 (patch)
tree52f57ce85e65361c534c461abc82fb1ed9768d49 /src/notification.cpp
parent7c44fd17bb6be54a2ea4b60761e91053ca988977 (diff)
downloadlibtwittercpp-38203b745ae1903ba0804ed5532b78d255bea635.tar.gz
libtwittercpp-38203b745ae1903ba0804ed5532b78d255bea635.tar.bz2
libtwittercpp-38203b745ae1903ba0804ed5532b78d255bea635.zip
Added timeline polling
Because the streaming API will sunset on August 16th, it is essential to implement timeline polling so that the library can still be used to access tweets. This commit breaks the current API even for clients still using the streaming API because the OAuth connection data was pulled from twitter::client into twitter::auth. Other than that, almost everything works the same, and if a client wants to update their libtwitter++ within the next week and a half, they are free to.
Diffstat (limited to 'src/notification.cpp')
-rw-r--r--src/notification.cpp460
1 files changed, 229 insertions, 231 deletions
diff --git a/src/notification.cpp b/src/notification.cpp index 0e46112..0d09fcf 100644 --- a/src/notification.cpp +++ b/src/notification.cpp
@@ -6,18 +6,16 @@
6#include "client.h" 6#include "client.h"
7 7
8namespace twitter { 8namespace twitter {
9 9
10 notification::type notification::getType() const 10 notification::type notification::getType() const
11 { 11 {
12 return _type; 12 return _type;
13 } 13 }
14 14
15 notification::notification(const client& tclient, std::string data) 15 notification::notification(const user& current_user, std::string data)
16 { 16 {
17 const user& current_user = tclient.getUser();
18
19 nlohmann::json json; 17 nlohmann::json json;
20 18
21 try 19 try
22 { 20 {
23 json = nlohmann::json::parse(data); 21 json = nlohmann::json::parse(data);
@@ -25,7 +23,7 @@ namespace twitter {
25 { 23 {
26 std::throw_with_nested(invalid_response(data)); 24 std::throw_with_nested(invalid_response(data));
27 } 25 }
28 26
29 try 27 try
30 { 28 {
31 if (!json["event"].is_null()) 29 if (!json["event"].is_null())
@@ -33,48 +31,48 @@ namespace twitter {
33 std::string event = json["event"]; 31 std::string event = json["event"];
34 user source(json["source"].dump()); 32 user source(json["source"].dump());
35 user target(json["target"].dump()); 33 user target(json["target"].dump());
36 34
37 if (event == "user_update") 35 if (event == "user_update")
38 { 36 {
39 _type = type::update_user; 37 _type = type::update_user;
40 38
41 new(&_user) user(source); 39 new(&_user) user(source);
42 } else if (event == "block") 40 } else if (event == "block")
43 { 41 {
44 _type = type::block; 42 _type = type::block;
45 43
46 new(&_user) user(target); 44 new(&_user) user(target);
47 } else if (event == "unblock") 45 } else if (event == "unblock")
48 { 46 {
49 _type = type::unblock; 47 _type = type::unblock;
50 48
51 new(&_user) user(target); 49 new(&_user) user(target);
52 } else if (event == "favorite") 50 } else if (event == "favorite")
53 { 51 {
54 new(&_user_and_tweet._tweet) tweet(json["target_object"].dump()); 52 new(&_user_and_tweet._tweet) tweet(json["target_object"].dump());
55 53
56 if (current_user == source) 54 if (current_user == source)
57 { 55 {
58 _type = type::favorite; 56 _type = type::favorite;
59 57
60 new(&_user_and_tweet._user) user(target); 58 new(&_user_and_tweet._user) user(target);
61 } else { 59 } else {
62 _type = type::favorited; 60 _type = type::favorited;
63 61
64 new(&_user_and_tweet._user) user(source); 62 new(&_user_and_tweet._user) user(source);
65 } 63 }
66 } else if (event == "unfavorite") 64 } else if (event == "unfavorite")
67 { 65 {
68 new(&_user_and_tweet._tweet) tweet(json["target_object"].dump()); 66 new(&_user_and_tweet._tweet) tweet(json["target_object"].dump());
69 67
70 if (current_user == source) 68 if (current_user == source)
71 { 69 {
72 _type = type::unfavorite; 70 _type = type::unfavorite;
73 71
74 new(&_user_and_tweet._user) user(target); 72 new(&_user_and_tweet._user) user(target);
75 } else { 73 } else {
76 _type = type::unfavorited; 74 _type = type::unfavorited;
77 75
78 new(&_user_and_tweet._user) user(source); 76 new(&_user_and_tweet._user) user(source);
79 } 77 }
80 } else if (event == "follow") 78 } else if (event == "follow")
@@ -82,93 +80,93 @@ namespace twitter {
82 if (current_user == source) 80 if (current_user == source)
83 { 81 {
84 _type = type::follow; 82 _type = type::follow;
85 83
86 new(&_user) user(target); 84 new(&_user) user(target);
87 } else { 85 } else {
88 _type = type::followed; 86 _type = type::followed;
89 87
90 new(&_user) user(source); 88 new(&_user) user(source);
91 } 89 }
92 } else if (event == "unfollow") 90 } else if (event == "unfollow")
93 { 91 {
94 _type = type::unfollow; 92 _type = type::unfollow;
95 93
96 new(&_user) user(target); 94 new(&_user) user(target);
97 } else if (event == "list_created") 95 } else if (event == "list_created")
98 { 96 {
99 _type = type::list_created; 97 _type = type::list_created;
100 98
101 new(&_list) list(json["target_object"].dump()); 99 new(&_list) list(json["target_object"].dump());
102 } else if (event == "list_destroyed") 100 } else if (event == "list_destroyed")
103 { 101 {
104 _type = type::list_destroyed; 102 _type = type::list_destroyed;
105 103
106 new(&_list) list(json["target_object"].dump()); 104 new(&_list) list(json["target_object"].dump());
107 } else if (event == "list_updated") 105 } else if (event == "list_updated")
108 { 106 {
109 _type = type::list_updated; 107 _type = type::list_updated;
110 108
111 new(&_list) list(json["target_object"].dump()); 109 new(&_list) list(json["target_object"].dump());
112 } else if (event == "list_member_added") 110 } else if (event == "list_member_added")
113 { 111 {
114 new(&_user_and_list._list) list(json["target_object"].dump()); 112 new(&_user_and_list._list) list(json["target_object"].dump());
115 113
116 if (current_user == source) 114 if (current_user == source)
117 { 115 {
118 _type = type::list_add; 116 _type = type::list_add;
119 117
120 new(&_user_and_list._user) user(target); 118 new(&_user_and_list._user) user(target);
121 } else { 119 } else {
122 _type = type::list_added; 120 _type = type::list_added;
123 121
124 new(&_user_and_list._user) user(source); 122 new(&_user_and_list._user) user(source);
125 } 123 }
126 } else if (event == "list_member_removed") 124 } else if (event == "list_member_removed")
127 { 125 {
128 new(&_user_and_list._list) list(json["target_object"].dump()); 126 new(&_user_and_list._list) list(json["target_object"].dump());
129 127
130 if (current_user == source) 128 if (current_user == source)
131 { 129 {
132 _type = type::list_remove; 130 _type = type::list_remove;
133 131
134 new(&_user_and_list._user) user(target); 132 new(&_user_and_list._user) user(target);
135 } else { 133 } else {
136 _type = type::list_removed; 134 _type = type::list_removed;
137 135
138 new(&_user_and_list._user) user(source); 136 new(&_user_and_list._user) user(source);
139 } 137 }
140 } else if (event == "list_member_subscribe") 138 } else if (event == "list_member_subscribe")
141 { 139 {
142 new(&_user_and_list._list) list(json["target_object"].dump()); 140 new(&_user_and_list._list) list(json["target_object"].dump());
143 141
144 if (current_user == source) 142 if (current_user == source)
145 { 143 {
146 _type = type::list_subscribe; 144 _type = type::list_subscribe;
147 145
148 new(&_user_and_list._user) user(target); 146 new(&_user_and_list._user) user(target);
149 } else { 147 } else {
150 _type = type::list_subscribed; 148 _type = type::list_subscribed;
151 149
152 new(&_user_and_list._user) user(source); 150 new(&_user_and_list._user) user(source);
153 } 151 }
154 } else if (event == "list_member_unsubscribe") 152 } else if (event == "list_member_unsubscribe")
155 { 153 {
156 new(&_user_and_list._list) list(json["target_object"].dump()); 154 new(&_user_and_list._list) list(json["target_object"].dump());
157 155
158 if (current_user == source) 156 if (current_user == source)
159 { 157 {
160 _type = type::list_unsubscribe; 158 _type = type::list_unsubscribe;
161 159
162 new(&_user_and_list._user) user(target); 160 new(&_user_and_list._user) user(target);
163 } else { 161 } else {
164 _type = type::list_unsubscribed; 162 _type = type::list_unsubscribed;
165 163
166 new(&_user_and_list._user) user(source); 164 new(&_user_and_list._user) user(source);
167 } 165 }
168 } else if (event == "quoted_tweet") 166 } else if (event == "quoted_tweet")
169 { 167 {
170 _type = type::quoted; 168 _type = type::quoted;
171 169
172 new(&_user_and_tweet._user) user(source); 170 new(&_user_and_tweet._user) user(source);
173 new(&_user_and_tweet._tweet) tweet(json["target_object"].dump()); 171 new(&_user_and_tweet._tweet) tweet(json["target_object"].dump());
174 } else { 172 } else {
@@ -177,7 +175,7 @@ namespace twitter {
177 } else if (!json["warning"].is_null()) 175 } else if (!json["warning"].is_null())
178 { 176 {
179 new(&_warning) std::string(json["warning"]["message"].get<std::string>()); 177 new(&_warning) std::string(json["warning"]["message"].get<std::string>());
180 178
181 auto warning_code = json["warning"]["code"].get<std::string>(); 179 auto warning_code = json["warning"]["code"].get<std::string>();
182 if (warning_code == "FALLING_BEHIND") 180 if (warning_code == "FALLING_BEHIND")
183 { 181 {
@@ -191,27 +189,27 @@ namespace twitter {
191 } else if (!json["delete"].is_null()) 189 } else if (!json["delete"].is_null())
192 { 190 {
193 _type = type::deletion; 191 _type = type::deletion;
194 192
195 _user_id_and_tweet_id._tweet_id = json["delete"]["status"]["id"].get<tweet_id>(); 193 _user_id_and_tweet_id._tweet_id = json["delete"]["status"]["id"].get<tweet_id>();
196 _user_id_and_tweet_id._user_id = json["delete"]["status"]["user_id"].get<user_id>(); 194 _user_id_and_tweet_id._user_id = json["delete"]["status"]["user_id"].get<user_id>();
197 } else if (!json["scrub_geo"].is_null()) 195 } else if (!json["scrub_geo"].is_null())
198 { 196 {
199 _type = type::scrub_location; 197 _type = type::scrub_location;
200 198
201 _user_id_and_tweet_id._tweet_id = json["scrub_geo"]["up_to_status_id"].get<tweet_id>(); 199 _user_id_and_tweet_id._tweet_id = json["scrub_geo"]["up_to_status_id"].get<tweet_id>();
202 _user_id_and_tweet_id._user_id = json["scrub_geo"]["user_id"].get<user_id>(); 200 _user_id_and_tweet_id._user_id = json["scrub_geo"]["user_id"].get<user_id>();
203 } else if (!json["limit"].is_null()) 201 } else if (!json["limit"].is_null())
204 { 202 {
205 _type = type::limit; 203 _type = type::limit;
206 204
207 _limit = json["limit"]["track"].get<int>(); 205 _limit = json["limit"]["track"].get<int>();
208 } else if (!json["status_withheld"].is_null()) 206 } else if (!json["status_withheld"].is_null())
209 { 207 {
210 _type = type::withhold_status; 208 _type = type::withhold_status;
211 209
212 _withhold_status._user_id = json["status_withheld"]["user_id"].get<user_id>(); 210 _withhold_status._user_id = json["status_withheld"]["user_id"].get<user_id>();
213 _withhold_status._tweet_id = json["status_withheld"]["id"].get<tweet_id>(); 211 _withhold_status._tweet_id = json["status_withheld"]["id"].get<tweet_id>();
214 212
215 new(&_withhold_status._countries) std::vector<std::string>(); 213 new(&_withhold_status._countries) std::vector<std::string>();
216 for (auto s : json["status_withheld"]["withheld_in_countries"]) 214 for (auto s : json["status_withheld"]["withheld_in_countries"])
217 { 215 {
@@ -220,9 +218,9 @@ namespace twitter {
220 } else if (!json["user_withheld"].is_null()) 218 } else if (!json["user_withheld"].is_null())
221 { 219 {
222 _type = type::withhold_user; 220 _type = type::withhold_user;
223 221
224 _withhold_user._user_id = json["user_withheld"]["id"].get<user_id>(); 222 _withhold_user._user_id = json["user_withheld"]["id"].get<user_id>();
225 223
226 new(&_withhold_user._countries) std::vector<std::string>(); 224 new(&_withhold_user._countries) std::vector<std::string>();
227 for (auto s : json["user_withheld"]["withheld_in_countries"]) 225 for (auto s : json["user_withheld"]["withheld_in_countries"])
228 { 226 {
@@ -231,7 +229,7 @@ namespace twitter {
231 } else if (!json["disconnect"].is_null()) 229 } else if (!json["disconnect"].is_null())
232 { 230 {
233 _type = type::disconnect; 231 _type = type::disconnect;
234 232
235 switch (json["disconnect"]["code"].get<int>()) 233 switch (json["disconnect"]["code"].get<int>())
236 { 234 {
237 case 1: _disconnect = disconnect_code::shutdown; break; 235 case 1: _disconnect = disconnect_code::shutdown; break;
@@ -249,16 +247,16 @@ namespace twitter {
249 } else if (!json["friends"].is_null()) 247 } else if (!json["friends"].is_null())
250 { 248 {
251 _type = type::friends; 249 _type = type::friends;
252 250
253 new(&_friends) std::set<user_id>(std::begin(json["friends"]), std::end(json["friends"])); 251 new(&_friends) std::set<user_id>(std::begin(json["friends"]), std::end(json["friends"]));
254 } else if (!json["direct_message"].is_null()) 252 } else if (!json["direct_message"].is_null())
255 { 253 {
256 _type = type::direct; 254 _type = type::direct;
257 255
258 new(&_direct_message) direct_message(json["direct_message"].dump()); 256 new(&_direct_message) direct_message(json["direct_message"].dump());
259 } else { 257 } else {
260 _type = type::tweet; 258 _type = type::tweet;
261 259
262 new(&_tweet) tweet(data); 260 new(&_tweet) tweet(data);
263 } 261 }
264 } catch (const std::domain_error& error) 262 } catch (const std::domain_error& error)
@@ -266,20 +264,20 @@ namespace twitter {
266 std::throw_with_nested(invalid_response(data)); 264 std::throw_with_nested(invalid_response(data));
267 } 265 }
268 } 266 }
269 267
270 notification::notification(const notification& other) 268 notification::notification(const notification& other)
271 { 269 {
272 _type = other._type; 270 _type = other._type;
273 271
274 switch (_type) 272 switch (_type)
275 { 273 {
276 case type::tweet: 274 case type::tweet:
277 { 275 {
278 new(&_tweet) tweet(other._tweet); 276 new(&_tweet) tweet(other._tweet);
279 277
280 break; 278 break;
281 } 279 }
282 280
283 case type::update_user: 281 case type::update_user:
284 case type::block: 282 case type::block:
285 case type::unblock: 283 case type::unblock:
@@ -288,10 +286,10 @@ namespace twitter {
288 case type::unfollow: 286 case type::unfollow:
289 { 287 {
290 new(&_user) user(other._user); 288 new(&_user) user(other._user);
291 289
292 break; 290 break;
293 } 291 }
294 292
295 case type::favorite: 293 case type::favorite:
296 case type::favorited: 294 case type::favorited:
297 case type::unfavorite: 295 case type::unfavorite:
@@ -300,19 +298,19 @@ namespace twitter {
300 { 298 {
301 new(&_user_and_tweet._user) user(other._user_and_tweet._user); 299 new(&_user_and_tweet._user) user(other._user_and_tweet._user);
302 new(&_user_and_tweet._tweet) tweet(other._user_and_tweet._tweet); 300 new(&_user_and_tweet._tweet) tweet(other._user_and_tweet._tweet);
303 301
304 break; 302 break;
305 } 303 }
306 304
307 case type::list_created: 305 case type::list_created:
308 case type::list_destroyed: 306 case type::list_destroyed:
309 case type::list_updated: 307 case type::list_updated:
310 { 308 {
311 new(&_list) list(other._list); 309 new(&_list) list(other._list);
312 310
313 break; 311 break;
314 } 312 }
315 313
316 case type::list_add: 314 case type::list_add:
317 case type::list_added: 315 case type::list_added:
318 case type::list_remove: 316 case type::list_remove:
@@ -324,73 +322,73 @@ namespace twitter {
324 { 322 {
325 new(&_user_and_list._user) user(other._user_and_list._user); 323 new(&_user_and_list._user) user(other._user_and_list._user);
326 new(&_user_and_list._list) list(other._user_and_list._list); 324 new(&_user_and_list._list) list(other._user_and_list._list);
327 325
328 break; 326 break;
329 } 327 }
330 328
331 case type::stall: 329 case type::stall:
332 case type::follow_limit: 330 case type::follow_limit:
333 case type::unknown_warning: 331 case type::unknown_warning:
334 { 332 {
335 new(&_warning) std::string(other._warning); 333 new(&_warning) std::string(other._warning);
336 334
337 break; 335 break;
338 } 336 }
339 337
340 case type::deletion: 338 case type::deletion:
341 case type::scrub_location: 339 case type::scrub_location:
342 { 340 {
343 _user_id_and_tweet_id._user_id = other._user_id_and_tweet_id._user_id; 341 _user_id_and_tweet_id._user_id = other._user_id_and_tweet_id._user_id;
344 _user_id_and_tweet_id._tweet_id = other._user_id_and_tweet_id._tweet_id; 342 _user_id_and_tweet_id._tweet_id = other._user_id_and_tweet_id._tweet_id;
345 343
346 break; 344 break;
347 } 345 }
348 346
349 case type::limit: 347 case type::limit:
350 { 348 {
351 _limit = other._limit; 349 _limit = other._limit;
352 350
353 break; 351 break;
354 } 352 }
355 353
356 case type::withhold_status: 354 case type::withhold_status:
357 { 355 {
358 _withhold_status._user_id = other._withhold_status._user_id; 356 _withhold_status._user_id = other._withhold_status._user_id;
359 _withhold_status._tweet_id = other._withhold_status._tweet_id; 357 _withhold_status._tweet_id = other._withhold_status._tweet_id;
360 new(&_withhold_status._countries) std::vector<std::string>(other._withhold_status._countries); 358 new(&_withhold_status._countries) std::vector<std::string>(other._withhold_status._countries);
361 359
362 break; 360 break;
363 } 361 }
364 362
365 case type::withhold_user: 363 case type::withhold_user:
366 { 364 {
367 _withhold_user._user_id = other._withhold_user._user_id; 365 _withhold_user._user_id = other._withhold_user._user_id;
368 new(&_withhold_user._countries) std::vector<std::string>(other._withhold_user._countries); 366 new(&_withhold_user._countries) std::vector<std::string>(other._withhold_user._countries);
369 367
370 break; 368 break;
371 } 369 }
372 370
373 case type::disconnect: 371 case type::disconnect:
374 { 372 {
375 _disconnect = other._disconnect; 373 _disconnect = other._disconnect;
376 374
377 break; 375 break;
378 } 376 }
379 377
380 case type::friends: 378 case type::friends:
381 { 379 {
382 new(&_friends) std::set<user_id>(other._friends); 380 new(&_friends) std::set<user_id>(other._friends);
383 381
384 break; 382 break;
385 } 383 }
386 384
387 case type::direct: 385 case type::direct:
388 { 386 {
389 new(&_direct_message) direct_message(other._direct_message); 387 new(&_direct_message) direct_message(other._direct_message);
390 388
391 break; 389 break;
392 } 390 }
393 391
394 case type::unknown: 392 case type::unknown:
395 case type::invalid: 393 case type::invalid:
396 { 394 {
@@ -398,19 +396,19 @@ namespace twitter {
398 } 396 }
399 } 397 }
400 } 398 }
401 399
402 notification::notification(notification&& other) : notification() 400 notification::notification(notification&& other) : notification()
403 { 401 {
404 swap(*this, other); 402 swap(*this, other);
405 } 403 }
406 404
407 notification& notification::operator=(notification other) 405 notification& notification::operator=(notification other)
408 { 406 {
409 swap(*this, other); 407 swap(*this, other);
410 408
411 return *this; 409 return *this;
412 } 410 }
413 411
414 notification::~notification() 412 notification::~notification()
415 { 413 {
416 switch (_type) 414 switch (_type)
@@ -418,10 +416,10 @@ namespace twitter {
418 case type::tweet: 416 case type::tweet:
419 { 417 {
420 _tweet.~tweet(); 418 _tweet.~tweet();
421 419
422 break; 420 break;
423 } 421 }
424 422
425 case type::update_user: 423 case type::update_user:
426 case type::block: 424 case type::block:
427 case type::unblock: 425 case type::unblock:
@@ -430,10 +428,10 @@ namespace twitter {
430 case type::unfollow: 428 case type::unfollow:
431 { 429 {
432 _user.~user(); 430 _user.~user();
433 431
434 break; 432 break;
435 } 433 }
436 434
437 case type::favorite: 435 case type::favorite:
438 case type::favorited: 436 case type::favorited:
439 case type::unfavorite: 437 case type::unfavorite:
@@ -442,19 +440,19 @@ namespace twitter {
442 { 440 {
443 _user_and_tweet._user.~user(); 441 _user_and_tweet._user.~user();
444 _user_and_tweet._tweet.~tweet(); 442 _user_and_tweet._tweet.~tweet();
445 443
446 break; 444 break;
447 } 445 }
448 446
449 case type::list_created: 447 case type::list_created:
450 case type::list_destroyed: 448 case type::list_destroyed:
451 case type::list_updated: 449 case type::list_updated:
452 { 450 {
453 _list.~list(); 451 _list.~list();
454 452
455 break; 453 break;
456 } 454 }
457 455
458 case type::list_add: 456 case type::list_add:
459 case type::list_added: 457 case type::list_added:
460 case type::list_remove: 458 case type::list_remove:
@@ -466,51 +464,51 @@ namespace twitter {
466 { 464 {
467 _user_and_list._user.~user(); 465 _user_and_list._user.~user();
468 _user_and_list._list.~list(); 466 _user_and_list._list.~list();
469 467
470 break; 468 break;
471 } 469 }
472 470
473 case type::stall: 471 case type::stall:
474 case type::follow_limit: 472 case type::follow_limit:
475 case type::unknown_warning: 473 case type::unknown_warning:
476 { 474 {
477 using string_type = std::string; 475 using string_type = std::string;
478 _warning.~string_type(); 476 _warning.~string_type();
479 477
480 break; 478 break;
481 } 479 }
482 480
483 case type::withhold_status: 481 case type::withhold_status:
484 { 482 {
485 using list_type = std::vector<std::string>; 483 using list_type = std::vector<std::string>;
486 _withhold_status._countries.~list_type(); 484 _withhold_status._countries.~list_type();
487 485
488 break; 486 break;
489 } 487 }
490 488
491 case type::withhold_user: 489 case type::withhold_user:
492 { 490 {
493 using list_type = std::vector<std::string>; 491 using list_type = std::vector<std::string>;
494 _withhold_user._countries.~list_type(); 492 _withhold_user._countries.~list_type();
495 493
496 break; 494 break;
497 } 495 }
498 496
499 case type::friends: 497 case type::friends:
500 { 498 {
501 using list_type = std::set<user_id>; 499 using list_type = std::set<user_id>;
502 _friends.~list_type(); 500 _friends.~list_type();
503 501
504 break; 502 break;
505 } 503 }
506 504
507 case type::direct: 505 case type::direct:
508 { 506 {
509 _direct_message.~direct_message(); 507 _direct_message.~direct_message();
510 508
511 break; 509 break;
512 } 510 }
513 511
514 case type::deletion: 512 case type::deletion:
515 case type::scrub_location: 513 case type::scrub_location:
516 case type::limit: 514 case type::limit:
@@ -522,11 +520,11 @@ namespace twitter {
522 } 520 }
523 } 521 }
524 } 522 }
525 523
526 void swap(notification& first, notification& second) 524 void swap(notification& first, notification& second)
527 { 525 {
528 using type = notification::type; 526 using type = notification::type;
529 527
530 type tempType = first._type; 528 type tempType = first._type;
531 tweet tempTweet; 529 tweet tempTweet;
532 user tempUser; 530 user tempUser;
@@ -539,16 +537,16 @@ namespace twitter {
539 disconnect_code tempDisconnectCode; 537 disconnect_code tempDisconnectCode;
540 std::set<user_id> tempFriends; 538 std::set<user_id> tempFriends;
541 direct_message tempDirectMessage; 539 direct_message tempDirectMessage;
542 540
543 switch (first._type) 541 switch (first._type)
544 { 542 {
545 case type::tweet: 543 case type::tweet:
546 { 544 {
547 tempTweet = std::move(first._tweet); 545 tempTweet = std::move(first._tweet);
548 546
549 break; 547 break;
550 } 548 }
551 549
552 case type::update_user: 550 case type::update_user:
553 case type::block: 551 case type::block:
554 case type::unblock: 552 case type::unblock:
@@ -557,10 +555,10 @@ namespace twitter {
557 case type::unfollow: 555 case type::unfollow:
558 { 556 {
559 tempUser = std::move(first._user); 557 tempUser = std::move(first._user);
560 558
561 break; 559 break;
562 } 560 }
563 561
564 case type::favorite: 562 case type::favorite:
565 case type::favorited: 563 case type::favorited:
566 case type::unfavorite: 564 case type::unfavorite:
@@ -569,19 +567,19 @@ namespace twitter {
569 { 567 {
570 tempTweet = std::move(first._user_and_tweet._tweet); 568 tempTweet = std::move(first._user_and_tweet._tweet);
571 tempUser = std::move(first._user_and_tweet._user); 569 tempUser = std::move(first._user_and_tweet._user);
572 570
573 break; 571 break;
574 } 572 }
575 573
576 case type::list_created: 574 case type::list_created:
577 case type::list_destroyed: 575 case type::list_destroyed:
578 case type::list_updated: 576 case type::list_updated:
579 { 577 {
580 tempList = std::move(first._list); 578 tempList = std::move(first._list);
581 579
582 break; 580 break;
583 } 581 }
584 582
585 case type::list_add: 583 case type::list_add:
586 case type::list_added: 584 case type::list_added:
587 case type::list_remove: 585 case type::list_remove:
@@ -593,97 +591,97 @@ namespace twitter {
593 { 591 {
594 tempList = std::move(first._user_and_list._list); 592 tempList = std::move(first._user_and_list._list);
595 tempUser = std::move(first._user_and_list._user); 593 tempUser = std::move(first._user_and_list._user);
596 594
597 break; 595 break;
598 } 596 }
599 597
600 case type::stall: 598 case type::stall:
601 case type::follow_limit: 599 case type::follow_limit:
602 case type::unknown_warning: 600 case type::unknown_warning:
603 { 601 {
604 tempWarning = std::move(first._warning); 602 tempWarning = std::move(first._warning);
605 603
606 break; 604 break;
607 } 605 }
608 606
609 case type::deletion: 607 case type::deletion:
610 case type::scrub_location: 608 case type::scrub_location:
611 { 609 {
612 tempUserId = first._user_id_and_tweet_id._user_id; 610 tempUserId = first._user_id_and_tweet_id._user_id;
613 tempTweetId = first._user_id_and_tweet_id._tweet_id; 611 tempTweetId = first._user_id_and_tweet_id._tweet_id;
614 612
615 break; 613 break;
616 } 614 }
617 615
618 case type::limit: 616 case type::limit:
619 { 617 {
620 tempLimit = first._limit; 618 tempLimit = first._limit;
621 619
622 break; 620 break;
623 } 621 }
624 622
625 case type::withhold_status: 623 case type::withhold_status:
626 { 624 {
627 tempUserId = first._withhold_status._user_id; 625 tempUserId = first._withhold_status._user_id;
628 tempTweetId = first._withhold_status._tweet_id; 626 tempTweetId = first._withhold_status._tweet_id;
629 tempCountries = std::move(first._withhold_status._countries); 627 tempCountries = std::move(first._withhold_status._countries);
630 628
631 break; 629 break;
632 } 630 }
633 631
634 case type::withhold_user: 632 case type::withhold_user:
635 { 633 {
636 tempUserId = first._withhold_user._user_id; 634 tempUserId = first._withhold_user._user_id;
637 tempCountries = std::move(first._withhold_user._countries); 635 tempCountries = std::move(first._withhold_user._countries);
638 636
639 break; 637 break;
640 } 638 }
641 639
642 case type::disconnect: 640 case type::disconnect:
643 { 641 {
644 tempDisconnectCode = first._disconnect; 642 tempDisconnectCode = first._disconnect;
645 643
646 break; 644 break;
647 } 645 }
648 646
649 case type::friends: 647 case type::friends:
650 { 648 {
651 tempFriends = std::move(first._friends); 649 tempFriends = std::move(first._friends);
652 650
653 break; 651 break;
654 } 652 }
655 653
656 case type::direct: 654 case type::direct:
657 { 655 {
658 tempDirectMessage = std::move(first._direct_message); 656 tempDirectMessage = std::move(first._direct_message);
659 657
660 break; 658 break;
661 } 659 }
662 660
663 case type::invalid: 661 case type::invalid:
664 case type::unknown: 662 case type::unknown:
665 { 663 {
666 break; 664 break;
667 } 665 }
668 } 666 }
669 667
670 first.~notification(); 668 first.~notification();
671 669
672 first._type = second._type; 670 first._type = second._type;
673 671
674 // Okay now you need to initialize the first with the data from the second 672 // Okay now you need to initialize the first with the data from the second
675 // And then destruct the second and initialize it with the data stored in temp 673 // And then destruct the second and initialize it with the data stored in temp
676 // This is hell 674 // This is hell
677 675
678 switch (second._type) 676 switch (second._type)
679 { 677 {
680 case type::tweet: 678 case type::tweet:
681 { 679 {
682 new(&first._tweet) tweet(std::move(second._tweet)); 680 new(&first._tweet) tweet(std::move(second._tweet));
683 681
684 break; 682 break;
685 } 683 }
686 684
687 case type::update_user: 685 case type::update_user:
688 case type::block: 686 case type::block:
689 case type::unblock: 687 case type::unblock:
@@ -692,10 +690,10 @@ namespace twitter {
692 case type::unfollow: 690 case type::unfollow:
693 { 691 {
694 new(&first._user) user(std::move(second._user)); 692 new(&first._user) user(std::move(second._user));
695 693
696 break; 694 break;
697 } 695 }
698 696
699 case type::favorite: 697 case type::favorite:
700 case type::favorited: 698 case type::favorited:
701 case type::unfavorite: 699 case type::unfavorite:
@@ -704,19 +702,19 @@ namespace twitter {
704 { 702 {
705 new(&first._user_and_tweet._user) user(std::move(second._user_and_tweet._user)); 703 new(&first._user_and_tweet._user) user(std::move(second._user_and_tweet._user));
706 new(&first._user_and_tweet._tweet) tweet(std::move(second._user_and_tweet._tweet)); 704 new(&first._user_and_tweet._tweet) tweet(std::move(second._user_and_tweet._tweet));
707 705
708 break; 706 break;
709 } 707 }
710 708
711 case type::list_created: 709 case type::list_created:
712 case type::list_destroyed: 710 case type::list_destroyed:
713 case type::list_updated: 711 case type::list_updated:
714 { 712 {
715 new(&first._list) list(std::move(second._list)); 713 new(&first._list) list(std::move(second._list));
716 714
717 break; 715 break;
718 } 716 }
719 717
720 case type::list_add: 718 case type::list_add:
721 case type::list_added: 719 case type::list_added:
722 case type::list_remove: 720 case type::list_remove:
@@ -728,94 +726,94 @@ namespace twitter {
728 { 726 {
729 new(&first._user_and_list._user) user(std::move(second._user_and_list._user)); 727 new(&first._user_and_list._user) user(std::move(second._user_and_list._user));
730 new(&first._user_and_list._list) list(std::move(second._user_and_list._list)); 728 new(&first._user_and_list._list) list(std::move(second._user_and_list._list));
731 729
732 break; 730 break;
733 } 731 }
734 732
735 case type::stall: 733 case type::stall:
736 case type::follow_limit: 734 case type::follow_limit:
737 case type::unknown_warning: 735 case type::unknown_warning:
738 { 736 {
739 new(&first._warning) std::string(std::move(second._warning)); 737 new(&first._warning) std::string(std::move(second._warning));
740 738
741 break; 739 break;
742 } 740 }
743 741
744 case type::deletion: 742 case type::deletion:
745 case type::scrub_location: 743 case type::scrub_location:
746 { 744 {
747 first._user_id_and_tweet_id._user_id = second._user_id_and_tweet_id._user_id; 745 first._user_id_and_tweet_id._user_id = second._user_id_and_tweet_id._user_id;
748 first._user_id_and_tweet_id._tweet_id = second._user_id_and_tweet_id._tweet_id; 746 first._user_id_and_tweet_id._tweet_id = second._user_id_and_tweet_id._tweet_id;
749 747
750 break; 748 break;
751 } 749 }
752 750
753 case type::limit: 751 case type::limit:
754 { 752 {
755 first._limit = second._limit; 753 first._limit = second._limit;
756 754
757 break; 755 break;
758 } 756 }
759 757
760 case type::withhold_status: 758 case type::withhold_status:
761 { 759 {
762 first._withhold_status._user_id = second._withhold_status._user_id; 760 first._withhold_status._user_id = second._withhold_status._user_id;
763 first._withhold_status._tweet_id = second._withhold_status._tweet_id; 761 first._withhold_status._tweet_id = second._withhold_status._tweet_id;
764 new(&first._withhold_status._countries) std::vector<std::string>(std::move(second._withhold_status._countries)); 762 new(&first._withhold_status._countries) std::vector<std::string>(std::move(second._withhold_status._countries));
765 763
766 break; 764 break;
767 } 765 }
768 766
769 case type::withhold_user: 767 case type::withhold_user:
770 { 768 {
771 first._withhold_user._user_id = second._withhold_user._user_id; 769 first._withhold_user._user_id = second._withhold_user._user_id;
772 new(&first._withhold_user._countries) std::vector<std::string>(std::move(second._withhold_user._countries)); 770 new(&first._withhold_user._countries) std::vector<std::string>(std::move(second._withhold_user._countries));
773 771
774 break; 772 break;
775 } 773 }
776 774
777 case type::disconnect: 775 case type::disconnect:
778 { 776 {
779 first._disconnect = second._disconnect; 777 first._disconnect = second._disconnect;
780 778
781 break; 779 break;
782 } 780 }
783 781
784 case type::friends: 782 case type::friends:
785 { 783 {
786 new(&first._friends) std::set<user_id>(std::move(second._friends)); 784 new(&first._friends) std::set<user_id>(std::move(second._friends));
787 785
788 break; 786 break;
789 } 787 }
790 788
791 case type::direct: 789 case type::direct:
792 { 790 {
793 new(&first._direct_message) direct_message(std::move(second._direct_message)); 791 new(&first._direct_message) direct_message(std::move(second._direct_message));
794 792
795 break; 793 break;
796 } 794 }
797 795
798 case type::invalid: 796 case type::invalid:
799 case type::unknown: 797 case type::unknown:
800 { 798 {
801 break; 799 break;
802 } 800 }
803 } 801 }
804 802
805 // Now destruct the second and initialize it with data from the first 803 // Now destruct the second and initialize it with data from the first
806 second.~notification(); 804 second.~notification();
807 805
808 second._type = tempType; 806 second._type = tempType;
809 807
810 switch (tempType) 808 switch (tempType)
811 { 809 {
812 case type::tweet: 810 case type::tweet:
813 { 811 {
814 new(&second._tweet) tweet(std::move(tempTweet)); 812 new(&second._tweet) tweet(std::move(tempTweet));
815 813
816 break; 814 break;
817 } 815 }
818 816
819 case type::update_user: 817 case type::update_user:
820 case type::block: 818 case type::block:
821 case type::unblock: 819 case type::unblock:
@@ -824,10 +822,10 @@ namespace twitter {
824 case type::unfollow: 822 case type::unfollow:
825 { 823 {
826 new(&second._user) user(std::move(tempUser)); 824 new(&second._user) user(std::move(tempUser));
827 825
828 break; 826 break;
829 } 827 }
830 828
831 case type::favorite: 829 case type::favorite:
832 case type::favorited: 830 case type::favorited:
833 case type::unfavorite: 831 case type::unfavorite:
@@ -836,19 +834,19 @@ namespace twitter {
836 { 834 {
837 new(&second._user_and_tweet._user) user(std::move(tempUser)); 835 new(&second._user_and_tweet._user) user(std::move(tempUser));
838 new(&second._user_and_tweet._tweet) tweet(std::move(tempTweet)); 836 new(&second._user_and_tweet._tweet) tweet(std::move(tempTweet));
839 837
840 break; 838 break;
841 } 839 }
842 840
843 case type::list_created: 841 case type::list_created:
844 case type::list_destroyed: 842 case type::list_destroyed:
845 case type::list_updated: 843 case type::list_updated:
846 { 844 {
847 new(&second._list) list(std::move(tempList)); 845 new(&second._list) list(std::move(tempList));
848 846
849 break; 847 break;
850 } 848 }
851 849
852 case type::list_add: 850 case type::list_add:
853 case type::list_added: 851 case type::list_added:
854 case type::list_remove: 852 case type::list_remove:
@@ -860,73 +858,73 @@ namespace twitter {
860 { 858 {
861 new(&second._user_and_list._user) user(std::move(tempUser)); 859 new(&second._user_and_list._user) user(std::move(tempUser));
862 new(&second._user_and_list._list) list(std::move(tempList)); 860 new(&second._user_and_list._list) list(std::move(tempList));
863 861
864 break; 862 break;
865 } 863 }
866 864
867 case type::stall: 865 case type::stall:
868 case type::follow_limit: 866 case type::follow_limit:
869 case type::unknown_warning: 867 case type::unknown_warning:
870 { 868 {
871 new(&second._warning) std::string(std::move(tempWarning)); 869 new(&second._warning) std::string(std::move(tempWarning));
872 870
873 break; 871 break;
874 } 872 }
875 873
876 case type::deletion: 874 case type::deletion:
877 case type::scrub_location: 875 case type::scrub_location:
878 { 876 {
879 second._user_id_and_tweet_id._user_id = tempUserId; 877 second._user_id_and_tweet_id._user_id = tempUserId;
880 second._user_id_and_tweet_id._tweet_id = tempTweetId; 878 second._user_id_and_tweet_id._tweet_id = tempTweetId;
881 879
882 break; 880 break;
883 } 881 }
884 882
885 case type::limit: 883 case type::limit:
886 { 884 {
887 second._limit = tempLimit; 885 second._limit = tempLimit;
888 886
889 break; 887 break;
890 } 888 }
891 889
892 case type::withhold_status: 890 case type::withhold_status:
893 { 891 {
894 second._withhold_status._user_id = tempUserId; 892 second._withhold_status._user_id = tempUserId;
895 second._withhold_status._tweet_id = tempTweetId; 893 second._withhold_status._tweet_id = tempTweetId;
896 new(&second._withhold_status._countries) std::vector<std::string>(std::move(tempCountries)); 894 new(&second._withhold_status._countries) std::vector<std::string>(std::move(tempCountries));
897 895
898 break; 896 break;
899 } 897 }
900 898
901 case type::withhold_user: 899 case type::withhold_user:
902 { 900 {
903 second._withhold_user._user_id = tempUserId; 901 second._withhold_user._user_id = tempUserId;
904 new(&second._withhold_user._countries) std::vector<std::string>(std::move(tempCountries)); 902 new(&second._withhold_user._countries) std::vector<std::string>(std::move(tempCountries));
905 903
906 break; 904 break;
907 } 905 }
908 906
909 case type::disconnect: 907 case type::disconnect:
910 { 908 {
911 second._disconnect = tempDisconnectCode; 909 second._disconnect = tempDisconnectCode;
912 910
913 break; 911 break;
914 } 912 }
915 913
916 case type::friends: 914 case type::friends:
917 { 915 {
918 new(&second._friends) std::set<user_id>(std::move(tempFriends)); 916 new(&second._friends) std::set<user_id>(std::move(tempFriends));
919 917
920 break; 918 break;
921 } 919 }
922 920
923 case type::direct: 921 case type::direct:
924 { 922 {
925 new(&second._direct_message) direct_message(std::move(tempDirectMessage)); 923 new(&second._direct_message) direct_message(std::move(tempDirectMessage));
926 924
927 break; 925 break;
928 } 926 }
929 927
930 case type::invalid: 928 case type::invalid:
931 case type::unknown: 929 case type::unknown:
932 { 930 {
@@ -934,7 +932,7 @@ namespace twitter {
934 } 932 }
935 } 933 }
936 } 934 }
937 935
938 const tweet& notification::getTweet() const 936 const tweet& notification::getTweet() const
939 { 937 {
940 switch (_type) 938 switch (_type)
@@ -943,7 +941,7 @@ namespace twitter {
943 { 941 {
944 return _tweet; 942 return _tweet;
945 } 943 }
946 944
947 case type::favorite: 945 case type::favorite:
948 case type::favorited: 946 case type::favorited:
949 case type::unfavorite: 947 case type::unfavorite:
@@ -952,14 +950,14 @@ namespace twitter {
952 { 950 {
953 return _user_and_tweet._tweet; 951 return _user_and_tweet._tweet;
954 } 952 }
955 953
956 default: 954 default:
957 { 955 {
958 assert(false); 956 assert(false);
959 } 957 }
960 } 958 }
961 } 959 }
962 960
963 const user& notification::getUser() const 961 const user& notification::getUser() const
964 { 962 {
965 switch (_type) 963 switch (_type)
@@ -973,7 +971,7 @@ namespace twitter {
973 { 971 {
974 return _user; 972 return _user;
975 } 973 }
976 974
977 case type::favorite: 975 case type::favorite:
978 case type::favorited: 976 case type::favorited:
979 case type::unfavorite: 977 case type::unfavorite:
@@ -982,7 +980,7 @@ namespace twitter {
982 { 980 {
983 return _user_and_tweet._user; 981 return _user_and_tweet._user;
984 } 982 }
985 983
986 case type::list_add: 984 case type::list_add:
987 case type::list_added: 985 case type::list_added:
988 case type::list_remove: 986 case type::list_remove:
@@ -994,25 +992,25 @@ namespace twitter {
994 { 992 {
995 return _user_and_list._user; 993 return _user_and_list._user;
996 } 994 }
997 995
998 default: 996 default:
999 { 997 {
1000 assert(false); 998 assert(false);
1001 } 999 }
1002 } 1000 }
1003 } 1001 }
1004 1002
1005 const list& notification::getList() const 1003 const list& notification::getList() const
1006 { 1004 {
1007 switch (_type) 1005 switch (_type)
1008 { 1006 {
1009 case type::list_created: 1007 case type::list_created:
1010 case type::list_destroyed: 1008 case type::list_destroyed:
1011 case type::list_updated: 1009 case type::list_updated:
1012 { 1010 {
1013 return _list; 1011 return _list;
1014 } 1012 }
1015 1013
1016 case type::list_add: 1014 case type::list_add:
1017 case type::list_added: 1015 case type::list_added:
1018 case type::list_remove: 1016 case type::list_remove:
@@ -1024,14 +1022,14 @@ namespace twitter {
1024 { 1022 {
1025 return _user_and_list._list; 1023 return _user_and_list._list;
1026 } 1024 }
1027 1025
1028 default: 1026 default:
1029 { 1027 {
1030 assert(false); 1028 assert(false);
1031 } 1029 }
1032 } 1030 }
1033 } 1031 }
1034 1032
1035 tweet_id notification::getTweetID() const 1033 tweet_id notification::getTweetID() const
1036 { 1034 {
1037 switch (_type) 1035 switch (_type)
@@ -1041,19 +1039,19 @@ namespace twitter {
1041 { 1039 {
1042 return _user_id_and_tweet_id._tweet_id; 1040 return _user_id_and_tweet_id._tweet_id;
1043 } 1041 }
1044 1042
1045 case type::withhold_status: 1043 case type::withhold_status:
1046 { 1044 {
1047 return _withhold_status._tweet_id; 1045 return _withhold_status._tweet_id;
1048 } 1046 }
1049 1047
1050 default: 1048 default:
1051 { 1049 {
1052 assert(false); 1050 assert(false);
1053 } 1051 }
1054 } 1052 }
1055 } 1053 }
1056 1054
1057 void notification::setTweetID(tweet_id _arg) 1055 void notification::setTweetID(tweet_id _arg)
1058 { 1056 {
1059 switch (_type) 1057 switch (_type)
@@ -1063,34 +1061,34 @@ namespace twitter {
1063 { 1061 {
1064 _user_id_and_tweet_id._tweet_id = _arg;; 1062 _user_id_and_tweet_id._tweet_id = _arg;;
1065 } 1063 }
1066 1064
1067 case type::withhold_status: 1065 case type::withhold_status:
1068 { 1066 {
1069 _withhold_status._tweet_id = _arg; 1067 _withhold_status._tweet_id = _arg;
1070 } 1068 }
1071 1069
1072 default: 1070 default:
1073 { 1071 {
1074 assert(false); 1072 assert(false);
1075 } 1073 }
1076 } 1074 }
1077 } 1075 }
1078 1076
1079 user_id notification::getUserID() const 1077 user_id notification::getUserID() const
1080 { 1078 {
1081 switch (_type) 1079 switch (_type)
1082 { 1080 {
1083 case type::deletion: 1081 case type::deletion:
1084 case type::scrub_location: 1082 case type::scrub_location:
1085 { 1083 {
1086 return _user_id_and_tweet_id._user_id; 1084 return _user_id_and_tweet_id._user_id;
1087 } 1085 }
1088 1086
1089 case type::withhold_status: 1087 case type::withhold_status:
1090 { 1088 {
1091 return _withhold_status._user_id; 1089 return _withhold_status._user_id;
1092 } 1090 }
1093 1091
1094 case type::withhold_user: 1092 case type::withhold_user:
1095 { 1093 {
1096 return _withhold_user._user_id; 1094 return _withhold_user._user_id;
@@ -1102,22 +1100,22 @@ namespace twitter {
1102 } 1100 }
1103 } 1101 }
1104 } 1102 }
1105 1103
1106 void notification::setUserID(user_id _arg) 1104 void notification::setUserID(user_id _arg)
1107 { 1105 {
1108 switch (_type) 1106 switch (_type)
1109 { 1107 {
1110 case type::deletion: 1108 case type::deletion:
1111 case type::scrub_location: 1109 case type::scrub_location:
1112 { 1110 {
1113 _user_id_and_tweet_id._user_id = _arg; 1111 _user_id_and_tweet_id._user_id = _arg;
1114 } 1112 }
1115 1113
1116 case type::withhold_status: 1114 case type::withhold_status:
1117 { 1115 {
1118 _withhold_status._user_id = _arg; 1116 _withhold_status._user_id = _arg;
1119 } 1117 }
1120 1118
1121 case type::withhold_user: 1119 case type::withhold_user:
1122 { 1120 {
1123 _withhold_user._user_id = _arg; 1121 _withhold_user._user_id = _arg;
@@ -1129,16 +1127,16 @@ namespace twitter {
1129 } 1127 }
1130 } 1128 }
1131 } 1129 }
1132 1130
1133 const std::vector<std::string>& notification::getCountries() const 1131 const std::vector<std::string>& notification::getCountries() const
1134 { 1132 {
1135 switch (_type) 1133 switch (_type)
1136 { 1134 {
1137 case type::withhold_status: 1135 case type::withhold_status:
1138 { 1136 {
1139 return _withhold_status._countries; 1137 return _withhold_status._countries;
1140 } 1138 }
1141 1139
1142 case type::withhold_user: 1140 case type::withhold_user:
1143 { 1141 {
1144 return _withhold_user._countries; 1142 return _withhold_user._countries;
@@ -1150,49 +1148,49 @@ namespace twitter {
1150 } 1148 }
1151 } 1149 }
1152 } 1150 }
1153 1151
1154 disconnect_code notification::getDisconnectCode() const 1152 disconnect_code notification::getDisconnectCode() const
1155 { 1153 {
1156 assert(_type == type::disconnect); 1154 assert(_type == type::disconnect);
1157 1155
1158 return _disconnect; 1156 return _disconnect;
1159 } 1157 }
1160 1158
1161 void notification::setDisconnectCode(disconnect_code _arg) 1159 void notification::setDisconnectCode(disconnect_code _arg)
1162 { 1160 {
1163 assert(_type == type::disconnect); 1161 assert(_type == type::disconnect);
1164 1162
1165 _disconnect = _arg; 1163 _disconnect = _arg;
1166 } 1164 }
1167 1165
1168 const std::set<user_id>& notification::getFriends() const 1166 const std::set<user_id>& notification::getFriends() const
1169 { 1167 {
1170 assert(_type == type::friends); 1168 assert(_type == type::friends);
1171 1169
1172 return _friends; 1170 return _friends;
1173 } 1171 }
1174 1172
1175 const direct_message& notification::getDirectMessage() const 1173 const direct_message& notification::getDirectMessage() const
1176 { 1174 {
1177 assert(_type == type::direct); 1175 assert(_type == type::direct);
1178 1176
1179 return _direct_message; 1177 return _direct_message;
1180 } 1178 }
1181 1179
1182 int notification::getLimit() const 1180 int notification::getLimit() const
1183 { 1181 {
1184 assert(_type == type::limit); 1182 assert(_type == type::limit);
1185 1183
1186 return _limit; 1184 return _limit;
1187 } 1185 }
1188 1186
1189 void notification::setLimit(int _arg) 1187 void notification::setLimit(int _arg)
1190 { 1188 {
1191 assert(_type == type::limit); 1189 assert(_type == type::limit);
1192 1190
1193 _limit = _arg; 1191 _limit = _arg;
1194 } 1192 }
1195 1193
1196 const std::string& notification::getWarning() const 1194 const std::string& notification::getWarning() const
1197 { 1195 {
1198 switch (_type) 1196 switch (_type)
@@ -1203,12 +1201,12 @@ namespace twitter {
1203 { 1201 {
1204 return _warning; 1202 return _warning;
1205 } 1203 }
1206 1204
1207 default: 1205 default:
1208 { 1206 {
1209 assert(false); 1207 assert(false);
1210 } 1208 }
1211 } 1209 }
1212 } 1210 }
1213 1211
1214}; 1212};