This repository has been archived on 2020-05-10. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon-cpp/src/easy/entities/attachment.hpp

238 lines
5.7 KiB
C++
Raw Normal View History

2018-03-22 00:33:36 +01:00
/* This file is part of mastodon-cpp.
2019-03-20 06:15:43 +01:00
* Copyright © 2018, 2019 tastytea <tastytea@tastytea.de>
*
2018-03-22 00:33:36 +01:00
* This program is free software: you can redistribute it and/or modify
2019-08-15 22:53:38 +02:00
* it under the terms of the GNU Affero General Public License as published by
2018-03-22 00:33:36 +01:00
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2019-08-15 22:53:38 +02:00
* GNU Affero General Public License for more details.
2018-03-22 00:33:36 +01:00
*
2019-08-15 22:53:38 +02:00
* You should have received a copy of the GNU Affero General Public License
2018-03-22 00:33:36 +01:00
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MASTODON_CPP_EASY_ATTACHMENT_HPP
#define MASTODON_CPP_EASY_ATTACHMENT_HPP
#include <string>
#include <cstdint>
#include <chrono>
#include <array>
2019-08-12 04:06:43 +02:00
#include "../../mastodon-cpp.hpp"
#include "../entity.hpp"
2018-03-22 00:33:36 +01:00
using std::string;
using std::uint64_t;
2018-03-22 00:33:36 +01:00
namespace Mastodon
2019-03-29 14:44:39 +01:00
{
namespace Easy
2018-03-22 00:33:36 +01:00
{
/*!
* @brief Class to hold attachments
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2019-03-29 14:44:39 +01:00
class Attachment : public Entity
2018-03-22 00:33:36 +01:00
{
public:
2019-03-11 20:48:54 +01:00
using Entity::Entity;
2018-03-30 20:16:31 +02:00
2018-03-22 00:33:36 +01:00
/*!
* @brief Metadata for attachments.
*
* @since 0.106.0
*/
class Meta : public Entity
{
public:
using Entity::Entity;
virtual bool valid() const override;
/*!
* @brief Aspect of original image.
*
* @since 0.106.0
*/
double aspect() const;
/*!
* @brief Aspect of preview image.
*
* @since 0.106.0
*/
double aspect_small() const;
/*!
* @brief Returns the bitrate of a video.
*
* @since 0.106.0
*/
uint64_t bitrate() const;
/*!
* @brief Returns the duration of a video in seconds.
*
* @since 0.106.0
*/
const std::chrono::duration<double> duration() const;
/*!
* @brief Returns the framerate of a video in frames per second.
*
* @since 0.106.0
*/
double frame_rate() const;
/*!
* @brief Returns the height of the original image.
*
* @since 0.106.0
*/
uint64_t height() const;
/*!
* @brief Returns the height of the preview image.
*
* @since 0.106.0
*/
uint64_t height_small() const;
/*!
* @brief Returns the size of the original image.
*
* @since 0.106.0
*/
const string size() const;
/*!
* @brief Returns the size of the preview image.
*
* @since 0.106.0
*/
const string size_small() const;
/*!
* @brief Returns the width of the original image.
*
* @since 0.106.0
*/
uint64_t width() const;
/*!
* @brief Returns the width of the preview image
*
* @since 0.106.0
*/
uint64_t width_small() const;
};
2018-03-22 00:33:36 +01:00
virtual bool valid() const override;
2018-06-14 01:53:28 +02:00
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns the image description
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string description() const;
2018-06-14 01:53:28 +02:00
/*!
* @brief Sets the image description
2019-03-29 14:44:39 +01:00
*
2018-06-14 01:53:28 +02:00
* @since 0.17.0
*/
Attachment description(const string &description);
/*!
* @brief Gets file to upload
2019-03-29 14:44:39 +01:00
*
2018-06-14 01:53:28 +02:00
* @since 0.17.0
*/
2018-06-14 04:11:28 +02:00
const string file() const;
2018-06-14 01:53:28 +02:00
/*!
* @brief Sets file to upload
2019-03-29 14:44:39 +01:00
*
2018-06-14 01:53:28 +02:00
* @since 0.17.0
*
* @param file Filename
*/
Attachment file(const string &file);
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns the focus point (x, y)
2019-03-29 14:44:39 +01:00
*
2018-04-01 02:20:10 +02:00
* Values are between -1.0 and 1.0.
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const std::array<double, 2> focus() const;
2018-06-14 01:53:28 +02:00
/*!
* @brief Sets the focus point (x, y)
2019-03-29 14:44:39 +01:00
*
2018-06-14 01:53:28 +02:00
* Values are between -1.0 and 1.0.
2019-03-29 14:44:39 +01:00
*
2018-06-14 01:53:28 +02:00
* @since 0.17.0
*/
Attachment focus(const std::array<double, 2> &focus);
/*!
* @brief Returns the ID of the attachment
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string id() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns metadata about the attachment.
2019-03-29 14:44:39 +01:00
*
* @since 0.106.0
2018-03-22 00:33:36 +01:00
*/
const Meta meta() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns the URL of the preview image
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string preview_url() const;
/*!
* @brief Returns the remote URL of the original image
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string remote_url() const;
/*!
* @brief Returns shorter URL for the image
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string text_url() const;
/*!
* @brief Returns attachment type
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
2018-12-04 11:26:28 +01:00
attachment_type type() const;
2018-03-22 00:33:36 +01:00
/*!
* @brief Returns URL of the locally hosted version of the image
2019-03-29 14:44:39 +01:00
*
* @since before 0.11.0
2018-03-22 00:33:36 +01:00
*/
const string url() const;
};
}
2019-03-29 14:44:39 +01:00
}
2018-03-22 00:33:36 +01:00
#endif // MASTODON_CPP_EASY_ATTACHMENT_HPP