From 5a6b541de2e1f2ee72e95c791944023690efd198 Mon Sep 17 00:00:00 2001 From: tastytea Date: Sun, 27 Jan 2019 03:50:28 +0100 Subject: [PATCH] Changed ids from uint_fast64_t to const string in all relevant places. --- CMakeLists.txt | 2 +- src/easy/easy.cpp | 16 ++++++++-------- src/easy/easy.hpp | 14 +++++++------- src/easy/simple_calls.cpp | 16 ++++++++-------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9bc8d5..dda71d5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required (VERSION 3.6) project (mastodon-cpp - VERSION 0.21.0 + VERSION 0.30.0 LANGUAGES CXX ) diff --git a/src/easy/easy.cpp b/src/easy/easy.cpp index 1bfc6c7..c383053 100644 --- a/src/easy/easy.cpp +++ b/src/easy/easy.cpp @@ -116,8 +116,8 @@ const string Easy::strtime(const system_clock::time_point &timepoint, } Easy::Link::Link(const string &link_header) -: _next(0) -, _prev(0) +: _next() +, _prev() { std::regex renext("max_id=([[:digit:]]*)"); std::regex reprev("since_id=([[:digit:]]*)"); @@ -125,30 +125,30 @@ Easy::Link::Link(const string &link_header) if (std::regex_search(link_header, match, renext)) { - _next = std::stoull(match[1].str()); + _next = match[1].str(); } if (std::regex_search(link_header, match, reprev)) { - _prev = std::stoull(match[1].str()); + _prev = match[1].str(); } } -uint_fast64_t Easy::Link::next() const +const string Easy::Link::next() const { return _next; } -uint_fast64_t Easy::Link::max_id() const +const string Easy::Link::max_id() const { return _next; } -uint_fast64_t Easy::Link::prev() const +const string Easy::Link::prev() const { return _prev; } -uint_fast64_t Easy::Link::since_id() const +const string Easy::Link::since_id() const { return _prev; } diff --git a/src/easy/easy.hpp b/src/easy/easy.hpp index 9b8f59a..90ca92d 100644 --- a/src/easy/easy.hpp +++ b/src/easy/easy.hpp @@ -172,32 +172,32 @@ public: * * @since before 0.11.0 */ - uint_fast64_t next() const; + const string next() const; /*! * @brief Returns max_id * * @since before 0.11.0 */ - uint_fast64_t max_id() const; + const string max_id() const; /*! * @brief Returns since_id * * @since before 0.11.0 */ - uint_fast64_t prev() const; + const string prev() const; /*! * @brief Returns since_id * * @since before 0.11.0 */ - uint_fast64_t since_id() const; + const string since_id() const; private: - uint_fast64_t _next; - uint_fast64_t _prev; + string _next; + string _prev; }; /*! @@ -309,7 +309,7 @@ public: */ const vector get_notifications( uint_fast16_t &error, const uint_fast16_t limit = 20, - const uint_fast64_t since_id = 0, const uint_fast64_t max_id = 0); + const string since_id = 0, const string max_id = 0); /*! * @brief Base class for all entities. diff --git a/src/easy/simple_calls.cpp b/src/easy/simple_calls.cpp index d619281..f65b1a3 100644 --- a/src/easy/simple_calls.cpp +++ b/src/easy/simple_calls.cpp @@ -45,10 +45,10 @@ const Easy::Status Easy::send_post(const Status &status, uint_fast16_t &error) return Status(); } - if (status.in_reply_to_id() != 0) + if (!status.in_reply_to_id().empty()) { parameters.insert({ "in_reply_to_id", - { std::to_string(status.in_reply_to_id()) }}); + { status.in_reply_to_id() }}); } if (status.sensitive()) { @@ -115,7 +115,7 @@ const Easy::Status Easy::send_post(const Status &status, uint_fast16_t &error) if (error == 0) { Attachment attachment(answer); - media_ids.push_back(std::to_string(attachment.id())); + media_ids.push_back(attachment.id()); } else { @@ -140,20 +140,20 @@ const Easy::Status Easy::send_post(const Status &status, uint_fast16_t &error) const vector Easy::get_notifications( uint_fast16_t &error, const uint_fast16_t limit, - const uint_fast64_t since_id, const uint_fast64_t max_id) + const string since_id, const string max_id) { API::parametermap parameters; string answer; error = 0; parameters.insert({ "limit", { std::to_string(limit) } }); - if (since_id != 0) + if (!since_id.empty()) { - parameters.insert({ "since_id", { std::to_string(since_id) } }); + parameters.insert({ "since_id", { since_id } }); } - if (max_id != 0) + if (!max_id.empty()) { - parameters.insert({ "max_id", { std::to_string(max_id) } }); + parameters.insert({ "max_id", { max_id } }); } error = API::get(Mastodon::API::v1::notifications, parameters, answer);