mastodon-cpp  0.15.1
attachment.hpp
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2018 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODON_CPP_EASY_ATTACHMENT_HPP
18 #define MASTODON_CPP_EASY_ATTACHMENT_HPP
19 
20 #include <string>
21 #include <cstdint>
22 #include <chrono>
23 #include <array>
24 
25 // If we are compiling mastodon-cpp, use another include path
26 #ifdef MASTODON_CPP
27  #include "mastodon-cpp.hpp"
28  #include "easy/easy.hpp"
29 #else
30  #include <mastodon-cpp/mastodon-cpp.hpp>
31  #include <mastodon-cpp/easy/easy.hpp>
32 #endif
33 
34 using std::string;
35 using std::uint_fast64_t;
36 
37 namespace Mastodon
38 {
43  {
44  public:
50  explicit Attachment(const string &json);
51 
55  Attachment();
56 
60  const double aspect() const;
61 
65  const double aspect_small() const;
66 
70  const uint_fast64_t bitrate() const;
74  const string description() const;
75 
79  const std::chrono::duration<double> duration() const;
80 
86  const std::array<double, 2> focus() const;
87 
91  const double framerate() const;
92 
96  const uint_fast64_t height() const;
97 
101  const uint_fast64_t height_small() const;
102 
106  const uint_fast64_t id() const;
107 
111  const string preview_url() const;
112 
116  const string remote_url() const;
117 
121  const string size() const;
122 
126  const string size_small() const;
127 
131  const string text_url() const;
132 
136  const attachment_type type() const;
137 
141  const string url() const;
142 
146  const uint_fast64_t width() const;
147 
151  const uint_fast64_t width_small() const;
152 
153 
154  };
155 }
156 
157 #endif // MASTODON_CPP_EASY_ATTACHMENT_HPP
const attachment_type type() const
Returns attachment type.
Definition: attachment.cpp:134
const uint_fast64_t bitrate() const
Returns the bitrate of a video.
Definition: attachment.cpp:42
const string preview_url() const
Returns the URL of the preview image.
Definition: attachment.cpp:109
Attachment()
Constructs an empty Attachment object.
Definition: attachment.cpp:28
const string description() const
Returns the image description.
Definition: attachment.cpp:47
Class to hold attachments.
Definition: attachment.hpp:42
const uint_fast64_t height() const
Returns the height of the original image.
Definition: attachment.cpp:94
const uint_fast64_t width_small() const
Returns the width of the preview image.
Definition: attachment.cpp:160
attachment_type
Describes the attachment type.
Definition: easy.hpp:73
const string text_url() const
Returns shorter URL for the image.
Definition: attachment.cpp:129
const string size_small() const
Returns the size of the preview image.
Definition: attachment.cpp:124
const string url() const
Returns URL of the locally hosted version of the image.
Definition: attachment.cpp:150
const string remote_url() const
Returns the remote URL of the original image.
Definition: attachment.cpp:114
const std::chrono::duration< double > duration() const
Returns the duration of a video in seconds.
Definition: attachment.cpp:52
Definition: mastodon-cpp.hpp:51
const double aspect_small() const
Aspect of preview image.
Definition: attachment.cpp:37
Base class for all entities.
Definition: easy.hpp:225
const uint_fast64_t width() const
Returns the width of the original image.
Definition: attachment.cpp:155
const string size() const
Returns the size of the original image.
Definition: attachment.cpp:119
const uint_fast64_t height_small() const
Returns the height of the preview image.
Definition: attachment.cpp:99
const uint_fast64_t id() const
Returns the ID of the attachment.
Definition: attachment.cpp:104
const std::array< double, 2 > focus() const
Returns the focus point (x, y)
Definition: attachment.cpp:59
const double aspect() const
Aspect of original image.
Definition: attachment.cpp:32
const double framerate() const
Returns the framerate of a video in frames per second.
Definition: attachment.cpp:75