mastodon-cpp  0.18.8
Public Member Functions | List of all members
Mastodon::Easy::Card Class Reference

Class to hold cards. More...

#include <card.hpp>

Inheritance diagram for Mastodon::Easy::Card:
Mastodon::Easy::Entity

Public Member Functions

 Card (const string &json)
 Constructs a Card object from a JSON string. More...
 
 Card ()
 Constructs an empty Card object. More...
 
virtual const bool valid () const
 Returns true if the Entity holds valid data. More...
 
const string author_name () const
 Returns the name of the author. More...
 
const string author_url () const
 Returns the URL of the author. More...
 
const string description () const
 Returns the description. More...
 
const uint_fast64_t height () const
 Returns the height of the card. More...
 
const string html () const
 Returns the HTML. More...
 
const string image () const
 Returns the URL of the image associated with the card. More...
 
const string provider_name () const
 Returns the name of the provider. More...
 
const string provider_url () const
 Returns the URL of the provider. More...
 
const string title () const
 Returns the title. More...
 
const Easy::card_type type () const
 Returns the type of the card. More...
 
const string url () const
 Returns the URL associated with the card. More...
 
const uint_fast64_t width () const
 Returns the width of the card. 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...
 
const 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...
 
const 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...
 
const uint_fast64_t get_uint64 (const string &key) const
 Returns the value of key as std::uint_fast64_t. More...
 
const double get_double (const string &key) const
 Returns the value of key as double. More...
 
const 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...
 
const void set (const string &key, const Json::Value &value)
 Sets the value of key. More...
 
const std::uint_fast64_t stouint64 (const string &str) const
 
const bool check_valid (const std::vector< string > &attributes) const
 Checks if an Entity is valid. More...
 

Detailed Description

Class to hold cards.

Since
before 0.11.0

Constructor & Destructor Documentation

◆ Card() [1/2]

Card::Card ( const string &  json)
explicit

Constructs a Card object from a JSON string.

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

◆ Card() [2/2]

Card::Card ( )

Constructs an empty Card object.

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

Member Function Documentation

◆ author_name()

const string Card::author_name ( ) const

Returns the name of the author.

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

◆ author_url()

const string Card::author_url ( ) const

Returns the URL of the author.

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

◆ description()

const string Card::description ( ) const

Returns the description.

Since
before 0.11.0
55 {
56  return get_string("description");
57 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ height()

const uint_fast64_t Card::height ( ) const

Returns the height of the card.

Since
before 0.11.0
60 {
61  return get_uint64("height");
62 }
const uint_fast64_t get_uint64(const string &key) const
Returns the value of key as std::uint_fast64_t.
Definition: entity.cpp:149

◆ html()

const string Card::html ( ) const

Returns the HTML.

Since
before 0.11.0
65 {
66  return get_string("html");
67 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ image()

const string Card::image ( ) const

Returns the URL of the image associated with the card.

Since
before 0.11.0
70 {
71  return get_string("image");
72 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ provider_name()

const string Card::provider_name ( ) const

Returns the name of the provider.

Since
before 0.11.0
75 {
76  return get_string("provider_name");
77 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ provider_url()

const string Card::provider_url ( ) const

Returns the URL of the provider.

Since
before 0.11.0
80 {
81  return get_string("provider_url");
82 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ title()

const string Card::title ( ) const

Returns the title.

Since
before 0.11.0
85 {
86  return get_string("title");
87 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ type()

const Easy::card_type Card::type ( ) const

Returns the type of the card.

Since
before 0.11.0
90 {
91  const string strtype = get_string("type");
92  if (strtype.compare("link") == 0)
93  return card_type::Link;
94  else if (strtype.compare("photo") == 0)
95  return card_type::Photo;
96  else if (strtype.compare("video") == 0)
97  return card_type::Video;
98  else if (strtype.compare("rich") == 0)
99  return card_type::Rich;
100 
101  ttdebug << "Could not get data: type\n";
102  return card_type::Undefined;
103 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ url()

const string Card::url ( ) const

Returns the URL associated with the card.

Since
before 0.11.0
106 {
107  return get_string("url");
108 }
const string get_string(const string &key) const
Returns the value of key as std::string.
Definition: entity.cpp:135

◆ valid()

const bool Card::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.

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

◆ width()

const uint_fast64_t Card::width ( ) const

Returns the width of the card.

Since
before 0.11.0
111 {
112  return get_uint64("width");
113 }
const uint_fast64_t get_uint64(const string &key) const
Returns the value of key as std::uint_fast64_t.
Definition: entity.cpp:149

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