Support for boost 1.71:

* replace boost::beast::detail::iequals with boost::iequals
* replace deprecated `buffers` function with `make_printable`
* replace boost::beast::detail::ascii_tolower with lambda
* add missing includes
This commit is contained in:
seelabs
2019-08-12 09:30:25 -07:00
committed by Manoj doshi
parent 2110b24090
commit ca6d5798e9
13 changed files with 51 additions and 29 deletions

View File

@@ -63,8 +63,11 @@
#include <ripple/resource/Fees.h> #include <ripple/resource/Fees.h>
#include <ripple/beast/asio/io_latency_probe.h> #include <ripple/beast/asio/io_latency_probe.h>
#include <ripple/beast/core/LexicalCast.h> #include <ripple/beast/core/LexicalCast.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/asio/steady_timer.hpp> #include <boost/asio/steady_timer.hpp>
#include <boost/system/error_code.hpp> #include <boost/system/error_code.hpp>
#include <condition_variable> #include <condition_variable>
#include <cstring> #include <cstring>
#include <fstream> #include <fstream>
@@ -1912,7 +1915,7 @@ bool ApplicationImp::loadOldLedger (
} }
} }
} }
else if (ledgerID.empty () || boost::beast::detail::iequals(ledgerID, "latest")) else if (ledgerID.empty () || boost::iequals(ledgerID, "latest"))
{ {
loadLedger = getLastFullLedger (); loadLedger = getLastFullLedger ();
} }

View File

@@ -25,7 +25,7 @@
#include <ripple/core/ConfigSections.h> #include <ripple/core/ConfigSections.h>
#include <ripple/nodestore/impl/DatabaseRotatingImp.h> #include <ripple/nodestore/impl/DatabaseRotatingImp.h>
#include <boost/beast/core/string.hpp> #include <boost/algorithm/string/predicate.hpp>
namespace ripple { namespace ripple {
void SHAMapStoreImp::SavedStateDB::init (BasicConfig const& config, void SHAMapStoreImp::SavedStateDB::init (BasicConfig const& config,
@@ -184,7 +184,7 @@ SHAMapStoreImp::SHAMapStoreImp(
} }
// RocksDB only. Use sensible defaults if no values specified. // RocksDB only. Use sensible defaults if no values specified.
if (boost::beast::detail::iequals( if (boost::iequals(
get<std::string>(section, "type"), "RocksDB")) get<std::string>(section, "type"), "RocksDB"))
{ {
if (!section.exists("cache_mb")) if (!section.exists("cache_mb"))

View File

@@ -318,15 +318,15 @@ void Config::loadFromString (std::string const& fileContents)
if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp, j_)) if (getSingleSection (secConfig, SECTION_NODE_SIZE, strTemp, j_))
{ {
if (boost::beast::detail::iequals(strTemp, "tiny")) if (boost::iequals(strTemp, "tiny"))
NODE_SIZE = 0; NODE_SIZE = 0;
else if (boost::beast::detail::iequals(strTemp, "small")) else if (boost::iequals(strTemp, "small"))
NODE_SIZE = 1; NODE_SIZE = 1;
else if (boost::beast::detail::iequals(strTemp, "medium")) else if (boost::iequals(strTemp, "medium"))
NODE_SIZE = 2; NODE_SIZE = 2;
else if (boost::beast::detail::iequals(strTemp, "large")) else if (boost::iequals(strTemp, "large"))
NODE_SIZE = 3; NODE_SIZE = 3;
else if (boost::beast::detail::iequals(strTemp, "huge")) else if (boost::iequals(strTemp, "huge"))
NODE_SIZE = 4; NODE_SIZE = 4;
else else
{ {
@@ -376,9 +376,9 @@ void Config::loadFromString (std::string const& fileContents)
if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp, j_)) if (getSingleSection (secConfig, SECTION_LEDGER_HISTORY, strTemp, j_))
{ {
if (boost::beast::detail::iequals(strTemp, "full")) if (boost::iequals(strTemp, "full"))
LEDGER_HISTORY = 1000000000u; LEDGER_HISTORY = 1000000000u;
else if (boost::beast::detail::iequals(strTemp, "none")) else if (boost::iequals(strTemp, "none"))
LEDGER_HISTORY = 0; LEDGER_HISTORY = 0;
else else
LEDGER_HISTORY = beast::lexicalCastThrow <std::uint32_t> (strTemp); LEDGER_HISTORY = beast::lexicalCastThrow <std::uint32_t> (strTemp);
@@ -386,9 +386,9 @@ void Config::loadFromString (std::string const& fileContents)
if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp, j_)) if (getSingleSection (secConfig, SECTION_FETCH_DEPTH, strTemp, j_))
{ {
if (boost::beast::detail::iequals(strTemp, "none")) if (boost::iequals(strTemp, "none"))
FETCH_DEPTH = 0; FETCH_DEPTH = 0;
else if (boost::beast::detail::iequals(strTemp, "full")) else if (boost::iequals(strTemp, "full"))
FETCH_DEPTH = 1000000000u; FETCH_DEPTH = 1000000000u;
else else
FETCH_DEPTH = beast::lexicalCastThrow <std::uint32_t> (strTemp); FETCH_DEPTH = beast::lexicalCastThrow <std::uint32_t> (strTemp);

View File

@@ -37,10 +37,13 @@
#include <ripple/protocol/UintTypes.h> #include <ripple/protocol/UintTypes.h>
#include <ripple/rpc/ServerHandler.h> #include <ripple/rpc/ServerHandler.h>
#include <ripple/beast/core/LexicalCast.h> #include <ripple/beast/core/LexicalCast.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/beast/core/string.hpp> #include <boost/beast/core/string.hpp>
#include <boost/asio/streambuf.hpp> #include <boost/asio/streambuf.hpp>
#include <boost/optional.hpp> #include <boost/optional.hpp>
#include <boost/regex.hpp> #include <boost/regex.hpp>
#include <array> #include <array>
#include <iostream> #include <iostream>
#include <type_traits> #include <type_traits>
@@ -163,10 +166,9 @@ private:
// If odd number of params then 'novalidate' may have been specified // If odd number of params then 'novalidate' may have been specified
if (sz & 1) if (sz & 1)
{ {
using namespace boost::beast::detail; if (boost::iequals(jvParams[0u].asString(), "novalidate"))
if (iequals(jvParams[0u].asString(), "novalidate"))
++i; ++i;
else if (!iequals(jvParams[--sz].asString(), "novalidate")) else if (!boost::iequals(jvParams[--sz].asString(), "novalidate"))
return rpcError(rpcINVALID_PARAMS); return rpcError(rpcINVALID_PARAMS);
jvResult[jss::validate] = false; jvResult[jss::validate] = false;
} }
@@ -471,9 +473,9 @@ private:
// This may look reversed, but it's intentional: jss::vetoed // This may look reversed, but it's intentional: jss::vetoed
// determines whether an amendment is vetoed - so "reject" means // determines whether an amendment is vetoed - so "reject" means
// that jss::vetoed is true. // that jss::vetoed is true.
if (boost::beast::detail::iequals(action, "reject")) if (boost::iequals(action, "reject"))
jvRequest[jss::vetoed] = Json::Value (true); jvRequest[jss::vetoed] = Json::Value (true);
else if (boost::beast::detail::iequals(action, "accept")) else if (boost::iequals(action, "accept"))
jvRequest[jss::vetoed] = Json::Value (false); jvRequest[jss::vetoed] = Json::Value (false);
else else
return rpcError (rpcINVALID_PARAMS); return rpcError (rpcINVALID_PARAMS);

View File

@@ -30,6 +30,8 @@
#include <ripple/overlay/predicates.h> #include <ripple/overlay/predicates.h>
#include <ripple/protocol/HashPrefix.h> #include <ripple/protocol/HashPrefix.h>
#include <boost/algorithm/string/predicate.hpp>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -72,7 +74,6 @@ bool
DatabaseShardImp::init() DatabaseShardImp::init()
{ {
using namespace boost::filesystem; using namespace boost::filesystem;
using namespace boost::beast::detail;
std::lock_guard lock(m_); std::lock_guard lock(m_);
auto fail = [j = j_](std::string const& msg) auto fail = [j = j_](std::string const& msg)
@@ -149,9 +150,9 @@ DatabaseShardImp::init()
// NuDB is the default and only supported permanent storage backend // NuDB is the default and only supported permanent storage backend
// "Memory" and "none" types are supported for tests // "Memory" and "none" types are supported for tests
backendName_ = get<std::string>(section, "type", "nudb"); backendName_ = get<std::string>(section, "type", "nudb");
if (!iequals(backendName_, "NuDB") && if (!boost::iequals(backendName_, "NuDB") &&
!iequals(backendName_, "Memory") && !boost::iequals(backendName_, "Memory") &&
!iequals(backendName_, "none")) !boost::iequals(backendName_, "none"))
{ {
return fail("'type' value unsupported"); return fail("'type' value unsupported");
} }

View File

@@ -20,6 +20,8 @@
#include <ripple/nodestore/impl/ManagerImp.h> #include <ripple/nodestore/impl/ManagerImp.h>
#include <ripple/nodestore/impl/DatabaseNodeImp.h> #include <ripple/nodestore/impl/DatabaseNodeImp.h>
#include <boost/algorithm/string/predicate.hpp>
namespace ripple { namespace ripple {
namespace NodeStore { namespace NodeStore {
@@ -102,7 +104,7 @@ ManagerImp::find (std::string const& name)
auto const iter = std::find_if(list_.begin(), list_.end(), auto const iter = std::find_if(list_.begin(), list_.end(),
[&name](Factory* other) [&name](Factory* other)
{ {
return boost::beast::detail::iequals(name, other->getName()); return boost::iequals(name, other->getName());
} ); } );
if (iter == list_.end()) if (iter == list_.end())
return nullptr; return nullptr;

View File

@@ -57,6 +57,7 @@ Shard::Shard(
bool bool
Shard::open(Scheduler& scheduler, nudb::context& ctx) Shard::open(Scheduler& scheduler, nudb::context& ctx)
{ {
using namespace boost::filesystem;
std::lock_guard lock(mutex_); std::lock_guard lock(mutex_);
assert(!backend_); assert(!backend_);

View File

@@ -36,6 +36,7 @@
#include <ripple/rpc/handlers/GetCounts.h> #include <ripple/rpc/handlers/GetCounts.h>
#include <ripple/server/SimpleWriter.h> #include <ripple/server/SimpleWriter.h>
#include <boost/algorithm/string/predicate.hpp>
#include <boost/utility/in_place_factory.hpp> #include <boost/utility/in_place_factory.hpp>
namespace ripple { namespace ripple {
@@ -226,7 +227,7 @@ OverlayImpl::onHandoff (std::unique_ptr <beast::asio::ssl_bundle>&& ssl_bundle,
if (std::find_if(types.begin(), types.end(), if (std::find_if(types.begin(), types.end(),
[](std::string const& s) [](std::string const& s)
{ {
return boost::beast::detail::iequals(s, "peer"); return boost::iequals(s, "peer");
}) == types.end()) }) == types.end())
{ {
handoff.moved = false; handoff.moved = false;

View File

@@ -42,6 +42,8 @@
#include <boost/algorithm/clamp.hpp> #include <boost/algorithm/clamp.hpp>
#include <boost/algorithm/string/predicate.hpp> #include <boost/algorithm/string/predicate.hpp>
#include <boost/algorithm/string.hpp> #include <boost/algorithm/string.hpp>
#include <boost/beast/core/ostream.hpp>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
#include <sstream> #include <sstream>
@@ -252,7 +254,7 @@ PeerImp::crawl() const
auto const iter = headers_.find("Crawl"); auto const iter = headers_.find("Crawl");
if (iter == headers_.end()) if (iter == headers_.end())
return false; return false;
return boost::beast::detail::iequals(iter->value(), "public"); return boost::iequals(iter->value(), "public");
} }
bool bool

View File

@@ -118,13 +118,18 @@ forwardedFor(http_request_type const& request)
it = request.find("Forwarded"); it = request.find("Forwarded");
if (it != request.end()) if (it != request.end())
{ {
auto ascii_tolower = [](char c) -> char
{
return ((static_cast<unsigned>(c) - 65U) < 26) ?
c + 'a' - 'A' : c;
};
static std::string const forStr{"for="}; static std::string const forStr{"for="};
auto found = std::search(it->value().begin(), it->value().end(), auto found = std::search(it->value().begin(), it->value().end(),
forStr.begin(), forStr.end(), forStr.begin(), forStr.end(),
[](char c1, char c2) [&ascii_tolower](char c1, char c2)
{ {
return boost::beast::detail::ascii_tolower(c1) == return ascii_tolower(c1) == ascii_tolower(c2);
boost::beast::detail::ascii_tolower(c2);
} }
); );

View File

@@ -23,10 +23,13 @@
#include <ripple/server/Handoff.h> #include <ripple/server/Handoff.h>
#include <ripple/server/Port.h> #include <ripple/server/Port.h>
#include <ripple/server/Writer.h> #include <ripple/server/Writer.h>
#include <boost/beast/websocket/rfc6455.hpp>
#include <boost/beast/core/buffers_prefix.hpp> #include <boost/beast/core/buffers_prefix.hpp>
#include <boost/asio/buffer.hpp> #include <boost/asio/buffer.hpp>
#include <boost/asio/ip/tcp.hpp> #include <boost/asio/ip/tcp.hpp>
#include <boost/logic/tribool.hpp> #include <boost/logic/tribool.hpp>
#include <algorithm> #include <algorithm>
#include <functional> #include <functional>
#include <memory> #include <memory>

View File

@@ -22,6 +22,8 @@
#include <ripple/beast/rfc2616.h> #include <ripple/beast/rfc2616.h>
#include <ripple/beast/core/LexicalCast.h> #include <ripple/beast/core/LexicalCast.h>
#include <boost/algorithm/string/predicate.hpp>
namespace ripple { namespace ripple {
bool bool
@@ -189,7 +191,7 @@ parse_Port (ParsedPort& port, Section const& section, std::ostream& log)
{ {
auto const lim = get (section, "limit", "unlimited"); auto const lim = get (section, "limit", "unlimited");
if (!boost::beast::detail::iequals (lim, "unlimited")) if (!boost::iequals (lim, "unlimited"))
{ {
try try
{ {

View File

@@ -749,7 +749,7 @@ class ServerStatus_test :
Json::Reader jr; Json::Reader jr;
if(! BEAST_EXPECT(jr.parse( if(! BEAST_EXPECT(jr.parse(
boost::lexical_cast<std::string>( boost::lexical_cast<std::string>(
boost::beast::buffers(sb.data())), resp))) boost::beast::make_printable(sb.data())), resp)))
return Json::objectValue; return Json::objectValue;
sb.consume(sb.size()); sb.consume(sb.size());
return resp; return resp;