52 template<
typename Container>
55 static_assert(
sizeof(
typename Container::value_type) == 1,
"sizeof(Container::value_type) != 1");
56 using Iter =
typename Container::const_iterator;
74 const std::size_t line_size = 100;
75 const char delimiter =
' ';
77 bool put_newlines =
true;
78 bool put_delimiters =
true;
79 bool use_uppercase =
false;
80 bool put_positions =
true;
83 template<
typename ParseContext>
84 auto parse(ParseContext &ctx) -> decltype(ctx.begin())
86 auto it = ctx.begin();
87 while (*it && *it !=
'}')
95 put_delimiters =
false;
98 put_positions =
false;
101 put_newlines =
false;
111 template<
typename FormatContext,
typename Container>
116 const char *hex_chars = use_uppercase ? hex_upper : hex_lower;
119 std::size_t column = line_size;
120 auto inserter = ctx.begin();
122 for (
auto &item : the_range)
124 auto ch =
static_cast<unsigned char>(item);
127 if (put_newlines && column >= line_size)
129 column = put_newline(inserter, pos);
132 *inserter++ = hex_chars[(ch >> 4) & 0x0f];
133 *inserter++ = hex_chars[ch & 0x0f];
140 *inserter++ = delimiter;
144 *inserter++ = hex_chars[(ch >> 4) & 0x0f];
145 *inserter++ = hex_chars[ch & 0x0f];
153 template<
typename It>
auto begin(const C &c) -> decltype(c.begin())
details::bytes_range< typename Container::const_iterator > to_hex(const Container &container)
bytes_range(It range_begin, It range_end)
std::enable_if< is_contiguous< Container >::value &&internal::is_string< S >::value, std::back_insert_iterator< Container > >::type format_to(std::back_insert_iterator< Container > out, const S &format_str, const Args &...args)
auto end(const C &c) -> decltype(c.end())