This commit is contained in:
parent
dff3b11c00
commit
54a1fb0d3e
|
@ -25,6 +25,43 @@
|
|||
using namespace Mastodon;
|
||||
using std::string;
|
||||
|
||||
Easy::time::operator const system_clock::time_point()
|
||||
{
|
||||
return timepoint;
|
||||
}
|
||||
|
||||
Easy::time::operator const string()
|
||||
{
|
||||
return strtime("%FT%T%z", true);
|
||||
}
|
||||
|
||||
const string Easy::time::strtime(const string &format, const bool &local) const
|
||||
{
|
||||
constexpr std::uint16_t bufsize = 1024;
|
||||
std::time_t time = system_clock::to_time_t(timepoint);
|
||||
std::tm *timeinfo;
|
||||
if (local)
|
||||
{
|
||||
timeinfo = std::localtime(&time);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeinfo = std::gmtime(&time);
|
||||
}
|
||||
char buffer[bufsize];
|
||||
|
||||
std::strftime(buffer, bufsize, format.c_str(), timeinfo);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
std::ostream &Mastodon::Easy::operator <<(std::ostream &out,
|
||||
const Easy::time &t)
|
||||
{
|
||||
out << t.strtime("%FT%T%z", true);
|
||||
return out;
|
||||
}
|
||||
|
||||
Easy::API::API(const string &instance, const string &access_token)
|
||||
: Mastodon::API(instance, access_token)
|
||||
{}
|
||||
|
@ -83,39 +120,6 @@ const Easy::Link Easy::API::get_link() const
|
|||
return Link(get_header("Link"));
|
||||
}
|
||||
|
||||
const string Easy::API::strtime_utc(const system_clock::time_point &timepoint,
|
||||
const string &format)
|
||||
{
|
||||
return strtime(timepoint, format, true);
|
||||
}
|
||||
|
||||
const string Easy::API::strtime_local(const system_clock::time_point &timepoint,
|
||||
const string &format)
|
||||
{
|
||||
return strtime(timepoint, format, false);
|
||||
}
|
||||
|
||||
const string Easy::API::strtime(const system_clock::time_point &timepoint,
|
||||
const string &format, const bool &utc)
|
||||
{
|
||||
constexpr std::uint16_t bufsize = 1024;
|
||||
std::time_t time = system_clock::to_time_t(timepoint);
|
||||
std::tm *timeinfo;
|
||||
if (utc)
|
||||
{
|
||||
timeinfo = std::gmtime(&time);
|
||||
}
|
||||
else
|
||||
{
|
||||
timeinfo = std::localtime(&time);
|
||||
}
|
||||
char buffer[bufsize];
|
||||
|
||||
std::strftime(buffer, bufsize, format.c_str(), timeinfo);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
||||
Easy::Link::Link(const string &link_header)
|
||||
: _next()
|
||||
, _prev()
|
||||
|
|
|
@ -25,13 +25,14 @@
|
|||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <jsoncpp/json/json.h>
|
||||
#include "return_types_easy.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/return_types_easy.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/return_types_easy.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
@ -134,6 +135,38 @@ namespace Easy
|
|||
*/
|
||||
typedef std::map<Easy::notification_type, bool> alertmap;
|
||||
|
||||
struct time
|
||||
{
|
||||
system_clock::time_point timepoint = system_clock::time_point();
|
||||
|
||||
operator const system_clock::time_point();
|
||||
operator const string();
|
||||
friend std::ostream &operator <<(std::ostream &out,
|
||||
const Easy::time &t);
|
||||
|
||||
/*!
|
||||
* @brief Converts time to a string.
|
||||
*
|
||||
* The return value can not exceed 1023 chars.
|
||||
*
|
||||
* @param format The format of the string, same as with
|
||||
* `strftime`.
|
||||
* @param local Use local time (default).
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* Mastodon::Easy::time timepoint = status.created_at();
|
||||
* std::cout << timepoint.strtime("%F, %T UTC", false) << '\n';
|
||||
* @endcode
|
||||
*
|
||||
* @return The time as string.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
const string strtime (const string &format,
|
||||
const bool &local = true) const;
|
||||
};
|
||||
|
||||
// TODO: Get rid of forward declarations.
|
||||
class Account;
|
||||
class Application;
|
||||
|
@ -253,42 +286,6 @@ namespace Easy
|
|||
*/
|
||||
const Link get_link() const;
|
||||
|
||||
/*!
|
||||
* @brief Converts a time_point to a string
|
||||
*
|
||||
* The return value can not exceed 1023 chars.
|
||||
*
|
||||
* @param timepoint The timepoint
|
||||
* @param format The format of the string, same as with
|
||||
* `strftime`.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* auto timepoint = status.created_at();
|
||||
* cout << Easy::strtime_utc(timepoint, "%F, %T") << '\n';
|
||||
* @endcode
|
||||
*
|
||||
* @return The UTC time as string
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
// TODO: Time type, convertible to time_point, str_utc and str_local.
|
||||
static const string strtime_utc(const system_clock::time_point &timepoint,
|
||||
const string &format);
|
||||
|
||||
/*!
|
||||
* @brief See strtime_utc
|
||||
*
|
||||
* @return The local time as string
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
static const string strtime_local(const system_clock::time_point &timepoint,
|
||||
const string &format);
|
||||
|
||||
// #### simple calls ####
|
||||
// TODO: Own file.
|
||||
|
||||
/*!
|
||||
* @brief Sends a post.
|
||||
*
|
||||
|
@ -323,12 +320,7 @@ namespace Easy
|
|||
const return_entity_vector<Easy::Notification> get_notifications(
|
||||
const uint16_t limit = 20, const string since_id = "",
|
||||
const string max_id = "");
|
||||
|
||||
protected:
|
||||
inline static const string strtime
|
||||
(const system_clock::time_point &timepoint,
|
||||
const string &format, const bool &utc);
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,9 +71,9 @@ bool Account::bot() const
|
|||
return get_bool("bot");
|
||||
}
|
||||
|
||||
const system_clock::time_point Account::created_at() const
|
||||
const Easy::time Account::created_at() const
|
||||
{
|
||||
return get_time_point("created_at");
|
||||
return get_time("created_at");
|
||||
}
|
||||
|
||||
const string Account::display_name() const
|
||||
|
|
|
@ -19,32 +19,33 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
#include <utility>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
using std::chrono::system_clock;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold accounts.
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Account : public Easy::Entity
|
||||
class Account : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -103,7 +104,7 @@ namespace Mastodon
|
|||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
const system_clock::time_point created_at() const;
|
||||
const Easy::time created_at() const;
|
||||
|
||||
/*!
|
||||
* @brief Returns display name
|
||||
|
@ -342,5 +343,6 @@ namespace Mastodon
|
|||
const string username() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_ACCOUNT_HPP
|
||||
|
|
|
@ -18,27 +18,30 @@
|
|||
#define MASTODON_CPP_EASY_APPLICATION_HPP
|
||||
|
||||
#include <string>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold applications.
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Application : public Easy::Entity
|
||||
class Application : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -60,5 +63,6 @@ namespace Mastodon
|
|||
const string website() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_APPLICATION_HPP
|
||||
|
|
|
@ -21,28 +21,31 @@
|
|||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include <array>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold attachments
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Attachment : public Easy::Entity
|
||||
class Attachment : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -219,5 +222,6 @@ namespace Mastodon
|
|||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_ATTACHMENT_HPP
|
||||
|
|
|
@ -19,28 +19,31 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold cards
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Card : public Easy::Entity
|
||||
class Card : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -132,5 +135,6 @@ namespace Mastodon
|
|||
uint64_t width() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_CARD_HPP
|
||||
|
|
|
@ -19,29 +19,32 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entities/status.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entities/status.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold contexts
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Context : public Easy::Entity
|
||||
class Context : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -63,5 +66,6 @@ namespace Mastodon
|
|||
const std::vector<Status> descendants() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_CONTEXT_HPP
|
||||
|
|
|
@ -18,27 +18,30 @@
|
|||
#define MASTODON_CPP_EASY_EMOJI_HPP
|
||||
|
||||
#include <string>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold emojis
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Emoji : public Easy::Entity
|
||||
class Emoji : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -67,5 +70,6 @@ namespace Mastodon
|
|||
const string url() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_EMOJI_HPP
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
using std::uint64_t;
|
||||
|
||||
|
@ -28,22 +27,26 @@ using std::uint64_t;
|
|||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entities/account.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entities/account.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold instances
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Instance : public Easy::Entity
|
||||
class Instance : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -119,5 +122,6 @@ namespace Mastodon
|
|||
uint64_t max_toot_chars() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_INSTANCE_HPP
|
||||
|
|
|
@ -20,28 +20,31 @@
|
|||
#include <string>
|
||||
#include <vector>
|
||||
#include <cstdint>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold lists
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::List : public Easy::Entity
|
||||
class List : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -63,5 +66,6 @@ namespace Mastodon
|
|||
const string title() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_LIST_HPP
|
||||
|
|
|
@ -19,15 +19,16 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
@ -35,13 +36,15 @@ using std::uint64_t;
|
|||
using std::chrono::system_clock;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold mentions
|
||||
*
|
||||
* before 0.11.0
|
||||
*/
|
||||
class Easy::Mention : public Easy::Entity
|
||||
class Mention : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -77,5 +80,6 @@ namespace Mastodon
|
|||
const string username() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_MENTION_HPP
|
||||
|
|
|
@ -45,9 +45,9 @@ const Easy::Account Notification::account() const
|
|||
return Easy::Account();
|
||||
}
|
||||
|
||||
const system_clock::time_point Notification::created_at() const
|
||||
const Easy::time Notification::created_at() const
|
||||
{
|
||||
return get_time_point("created_at");
|
||||
return get_time("created_at");
|
||||
}
|
||||
|
||||
const string Notification::id() const
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
|
@ -28,25 +26,28 @@
|
|||
#include "easy/easy.hpp"
|
||||
#include "easy/entities/account.hpp"
|
||||
#include "easy/entities/status.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entities/account.hpp>
|
||||
#include <mastodon-cpp/easy/entities/status.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
using std::chrono::system_clock;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold notifications
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Notification : public Easy::Entity
|
||||
class Notification : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -65,7 +66,7 @@ namespace Mastodon
|
|||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
const system_clock::time_point created_at() const;
|
||||
const Easy::time created_at() const;
|
||||
|
||||
/*!
|
||||
* @brief Returns notification ID
|
||||
|
@ -90,5 +91,6 @@ namespace Mastodon
|
|||
Easy::notification_type type() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_NOTIFICATION_HPP
|
||||
|
|
|
@ -20,27 +20,30 @@
|
|||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold push subscriptions.
|
||||
*
|
||||
* @since 0.14.0
|
||||
*/
|
||||
class Easy::PushSubscription : public Easy::Entity
|
||||
class PushSubscription : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -86,5 +89,6 @@ namespace Mastodon
|
|||
bool s_to_b(const string &str) const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_PUSHSUBSCRIPTION_HPP
|
||||
|
|
|
@ -19,28 +19,31 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold relationships
|
||||
*
|
||||
* before 0.11.0
|
||||
*/
|
||||
class Easy::Relationship : public Easy::Entity
|
||||
class Relationship : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -118,5 +121,6 @@ namespace Mastodon
|
|||
bool showing_notifications() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_RELATIONSHIP_HPP
|
||||
|
|
|
@ -39,4 +39,3 @@ const string Report::id() const
|
|||
{
|
||||
return get_string("id");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,27 +19,30 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold reports
|
||||
*
|
||||
* before 0.11.0
|
||||
*/
|
||||
class Easy::Report : public Easy::Entity
|
||||
class Report : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -62,5 +65,6 @@ namespace Mastodon
|
|||
const string id() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_REPORT_HPP
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
|
@ -28,24 +27,28 @@
|
|||
#include "easy/entities/account.hpp"
|
||||
#include "easy/entities/status.hpp"
|
||||
#include "easy/entities/tag.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entities/account.hpp>
|
||||
#include <mastodon-cpp/easy/entities/status.hpp>
|
||||
#include <mastodon-cpp/easy/entities/tag.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold results
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Results : public Easy::Entity
|
||||
class Results : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -81,5 +84,6 @@ namespace Mastodon
|
|||
const std::vector<Tag> hashtags_v2() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_RESULTS_HPP
|
||||
|
|
|
@ -77,9 +77,9 @@ const Easy::Card Status::card() const
|
|||
return Easy::Card();
|
||||
}
|
||||
|
||||
const system_clock::time_point Status::created_at() const
|
||||
const Easy::time Status::created_at() const
|
||||
{
|
||||
return get_time_point("created_at");
|
||||
return get_time("created_at");
|
||||
}
|
||||
|
||||
const string Status::content() const
|
||||
|
|
|
@ -19,9 +19,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <cstdint>
|
||||
#include <chrono>
|
||||
#include <vector>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
|
@ -34,6 +32,7 @@
|
|||
#include "easy/entities/tag.hpp"
|
||||
#include "easy/entities/application.hpp"
|
||||
#include "easy/entities/card.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
|
@ -44,20 +43,22 @@
|
|||
#include <mastodon-cpp/easy/entities/tag.hpp>
|
||||
#include <mastodon-cpp/easy/entities/application.hpp>
|
||||
#include <mastodon-cpp/easy/entities/card.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::uint64_t;
|
||||
using std::chrono::system_clock;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold statuses
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Status : public Easy::Entity
|
||||
class Status : public Entity
|
||||
{
|
||||
public:
|
||||
using Entity::Entity;
|
||||
|
@ -90,7 +91,7 @@ namespace Mastodon
|
|||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
const system_clock::time_point created_at() const;
|
||||
const Easy::time created_at() const;
|
||||
|
||||
/*!
|
||||
* @brief Returns content of status
|
||||
|
@ -297,5 +298,6 @@ namespace Mastodon
|
|||
Status visibility(const visibility_type &visibility);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_STATUS_HPP
|
||||
|
|
|
@ -77,18 +77,18 @@ uint64_t Tag::History::accounts()
|
|||
return stouint64(get_string("accounts"));
|
||||
}
|
||||
|
||||
const system_clock::time_point Tag::History::day()
|
||||
const Easy::time Tag::History::day()
|
||||
{
|
||||
const Json::Value node = get("day");
|
||||
|
||||
if (node.isString())
|
||||
{
|
||||
std::chrono::seconds seconds(stouint64(node.asString()));
|
||||
return system_clock::time_point(seconds);
|
||||
return {system_clock::time_point(seconds)};
|
||||
}
|
||||
|
||||
ttdebug << "Could not get data: day\n";
|
||||
return system_clock::time_point();
|
||||
return Easy::time();
|
||||
}
|
||||
|
||||
uint64_t Tag::History::uses()
|
||||
|
|
|
@ -18,31 +18,32 @@
|
|||
#define MASTODON_CPP_EASY_TAG_HPP
|
||||
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <cstdint>
|
||||
#include "easy/entity.hpp"
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "mastodon-cpp.hpp"
|
||||
#include "easy/easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/mastodon-cpp.hpp>
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#include <mastodon-cpp/easy/entity.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::chrono::system_clock;
|
||||
using std::uint64_t;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
namespace Easy
|
||||
{
|
||||
/*!
|
||||
* @brief Class to hold tags.
|
||||
*
|
||||
* @since before 0.11.0
|
||||
*/
|
||||
class Easy::Tag : public Easy::Entity
|
||||
class Tag : public Entity
|
||||
{
|
||||
public:
|
||||
/*!
|
||||
|
@ -69,7 +70,7 @@ namespace Mastodon
|
|||
*
|
||||
* @since 0.16.0
|
||||
*/
|
||||
const system_clock::time_point day();
|
||||
const Easy::time day();
|
||||
|
||||
/*!
|
||||
* @brief Returns the number of accounts using that hashtag.
|
||||
|
@ -105,5 +106,6 @@ namespace Mastodon
|
|||
const std::vector<History> history() const;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
#endif // MASTODON_CPP_EASY_TAG_HPP
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
#include <sstream>
|
||||
#include <chrono>
|
||||
#include <regex>
|
||||
// #include "easy.hpp"
|
||||
#include "easy/entity.hpp"
|
||||
#include "debug.hpp"
|
||||
|
||||
|
@ -212,8 +211,7 @@ bool Easy::Entity::get_bool(const string &key) const
|
|||
return false;
|
||||
}
|
||||
|
||||
const system_clock::time_point
|
||||
Easy::Entity::get_time_point(const string &key) const
|
||||
const Easy::time Easy::Entity::get_time(const string &key) const
|
||||
{
|
||||
const Json::Value node = get(key);
|
||||
|
||||
|
@ -224,12 +222,12 @@ const system_clock::time_point
|
|||
sstime >> std::get_time(&tm, "%Y-%m-%dT%T");
|
||||
std::time_t time = timegm(&tm);
|
||||
_was_set = true;
|
||||
return system_clock::from_time_t(time);
|
||||
return { system_clock::from_time_t(time) };
|
||||
}
|
||||
|
||||
_was_set = false;
|
||||
// Return clocks epoch
|
||||
return system_clock::time_point();
|
||||
return { system_clock::time_point() };
|
||||
}
|
||||
|
||||
const std::vector<string> Easy::Entity::get_vector(const string &key) const
|
||||
|
|
|
@ -18,11 +18,16 @@
|
|||
#define ENTITY_HPP
|
||||
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
#include <jsoncpp/json/json.h>
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
#ifdef MASTODON_CPP
|
||||
#include "easy/easy.hpp"
|
||||
#else
|
||||
#include <mastodon-cpp/easy/easy.hpp>
|
||||
#endif
|
||||
|
||||
using std::string;
|
||||
using std::chrono::system_clock;
|
||||
|
||||
namespace Mastodon
|
||||
{
|
||||
|
@ -194,11 +199,11 @@ namespace Easy
|
|||
bool get_bool(const string &key) const;
|
||||
|
||||
/*!
|
||||
* @brief Returns the value of key as time_point
|
||||
* @brief Returns the value of key as Easy::time.
|
||||
*
|
||||
* Returns clocks epoch if the value does not exist or is null.
|
||||
*/
|
||||
const system_clock::time_point get_time_point(const string &key) const;
|
||||
const Easy::time get_time(const string &key) const;
|
||||
|
||||
/*!
|
||||
* @brief Returns the value of key as vector
|
||||
|
|
|
@ -38,6 +38,8 @@ namespace Easy
|
|||
|
||||
/*!
|
||||
* @brief Return types for calls that return a single `Easy::Entity`.
|
||||
*
|
||||
* @since 0.100.0
|
||||
*/
|
||||
template <typename T>
|
||||
struct return_entity : return_base
|
||||
|
|
|
@ -47,7 +47,7 @@ return_call::operator const string() const
|
|||
return answer;
|
||||
}
|
||||
|
||||
std::ostream &operator <<(std::ostream &out, const return_call &ret)
|
||||
std::ostream &Mastodon::operator <<(std::ostream &out, const return_call &ret)
|
||||
{
|
||||
out << ret.answer;
|
||||
return out;
|
||||
|
|
Reference in New Issue
Block a user