diff options
author | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-08-30 20:43:23 -0400 |
---|---|---|
committer | Kelly Rauchenberger <fefferburbia@gmail.com> | 2018-08-30 20:43:23 -0400 |
commit | 8584857578c3a2946a03de98ff3803431143297a (patch) | |
tree | e3cb3d9487a7b72a22e5dd50d91011d966a4ee15 /src/user.h | |
parent | a9d33aa08df10102539e33c0c6d4334e9e99a470 (diff) | |
download | libtwittercpp-8584857578c3a2946a03de98ff3803431143297a.tar.gz libtwittercpp-8584857578c3a2946a03de98ff3803431143297a.tar.bz2 libtwittercpp-8584857578c3a2946a03de98ff3803431143297a.zip |
Refactored tweet and user classes
The only API-visible change is that these classes are no longer default constructible. Other than that, tweet now uses hatkirby::recptr to wrap its retweeted_status (tweet) and author (user) member objects, removing the need to implement the Rule of Five.
Diffstat (limited to 'src/user.h')
-rw-r--r-- | src/user.h | 94 |
1 files changed, 40 insertions, 54 deletions
diff --git a/src/user.h b/src/user.h index acd62d0..b743074 100644 --- a/src/user.h +++ b/src/user.h | |||
@@ -2,66 +2,52 @@ | |||
2 | #define USER_H_BF3AB38C | 2 | #define USER_H_BF3AB38C |
3 | 3 | ||
4 | #include <string> | 4 | #include <string> |
5 | #include <set> | ||
6 | #include <cassert> | ||
7 | 5 | ||
8 | namespace twitter { | 6 | namespace twitter { |
9 | 7 | ||
10 | class client; | ||
11 | |||
12 | typedef unsigned long long user_id; | 8 | typedef unsigned long long user_id; |
13 | 9 | ||
14 | class user { | 10 | class user { |
15 | public: | 11 | public: |
16 | 12 | ||
17 | user() {} | 13 | user(std::string data); |
18 | user(std::string data); | 14 | |
19 | 15 | user_id getID() const | |
20 | user_id getID() const | 16 | { |
21 | { | 17 | return _id; |
22 | assert(_valid); | 18 | } |
23 | 19 | ||
24 | return _id; | 20 | std::string getScreenName() const |
25 | } | 21 | { |
26 | 22 | return _screen_name; | |
27 | std::string getScreenName() const | 23 | } |
28 | { | 24 | |
29 | assert(_valid); | 25 | std::string getName() const |
30 | 26 | { | |
31 | return _screen_name; | 27 | return _name; |
32 | } | 28 | } |
33 | 29 | ||
34 | std::string getName() const | 30 | bool isProtected() const |
35 | { | 31 | { |
36 | assert(_valid); | 32 | return _protected; |
37 | 33 | } | |
38 | return _name; | 34 | |
39 | } | 35 | bool operator==(const user& other) const |
40 | 36 | { | |
41 | bool isProtected() const | 37 | return _id == other._id; |
42 | { | 38 | } |
43 | assert(_valid); | 39 | |
44 | 40 | bool operator!=(const user& other) const | |
45 | return _protected; | 41 | { |
46 | } | 42 | return _id != other._id; |
47 | 43 | } | |
48 | bool operator==(const user& other) const | 44 | |
49 | { | 45 | private: |
50 | return _id == other._id; | 46 | |
51 | } | 47 | user_id _id; |
52 | 48 | std::string _screen_name; | |
53 | bool operator!=(const user& other) const | 49 | std::string _name; |
54 | { | 50 | bool _protected = false; |
55 | return _id != other._id; | ||
56 | } | ||
57 | |||
58 | private: | ||
59 | |||
60 | bool _valid = false; | ||
61 | user_id _id; | ||
62 | std::string _screen_name; | ||
63 | std::string _name; | ||
64 | bool _protected = false; | ||
65 | }; | 51 | }; |
66 | 52 | ||
67 | }; | 53 | }; |