1#include <xrpl/basics/StringUtilities.h>
3#include <xrpl/basics/Blob.h>
4#include <xrpl/beast/core/LexicalCast.h>
5#include <xrpl/beast/net/IPEndpoint.h>
7#include <boost/algorithm/hex.hpp>
8#include <boost/algorithm/string/case_conv.hpp>
9#include <boost/algorithm/string/trim.hpp>
10#include <boost/regex/v5/regbase.hpp>
11#include <boost/regex/v5/regex.hpp>
12#include <boost/regex/v5/regex_match.hpp>
40 static boost::regex
const kReUrl(
43 "([[:alpha:]][-+.[:alpha:][:digit:]]*?):"
48 "(?:([^:@/]*?)(?::([^@/]*?))?@)?"
50 "([[:digit:]:]*[[:digit:]]|\\[[^]]+\\]|[^:/?#]*?)"
52 "(?::([[:digit:]]+))?"
56 boost::smatch smMatch;
61 if (!boost::regex_match(strUrl, smMatch, kReUrl))
70 boost::algorithm::to_lower(pUrl.
scheme);
78 pUrl.
domain = result ? result->address().to_string() : domain;
91 pUrl.
path = smMatch[6];
116 if (domain.
size() < 4 || domain.
size() > 128)
123 static boost::regex
const kRE(
134 boost::regex_constants::optimize);
136 return boost::regex_match(domain.
begin(), domain.
end(), kRE);
T back_inserter(T... args)
static std::optional< Endpoint > fromStringChecked(std::string const &s)
Create an Endpoint from a string.
Out lexicalCast(In in, Out defaultValue=Out())
Convert from one type to another.
bool lexicalCastChecked(Out &out, In in)
Intelligently convert from one type to another.
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
bool isProperlyFormedTomlDomain(std::string_view domain)
Determines if the given string looks like a TOML-file hosting domain.
std::string trimWhitespace(std::string str)
std::optional< std::uint64_t > toUInt64(std::string const &s)
std::string sqlBlobLiteral(Blob const &blob)
Format arbitrary binary data as an SQLite "blob literal".
std::vector< unsigned char > Blob
Storage for linear binary data.
bool parseUrl(ParsedUrl &pUrl, std::string const &strUrl)
std::optional< std::uint16_t > port