20 #include <ripple/beast/core/LexicalCast.h>
21 #include <ripple/beast/rfc2616.h>
22 #include <ripple/overlay/impl/ProtocolVersion.h>
23 #include <boost/function_output_iterator.hpp>
24 #include <boost/regex.hpp>
50 []() constexpr->bool {
51 auto const len = std::distance(
52 std::begin(supportedProtocolList), std::end(supportedProtocolList));
62 for (auto i = 0; i != len - 1; ++i)
64 if (supportedProtocolList[i] >= supportedProtocolList[i + 1])
71 "The list of supported protocols isn't properly sorted.");
87 static boost::regex re(
90 "([2-9]|(?:[1-9][0-9]+))"
97 boost::regex_constants::optimize);
111 if (boost::regex_match(s, m, re))
125 if (to_string(proto) == s)
137 boost::optional<ProtocolVersion>
140 boost::optional<ProtocolVersion> result;
155 boost::make_function_output_iterator(pickVersion));
160 boost::optional<ProtocolVersion>
constexpr ProtocolVersion make_protocol(std::uint16_t major, std::uint16_t minor)
std::vector< ProtocolVersion > parseProtocolVersions(boost::beast::string_view const &value)
Parse a set of protocol versions.
std::pair< std::uint16_t, std::uint16_t > ProtocolVersion
Represents a particular version of the peer-to-peer protocol.
boost::optional< ProtocolVersion > negotiateProtocolVersion(std::vector< ProtocolVersion > const &versions)
Given a list of supported protocol versions, choose the one we prefer.
constexpr const ProtocolVersion supportedProtocolList[]
The list of protocol versions we speak and we prefer to use.
Result split_commas(FwdIt first, FwdIt last)
std::string const & supportedProtocolVersions()
The list of all the protocol versions we support.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
bool isProtocolSupported(ProtocolVersion const &v)
Determine whether we support a specific protocol version.
T set_intersection(T... args)