printf.h
Go to the documentation of this file.
1 // Formatting library for C++ - legacy printf implementation
2 //
3 // Copyright (c) 2012 - 2016, Victor Zverovich
4 // All rights reserved.
5 //
6 // For the license information refer to format.h.
7 
8 #ifndef FMT_PRINTF_H_
9 #define FMT_PRINTF_H_
10 
11 #include <algorithm> // std::max
12 #include <limits> // std::numeric_limits
13 
14 #include "format.h"
15 
18 
19 template <typename T> struct printf_formatter {
20  printf_formatter() = delete;
21 };
22 
23 template <typename Char> class basic_printf_context {
24  private:
27 
28  static_assert(std::is_same<Char, char>::value ||
29  std::is_same<Char, wchar_t>::value,
30  "Unsupported code unit type.");
31 
32  public:
33  using char_type = Char;
35  template <typename T> using formatter_type = printf_formatter<T>;
36 
45  : out_(out), args_(args) {}
46 
47  auto out() -> detail::buffer_appender<Char> { return out_; }
49 
50  auto locale() -> detail::locale_ref { return {}; }
51 
53  return args_.get(id);
54  }
55 
56  FMT_CONSTEXPR void on_error(const char* message) {
58  }
59 };
60 
61 namespace detail {
62 
63 // Checks if a value fits in int - used to avoid warnings about comparing
64 // signed and unsigned integers.
65 template <bool IsSigned> struct int_checker {
66  template <typename T> static auto fits_in_int(T value) -> bool {
67  unsigned max = max_value<int>();
68  return value <= max;
69  }
70  static auto fits_in_int(bool) -> bool { return true; }
71 };
72 
73 template <> struct int_checker<true> {
74  template <typename T> static auto fits_in_int(T value) -> bool {
75  return value >= (std::numeric_limits<int>::min)() &&
77  }
78  static auto fits_in_int(int) -> bool { return true; }
79 };
80 
82  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
83  auto operator()(T value) -> int {
85  throw_format_error("number is too big");
86  return (std::max)(static_cast<int>(value), 0);
87  }
88 
89  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
90  auto operator()(T) -> int {
91  throw_format_error("precision is not integer");
92  return 0;
93  }
94 };
95 
96 // An argument visitor that returns true iff arg is a zero integer.
97 struct is_zero_int {
98  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
99  auto operator()(T value) -> bool {
100  return value == 0;
101  }
102 
103  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
104  auto operator()(T) -> bool {
105  return false;
106  }
107 };
108 
109 template <typename T> struct make_unsigned_or_bool : std::make_unsigned<T> {};
110 
111 template <> struct make_unsigned_or_bool<bool> {
112  using type = bool;
113 };
114 
115 template <typename T, typename Context> class arg_converter {
116  private:
117  using char_type = typename Context::char_type;
118 
121 
122  public:
124  : arg_(arg), type_(type) {}
125 
126  void operator()(bool value) {
127  if (type_ != 's') operator()<bool>(value);
128  }
129 
130  template <typename U, FMT_ENABLE_IF(std::is_integral<U>::value)>
131  void operator()(U value) {
132  bool is_signed = type_ == 'd' || type_ == 'i';
133  using target_type = conditional_t<std::is_same<T, void>::value, U, T>;
134  if (const_check(sizeof(target_type) <= sizeof(int))) {
135  // Extra casts are used to silence warnings.
136  if (is_signed) {
137  auto n = static_cast<int>(static_cast<target_type>(value));
138  arg_ = detail::make_arg<Context>(n);
139  } else {
140  using unsigned_type = typename make_unsigned_or_bool<target_type>::type;
141  auto n = static_cast<unsigned>(static_cast<unsigned_type>(value));
142  arg_ = detail::make_arg<Context>(n);
143  }
144  } else {
145  if (is_signed) {
146  // glibc's printf doesn't sign extend arguments of smaller types:
147  // std::printf("%lld", -42); // prints "4294967254"
148  // but we don't have to do the same because it's a UB.
149  auto n = static_cast<long long>(value);
150  arg_ = detail::make_arg<Context>(n);
151  } else {
152  auto n = static_cast<typename make_unsigned_or_bool<U>::type>(value);
153  arg_ = detail::make_arg<Context>(n);
154  }
155  }
156  }
157 
158  template <typename U, FMT_ENABLE_IF(!std::is_integral<U>::value)>
159  void operator()(U) {} // No conversion needed for non-integral types.
160 };
161 
162 // Converts an integer argument to T for printf, if T is an integral type.
163 // If T is void, the argument is converted to corresponding signed or unsigned
164 // type depending on the type specifier: 'd' and 'i' - signed, other -
165 // unsigned).
166 template <typename T, typename Context, typename Char>
169 }
170 
171 // Converts an integer argument to char for printf.
172 template <typename Context> class char_converter {
173  private:
175 
176  public:
178 
179  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
180  void operator()(T value) {
181  auto c = static_cast<typename Context::char_type>(value);
182  arg_ = detail::make_arg<Context>(c);
183  }
184 
185  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
186  void operator()(T) {} // No conversion needed for non-integral types.
187 };
188 
189 // An argument visitor that return a pointer to a C string if argument is a
190 // string or null otherwise.
191 template <typename Char> struct get_cstring {
192  template <typename T> auto operator()(T) -> const Char* { return nullptr; }
193  auto operator()(const Char* s) -> const Char* { return s; }
194 };
195 
196 // Checks if an argument is a valid printf width specifier and sets
197 // left alignment if it is negative.
198 template <typename Char> class printf_width_handler {
199  private:
201 
202  public:
203  explicit printf_width_handler(format_specs<Char>& specs) : specs_(specs) {}
204 
205  template <typename T, FMT_ENABLE_IF(std::is_integral<T>::value)>
206  auto operator()(T value) -> unsigned {
207  auto width = static_cast<uint32_or_64_or_128_t<T>>(value);
208  if (detail::is_negative(value)) {
209  specs_.align = align::left;
210  width = 0 - width;
211  }
212  unsigned int_max = max_value<int>();
213  if (width > int_max) throw_format_error("number is too big");
214  return static_cast<unsigned>(width);
215  }
216 
217  template <typename T, FMT_ENABLE_IF(!std::is_integral<T>::value)>
218  auto operator()(T) -> unsigned {
219  throw_format_error("width is not integer");
220  return 0;
221  }
222 };
223 
224 // Workaround for a bug with the XL compiler when initializing
225 // printf_arg_formatter's base class.
226 template <typename Char>
229  return {iter, s, locale_ref()};
230 }
231 
232 // The ``printf`` argument formatter.
233 template <typename Char>
234 class printf_arg_formatter : public arg_formatter<Char> {
235  private:
238 
240 
241  void write_null_pointer(bool is_string = false) {
242  auto s = this->specs;
243  s.type = presentation_type::none;
244  write_bytes(this->out, is_string ? "(null)" : "(nil)", s);
245  }
246 
247  public:
249  context_type& ctx)
250  : base(make_arg_formatter(iter, s)), context_(ctx) {}
251 
253 
254  template <typename T, FMT_ENABLE_IF(detail::is_integral<T>::value)>
255  void operator()(T value) {
256  // MSVC2013 fails to compile separate overloads for bool and Char so use
257  // std::is_same instead.
258  if (!std::is_same<T, Char>::value) {
260  return;
261  }
262  format_specs<Char> fmt_specs = this->specs;
263  if (fmt_specs.type != presentation_type::none &&
264  fmt_specs.type != presentation_type::chr) {
265  return (*this)(static_cast<int>(value));
266  }
267  fmt_specs.sign = sign::none;
268  fmt_specs.alt = false;
269  fmt_specs.fill[0] = ' '; // Ignore '0' flag for char types.
270  // align::numeric needs to be overwritten here since the '0' flag is
271  // ignored for non-numeric types
272  if (fmt_specs.align == align::none || fmt_specs.align == align::numeric)
273  fmt_specs.align = align::right;
274  write<Char>(this->out, static_cast<Char>(value), fmt_specs);
275  }
276 
277  template <typename T, FMT_ENABLE_IF(std::is_floating_point<T>::value)>
278  void operator()(T value) {
280  }
281 
283  void operator()(const char* value) {
284  if (value)
286  else
288  }
289 
291  void operator()(const wchar_t* value) {
292  if (value)
294  else
296  }
297 
299 
301  void operator()(const void* value) {
302  if (value)
304  else
306  }
307 
310  auto parse_ctx = basic_format_parse_context<Char>({});
311  handle.format(parse_ctx, context_);
312  }
313 };
314 
315 template <typename Char>
316 void parse_flags(format_specs<Char>& specs, const Char*& it, const Char* end) {
317  for (; it != end; ++it) {
318  switch (*it) {
319  case '-':
320  specs.align = align::left;
321  break;
322  case '+':
323  specs.sign = sign::plus;
324  break;
325  case '0':
326  specs.fill[0] = '0';
327  break;
328  case ' ':
329  if (specs.sign != sign::plus) specs.sign = sign::space;
330  break;
331  case '#':
332  specs.alt = true;
333  break;
334  default:
335  return;
336  }
337  }
338 }
339 
340 template <typename Char, typename GetArg>
341 auto parse_header(const Char*& it, const Char* end, format_specs<Char>& specs,
342  GetArg get_arg) -> int {
343  int arg_index = -1;
344  Char c = *it;
345  if (c >= '0' && c <= '9') {
346  // Parse an argument index (if followed by '$') or a width possibly
347  // preceded with '0' flag(s).
348  int value = parse_nonnegative_int(it, end, -1);
349  if (it != end && *it == '$') { // value is an argument index
350  ++it;
351  arg_index = value != -1 ? value : max_value<int>();
352  } else {
353  if (c == '0') specs.fill[0] = '0';
354  if (value != 0) {
355  // Nonzero value means that we parsed width and don't need to
356  // parse it or flags again, so return now.
357  if (value == -1) throw_format_error("number is too big");
358  specs.width = value;
359  return arg_index;
360  }
361  }
362  }
363  parse_flags(specs, it, end);
364  // Parse width.
365  if (it != end) {
366  if (*it >= '0' && *it <= '9') {
367  specs.width = parse_nonnegative_int(it, end, -1);
368  if (specs.width == -1) throw_format_error("number is too big");
369  } else if (*it == '*') {
370  ++it;
371  specs.width = static_cast<int>(visit_format_arg(
373  }
374  }
375  return arg_index;
376 }
377 
378 inline auto parse_printf_presentation_type(char c, type t)
379  -> presentation_type {
380  using pt = presentation_type;
381  constexpr auto integral_set = sint_set | uint_set | bool_set | char_set;
382  switch (c) {
383  case 'd':
384  return in(t, integral_set) ? pt::dec : pt::none;
385  case 'o':
386  return in(t, integral_set) ? pt::oct : pt::none;
387  case 'x':
388  return in(t, integral_set) ? pt::hex_lower : pt::none;
389  case 'X':
390  return in(t, integral_set) ? pt::hex_upper : pt::none;
391  case 'a':
392  return in(t, float_set) ? pt::hexfloat_lower : pt::none;
393  case 'A':
394  return in(t, float_set) ? pt::hexfloat_upper : pt::none;
395  case 'e':
396  return in(t, float_set) ? pt::exp_lower : pt::none;
397  case 'E':
398  return in(t, float_set) ? pt::exp_upper : pt::none;
399  case 'f':
400  return in(t, float_set) ? pt::fixed_lower : pt::none;
401  case 'F':
402  return in(t, float_set) ? pt::fixed_upper : pt::none;
403  case 'g':
404  return in(t, float_set) ? pt::general_lower : pt::none;
405  case 'G':
406  return in(t, float_set) ? pt::general_upper : pt::none;
407  case 'c':
408  return in(t, integral_set) ? pt::chr : pt::none;
409  case 's':
410  return in(t, string_set | cstring_set) ? pt::string : pt::none;
411  case 'p':
412  return in(t, pointer_set | cstring_set) ? pt::pointer : pt::none;
413  default:
414  return pt::none;
415  }
416 }
417 
418 template <typename Char, typename Context>
421  using iterator = buffer_appender<Char>;
422  auto out = iterator(buf);
423  auto context = basic_printf_context<Char>(out, args);
424  auto parse_ctx = basic_format_parse_context<Char>(format);
425 
426  // Returns the argument with specified index or, if arg_index is -1, the next
427  // argument.
428  auto get_arg = [&](int arg_index) {
429  if (arg_index < 0)
430  arg_index = parse_ctx.next_arg_id();
431  else
432  parse_ctx.check_arg_id(--arg_index);
433  return detail::get_arg(context, arg_index);
434  };
435 
436  const Char* start = parse_ctx.begin();
437  const Char* end = parse_ctx.end();
438  auto it = start;
439  while (it != end) {
440  if (!find<false, Char>(it, end, '%', it)) {
441  it = end; // find leaves it == nullptr if it doesn't find '%'.
442  break;
443  }
444  Char c = *it++;
445  if (it != end && *it == c) {
447  start = ++it;
448  continue;
449  }
451 
452  auto specs = format_specs<Char>();
453  specs.align = align::right;
454 
455  // Parse argument index, flags and width.
456  int arg_index = parse_header(it, end, specs, get_arg);
457  if (arg_index == 0) throw_format_error("argument not found");
458 
459  // Parse precision.
460  if (it != end && *it == '.') {
461  ++it;
462  c = it != end ? *it : 0;
463  if ('0' <= c && c <= '9') {
464  specs.precision = parse_nonnegative_int(it, end, 0);
465  } else if (c == '*') {
466  ++it;
467  specs.precision = static_cast<int>(
469  } else {
470  specs.precision = 0;
471  }
472  }
473 
474  auto arg = get_arg(arg_index);
475  // For d, i, o, u, x, and X conversion specifiers, if a precision is
476  // specified, the '0' flag is ignored
477  if (specs.precision >= 0 && arg.is_integral()) {
478  // Ignore '0' for non-numeric types or if '-' present.
479  specs.fill[0] = ' ';
480  }
481  if (specs.precision >= 0 && arg.type() == type::cstring_type) {
482  auto str = visit_format_arg(get_cstring<Char>(), arg);
483  auto str_end = str + specs.precision;
484  auto nul = std::find(str, str_end, Char());
485  auto sv = basic_string_view<Char>(
486  str, to_unsigned(nul != str_end ? nul - str : specs.precision));
487  arg = make_arg<basic_printf_context<Char>>(sv);
488  }
489  if (specs.alt && visit_format_arg(is_zero_int(), arg)) specs.alt = false;
490  if (specs.fill[0] == '0') {
491  if (arg.is_arithmetic() && specs.align != align::left)
492  specs.align = align::numeric;
493  else
494  specs.fill[0] = ' '; // Ignore '0' flag for non-numeric types or if '-'
495  // flag is also present.
496  }
497 
498  // Parse length and convert the argument to the required type.
499  c = it != end ? *it++ : 0;
500  Char t = it != end ? *it : 0;
501  switch (c) {
502  case 'h':
503  if (t == 'h') {
504  ++it;
505  t = it != end ? *it : 0;
506  convert_arg<signed char>(arg, t);
507  } else {
508  convert_arg<short>(arg, t);
509  }
510  break;
511  case 'l':
512  if (t == 'l') {
513  ++it;
514  t = it != end ? *it : 0;
515  convert_arg<long long>(arg, t);
516  } else {
517  convert_arg<long>(arg, t);
518  }
519  break;
520  case 'j':
521  convert_arg<intmax_t>(arg, t);
522  break;
523  case 'z':
524  convert_arg<size_t>(arg, t);
525  break;
526  case 't':
527  convert_arg<std::ptrdiff_t>(arg, t);
528  break;
529  case 'L':
530  // printf produces garbage when 'L' is omitted for long double, no
531  // need to do the same.
532  break;
533  default:
534  --it;
535  convert_arg<void>(arg, c);
536  }
537 
538  // Parse type.
539  if (it == end) throw_format_error("invalid format string");
540  char type = static_cast<char>(*it++);
541  if (arg.is_integral()) {
542  // Normalize type.
543  switch (type) {
544  case 'i':
545  case 'u':
546  type = 'd';
547  break;
548  case 'c':
550  break;
551  }
552  }
553  specs.type = parse_printf_presentation_type(type, arg.type());
554  if (specs.type == presentation_type::none)
555  throw_format_error("invalid format specifier");
556 
557  start = it;
558 
559  // Format argument.
560  visit_format_arg(printf_arg_formatter<Char>(out, specs, context), arg);
561  }
563 }
564 } // namespace detail
565 
568 
571 
578 template <typename... T>
579 inline auto make_printf_args(const T&... args)
580  -> format_arg_store<printf_context, T...> {
581  return {args...};
582 }
583 
584 // DEPRECATED!
585 template <typename... T>
586 inline auto make_wprintf_args(const T&... args)
588  return {args...};
589 }
590 
591 template <typename Char>
592 inline auto vsprintf(
595  -> std::basic_string<Char> {
596  auto buf = basic_memory_buffer<Char>();
597  detail::vprintf(buf, fmt, args);
598  return to_string(buf);
599 }
600 
610 template <typename S, typename... T,
612 inline auto sprintf(const S& fmt, const T&... args) -> std::basic_string<Char> {
613  return vsprintf(detail::to_string_view(fmt),
615 }
616 
617 template <typename Char>
618 inline auto vfprintf(
619  std::FILE* f, basic_string_view<Char> fmt,
621  -> int {
622  auto buf = basic_memory_buffer<Char>();
623  detail::vprintf(buf, fmt, args);
624  size_t size = buf.size();
625  return std::fwrite(buf.data(), sizeof(Char), size, f) < size
626  ? -1
627  : static_cast<int>(size);
628 }
629 
639 template <typename S, typename... T, typename Char = char_t<S>>
640 inline auto fprintf(std::FILE* f, const S& fmt, const T&... args) -> int {
641  return vfprintf(f, detail::to_string_view(fmt),
643 }
644 
645 template <typename Char>
649  -> int {
650  return vfprintf(stdout, fmt, args);
651 }
652 
662 template <typename... T>
663 inline auto printf(string_view fmt, const T&... args) -> int {
664  return vfprintf(stdout, fmt, make_printf_args(args...));
665 }
666 template <typename... T>
668  const T&... args) -> int {
669  return vfprintf(stdout, fmt, make_wprintf_args(args...));
670 }
671 
674 
675 #endif // FMT_PRINTF_H_
detail::printf_precision_handler::operator()
auto operator()(T value) -> int
Definition: printf.h:83
detail::make_unsigned_or_bool
Definition: printf.h:109
presentation_type
presentation_type
Definition: core.h:2053
printf_formatter
Definition: printf.h:19
left
lu_byte left
Definition: lparser.c:1226
printf_formatter::printf_formatter
printf_formatter()=delete
detail::arg_converter::operator()
void operator()(bool value)
Definition: printf.h:126
basic_printf_context::out_
detail::buffer_appender< Char > out_
Definition: printf.h:25
format_specs::align
align_t align
Definition: core.h:2080
wprintf_context
basic_printf_context< wchar_t > wprintf_context
Definition: printf.h:567
format_arg_store
Definition: core.h:1808
detail::printf_precision_handler::operator()
auto operator()(T) -> int
Definition: printf.h:90
detail::to_string_view
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition: core.h:534
detail::arg_converter::operator()
void operator()(U)
Definition: printf.h:159
detail::char_converter::arg_
basic_format_arg< Context > & arg_
Definition: printf.h:174
basic_memory_buffer
Definition: format.h:883
printf
auto printf(string_view fmt, const T &... args) -> int
Definition: printf.h:663
detail::buffer
Definition: core.h:816
detail::arg_formatter::operator()
FMT_CONSTEXPR FMT_INLINE auto operator()(T value) -> iterator
Definition: format.h:3795
detail::parse_flags
void parse_flags(format_specs< Char > &specs, const Char *&it, const Char *end)
Definition: printf.h:316
detail::get_cstring::operator()
auto operator()(T) -> const Char *
Definition: printf.h:192
detail::printf_arg_formatter::operator()
void operator()(const wchar_t *value)
Definition: printf.h:291
basic_string_view
Definition: core.h:415
visit_format_arg
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
Definition: core.h:1698
s
XmlRpcServer s
detail::error_handler::on_error
FMT_NORETURN void on_error(const char *message)
Definition: core.h:654
detail::printf_arg_formatter::operator()
void operator()(basic_string_view< Char > value)
Definition: printf.h:298
format.h
format_specs
Definition: core.h:2076
basic_printf_context::on_error
FMT_CONSTEXPR void on_error(const char *message)
Definition: printf.h:56
detail::int_checker< true >::fits_in_int
static auto fits_in_int(int) -> bool
Definition: printf.h:78
detail::write
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:419
right
lu_byte right
Definition: lparser.c:1227
detail::printf_width_handler::printf_width_handler
printf_width_handler(format_specs< Char > &specs)
Definition: printf.h:203
detail::is_negative
constexpr auto is_negative(T value) -> bool
Definition: format.h:1095
detail::printf_arg_formatter::printf_arg_formatter
printf_arg_formatter(buffer_appender< Char > iter, format_specs< Char > &s, context_type &ctx)
Definition: printf.h:248
arg
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
Definition: core.h:1875
make_wprintf_args
auto make_wprintf_args(const T &... args) -> format_arg_store< wprintf_context, T... >
Definition: printf.h:586
detail::arg_converter
Definition: printf.h:115
format_specs::sign
sign_t sign
Definition: core.h:2081
detail
Definition: args.h:19
detail::arg_converter::arg_converter
arg_converter(basic_format_arg< Context > &arg, char_type type)
Definition: printf.h:123
basic_printf_context::basic_printf_context
basic_printf_context(detail::buffer_appender< Char > out, basic_format_args< basic_printf_context > args)
Definition: printf.h:43
detail::error_handler
Definition: core.h:650
detail::printf_width_handler::operator()
auto operator()(T) -> unsigned
Definition: printf.h:218
detail::convert_arg
void convert_arg(basic_format_arg< Context > &arg, Char type)
Definition: printf.h:167
basic_printf_context::arg
auto arg(int id) const -> basic_format_arg< basic_printf_context >
Definition: printf.h:52
basic_printf_context::out
auto out() -> detail::buffer_appender< Char >
Definition: printf.h:47
detail::in
constexpr auto in(type t, int set) -> bool
Definition: core.h:628
basic_format_arg
Definition: core.h:1080
basic_printf_context::locale
auto locale() -> detail::locale_ref
Definition: printf.h:50
detail::find
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2154
vprintf
FMT_DEPRECATED auto vprintf(basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char >>> args) -> int
Definition: printf.h:646
detail::parse_header
auto parse_header(const Char *&it, const Char *end, format_specs< Char > &specs, GetArg get_arg) -> int
Definition: printf.h:341
detail::int_checker
Definition: printf.h:65
detail::state::width
@ width
detail::printf_arg_formatter::operator()
void operator()(monostate value)
Definition: printf.h:252
f
f
FMT_DEPRECATED
#define FMT_DEPRECATED
Definition: format.h:77
detail::arg_converter::type_
char_type type_
Definition: printf.h:120
basic_format_args< basic_printf_context >
detail::buffer_appender
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > >> buffer_appender
Definition: core.h:1132
detail::parse_nonnegative_int
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept -> int
Definition: core.h:2172
detail::printf_arg_formatter::operator()
void operator()(const void *value)
Definition: printf.h:301
detail::arg_formatter::specs
const format_specs< Char > & specs
Definition: format.h:3791
nonstd::span_lite::size
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1554
detail::parse_printf_presentation_type
auto parse_printf_presentation_type(char c, type t) -> presentation_type
Definition: printf.h:378
detail::string_set
@ string_set
Definition: core.h:642
detail::int_checker< true >::fits_in_int
static auto fits_in_int(T value) -> bool
Definition: printf.h:74
detail::char_converter::operator()
void operator()(T value)
Definition: printf.h:180
detail::printf_arg_formatter
Definition: printf.h:234
detail::write_bytes
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const format_specs< Char > &specs) -> OutputIt
Definition: format.h:1755
detail::printf_precision_handler
Definition: printf.h:81
printf_context
basic_printf_context< char > printf_context
Definition: printf.h:566
basic_printf_context::advance_to
void advance_to(detail::buffer_appender< Char >)
Definition: printf.h:48
FMT_END_NAMESPACE
#define FMT_END_NAMESPACE
Definition: core.h:180
detail::arg_converter::char_type
typename Context::char_type char_type
Definition: printf.h:117
detail::make_arg_formatter
auto make_arg_formatter(buffer_appender< Char > iter, format_specs< Char > &s) -> arg_formatter< Char >
Definition: printf.h:227
detail::printf_width_handler::operator()
auto operator()(T value) -> unsigned
Definition: printf.h:206
FMT_END_EXPORT
#define FMT_END_EXPORT
Definition: core.h:188
presentation_type::chr
@ chr
detail::value
Definition: core.h:1257
make_format_args
constexpr auto make_format_args(T &... args) -> format_arg_store< Context, remove_cvref_t< T >... >
Definition: core.h:1858
basic_format_args::get
FMT_CONSTEXPR auto get(int id) const -> format_arg
Definition: core.h:1965
detail::is_zero_int::operator()
auto operator()(T) -> bool
Definition: printf.h:104
enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:271
basic_printf_context
Definition: printf.h:23
type_identity_t
typename type_identity< T >::type type_identity_t
Definition: core.h:284
detail::get_cstring
Definition: printf.h:191
detail::vprintf
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
Definition: printf.h:419
detail::is_zero_int::operator()
auto operator()(T value) -> bool
Definition: printf.h:99
detail::arg_formatter::out
iterator out
Definition: format.h:3790
format_specs::alt
bool alt
Definition: core.h:2082
basic_format_arg::handle
Definition: core.h:1653
basic_format_arg::handle::format
void format(typename Context::parse_context_type &parse_ctx, Context &ctx) const
Definition: core.h:1657
format
auto format(const text_style &ts, const S &format_str, const Args &... args) -> std::basic_string< Char >
Definition: color.h:543
detail::char_converter
Definition: printf.h:172
basic_format_parse_context
Definition: core.h:674
detail::is_signed
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
Definition: format.h:776
detail::uint32_or_64_or_128_t
conditional_t< num_bits< T >()<=32 &&!FMT_REDUCE_INT_INSTANTIATIONS, uint32_t, conditional_t< num_bits< T >()<=64, uint64_t, uint128_t > > uint32_or_64_or_128_t
Definition: format.h:1117
start
ROSCPP_DECL void start()
detail::int_checker::fits_in_int
static auto fits_in_int(T value) -> bool
Definition: printf.h:66
detail::is_zero_int
Definition: printf.h:97
detail::printf_width_handler::specs_
format_specs< Char > & specs_
Definition: printf.h:200
detail::float_set
@ float_set
Definition: core.h:640
detail::printf_arg_formatter::operator()
void operator()(T value)
Definition: printf.h:255
detail::make_unsigned_or_bool< bool >::type
bool type
Definition: printf.h:112
presentation_type::none
@ none
make_printf_args
auto make_printf_args(const T &... args) -> format_arg_store< printf_context, T... >
Definition: printf.h:579
detail::arg_formatter
Definition: format.h:3786
format_specs::fill
detail::fill_t< Char > fill
Definition: core.h:2084
detail::pointer_set
@ pointer_set
Definition: core.h:644
detail::printf_width_handler
Definition: printf.h:198
detail::printf_arg_formatter::write_null_pointer
void write_null_pointer(bool is_string=false)
Definition: printf.h:241
format_specs::type
presentation_type type
Definition: core.h:2079
detail::char_converter::operator()
void operator()(T)
Definition: printf.h:186
FMT_BEGIN_EXPORT
#define FMT_BEGIN_EXPORT
Definition: core.h:187
detail::locale_ref
Definition: core.h:1553
mcap::internal::to_string
std::string to_string(const std::string &arg)
Definition: internal.hpp:35
detail::printf_arg_formatter::operator()
void operator()(typename basic_format_arg< context_type >::handle handle)
Definition: printf.h:309
FMT_BEGIN_NAMESPACE
#define FMT_BEGIN_NAMESPACE
Definition: core.h:177
detail::get_arg
FMT_CONSTEXPR auto get_arg(Context &ctx, ID id) -> decltype(ctx.arg(id))
Definition: format.h:3842
detail::char_converter::char_converter
char_converter(basic_format_arg< Context > &arg)
Definition: printf.h:177
vfprintf
auto vfprintf(std::FILE *f, basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char >>> args) -> int
Definition: printf.h:618
conditional_t
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:273
monostate
Definition: core.h:293
detail::is_string
Definition: core.h:564
presentation_type::pointer
@ pointer
detail::get_cstring::operator()
auto operator()(const Char *s) -> const Char *
Definition: printf.h:193
detail::to_unsigned
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition: core.h:391
detail::arg_converter::operator()
void operator()(U value)
Definition: printf.h:131
detail::int_checker::fits_in_int
static auto fits_in_int(bool) -> bool
Definition: printf.h:70
vsprintf
auto vsprintf(basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char >>> args) -> std::basic_string< Char >
Definition: printf.h:592
detail::printf_arg_formatter::operator()
void operator()(const char *value)
Definition: printf.h:283
detail::type
type
Definition: core.h:573
detail::throw_format_error
FMT_NORETURN FMT_API void throw_format_error(const char *message)
Definition: format-inl.h:39
basic_printf_context::char_type
Char char_type
Definition: printf.h:33
detail::char_set
@ char_set
Definition: core.h:639
sprintf
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
Definition: printf.h:612
char_t
typename detail::char_t_impl< S >::type char_t
Definition: core.h:664
detail::const_check
constexpr FMT_INLINE auto const_check(T value) -> T
Definition: core.h:340
detail::type::cstring_type
@ cstring_type
detail::uint_set
@ uint_set
Definition: core.h:636
S
#define S(x)
Definition: luac.c:667
detail::cstring_set
@ cstring_set
Definition: core.h:643
FMT_CONSTEXPR
#define FMT_CONSTEXPR
Definition: core.h:105
detail::arg_converter::arg_
basic_format_arg< Context > & arg_
Definition: printf.h:119
detail::printf_arg_formatter::context_
context_type & context_
Definition: printf.h:239
basic_printf_context::args_
basic_format_args< basic_printf_context > args_
Definition: printf.h:26
fprintf
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
Definition: printf.h:640
detail::bool_set
@ bool_set
Definition: core.h:638
udp_client.args
args
Definition: udp_client.py:12
detail::sint_set
@ sint_set
Definition: core.h:634


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Aug 11 2024 02:24:23