parent
929e815c73
commit
8f30451ec1
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (mastodon-cpp
|
project (mastodon-cpp
|
||||||
VERSION 0.16.1
|
VERSION 0.17.0
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,12 @@ const string Attachment::description() const
|
||||||
return get_string("description");
|
return get_string("description");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Attachment Attachment::description(const string &description)
|
||||||
|
{
|
||||||
|
set("description", Json::Value(description));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
const std::chrono::duration<double> Attachment::duration() const
|
const std::chrono::duration<double> Attachment::duration() const
|
||||||
{
|
{
|
||||||
const double sec = get_double("meta.original.duration");
|
const double sec = get_double("meta.original.duration");
|
||||||
|
@ -56,6 +62,18 @@ const std::chrono::duration<double> Attachment::duration() const
|
||||||
return std::chrono::duration<double>(sec);
|
return std::chrono::duration<double>(sec);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const string Attachment::file()
|
||||||
|
{
|
||||||
|
return get_string("file");
|
||||||
|
}
|
||||||
|
|
||||||
|
Attachment Attachment::file(const string &file)
|
||||||
|
{
|
||||||
|
set("file", Json::Value(file));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const std::array<double, 2> Attachment::focus() const
|
const std::array<double, 2> Attachment::focus() const
|
||||||
{
|
{
|
||||||
const Json::Value x = get("meta.focus.x");
|
const Json::Value x = get("meta.focus.x");
|
||||||
|
@ -72,6 +90,13 @@ const std::array<double, 2> Attachment::focus() const
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Attachment Attachment::focus(const std::array<double, 2> &focus)
|
||||||
|
{
|
||||||
|
set("meta.focus.x", Json::Value(focus[0]));
|
||||||
|
set("meta.focus.y", Json::Value(focus[1]));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
const double Attachment::framerate() const
|
const double Attachment::framerate() const
|
||||||
{
|
{
|
||||||
string strframes = get_string("meta.original.frame_rate");
|
string strframes = get_string("meta.original.frame_rate");
|
||||||
|
|
|
@ -68,16 +68,40 @@ namespace Mastodon
|
||||||
* @brief Returns the bitrate of a video
|
* @brief Returns the bitrate of a video
|
||||||
*/
|
*/
|
||||||
const uint_fast64_t bitrate() const;
|
const uint_fast64_t bitrate() const;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the image description
|
* @brief Returns the image description
|
||||||
*/
|
*/
|
||||||
const string description() const;
|
const string description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Sets the image description
|
||||||
|
*
|
||||||
|
* @since 0.17.0
|
||||||
|
*/
|
||||||
|
Attachment description(const string &description);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the duration of a video in seconds
|
* @brief Returns the duration of a video in seconds
|
||||||
*/
|
*/
|
||||||
const std::chrono::duration<double> duration() const;
|
const std::chrono::duration<double> duration() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Gets file to upload
|
||||||
|
*
|
||||||
|
* @since 0.17.0
|
||||||
|
*/
|
||||||
|
const string file();
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Sets file to upload
|
||||||
|
*
|
||||||
|
* @since 0.17.0
|
||||||
|
*
|
||||||
|
* @param file Filename
|
||||||
|
*/
|
||||||
|
Attachment file(const string &file);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the focus point (x, y)
|
* @brief Returns the focus point (x, y)
|
||||||
*
|
*
|
||||||
|
@ -85,6 +109,15 @@ namespace Mastodon
|
||||||
*/
|
*/
|
||||||
const std::array<double, 2> focus() const;
|
const std::array<double, 2> focus() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Sets the focus point (x, y)
|
||||||
|
*
|
||||||
|
* Values are between -1.0 and 1.0.
|
||||||
|
*
|
||||||
|
* @since 0.17.0
|
||||||
|
*/
|
||||||
|
Attachment focus(const std::array<double, 2> &focus);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns the framerate of a video in frames per second
|
* @brief Returns the framerate of a video in frames per second
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -225,7 +225,40 @@ const std::vector<string> Easy::Entity::get_vector(const string &key) const
|
||||||
|
|
||||||
const void Easy::Entity::set(const string &key, const Json::Value &value)
|
const void Easy::Entity::set(const string &key, const Json::Value &value)
|
||||||
{
|
{
|
||||||
_tree[key] = value;
|
if (key.find('.') == std::string::npos)
|
||||||
|
{
|
||||||
|
_tree[key] = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
std::size_t pos = 0;
|
||||||
|
string current_key = key;
|
||||||
|
Json::Value *node = &_tree;
|
||||||
|
|
||||||
|
while ((pos = current_key.find('.')) != std::string::npos)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
node = &(*node)[current_key.substr(0, pos)];
|
||||||
|
if (node->isNull())
|
||||||
|
{
|
||||||
|
*node = Json::Value(Json::objectValue);
|
||||||
|
}
|
||||||
|
current_key = current_key.substr(pos + 1);
|
||||||
|
}
|
||||||
|
catch (const Json::LogicError &e)
|
||||||
|
{
|
||||||
|
ttdebug << e.what() << '\n';
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
(*node)[current_key] = value;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
error:
|
||||||
|
ttdebug << "Could not set data: " << key << '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::uint_fast64_t Easy::Entity::stouint64(const string &str) const
|
const std::uint_fast64_t Easy::Entity::stouint64(const string &str) const
|
||||||
|
|
Reference in New Issue