Added operator overloads to return_entity and return_entity_vector
This commit is contained in:
parent
e1b32d13c8
commit
5fa7887fb1
|
@ -36,6 +36,22 @@ return_entity::return_entity(const uint8_t ec, const string &em,
|
|||
error_message = em;
|
||||
}
|
||||
|
||||
return_entity::operator const Easy::GenericEntity() const
|
||||
{
|
||||
return entity;
|
||||
}
|
||||
|
||||
return_entity::operator const string() const
|
||||
{
|
||||
return entity.to_string();
|
||||
}
|
||||
|
||||
std::ostream &operator <<(std::ostream &out, const return_entity &ret)
|
||||
{
|
||||
out << ret.entity.to_string();
|
||||
return out;
|
||||
}
|
||||
|
||||
return_entity_vector::return_entity_vector()
|
||||
: entities()
|
||||
{}
|
||||
|
@ -48,6 +64,11 @@ return_entity_vector::return_entity_vector(const uint8_t ec, const string &em,
|
|||
error_message = em;
|
||||
}
|
||||
|
||||
return_entity_vector::operator const vector<Easy::GenericEntity>() const
|
||||
{
|
||||
return entities;
|
||||
}
|
||||
|
||||
Easy::Easy(const string &instance, const string &access_token)
|
||||
: API(instance, access_token)
|
||||
{}
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
#include <vector>
|
||||
#include <utility>
|
||||
#include <functional>
|
||||
#include <ostream>
|
||||
#include <jsoncpp/json/json.h>
|
||||
|
||||
// If we are compiling mastodon-cpp, use another include path
|
||||
|
@ -548,6 +549,10 @@ typedef struct return_entity : return_base
|
|||
return_entity();
|
||||
return_entity(const uint8_t ec, const string &em,
|
||||
const Easy::GenericEntity &ent);
|
||||
|
||||
operator const Easy::GenericEntity() const;
|
||||
operator const string() const;
|
||||
friend std::ostream &operator <<(std::ostream &out, const return_entity &ret);
|
||||
} return_entity;
|
||||
|
||||
/*!
|
||||
|
@ -561,6 +566,8 @@ typedef struct return_entity_vector : return_base
|
|||
return_entity_vector();
|
||||
return_entity_vector(const uint8_t ec, const string &em,
|
||||
const vector<Easy::GenericEntity> &vec);
|
||||
|
||||
operator const vector<Easy::GenericEntity>() const;
|
||||
} return_entity_vector;
|
||||
}
|
||||
|
||||
|
|
Reference in New Issue
Block a user