about summary refs log tree commit diff stats
path: root/src/tweet.h
blob: ae1c916776e2f3c27ae7c99e5153aa7503e4d5ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#ifndef TWEET_H_CE980721
#define TWEET_H_CE980721

#include <string>
#include <vector>
#include <utility>
#include <cassert>
#include <list>
#include <memory>
#include "user.h"

namespace twitter {
  
  class client;
  
  typedef unsigned long long tweet_id;
  
  class tweet {
    public:
      
      tweet() {}
      tweet(std::string data);
      
      tweet(const tweet& other);
      tweet(tweet&& other);
      
      tweet& operator=(tweet other);
      
      friend void swap(tweet& first, tweet& second);
      
      tweet_id getID() const
      {
        assert(_valid);
        
        return _id;
      }
      
      std::string getText() const
      {
        assert(_valid);
        
        return _text;
      }
      
      const user& getAuthor() const
      {
        assert(_valid);
        
        return *_author;
      }

      bool isRetweet() const
      {
        assert(_valid);
        
        return _is_retweet;
      }
      
      const tweet& getRetweet() const
      {
        assert(_valid && _is_retweet);
        
        return *_retweeted_status;
      }
      
      const std::vector<std::pair<user_id, std::string>>& getMentions() const
      {
        assert(_valid);
        
        return _mentions;
      }
      
      std::string generateReplyPrefill(const user& me) const;
      
      std::string getURL() const;
      
    private:
      
      bool _valid = false;
      tweet_id _id;
      std::string _text;
      std::unique_ptr<user> _author;
      bool _is_retweet = false;
      std::unique_ptr<tweet> _retweeted_status;
      std::vector<std::pair<user_id, std::string>> _mentions;
  };
  
};

#endif /* end of include guard: TWEET_H_CE980721 */