about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--src/tweet.cpp15
-rw-r--r--src/tweet.h2
2 files changed, 17 insertions, 0 deletions
diff --git a/src/tweet.cpp b/src/tweet.cpp index e515595..5885b51 100644 --- a/src/tweet.cpp +++ b/src/tweet.cpp
@@ -1,5 +1,6 @@
1#include "tweet.h" 1#include "tweet.h"
2#include <json.hpp> 2#include <json.hpp>
3#include <cassert>
3 4
4using nlohmann::json; 5using nlohmann::json;
5 6
@@ -16,23 +17,37 @@ namespace twitter {
16 _id = _data.at("id"); 17 _id = _data.at("id");
17 _text = _data.at("text"); 18 _text = _data.at("text");
18 _author = user(_data.at("user").dump()); 19 _author = user(_data.at("user").dump());
20 _retweeted = _data.at("retweeted");
19 } 21 }
20 22
21 tweet_id tweet::getID() const 23 tweet_id tweet::getID() const
22 { 24 {
25 assert(_valid);
26
23 return _id; 27 return _id;
24 } 28 }
25 29
26 std::string tweet::getText() const 30 std::string tweet::getText() const
27 { 31 {
32 assert(_valid);
33
28 return _text; 34 return _text;
29 } 35 }
30 36
31 const user& tweet::getAuthor() const 37 const user& tweet::getAuthor() const
32 { 38 {
39 assert(_valid);
40
33 return _author; 41 return _author;
34 } 42 }
35 43
44 bool tweet::isRetweet() const
45 {
46 assert(_valid);
47
48 return _retweeted;
49 }
50
36 tweet::operator bool() const 51 tweet::operator bool() const
37 { 52 {
38 return _valid; 53 return _valid;
diff --git a/src/tweet.h b/src/tweet.h index 137776c..fba1ced 100644 --- a/src/tweet.h +++ b/src/tweet.h
@@ -16,6 +16,7 @@ namespace twitter {
16 tweet_id getID() const; 16 tweet_id getID() const;
17 std::string getText() const; 17 std::string getText() const;
18 const user& getAuthor() const; 18 const user& getAuthor() const;
19 bool isRetweet() const;
19 20
20 operator bool() const; 21 operator bool() const;
21 22
@@ -24,6 +25,7 @@ namespace twitter {
24 tweet_id _id; 25 tweet_id _id;
25 std::string _text; 26 std::string _text;
26 user _author; 27 user _author;
28 bool _retweeted;
27 }; 29 };
28 30
29}; 31};