mirror of
https://github.com/XRPLF/rippled.git
synced 2026-08-21 14:20:56 +00:00
refactor: Replace boost::lexical_cast with existing alternatives (#7991)
This commit is contained in:
@@ -8,7 +8,6 @@
|
||||
#include <xrpl/beast/unit_test/runner.h>
|
||||
#include <xrpl/beast/unit_test/suite_info.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/optional.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
@@ -188,7 +187,7 @@ Reporter<Unused>::fmtdur(clock_type::duration const& d)
|
||||
using namespace std::chrono;
|
||||
auto const ms = duration_cast<milliseconds>(d);
|
||||
if (ms < seconds{1})
|
||||
return boost::lexical_cast<std::string>(ms.count()) + "ms";
|
||||
return std::to_string(ms.count()) + "ms";
|
||||
std::stringstream ss;
|
||||
ss << std::fixed << std::setprecision(1) << (ms.count() / 1000.) << "s";
|
||||
return ss.str();
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <xrpl/beast/unit_test/runner.h>
|
||||
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/throw_exception.hpp>
|
||||
|
||||
#include <exception>
|
||||
@@ -30,7 +29,7 @@ makeReason(String const& reason, char const* file, int line)
|
||||
namespace fs = boost::filesystem;
|
||||
s.append(fs::path{file}.filename().string());
|
||||
s.append("(");
|
||||
s.append(boost::lexical_cast<std::string>(line));
|
||||
s.append(std::to_string(line));
|
||||
s.append(")");
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
#include <boost/interprocess/creation_tags.hpp>
|
||||
#include <boost/interprocess/detail/os_file_functions.hpp>
|
||||
#include <boost/interprocess/shared_memory_object.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@@ -36,7 +35,7 @@ fmtdur(typename clock_type::duration const& d)
|
||||
using namespace std::chrono;
|
||||
auto const ms = duration_cast<milliseconds>(d);
|
||||
if (ms < seconds{1})
|
||||
return boost::lexical_cast<std::string>(ms.count()) + "ms";
|
||||
return std::to_string(ms.count()) + "ms";
|
||||
std::stringstream ss;
|
||||
ss << std::fixed << std::setprecision(1) << (ms.count() / 1000.) << "s";
|
||||
return ss.str();
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
|
||||
#include <xrpld/rpc/detail/Tuning.h>
|
||||
|
||||
#include <xrpl/basics/StringUtilities.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/basics/strHex.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
@@ -22,9 +23,6 @@
|
||||
#include <xrpl/protocol/tokens.h>
|
||||
#include <xrpl/resource/Fees.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -129,7 +127,7 @@ doAccountChannels(rpc::JsonContext& context)
|
||||
return rpc::expectedFieldError(jss::marker, "string");
|
||||
|
||||
// Marker is composed of a comma separated index and start hint. The
|
||||
// former will be read as hex, and the latter using boost lexical cast.
|
||||
// former will be read as hex, and the latter as a decimal integer.
|
||||
std::stringstream marker(params[jss::marker].asString());
|
||||
std::string value;
|
||||
if (!std::getline(marker, value, ','))
|
||||
@@ -141,14 +139,10 @@ doAccountChannels(rpc::JsonContext& context)
|
||||
if (!std::getline(marker, value, ','))
|
||||
return rpcError(RpcInvalidParams);
|
||||
|
||||
try
|
||||
{
|
||||
startHint = boost::lexical_cast<std::uint64_t>(value);
|
||||
}
|
||||
catch (boost::bad_lexical_cast&)
|
||||
{
|
||||
auto const hint = toUInt64(value);
|
||||
if (!hint.has_value())
|
||||
return rpcError(RpcInvalidParams);
|
||||
}
|
||||
startHint = *hint;
|
||||
|
||||
// We then must check if the object pointed to by the marker is actually
|
||||
// owned by the account in the request.
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <xrpld/rpc/detail/TrustLine.h>
|
||||
#include <xrpld/rpc/detail/Tuning.h>
|
||||
|
||||
#include <xrpl/basics/StringUtilities.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
@@ -22,9 +23,6 @@
|
||||
#include <xrpl/protocol/jss.h>
|
||||
#include <xrpl/resource/Fees.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -153,7 +151,7 @@ doAccountLines(rpc::JsonContext& context)
|
||||
return rpc::expectedFieldError(jss::marker, "string");
|
||||
|
||||
// Marker is composed of a comma separated index and start hint. The
|
||||
// former will be read as hex, and the latter using boost lexical cast.
|
||||
// former will be read as hex, and the latter as a decimal integer.
|
||||
std::stringstream marker(params[jss::marker].asString());
|
||||
std::string value;
|
||||
if (!std::getline(marker, value, ','))
|
||||
@@ -165,14 +163,10 @@ doAccountLines(rpc::JsonContext& context)
|
||||
if (!std::getline(marker, value, ','))
|
||||
return rpcError(RpcInvalidParams);
|
||||
|
||||
try
|
||||
{
|
||||
startHint = boost::lexical_cast<std::uint64_t>(value);
|
||||
}
|
||||
catch (boost::bad_lexical_cast&)
|
||||
{
|
||||
auto const hint = toUInt64(value);
|
||||
if (!hint.has_value())
|
||||
return rpcError(RpcInvalidParams);
|
||||
}
|
||||
startHint = *hint;
|
||||
|
||||
// We then must check if the object pointed to by the marker is actually
|
||||
// owned by the account in the request.
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <xrpld/rpc/detail/RPCLedgerHelpers.h>
|
||||
#include <xrpld/rpc/detail/Tuning.h>
|
||||
|
||||
#include <xrpl/basics/StringUtilities.h>
|
||||
#include <xrpl/basics/base_uint.h>
|
||||
#include <xrpl/beast/utility/Zero.h>
|
||||
#include <xrpl/beast/utility/instrumentation.h>
|
||||
@@ -20,9 +21,6 @@
|
||||
#include <xrpl/protocol/jss.h>
|
||||
#include <xrpl/resource/Fees.h>
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/lexical_cast/bad_lexical_cast.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <optional>
|
||||
@@ -97,7 +95,7 @@ doAccountOffers(rpc::JsonContext& context)
|
||||
return rpc::expectedFieldError(jss::marker, "string");
|
||||
|
||||
// Marker is composed of a comma separated index and start hint. The
|
||||
// former will be read as hex, and the latter using boost lexical cast.
|
||||
// former will be read as hex, and the latter as a decimal integer.
|
||||
std::stringstream marker(params[jss::marker].asString());
|
||||
std::string value;
|
||||
if (!std::getline(marker, value, ','))
|
||||
@@ -109,14 +107,10 @@ doAccountOffers(rpc::JsonContext& context)
|
||||
if (!std::getline(marker, value, ','))
|
||||
return rpc::invalidFieldError(jss::marker);
|
||||
|
||||
try
|
||||
{
|
||||
startHint = boost::lexical_cast<std::uint64_t>(value);
|
||||
}
|
||||
catch (boost::bad_lexical_cast&)
|
||||
{
|
||||
auto const hint = toUInt64(value);
|
||||
if (!hint.has_value())
|
||||
return rpc::invalidFieldError(jss::marker);
|
||||
}
|
||||
startHint = *hint;
|
||||
|
||||
// We then must check if the object pointed to by the marker is actually
|
||||
// owned by the account in the request.
|
||||
|
||||
Reference in New Issue
Block a user