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