diff --git a/lib/incredis b/lib/incredis index c4f8462..a8a27b3 160000 --- a/lib/incredis +++ b/lib/incredis @@ -1 +1 @@ -Subproject commit c4f84622fe664a13dbe0fbbf928fe116eacfedbc +Subproject commit a8a27b307f5cf516f967ea1e5321587ad6df0b7e diff --git a/src/kamokan_impl/error_response.cpp b/src/kamokan_impl/error_response.cpp index 7e456dd..0c64fb4 100644 --- a/src/kamokan_impl/error_response.cpp +++ b/src/kamokan_impl/error_response.cpp @@ -20,8 +20,8 @@ #include "cgi_env.hpp" #include "sprout/array/array.hpp" #include "string_lengths.hpp" +#include "incredis/int_conv.hpp" #include -#include #include #include #include @@ -40,7 +40,7 @@ namespace kamokan { using tawashi::ErrorReasons; auto get = cgi_env().query_string_split(); - const int reason_int = boost::lexical_cast(get["reason"]); + const int reason_int = redis::int_conv(get["reason"]); ErrorReasons reason_code(ErrorReasons::UnknownReason); if (reason_int >= 0 and reason_int < ErrorReasons::_size()) reason_code = ErrorReasons::_from_integral(reason_int); diff --git a/src/kamokan_impl/response.cpp b/src/kamokan_impl/response.cpp index c2a86a7..3bc7366 100644 --- a/src/kamokan_impl/response.cpp +++ b/src/kamokan_impl/response.cpp @@ -18,7 +18,6 @@ #include "response.hpp" #include "settings_bag.hpp" #include "duckhandy/stringize.h" -#include "duckhandy/lexical_cast.hpp" #include "pathname/pathname.hpp" #include "highlight_functions.hpp" #include "cgi_env.hpp" diff --git a/src/kamokan_impl/settings_bag.cpp b/src/kamokan_impl/settings_bag.cpp index b72b661..661e45c 100644 --- a/src/kamokan_impl/settings_bag.cpp +++ b/src/kamokan_impl/settings_bag.cpp @@ -16,7 +16,6 @@ */ #include "settings_bag.hpp" -#include "duckhandy/lexical_cast.hpp" #include "spdlog.hpp" #include #include diff --git a/src/kamokan_impl/storage.cpp b/src/kamokan_impl/storage.cpp index a3c8f6a..7faa525 100644 --- a/src/kamokan_impl/storage.cpp +++ b/src/kamokan_impl/storage.cpp @@ -24,6 +24,7 @@ #include "string_conv.hpp" #include "lua_scripts_for_redis.hpp" #include "redis_to_error_reason.hpp" +#include "incredis/int_conv.hpp" #include #include #include @@ -140,7 +141,6 @@ namespace kamokan { ) const { using tawashi::ErrorReasons; using boost::string_view; - using dhandy::lexical_cast; if (not is_connected()) return make_submission_result(ErrorReasons::RedisDisconnected); @@ -153,12 +153,12 @@ namespace kamokan { { string_view paste_counter_token(TOKEN_PREFIX "paste_counter"); std::string prefix(g_token_prefix); - const auto expiry = lexical_cast(parExpiry); + const auto expiry = redis::int_to_ary_dec(parExpiry); const auto self_des = string_view(parSelfDestruct ? "1" : "0"); const auto flood_wait = m_settings->as("resubmit_wait"); retrieve.run(batch, std::make_tuple(paste_counter_token, prefix + parRemoteIP), - std::make_tuple(prefix, parText, expiry, parLang, self_des, flood_wait) + std::make_tuple(prefix, parText, expiry.to(), parLang, self_des, flood_wait) ); } auto raw_replies = batch.replies(); @@ -216,7 +216,7 @@ namespace kamokan { using std::string; using boost::make_optional; retval.error = - make_optional(string(get_error_string(raw_replies.front()).message())); + make_optional(get_error_string(raw_replies.front()).message()); return retval; } auto pastie_reply = get_array(raw_replies.front()); diff --git a/src/kamokan_impl/string_conv.hpp b/src/kamokan_impl/string_conv.hpp index b72609b..f95cad7 100644 --- a/src/kamokan_impl/string_conv.hpp +++ b/src/kamokan_impl/string_conv.hpp @@ -17,8 +17,8 @@ #pragma once -#include "duckhandy/lexical_cast.hpp" #include +#include #include #include #include @@ -41,19 +41,19 @@ namespace kamokan { template <> [[gnu::pure,gnu::always_inline]] inline uint16_t string_conv (boost::string_view parStr) { - return dhandy::lexical_cast(parStr); + return boost::lexical_cast(parStr); } template <> [[gnu::pure,gnu::always_inline]] inline uint32_t string_conv (boost::string_view parStr) { - return dhandy::lexical_cast(parStr); + return boost::lexical_cast(parStr); } template <> [[gnu::pure,gnu::always_inline]] inline long long string_conv (boost::string_view parStr) { - return dhandy::lexical_cast(parStr); + return boost::lexical_cast(parStr); } template <> diff --git a/src/kamokan_impl/submit_paste_response.cpp b/src/kamokan_impl/submit_paste_response.cpp index 0f24efd..575166b 100644 --- a/src/kamokan_impl/submit_paste_response.cpp +++ b/src/kamokan_impl/submit_paste_response.cpp @@ -20,14 +20,13 @@ #include "cgi_post.hpp" #include "settings_bag.hpp" #include "duckhandy/compatibility.h" -#include "duckhandy/lexical_cast.hpp" +#include "incredis/int_conv.hpp" #include "tawashi_exception.hpp" #include "ip_utils.hpp" #include "string_conv.hpp" #include "highlight_functions.hpp" #include #include -#include #include #include #include @@ -152,9 +151,7 @@ namespace kamokan { } } - //TODO: replace boost's lexical_cast with mine when I have some checks - //over invalid inputs - const uint32_t duration_int = std::max(std::min((duration.empty() ? 86400U : boost::lexical_cast(duration)), 2628000U), 1U); + const uint32_t duration_int = std::max(std::min((duration.empty() ? 86400U : redis::int_conv(duration)), 2628000U), 1U); StringOrHeader submit_result = submit_to_storage(pastie, duration_int, m_local->pastie_lang, self_destruct); const boost::optional& token = submit_result.first; diff --git a/src/tawashi/http_header.cpp b/src/tawashi/http_header.cpp index ad7710b..eba1a47 100644 --- a/src/tawashi/http_header.cpp +++ b/src/tawashi/http_header.cpp @@ -16,7 +16,6 @@ */ #include "http_header.hpp" -#include "duckhandy/lexical_cast.hpp" #include "duckhandy/sequence_bt.hpp" #include "sprout/array/array.hpp" #include diff --git a/src/tawashi/ip_utils.cpp b/src/tawashi/ip_utils.cpp index 7ac25d9..2164e0c 100644 --- a/src/tawashi/ip_utils.cpp +++ b/src/tawashi/ip_utils.cpp @@ -16,8 +16,6 @@ */ #include "ip_utils.hpp" -#include "duckhandy/lexical_cast.hpp" -#include "duckhandy/int_to_string_ary.hpp" #include "cgi_env.hpp" #include "tawashi_config.h" #include diff --git a/test/simulation/test_submit_pastie.cpp b/test/simulation/test_submit_pastie.cpp index 5f29012..6fbc465 100644 --- a/test/simulation/test_submit_pastie.cpp +++ b/test/simulation/test_submit_pastie.cpp @@ -25,9 +25,9 @@ #include "cgi_env.hpp" #include "cgi_post.hpp" #include "fake_storage.hpp" +#include "duckhandy/int_conv.hpp" #include #include -#include namespace kamokan { class SubmitPasteResponseWithFakeStorage : public SubmitPasteResponse { @@ -143,7 +143,7 @@ TEST_CASE ("Submit paste response", "[submitpaste][response]") { CHECK(submitted_pastie.remote_ip == "127.0.0.1"); #endif CHECK(submitted_pastie.token == "b"); - CHECK(submitted_pastie.expiry == boost::lexical_cast(original_expiry)); + CHECK(submitted_pastie.expiry == dhandy::int_conv(original_expiry)); { std::string output = oss.str();