6#ifndef ALT_INTEGRATION_VERIBLOCK_STRUTIL_HPP
7#define ALT_INTEGRATION_VERIBLOCK_STRUTIL_HPP
18bool IsHex(
const std::string& str);
23std::vector<uint8_t>
ParseHex(
const std::string& hex);
37constexpr inline bool IsSpace(
char c)
noexcept {
38 return c ==
' ' || c ==
'\f' || c ==
'\n' || c ==
'\r' || c ==
'\t' ||
44std::string
HexStr(
const T itbegin,
const T itend) {
47 static const char hexmap[16] = {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'a',
'b',
'c',
'd',
'e',
'f'};
49 rv.reserve(std::distance(itbegin, itend) * 2u);
50 for (T it = itbegin; it < itend; ++it) {
51 auto val = (uint8_t)(*it);
52 rv.push_back(hexmap[val >> 4u]);
53 rv.push_back(hexmap[val & 15u]);
60inline std::string
HexStr(
const T& vch,
bool reverseHex =
false) {
62 return HexStr(vch.rbegin(), vch.rend());
64 return HexStr(vch.begin(), vch.end());
69std::vector<uint8_t> toBytes(
const std::string& input);
constexpr bool IsSpace(char c) noexcept
Tests if the given character is a whitespace character.
std::string HexStr(const T itbegin, const T itend)
Convert bytes to hex.
std::vector< uint8_t > ParseHex(const char *psz)
Parse bytes from hex.