mastodon-cpp  0.110.0
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 Affero 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 Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero 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 #include "../../mastodon-cpp.hpp"
26 #include "../entity.hpp"
27 
28 using std::string;
29 using std::uint64_t;
30 
31 namespace Mastodon
32 {
33 namespace Easy
34 {
40  class Attachment : public Entity
41  {
42  public:
43  using Entity::Entity;
44 
50  class Meta : public Entity
51  {
52  public:
53  using Entity::Entity;
54 
55  virtual bool valid() const override;
56 
62  double aspect() const;
63 
69  double aspect_small() const;
70 
76  uint64_t bitrate() const;
77 
83  const std::chrono::duration<double> duration() const;
84 
90  double frame_rate() const;
91 
97  uint64_t height() const;
98 
104  uint64_t height_small() const;
105 
111  const string size() const;
112 
118  const string size_small() const;
119 
125  uint64_t width() const;
126 
132  uint64_t width_small() const;
133  };
134 
135  virtual bool valid() const override;
136 
142  const string description() const;
143 
149  Attachment description(const string &description);
150 
156  const string file() const;
157 
165  Attachment file(const string &file);
166 
174  const std::array<double, 2> focus() const;
175 
183  Attachment focus(const std::array<double, 2> &focus);
184 
190  const string id() const;
191 
197  const Meta meta() const;
198 
204  const string preview_url() const;
205 
211  const string remote_url() const;
212 
218  const string text_url() const;
219 
225  attachment_type type() const;
226 
232  const string url() const;
233  };
234 }
235 }
236 
237 #endif // MASTODON_CPP_EASY_ATTACHMENT_HPP
virtual bool valid() const override
Returns true if the Entity holds valid data.
Definition: attachment.cpp:24
uint64_t width_small() const
Returns the width of the preview image.
Definition: attachment.cpp:198
const string preview_url() const
Returns the URL of the preview image.
Definition: attachment.cpp:91
uint64_t height() const
Returns the height of the original image.
Definition: attachment.cpp:173
Entity()
Constructs an empty Entity object.
Definition: entity.cpp:43
const string description() const
Returns the image description.
Definition: attachment.cpp:35
Class to hold attachments.
Definition: attachment.hpp:40
double frame_rate() const
Returns the framerate of a video in frames per second.
Definition: attachment.cpp:154
const std::chrono::duration< double > duration() const
Returns the duration of a video in seconds.
Definition: attachment.cpp:147
const string text_url() const
Returns shorter URL for the image.
Definition: attachment.cpp:101
virtual bool valid() const override
Returns true if the Entity holds valid data.
Definition: attachment.cpp:127
const string url() const
Returns URL of the locally hosted version of the image.
Definition: attachment.cpp:122
const string remote_url() const
Returns the remote URL of the original image.
Definition: attachment.cpp:96
const Meta meta() const
Returns metadata about the attachment.
Definition: attachment.cpp:86
uint64_t width() const
Returns the width of the original image.
Definition: attachment.cpp:193
const string size_small() const
Returns the size of the preview image.
Definition: attachment.cpp:188
double aspect_small() const
Aspect of preview image.
Definition: attachment.cpp:137
uint64_t height_small() const
Returns the height of the preview image.
Definition: attachment.cpp:178
const string size() const
Returns the size of the original image.
Definition: attachment.cpp:183
Metadata for attachments.
Definition: attachment.hpp:50
attachment_type type() const
Returns attachment type.
Definition: attachment.cpp:106
Collection of things to interface with server software that implements the Mastodon API.
Definition: mastodon-cpp.hpp:47
Base class for all entities.
Definition: entity.hpp:36
const string id() const
Returns the ID of the attachment.
Definition: attachment.cpp:81
uint64_t bitrate() const
Returns the bitrate of a video.
Definition: attachment.cpp:142
const string file() const
Gets file to upload.
Definition: attachment.cpp:46
double aspect() const
Aspect of original image.
Definition: attachment.cpp:132
attachment_type
Describes the attachment type.
Definition: types_easy.hpp:69
const std::array< double, 2 > focus() const
Returns the focus point (x, y)
Definition: attachment.cpp:58