Added max_id() and since_id() to Easy::Link

This commit is contained in:
tastytea 2018-04-03 01:20:15 +02:00
parent 94b2c2e7c9
commit 9f75b7d2b2
Signed by: tastytea
GPG Key ID: 59346E0EA35C67E5
3 changed files with 28 additions and 4 deletions

View File

@ -1,6 +1,6 @@
cmake_minimum_required (VERSION 3.7) cmake_minimum_required (VERSION 3.7)
project (mastodon-cpp project (mastodon-cpp
VERSION 0.8.3 VERSION 0.8.4
LANGUAGES CXX LANGUAGES CXX
) )

View File

@ -77,6 +77,11 @@ const std::vector<Easy::stream_event>
return vec; return vec;
} }
const Easy::Link Easy::get_link() const
{
return Link(get_header("Link"));
}
Easy::Link::Link(const string &link_header) Easy::Link::Link(const string &link_header)
: _next(0) : _next(0)
, _prev(0) , _prev(0)
@ -100,12 +105,17 @@ const uint_fast64_t Easy::Link::next() const
return _next; return _next;
} }
const uint_fast64_t Easy::Link::max_id() const
{
return _next;
}
const uint_fast64_t Easy::Link::prev() const const uint_fast64_t Easy::Link::prev() const
{ {
return _prev; return _prev;
} }
const Easy::Link Easy::get_link() const const uint_fast64_t Easy::Link::since_id() const
{ {
return Link(get_header("Link")); return _prev;
} }

View File

@ -22,6 +22,7 @@
#include <chrono> #include <chrono>
#include <vector> #include <vector>
#include <utility> #include <utility>
#include <functional>
#include <jsoncpp/json/json.h> #include <jsoncpp/json/json.h>
// If we are compiling mastodon-cpp, use another include path // If we are compiling mastodon-cpp, use another include path
@ -102,12 +103,15 @@ public:
Undefined Undefined
}; };
/*!
* @brief Used for stream events.
*/
typedef std::pair<event_type, string> stream_event; typedef std::pair<event_type, string> stream_event;
/*! /*!
* @brief Class to hold the `Link`-header. * @brief Class to hold the `Link`-header.
* *
* Extracts max_id and since_id from the `Link:`-header * Extracts max_id and since_id from the `Link`-header
*/ */
class Link class Link
{ {
@ -119,11 +123,21 @@ public:
*/ */
const uint_fast64_t next() const; const uint_fast64_t next() const;
/*!
* @brief Returns max_id
*/
const uint_fast64_t max_id() const;
/*! /*!
* @brief Returns since_id * @brief Returns since_id
*/ */
const uint_fast64_t prev() const; const uint_fast64_t prev() const;
/*!
* @brief Returns since_id
*/
const uint_fast64_t since_id() const;
private: private:
uint_fast64_t _next; uint_fast64_t _next;
uint_fast64_t _prev; uint_fast64_t _prev;