about summary refs log tree commit diff stats
path: root/src/tweet.h
blob: a29e45cfd48d64c30c2b7f1e7017deaa4f29ad8e (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
#ifndef TWEET_H_CE980721
#define TWEET_H_CE980721

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

namespace twitter {
  
  class client;
  
  typedef unsigned long long tweet_id;
  
  class tweet {
    public:
      
      tweet(const client& tclient, std::string data);
      
      tweet(const tweet& other) = delete;
      tweet& operator=(const tweet& other) = delete;
      
      tweet(tweet&& other) = default;
      tweet& operator=(tweet&& other) = default;
      
      tweet_id getID() const
      {
        return _id;
      }
      
      std::string getText() const
      {
        return _text;
      }
      
      const user& getAuthor() const
      {
        return *_author;
      }

      bool isRetweet() const
      {
        return _is_retweet;
      }
      
      const tweet& getRetweet() const
      {
        assert(_is_retweet);
        
        return *_retweeted_status;
      }
      
      const std::vector<std::pair<user_id, std::string>>& getMentions() const
      {
        return _mentions;
      }
      
      std::string generateReplyPrefill() const;
      
      tweet reply(std::string message, std::list<long> media_ids = {}) const;
      
      bool isMyTweet() const;
      
      std::string getURL() const;
      
    private:
      
      const client& _client;
      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 */