rippled
Loading...
Searching...
No Matches
include
xrpl
basics
strHex.h
1
#pragma once
2
3
#include <boost/algorithm/hex.hpp>
4
#include <boost/endian/conversion.hpp>
5
6
namespace
xrpl
{
7
8
template
<
class
FwdIt>
9
std::string
10
strHex
(FwdIt begin, FwdIt end)
11
{
12
static_assert
(
13
std::is_convertible<typename std::iterator_traits<FwdIt>::iterator_category
,
std::forward_iterator_tag
>::value,
14
"FwdIt must be a forward iterator"
);
15
std::string
result;
16
result.
reserve
(2 *
std::distance
(begin, end));
17
boost::algorithm::hex(begin, end,
std::back_inserter
(result));
18
return
result;
19
}
20
21
template <class T, class = decltype(std::declval<T>().
begin
())>
22
std::string
23
strHex
(T
const
& from)
24
{
25
return
strHex
(from.begin(), from.end());
26
}
27
28
}
// namespace xrpl
std::back_inserter
T back_inserter(T... args)
std::string
std::string::begin
T begin(T... args)
std::distance
T distance(T... args)
std::is_convertible
std::forward_iterator_tag
xrpl
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition
algorithm.h:5
xrpl::strHex
std::string strHex(FwdIt begin, FwdIt end)
Definition
strHex.h:10
std::string::reserve
T reserve(T... args)
Generated by
1.9.8