mastodon-cpp  0.101.1
attachment.hpp
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2018, 2019 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/entity.hpp"
29 #else
30  #include <mastodon-cpp/mastodon-cpp.hpp>
31  #include <mastodon-cpp/easy/entity.hpp>
32 #endif
33 
34 using std::string;
35 using std::uint64_t;
36 
37 namespace Mastodon
38 {
39 namespace Easy
40 {
46  class Attachment : public Entity
47  {
48  public:
49  using Entity::Entity;
50 
51  virtual bool valid() const override;
52 
58  double aspect() const;
59 
65  double aspect_small() const;
66 
72  uint64_t bitrate() const;
73 
79  const string description() const;
80 
86  Attachment description(const string &description);
87 
93  const std::chrono::duration<double> duration() const;
94 
100  const string file() const;
101 
109  Attachment file(const string &file);
110 
118  const std::array<double, 2> focus() const;
119 
127  Attachment focus(const std::array<double, 2> &focus);
128 
134  double framerate() const;
135 
141  uint64_t height() const;
142 
148  uint64_t height_small() const;
149 
155  const string id() const;
156 
162  const string preview_url() const;
163 
169  const string remote_url() const;
170 
176  const string size() const;
177 
183  const string size_small() const;
184 
190  const string text_url() const;
191 
197  attachment_type type() const;
198 
204  const string url() const;
205 
211  uint64_t width() const;
212 
218  uint64_t width_small() const;
219 
220 
221  };
222 }
223 }
224 
225 #endif // MASTODON_CPP_EASY_ATTACHMENT_HPP
virtual bool valid() const override
Returns true if the Entity holds valid data.
Definition: attachment.cpp:24
const string preview_url() const
Returns the URL of the preview image.
Definition: attachment.cpp:139
Entity()
Constructs an empty Entity object.
Definition: entity.cpp:42
const string description() const
Returns the image description.
Definition: attachment.cpp:52
Class to hold attachments.
Definition: attachment.hpp:46
uint64_t height() const
Returns the height of the original image.
Definition: attachment.cpp:124
uint64_t bitrate() const
Returns the bitrate of a video.
Definition: attachment.cpp:47
const string text_url() const
Returns shorter URL for the image.
Definition: attachment.cpp:159
const string size_small() const
Returns the size of the preview image.
Definition: attachment.cpp:154
double aspect() const
Aspect of original image.
Definition: attachment.cpp:37
const string url() const
Returns URL of the locally hosted version of the image.
Definition: attachment.cpp:180
uint64_t width_small() const
Returns the width of the preview image.
Definition: attachment.cpp:190
const string remote_url() const
Returns the remote URL of the original image.
Definition: attachment.cpp:144
uint64_t height_small() const
Returns the height of the preview image.
Definition: attachment.cpp:129
const std::chrono::duration< double > duration() const
Returns the duration of a video in seconds.
Definition: attachment.cpp:63
attachment_type type() const
Returns attachment type.
Definition: attachment.cpp:164
Collection of things to interface with server software that implements the Mastodon API...
Definition: mastodon-cpp.hpp:52
Base class for all entities.
Definition: entity.hpp:41
uint64_t width() const
Returns the width of the original image.
Definition: attachment.cpp:185
const string id() const
Returns the ID of the attachment.
Definition: attachment.cpp:134
const string size() const
Returns the size of the original image.
Definition: attachment.cpp:149
double aspect_small() const
Aspect of preview image.
Definition: attachment.cpp:42
const string file() const
Gets file to upload.
Definition: attachment.cpp:70
double framerate() const
Returns the framerate of a video in frames per second.
Definition: attachment.cpp:105
attachment_type
Describes the attachment type.
Definition: types_easy.hpp:68
const std::array< double, 2 > focus() const
Returns the focus point (x, y)
Definition: attachment.cpp:82