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

#include <string>
#include <vector>
#include <utility>
#include <ctime>
#include "../vendor/hkutil/hkutil/recptr.h"
#include "user.h"

namespace twitter {

  typedef unsigned long long tweet_id;

  class tweet {
  public:

    tweet(std::string data);

    tweet_id getID() const
    {
      return _id;
    }

    std::string getText() const
    {
      return _text;
    }

    const user& getAuthor() const
    {
      return *_author;
    }

    const std::time_t& getCreatedAt() const
    {
      return _created_at;
    }

    bool isRetweet() const
    {
      return _is_retweet;
    }

    const tweet& getRetweet() const
    {
      if (!_is_retweet)
      {
        throw std::logic_error("Tweet is not a retweet");
      }

      return *_retweeted_status;
    }

    const std::vector<std::pair<user_id, std::string>>& getMentions() const
    {
      return _mentions;
    }

    std::string generateReplyPrefill(const user& me) const;

    std::string getURL() const;

  private:

    tweet_id _id;
    std::string _text;
    hatkirby::recptr<user> _author;
    std::time_t _created_at;
    bool _is_retweet = false;
    hatkirby::recptr<tweet> _retweeted_status;
    std::vector<std::pair<user_id, std::string>> _mentions;
  };

};

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