From 9f75b7d2b22a020ed8f9662ea4e26c97dbddaccb Mon Sep 17 00:00:00 2001 From: tastytea Date: Tue, 3 Apr 2018 01:20:15 +0200 Subject: [PATCH] Added max_id() and since_id() to Easy::Link --- CMakeLists.txt | 2 +- src/easy/easy.cpp | 14 ++++++++++++-- src/easy/easy.hpp | 16 +++++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1393fc1..bbdef60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.7) project (mastodon-cpp - VERSION 0.8.3 + VERSION 0.8.4 LANGUAGES CXX ) diff --git a/src/easy/easy.cpp b/src/easy/easy.cpp index 86faf3d..ff048f1 100644 --- a/src/easy/easy.cpp +++ b/src/easy/easy.cpp @@ -77,6 +77,11 @@ const std::vector return vec; } +const Easy::Link Easy::get_link() const +{ + return Link(get_header("Link")); +} + Easy::Link::Link(const string &link_header) : _next(0) , _prev(0) @@ -100,12 +105,17 @@ const uint_fast64_t Easy::Link::next() const return _next; } +const uint_fast64_t Easy::Link::max_id() const +{ + return _next; +} + const uint_fast64_t Easy::Link::prev() const { 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; } diff --git a/src/easy/easy.hpp b/src/easy/easy.hpp index 2a54403..f5c3439 100644 --- a/src/easy/easy.hpp +++ b/src/easy/easy.hpp @@ -22,6 +22,7 @@ #include #include #include +#include #include // If we are compiling mastodon-cpp, use another include path @@ -102,12 +103,15 @@ public: Undefined }; + /*! + * @brief Used for stream events. + */ typedef std::pair stream_event; /*! * @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 { @@ -119,11 +123,21 @@ public: */ const uint_fast64_t next() const; + /*! + * @brief Returns max_id + */ + const uint_fast64_t max_id() const; + /*! * @brief Returns since_id */ const uint_fast64_t prev() const; + /*! + * @brief Returns since_id + */ + const uint_fast64_t since_id() const; + private: uint_fast64_t _next; uint_fast64_t _prev;