17 #ifndef MASTODON_CPP_EASY_ENTITY_HPP 18 #define MASTODON_CPP_EASY_ENTITY_HPP 21 #include <jsoncpp/json/json.h> 23 #include "types_easy.hpp" 46 explicit Entity(
const string &json);
55 explicit Entity(
const Json::Value &
object);
76 operator const Json::Value()
const;
119 virtual bool valid()
const = 0;
126 const string error()
const;
165 const Json::Value
get(
const string &key)
const;
172 const string get_string(
const string &key)
const;
193 bool get_bool(
const string &key)
const;
208 const std::vector<string>
get_vector(
const string &key)
const;
215 void set(
const string &key,
const Json::Value &value);
220 std::uint64_t
stouint64(
const string &str)
const;
231 bool check_valid(
const std::vector<string> &attributes)
const;
235 mutable bool _was_set;
240 #endif // MASTODON_CPP_EASY_ENTITY_HPP const Easy::time_type get_time(const string &key) const
Returns the value of key as Easy::time.
Definition: entity.cpp:230
const Json::Value get(const string &key) const
Returns the value of key as Json::Value.
Definition: entity.cpp:133
uint64_t get_uint64(const string &key) const
Returns the value of key as std::uint64_t.
Definition: entity.cpp:188
Entity()
Constructs an empty Entity object.
Definition: entity.cpp:43
void set(const string &key, const Json::Value &value)
Sets the value of key.
Definition: entity.cpp:263
double get_double(const string &key) const
Returns the value of key as double.
Definition: entity.cpp:202
virtual bool valid() const =0
Returns true if the Entity holds valid data.
Type for time. Converts to time_point and string.
Definition: types_easy.hpp:150
const string to_string() const
Returns the JSON of the Entity as formatted string.
Definition: entity.cpp:87
void from_object(const Json::Value &object)
Replaces the Entity with a new one from a JSON object.
Definition: entity.cpp:92
bool was_set() const
Returns true if the last requested value was set, false if it was unset.
Definition: entity.cpp:128
virtual ~Entity()
Destroys the object.
Definition: entity.cpp:48
const Json::Value to_object() const
Returns the JSON object of the Entity.
Definition: entity.cpp:97
bool check_valid(const std::vector< string > &attributes) const
Checks if an Entity is valid.
Definition: entity.cpp:102
void from_string(const string &json)
Replaces the Entity with a new one from a JSON string.
Definition: entity.cpp:56
bool get_bool(const string &key) const
Returns the value of key as bool.
Definition: entity.cpp:216
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 error() const
Returns error string sent by the server.
Definition: entity.cpp:116
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:174
const std::vector< string > get_vector(const string &key) const
Returns the value of key as vector.
Definition: entity.cpp:245
std::uint64_t stouint64(const string &str) const
Returns value of str as uint64_t.
Definition: entity.cpp:301