diff options
-rw-r--r-- | .gitmodules | 3 | ||||
-rw-r--r-- | CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/client.cpp | 11 | ||||
-rw-r--r-- | src/client.h | 1 | ||||
-rw-r--r-- | src/timeline.cpp | 5 | ||||
-rw-r--r-- | src/util.h | 21 | ||||
m--------- | vendor/hkutil | 0 |
7 files changed, 15 insertions, 28 deletions
diff --git a/.gitmodules b/.gitmodules index 4f1abfd..a17e923 100644 --- a/.gitmodules +++ b/.gitmodules | |||
@@ -4,3 +4,6 @@ | |||
4 | [submodule "vendor/curlcpp"] | 4 | [submodule "vendor/curlcpp"] |
5 | path = vendor/curlcpp | 5 | path = vendor/curlcpp |
6 | url = https://github.com/JosephP91/curlcpp | 6 | url = https://github.com/JosephP91/curlcpp |
7 | [submodule "vendor/hkutil"] | ||
8 | path = vendor/hkutil | ||
9 | 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) | |||
10 | add_subdirectory(vendor/curlcpp) | 10 | add_subdirectory(vendor/curlcpp) |
11 | include_directories(${CURLCPP_SOURCE_DIR}/include) | 11 | include_directories(${CURLCPP_SOURCE_DIR}/include) |
12 | 12 | ||
13 | include_directories(vendor/hkutil) | ||
14 | |||
13 | add_library(twitter++ | 15 | add_library(twitter++ |
14 | src/client.cpp | 16 | src/client.cpp |
15 | src/request.cpp | 17 | 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 @@ | |||
4 | #include <algorithm> | 4 | #include <algorithm> |
5 | #include <json.hpp> | 5 | #include <json.hpp> |
6 | #include <thread> | 6 | #include <thread> |
7 | #include <hkutil/string.h> | ||
7 | #include "request.h" | 8 | #include "request.h" |
8 | 9 | ||
9 | namespace twitter { | 10 | namespace twitter { |
@@ -26,7 +27,7 @@ namespace twitter { | |||
26 | if (!media_ids.empty()) | 27 | if (!media_ids.empty()) |
27 | { | 28 | { |
28 | datastrstream << "&media_ids="; | 29 | datastrstream << "&media_ids="; |
29 | datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ","); | 30 | datastrstream << hatkirby::implode(std::begin(media_ids), std::end(media_ids), ","); |
30 | } | 31 | } |
31 | 32 | ||
32 | return tweet( | 33 | return tweet( |
@@ -46,7 +47,7 @@ namespace twitter { | |||
46 | if (!media_ids.empty()) | 47 | if (!media_ids.empty()) |
47 | { | 48 | { |
48 | datastrstream << "&media_ids="; | 49 | datastrstream << "&media_ids="; |
49 | datastrstream << twitter::implode(std::begin(media_ids), std::end(media_ids), ","); | 50 | datastrstream << hatkirby::implode(std::begin(media_ids), std::end(media_ids), ","); |
50 | } | 51 | } |
51 | 52 | ||
52 | return tweet( | 53 | return tweet( |
@@ -366,7 +367,8 @@ namespace twitter { | |||
366 | } | 367 | } |
367 | 368 | ||
368 | std::string datastr = "id=" + | 369 | std::string datastr = "id=" + |
369 | OAuth::PercentEncode(implode(std::begin(cur), std::end(cur), ",")); | 370 | OAuth::PercentEncode( |
371 | hatkirby::implode(std::begin(cur), std::end(cur), ",")); | ||
370 | 372 | ||
371 | std::string response = | 373 | std::string response = |
372 | post(auth_, | 374 | post(auth_, |
@@ -399,7 +401,8 @@ namespace twitter { | |||
399 | } | 401 | } |
400 | 402 | ||
401 | std::string datastr = "user_id=" + | 403 | std::string datastr = "user_id=" + |
402 | OAuth::PercentEncode(implode(std::begin(cur), std::end(cur), ",")); | 404 | OAuth::PercentEncode( |
405 | hatkirby::implode(std::begin(cur), std::end(cur), ",")); | ||
403 | 406 | ||
404 | std::string response = | 407 | std::string response = |
405 | post(auth_, | 408 | 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 @@ | |||
9 | #include "tweet.h" | 9 | #include "tweet.h" |
10 | #include "auth.h" | 10 | #include "auth.h" |
11 | #include "configuration.h" | 11 | #include "configuration.h" |
12 | #include "util.h" | ||
13 | #include "timeline.h" | 12 | #include "timeline.h" |
14 | 13 | ||
15 | namespace twitter { | 14 | 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 @@ | |||
1 | #include "timeline.h" | 1 | #include "timeline.h" |
2 | #include <sstream> | 2 | #include <sstream> |
3 | #include <json.hpp> | 3 | #include <json.hpp> |
4 | #include <hkutil/string.h> | ||
4 | #include "codes.h" | 5 | #include "codes.h" |
5 | #include "util.h" | ||
6 | #include "request.h" | 6 | #include "request.h" |
7 | 7 | ||
8 | namespace twitter { | 8 | namespace twitter { |
@@ -40,7 +40,8 @@ namespace twitter { | |||
40 | if (!arguments.empty()) | 40 | if (!arguments.empty()) |
41 | { | 41 | { |
42 | urlstr << "?"; | 42 | urlstr << "?"; |
43 | urlstr << implode(std::begin(arguments), std::end(arguments), "&"); | 43 | urlstr << hatkirby::implode( |
44 | std::begin(arguments), std::end(arguments), "&"); | ||
44 | } | 45 | } |
45 | 46 | ||
46 | std::string theUrl = urlstr.str(); | 47 | 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 @@ | |||
1 | #ifndef UTIL_H_440DEAA0 | 1 | #ifndef UTIL_H_440DEAA0 |
2 | #define UTIL_H_440DEAA0 | 2 | #define UTIL_H_440DEAA0 |
3 | 3 | ||
4 | #include <string> | ||
5 | #include <sstream> | ||
6 | #include <memory> | ||
7 | #include <ctime> | 4 | #include <ctime> |
8 | 5 | ||
9 | namespace twitter { | 6 | namespace twitter { |
10 | 7 | ||
11 | template <class InputIterator> | ||
12 | std::string implode(InputIterator first, InputIterator last, std::string delimiter) | ||
13 | { | ||
14 | std::stringstream result; | ||
15 | |||
16 | for (InputIterator it = first; it != last; it++) | ||
17 | { | ||
18 | if (it != first) | ||
19 | { | ||
20 | result << delimiter; | ||
21 | } | ||
22 | |||
23 | result << *it; | ||
24 | } | ||
25 | |||
26 | return result.str(); | ||
27 | } | ||
28 | |||
29 | time_t timegm(struct tm * t); | 8 | time_t timegm(struct tm * t); |
30 | 9 | ||
31 | }; | 10 | }; |
diff --git a/vendor/hkutil b/vendor/hkutil new file mode 160000 | |||
Subproject a9a5996310bb33207d3338f353aab97b9ed3a5e | |||