mastodon-cpp  0.20.0
Classes | Public Member Functions | List of all members
Mastodon::Easy::Tag Class Reference

Class to hold tags. More...

#include <tag.hpp>

Inheritance diagram for Mastodon::Easy::Tag:
Mastodon::Easy::Entity

Classes

class  History
 Class to hold Tag history. More...
 

Public Member Functions

 Tag (const string &json)
 Constructs an Tag object from a JSON string. More...
 
 Tag ()
 Constructs an empty Tag object. More...
 
virtual bool valid () const
 Returns true if the Entity holds valid data. More...
 
const string name () const
 Returns the name of the tag. More...
 
const string url () const
 Returns the URL of the tag. More...
 
const std::vector< Historyhistory () const
 Returns the history of the tag. More...
 
- Public Member Functions inherited from Mastodon::Easy::Entity
 Entity (const string &json)
 Constructs an Entity object from a JSON string. More...
 
 Entity ()
 Constructs an empty Entity object. More...
 
void from_string (const string &json)
 Replaces the Entity with a new one from a JSON string. More...
 
const Json::Value to_object () const
 Returns the JSON object of the Entity. More...
 
const string error () const
 Returns error string sent by the server. More...
 
bool was_set () const
 Returns true if the last requested value was set, false if it was unset. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Mastodon::Easy::Entity
const Json::Value get (const string &key) const
 Returns the value of key as Json::Value. More...
 
const string get_string (const string &key) const
 Returns the value of key as std::string. More...
 
uint_fast64_t get_uint64 (const string &key) const
 Returns the value of key as std::uint_fast64_t. More...
 
double get_double (const string &key) const
 Returns the value of key as double. More...
 
bool get_bool (const string &key) const
 Returns the value of key as bool. More...
 
const system_clock::time_point get_time_point (const string &key) const
 Returns the value of key as time_point. More...
 
const std::vector< string > get_vector (const string &key) const
 Returns the value of key as vector. More...
 
void set (const string &key, const Json::Value &value)
 Sets the value of key. More...
 
std::uint_fast64_t stouint64 (const string &str) const
 
bool check_valid (const std::vector< string > &attributes) const
 Checks if an Entity is valid. More...
 

Detailed Description

Class to hold tags.

Since
before 0.11.0

Constructor & Destructor Documentation

◆ Tag() [1/2]

Tag::Tag ( const string &  json)
explicit

Constructs an Tag object from a JSON string.

Parameters
jsonJSON string
Since
before 0.11.0
26 : Entity(json)
27 {}
Entity()
Constructs an empty Entity object.
Definition: entity.cpp:65

◆ Tag() [2/2]

Tag::Tag ( )

Constructs an empty Tag object.

Since
before 0.11.0
30 : Entity()
31 {}
Entity()
Constructs an empty Entity object.
Definition: entity.cpp:65

Member Function Documentation

◆ history()

const std::vector< Tag::History > Tag::history ( ) const

Returns the history of the tag.

Since
0.16.0
55 {
56  const Json::Value node = get("history");
57  if (node.isArray())
58  {
59  std::vector<Easy::Tag::History> vec;
60  for (const Json::Value &value : node)
61  {
62  vec.push_back(Easy::Tag::History(value.toStyledString()));
63  }
64  return vec;
65  }
66 
67  ttdebug << "Could not get data: history\n";
68  return {};
69 }
Class to hold Tag history.
Definition: tag.hpp:52

◆ name()

const string Tag::name ( ) const

Returns the name of the tag.

Since
before 0.11.0
45 {
46  return get_string("name");
47 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:134

◆ url()

const string Tag::url ( ) const

Returns the URL of the tag.

Since
before 0.11.0
50 {
51  return get_string("url");
52 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:134

◆ valid()

bool Tag::valid ( ) const
virtual

Returns true if the Entity holds valid data.

Since
before 0.11.0 (virtual since 0.18.2)

Implements Mastodon::Easy::Entity.

34 {
35  const std::vector<string> attributes =
36  {{
37  "name",
38  "url"
39  }};
40 
41  return Entity::check_valid(attributes);
42 }
bool check_valid(const std::vector< string > &attributes) const
Checks if an Entity is valid.
Definition: entity.cpp:69

The documentation for this class was generated from the following files: