mastodon-cpp  0.110.0
return_types_easy.hpp
1 /* This file is part of mastodon-cpp.
2  * Copyright © 2019 tastytea <tastytea@tastytea.de>
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Affero General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Affero General Public License for more details.
12  *
13  * You should have received a copy of the GNU Affero General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  */
16 
17 #ifndef MASTODON_CPP_EASY_RETURN_TYPES_EASY_HPP
18 #define MASTODON_CPP_EASY_RETURN_TYPES_EASY_HPP
19 
20 #include <string>
21 #include <vector>
22 #include <ostream>
23 #include <cstdint>
24 #include "../mastodon-cpp.hpp"
25 
26 using std::string;
27 using std::vector;
28 using std::uint8_t;
29 
30 namespace Mastodon
31 {
32 namespace Easy
33 {
39  template <typename T>
41  {
47  T entity;
48 
49  return_entity();
50 
61  return_entity(const uint8_t ec, const string &em,
62  const uint16_t hec, const T &ent);
63 
74  return_entity(const error ec, const string &em,
75  const uint16_t hec, const T &ent);
76 
82  operator const T() const;
83 
89  operator const string() const;
90 
96  friend std::ostream &operator <<(std::ostream &out,
97  const return_entity<T> &ret)
98  {
99  // Could only get it to work by implementing it here.
100  out << ret.entity.to_string();
101  return out;
102  }
103  };
104 
110  template <typename T>
112  {
118  vector<T> entities;
119 
121  return_entity_vector(const uint8_t ec, const string &em,
122  const uint16_t hec, const vector<T> &vec);
123 
129  operator const vector<T>() const;
130  };
131 }
132 }
133 
134 #endif // MASTODON_CPP_EASY_RETURN_TYPES_EASY_HPP
friend std::ostream & operator<<(std::ostream &out, const return_entity< T > &ret)
Mastodon::Easy::Entity as formatted string.
Definition: return_types_easy.hpp:96
T entity
Mastodon::Easy::Entity.
Definition: return_types_easy.hpp:47
Return types for calls that return multiple Easy::Entitys.
Definition: return_types_easy.hpp:111
Collection of things to interface with server software that implements the Mastodon API.
Definition: mastodon-cpp.hpp:47
Return types for calls that return a single Easy::Entity.
Definition: return_types_easy.hpp:40
Basis for return types.
Definition: return_types.hpp:35
vector< T > entities
std::vector of Mastodon::Easy::Entity.
Definition: return_types_easy.hpp:118