11 #if defined(__has_include) && __has_include(<version>)
15 #if __cpp_lib_span >= 202002L
71 template<
typename Container>
75 using Iter =
typename Container::const_iterator;
79 #if __cpp_lib_span >= 202002L
81 template<
typename Value,
size_t Extent>
82 inline details::dump_info<typename std::span<Value, Extent>::iterator>
to_hex(
83 const std::span<Value, Extent> &container,
size_t size_per_line = 32)
85 using Container = std::span<Value, Extent>;
87 using Iter =
typename Container::iterator;
88 return details::dump_info<Iter>(
std::begin(container),
std::end(container), size_per_line);
103 #ifdef SPDLOG_USE_STD_FORMAT
113 const char delimiter =
' ';
114 bool put_newlines =
true;
115 bool put_delimiters =
true;
116 bool use_uppercase =
false;
117 bool put_positions =
true;
118 bool show_ascii =
false;
121 template<
typename ParseContext>
124 auto it = ctx.begin();
125 while (it != ctx.end() && *it !=
'}')
130 use_uppercase =
true;
133 put_delimiters =
false;
136 put_positions =
false;
139 put_newlines =
false;
156 template<
typename FormatContext,
typename Container>
161 const char *hex_chars = use_uppercase ? hex_upper : hex_lower;
163 #if !defined(SPDLOG_USE_STD_FORMAT) && FMT_VERSION < 60000
164 auto inserter = ctx.begin();
166 auto inserter = ctx.out();
169 int size_per_line =
static_cast<int>(the_range.size_per_line());
170 auto start_of_line = the_range.get_begin();
171 for (
auto i = the_range.get_begin();
i != the_range.get_end();
i++)
173 auto ch =
static_cast<unsigned char>(*i);
175 if (put_newlines && (
i == the_range.get_begin() ||
i - start_of_line >= size_per_line))
177 if (show_ascii &&
i != the_range.get_begin())
179 *inserter++ = delimiter;
180 *inserter++ = delimiter;
181 for (
auto j = start_of_line; j <
i; j++)
183 auto pc =
static_cast<unsigned char>(*j);
184 *inserter++ = std::isprint(pc) ?
static_cast<char>(*j) :
'.';
188 put_newline(inserter,
static_cast<size_t>(
i - the_range.get_begin()));
191 *inserter++ = hex_chars[(ch >> 4) & 0x0f];
192 *inserter++ = hex_chars[ch & 0x0f];
199 *inserter++ = delimiter;
202 *inserter++ = hex_chars[(ch >> 4) & 0x0f];
203 *inserter++ = hex_chars[ch & 0x0f];
207 if (the_range.get_end() - the_range.get_begin() > size_per_line)
209 auto blank_num = size_per_line - (the_range.get_end() - start_of_line);
210 while (blank_num-- > 0)
212 *inserter++ = delimiter;
213 *inserter++ = delimiter;
216 *inserter++ = delimiter;
220 *inserter++ = delimiter;
221 *inserter++ = delimiter;
222 for (
auto j = start_of_line; j != the_range.get_end(); j++)
224 auto pc =
static_cast<unsigned char>(*j);
225 *inserter++ = std::isprint(pc) ?
static_cast<char>(*j) :
'.';
232 template<
typename It>