11#if defined(__has_include)
12#if __has_include(<version>)
17#if __cpp_lib_span >= 202002L
44 template <
typename It>
74 template <
typename Container>
77 static_assert(
sizeof(
typename Container::value_type) == 1,
"sizeof(Container::value_type) != 1");
78 using Iter =
typename Container::const_iterator;
82#if __cpp_lib_span >= 202002L
84 template <
typename Value,
size_t Extent>
85 inline details::dump_info<typename std::span<Value, Extent>::iterator>
to_hex(
86 const std::span<Value, Extent>& container,
size_t size_per_line = 32)
88 using Container = std::span<Value, Extent>;
89 static_assert(
sizeof(
typename Container::value_type) == 1,
"sizeof(Container::value_type) != 1");
90 using Iter =
typename Container::iterator;
91 return details::dump_info<Iter>(std::begin(container), std::end(container), size_per_line);
97 template <
typename It>
106#ifdef SPDLOG_USE_STD_FORMAT
113 template <
typename T>
116 const char delimiter =
' ';
117 bool put_newlines =
true;
118 bool put_delimiters =
true;
119 bool use_uppercase =
false;
120 bool put_positions =
true;
121 bool show_ascii =
false;
124 template <
typename ParseContext>
127 auto it = ctx.begin();
128 while (it != ctx.end() && *it !=
'}')
133 use_uppercase =
true;
136 put_delimiters =
false;
139 put_positions =
false;
142 put_newlines =
false;
159 template <
typename FormatContext,
typename Container>
166#if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION < 60000
167 auto inserter = ctx.begin();
169 auto inserter = ctx.out();
172 int size_per_line =
static_cast<int>(the_range.size_per_line());
173 auto start_of_line = the_range.get_begin();
174 for (
auto i = the_range.get_begin();
i != the_range.get_end();
i++)
176 auto ch =
static_cast<unsigned char>(*i);
178 if (put_newlines && (
i == the_range.get_begin() ||
i - start_of_line >= size_per_line))
180 if (show_ascii &&
i != the_range.get_begin())
182 *inserter++ = delimiter;
183 *inserter++ = delimiter;
184 for (
auto j = start_of_line; j <
i; j++)
186 auto pc =
static_cast<unsigned char>(*j);
187 *inserter++ = std::isprint(pc) ?
static_cast<char>(*j) :
'.';
191 put_newline(inserter,
static_cast<size_t>(
i - the_range.get_begin()));
194 *inserter++ = hex_chars[(ch >> 4) & 0x0f];
195 *inserter++ = hex_chars[ch & 0x0f];
200 if (put_delimiters &&
i != the_range.get_begin())
202 *inserter++ = delimiter;
205 *inserter++ = hex_chars[(ch >> 4) & 0x0f];
206 *inserter++ = hex_chars[ch & 0x0f];
210 if (the_range.get_end() - the_range.get_begin() > size_per_line)
212 auto blank_num = size_per_line - (the_range.get_end() - start_of_line);
213 while (blank_num-- > 0)
215 *inserter++ = delimiter;
216 *inserter++ = delimiter;
219 *inserter++ = delimiter;
223 *inserter++ = delimiter;
224 *inserter++ = delimiter;
225 for (
auto j = start_of_line; j != the_range.get_end(); j++)
227 auto pc =
static_cast<unsigned char>(*j);
228 *inserter++ = std::isprint(pc) ?
static_cast<char>(*j) :
'.';
235 template <
typename It>
Definition bin_to_hex.h:46
dump_info(It range_begin, It range_end, size_t size_per_line)
Definition bin_to_hex.h:48
size_t size_per_line_
Definition bin_to_hex.h:69
It get_end() const
Definition bin_to_hex.h:58
size_t size_per_line() const
Definition bin_to_hex.h:62
It begin_
Definition bin_to_hex.h:68
It end_
Definition bin_to_hex.h:68
It get_begin() const
Definition bin_to_hex.h:54
#define SPDLOG_CONSTEXPR_FUNC
Definition common.h:74
#define SPDLOG_FMT_STRING(format_string)
Definition common.h:60
#define SPDLOG_CONSTEXPR
Definition common.h:70
Definition bin_to_hex.h:111
details::dump_info< typename Container::const_iterator > to_hex(const Container &container, size_t size_per_line=32)
Definition bin_to_hex.h:75
annotation details
Definition tag_strings.h:125
i
Definition tag_strings.h:60