20 #ifndef RIPPLE_BASICS_STRINGUTILITIES_H_INCLUDED
21 #define RIPPLE_BASICS_STRINGUTILITIES_H_INCLUDED
23 #include <ripple/basics/Blob.h>
24 #include <ripple/basics/strHex.h>
26 #include <boost/format.hpp>
27 #include <boost/optional.hpp>
28 #include <boost/utility/string_view.hpp>
36 static boost::format f(
"X'%s'");
37 return str(boost::format(f) %
strHex(strSrc));
43 size_t size = vecSrc.
size();
50 unsigned char* oPtr =
reinterpret_cast<unsigned char*
>(&*j.
begin());
51 const unsigned char* iPtr = &vecSrc[0];
56 for (
int i = size; i != 0; --i)
58 unsigned char c = *iPtr++;
70 template <
class Iterator>
76 out.reserve((strSize + 1) / 2);
105 out.push_back(
static_cast<unsigned char>((cHigh << 4) | cLow));
108 return {std::move(
out)};
111 inline boost::optional<Blob>
117 inline boost::optional<Blob>
120 return strUnHex(strSrc.size(), strSrc.cbegin(), strSrc.cend());
131 boost::optional<std::uint16_t>
port;
148 boost::optional<std::uint64_t>
int charUnHex(unsigned char c)
Converts a hex digit to the corresponding integer.
uint64_t uintFromHex(std::string const &strSrc)
boost::optional< std::uint64_t > to_uint64(std::string const &s)
boost::optional< Blob > strUnHex(std::size_t strSize, Iterator begin, Iterator end)
bool operator==(parsedURL const &other) const
static std::string sqlEscape(std::string const &strSrc)
std::string trim_whitespace(std::string str)
bool parseUrl(parsedURL &pUrl, std::string const &strUrl)
boost::optional< std::uint16_t > port
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
boost::optional< Blob > strViewUnHex(boost::string_view const &strSrc)
char charHex(unsigned int digit)
Converts an integer to the corresponding hex digit.
std::string strHex(FwdIt begin, FwdIt end)