Split easy.hpp into several files
This commit is contained in:
parent
0223b9e854
commit
bcc5c304e9
|
@ -1,6 +1,6 @@
|
||||||
cmake_minimum_required (VERSION 3.7)
|
cmake_minimum_required (VERSION 3.7)
|
||||||
project (mastodon-cpp
|
project (mastodon-cpp
|
||||||
VERSION 0.7.2
|
VERSION 0.7.3
|
||||||
LANGUAGES CXX
|
LANGUAGES CXX
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -53,8 +53,12 @@ install(TARGETS mastodon-cpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||||
install(FILES src/mastodon-cpp.hpp
|
install(FILES src/mastodon-cpp.hpp
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp)
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp)
|
||||||
if(NOT WITHOUT_EASY)
|
if(NOT WITHOUT_EASY)
|
||||||
|
file(GLOB easy_header src/easy/*.hpp)
|
||||||
|
list(FILTER easy_header EXCLUDE REGEX "easy\.hpp$")
|
||||||
install(FILES src/easy/easy.hpp
|
install(FILES src/easy/easy.hpp
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp)
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp)
|
||||||
|
install(FILES ${easy_header}
|
||||||
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mastodon-cpp/easy)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
#include <iomanip> // get_time
|
#include <iomanip> // get_time
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <jsoncpp/json/json.h>
|
#include <jsoncpp/json/json.h>
|
||||||
#include "easy.hpp"
|
#include "account.hpp"
|
||||||
#include "macros.hpp"
|
#include "macros.hpp"
|
||||||
|
|
||||||
using namespace Mastodon;
|
using namespace Mastodon;
|
||||||
|
@ -30,25 +30,9 @@ using Account = Easy::Account;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
Account::Account(const string &json)
|
Account::Account(const string &json)
|
||||||
: _valid(false)
|
: Entity(json)
|
||||||
{
|
{
|
||||||
std::stringstream ss(json);
|
//
|
||||||
ss >> _tree;
|
|
||||||
|
|
||||||
if (_tree.isNull())
|
|
||||||
{
|
|
||||||
std::cerr << "ERROR: Could not build Account from JSON string\n";
|
|
||||||
ttdebug << "String was: " << json << '\n';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_valid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool Account::valid() const
|
|
||||||
{
|
|
||||||
return _valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const string Account::acct() const
|
const string Account::acct() const
|
||||||
|
|
|
@ -0,0 +1,158 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* 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
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MASTODON_CPP_EASY_ACCOUNT_HPP
|
||||||
|
#define MASTODON_CPP_EASY_ACCOUNT_HPP
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <cstdint>
|
||||||
|
#include <chrono>
|
||||||
|
|
||||||
|
// If we are compiling mastodon-cpp, use another include path
|
||||||
|
#ifdef MASTODON_CPP
|
||||||
|
#include "mastodon-cpp.hpp"
|
||||||
|
#include "easy.hpp"
|
||||||
|
#else
|
||||||
|
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||||
|
#include <mastodon-cpp/easy.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::uint16_t;
|
||||||
|
using std::uint64_t;
|
||||||
|
|
||||||
|
namespace Mastodon
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* @brief Class to hold accounts.
|
||||||
|
*/
|
||||||
|
class Easy::Account : public Easy::Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* @brief Constructs an Account object from a JSON string.
|
||||||
|
*
|
||||||
|
* @param json JSON string
|
||||||
|
*/
|
||||||
|
explicit Account(const string &json);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns username
|
||||||
|
*
|
||||||
|
* `username` for users on the same instance, `user@hostname`
|
||||||
|
* for users on other instances.
|
||||||
|
*/
|
||||||
|
const string acct() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns URL of avatar
|
||||||
|
*/
|
||||||
|
const string avatar() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns URL of static avatar
|
||||||
|
*/
|
||||||
|
const string avatar_static() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns time of creation
|
||||||
|
*/
|
||||||
|
const std::chrono::system_clock::time_point created_at() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns display name
|
||||||
|
*/
|
||||||
|
const string display_name() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns number of followers
|
||||||
|
*/
|
||||||
|
const uint64_t followers_count() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns number of people this account follows
|
||||||
|
*/
|
||||||
|
const uint64_t following_count() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns URL of header image
|
||||||
|
*/
|
||||||
|
const string header() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns URL of static header image
|
||||||
|
*/
|
||||||
|
const string header_static() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns account-ID
|
||||||
|
*/
|
||||||
|
const uint64_t id() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the account is locked
|
||||||
|
*/
|
||||||
|
const bool locked() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns true if the account has been moved
|
||||||
|
*/
|
||||||
|
const bool has_moved() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief If the owner decided to switch accounts, new account is in
|
||||||
|
* this attribute
|
||||||
|
*/
|
||||||
|
const Account moved() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns note
|
||||||
|
*/
|
||||||
|
const string note() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns plaintext version of note
|
||||||
|
*/
|
||||||
|
const string note_plain() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns default privacy of new toots
|
||||||
|
*/
|
||||||
|
const visibility privacy() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns if media is marked as sensitive by default
|
||||||
|
*/
|
||||||
|
const bool sensitive() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns number of statuses
|
||||||
|
*/
|
||||||
|
const uint64_t statuses_count() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns URL of the profile
|
||||||
|
*/
|
||||||
|
const string url() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns username (without @hostname)
|
||||||
|
*/
|
||||||
|
const string username() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MASTODON_CPP_EASY_ACCOUNT_HPP
|
|
@ -0,0 +1,32 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* 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
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef MASTODON_CPP_EASY_ALL_HPP
|
||||||
|
#define MASTODON_CPP_EASY_ALL_HPP
|
||||||
|
|
||||||
|
#ifdef MASTODON_CPP
|
||||||
|
#include "easy.hpp"
|
||||||
|
#include "easy/account.hpp"
|
||||||
|
#include "easy/attachment.hpp"
|
||||||
|
//#include "easy/card.hpp"
|
||||||
|
#else
|
||||||
|
#include <mastodon-cpp/easy.hpp>
|
||||||
|
#include <mastodon-cpp/easy/account.hpp>
|
||||||
|
#include <mastodon-cpp/easy/attachment.hpp>
|
||||||
|
//#include <mastodon-cpp/easy/card.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif // MASTODON_CPP_EASY_ALL_HPP
|
|
@ -18,7 +18,7 @@
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <jsoncpp/json/json.h>
|
#include <jsoncpp/json/json.h>
|
||||||
#include "easy.hpp"
|
#include "attachment.hpp"
|
||||||
#include "macros.hpp"
|
#include "macros.hpp"
|
||||||
|
|
||||||
using namespace Mastodon;
|
using namespace Mastodon;
|
||||||
|
@ -26,25 +26,9 @@ using Attachment = Easy::Attachment;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
|
||||||
Attachment::Attachment(const string &json)
|
Attachment::Attachment(const string &json)
|
||||||
: _valid(false)
|
: Entity(json)
|
||||||
{
|
{
|
||||||
std::stringstream ss(json);
|
//
|
||||||
ss >> _tree;
|
|
||||||
|
|
||||||
if (_tree.isNull())
|
|
||||||
{
|
|
||||||
std::cerr << "ERROR: Could not build Attachment from JSON string\n";
|
|
||||||
ttdebug << "String was: " << json << '\n';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_valid = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const bool Attachment::valid() const
|
|
||||||
{
|
|
||||||
return _valid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const double Attachment::aspect() const
|
const double Attachment::aspect() const
|
||||||
|
@ -85,10 +69,10 @@ const std::array<uint64_t, 2> Attachment::focus() const
|
||||||
if (_tree["meta"]["focus"]["x"].isUInt64())
|
if (_tree["meta"]["focus"]["x"].isUInt64())
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
{
|
{{
|
||||||
_tree["meta"]["focus"]["x"].asUInt64(),
|
_tree["meta"]["focus"]["x"].asUInt64(),
|
||||||
_tree["meta"]["focus"]["y"].asUInt64()
|
_tree["meta"]["focus"]["y"].asUInt64()
|
||||||
};
|
}};
|
||||||
}
|
}
|
||||||
|
|
||||||
ttdebug << "Could not get attachment data: focus\n";
|
ttdebug << "Could not get attachment data: focus\n";
|
||||||
|
|
|
@ -0,0 +1,142 @@
|
||||||
|
/* This file is part of mastodon-cpp.
|
||||||
|
* Copyright © 2018 tastytea <tastytea@tastytea.de>
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* 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
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* 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>
|
||||||
|
|
||||||
|
// If we are compiling mastodon-cpp, use another include path
|
||||||
|
#ifdef MASTODON_CPP
|
||||||
|
#include "mastodon-cpp.hpp"
|
||||||
|
#include "easy.hpp"
|
||||||
|
#else
|
||||||
|
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||||
|
#include <mastodon-cpp/easy.hpp>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
using std::string;
|
||||||
|
using std::uint16_t;
|
||||||
|
using std::uint64_t;
|
||||||
|
|
||||||
|
namespace Mastodon
|
||||||
|
{
|
||||||
|
/*!
|
||||||
|
* @brief Class to hold attachments
|
||||||
|
*/
|
||||||
|
class Easy::Attachment : public Easy::Entity
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
/*!
|
||||||
|
* @brief Constructs an Attachment object from a JSON string.
|
||||||
|
*
|
||||||
|
* @param json JSON string
|
||||||
|
*/
|
||||||
|
explicit Attachment(const string &json);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Aspect of original image
|
||||||
|
*/
|
||||||
|
const double aspect() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Aspect of preview image
|
||||||
|
*/
|
||||||
|
const double aspect_small() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the image description
|
||||||
|
*/
|
||||||
|
const string description() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the focus point (x, y)
|
||||||
|
*/
|
||||||
|
// TODO: find attachment with focus
|
||||||
|
const std::array<uint64_t, 2> focus() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the height of the original image
|
||||||
|
*/
|
||||||
|
const uint64_t height() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the height of the preview image
|
||||||
|
*/
|
||||||
|
const uint64_t height_small() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the ID of the attachment
|
||||||
|
*/
|
||||||
|
const uint64_t id() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the URL of the preview image
|
||||||
|
*/
|
||||||
|
const string preview_url() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the remote URL of the original image
|
||||||
|
*/
|
||||||
|
const string remote_url() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the size of the original image
|
||||||
|
*/
|
||||||
|
const string size() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the size of the preview image
|
||||||
|
*/
|
||||||
|
const string size_small() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns shorter URL for the image
|
||||||
|
*/
|
||||||
|
const string text_url() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns attachment type
|
||||||
|
*/
|
||||||
|
const attachment_type type() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns URL of the locally hosted version of the image
|
||||||
|
*/
|
||||||
|
const string url() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the width of the original image
|
||||||
|
*/
|
||||||
|
const uint64_t width() const;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Returns the width of the preview image
|
||||||
|
*/
|
||||||
|
const uint64_t width_small() const;
|
||||||
|
|
||||||
|
|
||||||
|
// TODO: find an attachment with framerate, duration or bitrate set
|
||||||
|
// const uint16_t framerate() const;
|
||||||
|
// const std::chrono::seconds duration() const;
|
||||||
|
// const uint64_t bitrate() const;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // MASTODON_CPP_EASY_ATTACHMENT_HPP
|
|
@ -15,7 +15,9 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <sstream>
|
||||||
#include "easy.hpp"
|
#include "easy.hpp"
|
||||||
|
#include "macros.hpp"
|
||||||
|
|
||||||
using namespace Mastodon;
|
using namespace Mastodon;
|
||||||
using std::string;
|
using std::string;
|
||||||
|
@ -25,3 +27,25 @@ Easy::Easy(const string &instance, const string &access_token)
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Easy::Entity::Entity(const string &json)
|
||||||
|
: _valid(false)
|
||||||
|
{
|
||||||
|
std::stringstream ss(json);
|
||||||
|
ss >> _tree;
|
||||||
|
|
||||||
|
if (_tree.isNull())
|
||||||
|
{
|
||||||
|
std::cerr << "ERROR: Could not build Entity from JSON string\n";
|
||||||
|
ttdebug << "String was: " << json << '\n';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_valid = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const bool Easy::Entity::valid() const
|
||||||
|
{
|
||||||
|
return _valid;
|
||||||
|
}
|
||||||
|
|
|
@ -18,10 +18,8 @@
|
||||||
#define MASTODON_EASY_CPP_HPP
|
#define MASTODON_EASY_CPP_HPP
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <cstdint>
|
|
||||||
#include <chrono>
|
|
||||||
#include <array>
|
|
||||||
#include <jsoncpp/json/json.h>
|
#include <jsoncpp/json/json.h>
|
||||||
|
|
||||||
// If we are compiling mastodon-cpp, use another include path
|
// If we are compiling mastodon-cpp, use another include path
|
||||||
#ifdef MASTODON_CPP
|
#ifdef MASTODON_CPP
|
||||||
#include "mastodon-cpp.hpp"
|
#include "mastodon-cpp.hpp"
|
||||||
|
@ -30,8 +28,6 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::uint16_t;
|
|
||||||
using std::uint64_t;
|
|
||||||
|
|
||||||
namespace Mastodon
|
namespace Mastodon
|
||||||
{
|
{
|
||||||
|
@ -78,278 +74,24 @@ public:
|
||||||
*/
|
*/
|
||||||
explicit Easy(const string &instance, const string &access_token);
|
explicit Easy(const string &instance, const string &access_token);
|
||||||
|
|
||||||
/*!
|
class Entity
|
||||||
* @brief Class to hold accounts.
|
|
||||||
*/
|
|
||||||
class Account
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
/*!
|
explicit Entity(const string &json);
|
||||||
* @brief Constructs an Account object from a JSON string.
|
|
||||||
*
|
|
||||||
* @param json JSON string
|
|
||||||
*/
|
|
||||||
explicit Account(const string &json);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Returns true if the account holds valid data
|
* @brief Returns true if the Entity holds valid data
|
||||||
*/
|
*/
|
||||||
const bool valid() const;
|
const bool valid() const;
|
||||||
|
|
||||||
/*!
|
protected:
|
||||||
* @brief Returns username
|
|
||||||
*
|
|
||||||
* `username` for users on the same instance, `user@hostname`
|
|
||||||
* for users on other instances.
|
|
||||||
*/
|
|
||||||
const string acct() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns URL of avatar
|
|
||||||
*/
|
|
||||||
const string avatar() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns URL of static avatar
|
|
||||||
*/
|
|
||||||
const string avatar_static() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns time of creation
|
|
||||||
*/
|
|
||||||
const std::chrono::system_clock::time_point created_at() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns display name
|
|
||||||
*/
|
|
||||||
const string display_name() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns number of followers
|
|
||||||
*/
|
|
||||||
const uint64_t followers_count() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns number of people this account follows
|
|
||||||
*/
|
|
||||||
const uint64_t following_count() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns URL of header image
|
|
||||||
*/
|
|
||||||
const string header() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns URL of static header image
|
|
||||||
*/
|
|
||||||
const string header_static() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns account-ID
|
|
||||||
*/
|
|
||||||
const uint64_t id() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns true if the account is locked
|
|
||||||
*/
|
|
||||||
const bool locked() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns true if the account has been moved
|
|
||||||
*/
|
|
||||||
const bool has_moved() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief If the owner decided to switch accounts, new account is in
|
|
||||||
* this attribute
|
|
||||||
*/
|
|
||||||
const Account moved() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns note
|
|
||||||
*/
|
|
||||||
const string note() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns plaintext version of note
|
|
||||||
*/
|
|
||||||
const string note_plain() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns default privacy of new toots
|
|
||||||
*/
|
|
||||||
const visibility privacy() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns if media is marked as sensitive by default
|
|
||||||
*/
|
|
||||||
const bool sensitive() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns number of statuses
|
|
||||||
*/
|
|
||||||
const uint64_t statuses_count() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns URL of the profile
|
|
||||||
*/
|
|
||||||
const string url() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns username (without @hostname)
|
|
||||||
*/
|
|
||||||
const string username() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Json::Value _tree;
|
Json::Value _tree;
|
||||||
bool _valid;
|
bool _valid;
|
||||||
};
|
};
|
||||||
|
|
||||||
/*!
|
class Account;
|
||||||
* @brief Class to hold attachments
|
class Attachment;
|
||||||
*/
|
class Card;
|
||||||
class Attachment
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/*!
|
|
||||||
* @brief Constructs an Attachment object from a JSON string.
|
|
||||||
*
|
|
||||||
* @param json JSON string
|
|
||||||
*/
|
|
||||||
explicit Attachment(const string &json);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns true if the attachment holds valid data
|
|
||||||
*/
|
|
||||||
const bool valid() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Aspect of original image
|
|
||||||
*/
|
|
||||||
const double aspect() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Aspect of preview image
|
|
||||||
*/
|
|
||||||
const double aspect_small() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the image description
|
|
||||||
*/
|
|
||||||
const string description() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the focus point (x, y)
|
|
||||||
*/
|
|
||||||
// TODO: find attachment with focus
|
|
||||||
const std::array<uint64_t, 2> focus() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the height of the original image
|
|
||||||
*/
|
|
||||||
const uint64_t height() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the height of the preview image
|
|
||||||
*/
|
|
||||||
const uint64_t height_small() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the ID of the attachment
|
|
||||||
*/
|
|
||||||
const uint64_t id() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the URL of the preview image
|
|
||||||
*/
|
|
||||||
const string preview_url() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the remote URL of the original image
|
|
||||||
*/
|
|
||||||
const string remote_url() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the size of the original image
|
|
||||||
*/
|
|
||||||
const string size() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the size of the preview image
|
|
||||||
*/
|
|
||||||
const string size_small() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns shorter URL for the image
|
|
||||||
*/
|
|
||||||
const string text_url() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns attachment type
|
|
||||||
*/
|
|
||||||
const attachment_type type() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns URL of the locally hosted version of the image
|
|
||||||
*/
|
|
||||||
const string url() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the width of the original image
|
|
||||||
*/
|
|
||||||
const uint64_t width() const;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns the width of the preview image
|
|
||||||
*/
|
|
||||||
const uint64_t width_small() const;
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: find an attachment with framerate, duration or bitrate set
|
|
||||||
// const uint16_t framerate() const;
|
|
||||||
// const std::chrono::seconds duration() const;
|
|
||||||
// const uint64_t bitrate() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Json::Value _tree;
|
|
||||||
bool _valid;
|
|
||||||
};
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Class to hold cards
|
|
||||||
*/
|
|
||||||
class Card
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
/*!
|
|
||||||
* @brief Constructs a Card object from a JSON string.
|
|
||||||
*
|
|
||||||
* @param json JSON string
|
|
||||||
*/
|
|
||||||
explicit Card(const string &json);
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Returns true if the card holds valid data
|
|
||||||
*/
|
|
||||||
const bool valid() const;
|
|
||||||
|
|
||||||
const string url() const;
|
|
||||||
const string title() const;
|
|
||||||
const string description() const;
|
|
||||||
const string image() const;
|
|
||||||
const string type() const;
|
|
||||||
const string author_name() const;
|
|
||||||
const string author_url() const;
|
|
||||||
const string provider_name() const;
|
|
||||||
const string provider_url() const;
|
|
||||||
const string html() const;
|
|
||||||
const string width() const;
|
|
||||||
const string height() const;
|
|
||||||
|
|
||||||
private:
|
|
||||||
Json::Value _tree;
|
|
||||||
bool _valid;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue