From a9d33aa08df10102539e33c0c6d4334e9e99a470 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 30 Aug 2018 20:38:37 -0400 Subject: Started using hkutil As of this commit, the only change is using hatkirby::implode instead of the implode that was in util.cpp. --- .gitmodules | 3 +++ CMakeLists.txt | 2 ++ src/client.cpp | 11 +++++++---- src/client.h | 1 - src/timeline.cpp | 5 +++-- src/util.h | 21 --------------------- vendor/hkutil | 1 + 7 files changed, 16 insertions(+), 28 deletions(-) create mode 160000 vendor/hkutil diff --git a/.gitmodules b/.gitmodules index 4f1abfd..a17e923 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "vendor/curlcpp"] path = vendor/curlcpp url = https://github.com/JosephP91/curlcpp +[submodule "vendor/hkutil"] + path = vendor/hkutil + url = git@github.com:hatkirby/hkutil diff --git a/CMakeLists.txt b/CMakeLists.txt index bdca0f5..766e302 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,8 @@ include_directories(vendor/liboauthcpp/include) add_subdirectory(vendor/curlcpp) include_directories(${CURLCPP_SOURCE_DIR}/include) +include_directories(vendor/hkutil) + add_library(twitter++ src/client.cpp src/request.cpp diff --git a/src/client.cpp b/src/client.cpp index 3a01c90..07f7580 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -4,6 +4,7 @@ #include #include #include +#include #include "request.h" namespace twitter { @@ -26,7 +27,7 @@ namespace twitter { if (!media_ids.empty()) { datastrstream << "&media_ids="; - datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ","); + datastrstream << hatkirby::implode(std::begin(media_ids), std::end(media_ids), ","); } return tweet( @@ -46,7 +47,7 @@ namespace twitter { if (!media_ids.empty()) { datastrstream << "&media_ids="; - datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ","); + datastrstream << hatkirby::implode(std::begin(media_ids), std::end(media_ids), ","); } return tweet( @@ -366,7 +367,8 @@ namespace twitter { } std::string datastr = "id=" + - OAuth::PercentEncode(implode(std::begin(cur), std::end(cur), ",")); + OAuth::PercentEncode( + hatkirby::implode(std::begin(cur), std::end(cur), ",")); std::string response = post(auth_, @@ -399,7 +401,8 @@ namespace twitter { } std::string datastr = "user_id=" + - OAuth::PercentEncode(implode(std::begin(cur), std::end(cur), ",")); + OAuth::PercentEncode( + hatkirby::implode(std::begin(cur), std::end(cur), ",")); std::string response = post(auth_, diff --git a/src/client.h b/src/client.h index ba68e6b..5329edb 100644 --- a/src/client.h +++ b/src/client.h @@ -9,7 +9,6 @@ #include "tweet.h" #include "auth.h" #include "configuration.h" -#include "util.h" #include "timeline.h" namespace twitter { diff --git a/src/timeline.cpp b/src/timeline.cpp index fd75a69..280c814 100644 --- a/src/timeline.cpp +++ b/src/timeline.cpp @@ -1,8 +1,8 @@ #include "timeline.h" #include #include +#include #include "codes.h" -#include "util.h" #include "request.h" namespace twitter { @@ -40,7 +40,8 @@ namespace twitter { if (!arguments.empty()) { urlstr << "?"; - urlstr << implode(std::begin(arguments), std::end(arguments), "&"); + urlstr << hatkirby::implode( + std::begin(arguments), std::end(arguments), "&"); } std::string theUrl = urlstr.str(); diff --git a/src/util.h b/src/util.h index b950728..8b9cf86 100644 --- a/src/util.h +++ b/src/util.h @@ -1,31 +1,10 @@ #ifndef UTIL_H_440DEAA0 #define UTIL_H_440DEAA0 -#include -#include -#include #include namespace twitter { - template - std::string implode(InputIterator first, InputIterator last, std::string delimiter) - { - std::stringstream result; - - for (InputIterator it = first; it != last; it++) - { - if (it != first) - { - result << delimiter; - } - - result << *it; - } - - return result.str(); - } - time_t timegm(struct tm * t); }; diff --git a/vendor/hkutil b/vendor/hkutil new file mode 160000 index 0000000..a9a5996 --- /dev/null +++ b/vendor/hkutil @@ -0,0 +1 @@ +Subproject commit a9a5996310bb33207d3338f353aab97b9ed3a5e8 -- cgit 1.4.1