1
0
Fork 0
mirror of https://github.com/KingDuckZ/kamokan.git synced 2024-12-23 21:25:43 +00:00

Don't use dhandy::lexical_cast anymore.

This commit is contained in:
King_DuckZ 2018-10-13 14:49:55 +01:00
parent c1224d9a7f
commit 1f836218f5
10 changed files with 15 additions and 23 deletions

@ -1 +1 @@
Subproject commit c4f84622fe664a13dbe0fbbf928fe116eacfedbc
Subproject commit a8a27b307f5cf516f967ea1e5321587ad6df0b7e

View file

@ -20,8 +20,8 @@
#include "cgi_env.hpp"
#include "sprout/array/array.hpp"
#include "string_lengths.hpp"
#include "incredis/int_conv.hpp"
#include <boost/algorithm/string/replace.hpp>
#include <boost/lexical_cast.hpp>
#include <ciso646>
#include <string>
#include <cassert>
@ -40,7 +40,7 @@ namespace kamokan {
using tawashi::ErrorReasons;
auto get = cgi_env().query_string_split();
const int reason_int = boost::lexical_cast<int>(get["reason"]);
const int reason_int = redis::int_conv<int>(get["reason"]);
ErrorReasons reason_code(ErrorReasons::UnknownReason);
if (reason_int >= 0 and reason_int < ErrorReasons::_size())
reason_code = ErrorReasons::_from_integral(reason_int);

View file

@ -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"

View file

@ -16,7 +16,6 @@
*/
#include "settings_bag.hpp"
#include "duckhandy/lexical_cast.hpp"
#include "spdlog.hpp"
#include <ciso646>
#include <cassert>

View file

@ -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 <cassert>
#include <ciso646>
#include <string>
@ -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<std::string>(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<string_view>("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<boost::string_view>(), 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>(string(get_error_string(raw_replies.front()).message()));
make_optional<string>(get_error_string(raw_replies.front()).message());
return retval;
}
auto pastie_reply = get_array(raw_replies.front());

View file

@ -17,8 +17,8 @@
#pragma once
#include "duckhandy/lexical_cast.hpp"
#include <boost/utility/string_view.hpp>
#include <boost/lexical_cast.hpp>
#include <type_traits>
#include <cstdint>
#include <string>
@ -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<uint16_t>(parStr);
return boost::lexical_cast<uint16_t>(parStr);
}
template <>
[[gnu::pure,gnu::always_inline]] inline
uint32_t string_conv (boost::string_view parStr) {
return dhandy::lexical_cast<uint32_t>(parStr);
return boost::lexical_cast<uint32_t>(parStr);
}
template <>
[[gnu::pure,gnu::always_inline]] inline
long long string_conv (boost::string_view parStr) {
return dhandy::lexical_cast<long long>(parStr);
return boost::lexical_cast<long long>(parStr);
}
template <>

View file

@ -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 <ciso646>
#include <algorithm>
#include <boost/lexical_cast.hpp>
#include <cstdint>
#include <spdlog/spdlog.h>
#include <utility>
@ -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<uint32_t>(duration)), 2628000U), 1U);
const uint32_t duration_int = std::max(std::min((duration.empty() ? 86400U : redis::int_conv<uint32_t>(duration)), 2628000U), 1U);
StringOrHeader submit_result = submit_to_storage(pastie, duration_int, m_local->pastie_lang, self_destruct);
const boost::optional<std::string>& token = submit_result.first;

View file

@ -16,7 +16,6 @@
*/
#include "http_header.hpp"
#include "duckhandy/lexical_cast.hpp"
#include "duckhandy/sequence_bt.hpp"
#include "sprout/array/array.hpp"
#include <utility>

View file

@ -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 <spdlog/spdlog.h>

View file

@ -25,9 +25,9 @@
#include "cgi_env.hpp"
#include "cgi_post.hpp"
#include "fake_storage.hpp"
#include "duckhandy/int_conv.hpp"
#include <spdlog/spdlog.h>
#include <sstream>
#include <boost/lexical_cast.hpp>
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<uint32_t>(original_expiry));
CHECK(submitted_pastie.expiry == dhandy::int_conv<uint32_t>(original_expiry));
{
std::string output = oss.str();