Go to the documentation of this file.
28 static_assert(std::is_same<Char, char>::value ||
29 std::is_same<Char, wchar_t>::value,
30 "Unsupported code unit type.");
67 unsigned max = max_value<int>();
75 return value >= (std::numeric_limits<int>::min)() &&
82 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
86 return (std::max)(
static_cast<int>(
value), 0);
89 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
98 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
103 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
130 template <
typename U, FMT_ENABLE_IF(std::is_
integral<U>::value)>
134 if (
const_check(
sizeof(target_type) <=
sizeof(
int))) {
137 auto n =
static_cast<int>(
static_cast<target_type
>(
value));
138 arg_ = detail::make_arg<Context>(n);
141 auto n =
static_cast<unsigned>(
static_cast<unsigned_type
>(
value));
142 arg_ = detail::make_arg<Context>(n);
149 auto n =
static_cast<long long>(
value);
150 arg_ = detail::make_arg<Context>(n);
153 arg_ = detail::make_arg<Context>(n);
158 template <
typename U, FMT_ENABLE_IF(!std::is_
integral<U>::value)>
166 template <
typename T,
typename Context,
typename Char>
179 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
181 auto c =
static_cast<typename Context::char_type
>(
value);
182 arg_ = detail::make_arg<Context>(c);
185 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
192 template <
typename T>
auto operator()(T) ->
const Char* {
return nullptr; }
205 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
212 unsigned int_max = max_value<int>();
214 return static_cast<unsigned>(
width);
217 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
226 template <
typename Char>
233 template <
typename Char>
254 template <
typename T, FMT_ENABLE_IF(detail::is_
integral<T>::value)>
258 if (!std::is_same<T, Char>::value) {
265 return (*
this)(
static_cast<int>(
value));
267 fmt_specs.
sign = sign::none;
268 fmt_specs.
alt =
false;
269 fmt_specs.
fill[0] =
' ';
272 if (fmt_specs.
align == align::none || fmt_specs.
align == align::numeric)
274 write<Char>(this->
out,
static_cast<Char
>(
value), fmt_specs);
277 template <
typename T, FMT_ENABLE_IF(std::is_
floating_po
int<T>::value)>
315 template <
typename Char>
317 for (; it != end; ++it) {
323 specs.
sign = sign::plus;
329 if (specs.
sign != sign::plus) specs.
sign = sign::space;
340 template <
typename Char,
typename GetArg>
345 if (c >=
'0' && c <=
'9') {
349 if (it != end && *it ==
'$') {
351 arg_index =
value != -1 ?
value : max_value<int>();
353 if (c ==
'0') specs.fill[0] =
'0';
366 if (*it >=
'0' && *it <=
'9') {
369 }
else if (*it ==
'*') {
384 return in(t, integral_set) ? pt::dec : pt::none;
386 return in(t, integral_set) ? pt::oct : pt::none;
388 return in(t, integral_set) ? pt::hex_lower : pt::none;
390 return in(t, integral_set) ? pt::hex_upper : pt::none;
392 return in(t,
float_set) ? pt::hexfloat_lower : pt::none;
394 return in(t,
float_set) ? pt::hexfloat_upper : pt::none;
396 return in(t,
float_set) ? pt::exp_lower : pt::none;
398 return in(t,
float_set) ? pt::exp_upper : pt::none;
400 return in(t,
float_set) ? pt::fixed_lower : pt::none;
402 return in(t,
float_set) ? pt::fixed_upper : pt::none;
404 return in(t,
float_set) ? pt::general_lower : pt::none;
406 return in(t,
float_set) ? pt::general_upper : pt::none;
408 return in(t, integral_set) ? pt::chr : pt::none;
418 template <
typename Char,
typename Context>
422 auto out = iterator(buf);
428 auto get_arg = [&](
int arg_index) {
430 arg_index = parse_ctx.next_arg_id();
432 parse_ctx.check_arg_id(--arg_index);
436 const Char*
start = parse_ctx.begin();
437 const Char* end = parse_ctx.end();
440 if (!find<false, Char>(it, end,
'%', it)) {
445 if (it != end && *it == c) {
460 if (it != end && *it ==
'.') {
462 c = it != end ? *it : 0;
463 if (
'0' <= c && c <=
'9') {
465 }
else if (c ==
'*') {
467 specs.precision =
static_cast<int>(
477 if (specs.precision >= 0 &&
arg.is_integral()) {
483 auto str_end = str + specs.precision;
484 auto nul =
std::find(str, str_end, Char());
486 str,
to_unsigned(nul != str_end ? nul - str : specs.precision));
487 arg = make_arg<basic_printf_context<Char>>(sv);
490 if (specs.fill[0] ==
'0') {
492 specs.align = align::numeric;
499 c = it != end ? *it++ : 0;
500 Char t = it != end ? *it : 0;
505 t = it != end ? *it : 0;
506 convert_arg<signed char>(
arg, t);
508 convert_arg<short>(
arg, t);
514 t = it != end ? *it : 0;
515 convert_arg<long long>(
arg, t);
517 convert_arg<long>(
arg, t);
521 convert_arg<intmax_t>(
arg, t);
524 convert_arg<size_t>(
arg, t);
527 convert_arg<std::ptrdiff_t>(
arg, t);
535 convert_arg<void>(
arg, c);
540 char type =
static_cast<char>(*it++);
541 if (
arg.is_integral()) {
578 template <
typename... T>
585 template <
typename... T>
591 template <
typename Char>
595 -> std::basic_string<Char> {
610 template <
typename S,
typename... T,
612 inline auto sprintf(
const S& fmt,
const T&...
args) -> std::basic_string<Char> {
617 template <
typename Char>
624 size_t size = buf.size();
625 return std::fwrite(buf.data(),
sizeof(Char),
size,
f) <
size
627 :
static_cast<int>(
size);
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 {
645 template <
typename Char>
662 template <
typename... T>
666 template <
typename... T>
668 const T&...
args) ->
int {
675 #endif // FMT_PRINTF_H_
auto operator()(T value) -> int
void operator()(bool value)
detail::buffer_appender< Char > out_
basic_printf_context< wchar_t > wprintf_context
auto operator()(T) -> int
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
basic_format_arg< Context > & arg_
auto printf(string_view fmt, const T &... args) -> int
void parse_flags(format_specs< Char > &specs, const Char *&it, const Char *end)
auto operator()(T) -> const Char *
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
FMT_NORETURN void on_error(const char *message)
FMT_CONSTEXPR void on_error(const char *message)
static auto fits_in_int(int) -> bool
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
printf_width_handler(format_specs< Char > &specs)
constexpr auto is_negative(T value) -> bool
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
auto make_wprintf_args(const T &... args) -> format_arg_store< wprintf_context, T... >
arg_converter(basic_format_arg< Context > &arg, char_type type)
basic_printf_context(detail::buffer_appender< Char > out, basic_format_args< basic_printf_context > args)
auto operator()(T) -> unsigned
void convert_arg(basic_format_arg< Context > &arg, Char type)
auto arg(int id) const -> basic_format_arg< basic_printf_context >
auto out() -> detail::buffer_appender< Char >
constexpr auto in(type t, int set) -> bool
auto locale() -> detail::locale_ref
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
FMT_DEPRECATED auto vprintf(basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char >>> args) -> int
auto parse_header(const Char *&it, const Char *end, format_specs< Char > &specs, GetArg get_arg) -> int
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > >> buffer_appender
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept -> int
span_constexpr std::size_t size(span< T, Extent > const &spn)
auto parse_printf_presentation_type(char c, type t) -> presentation_type
static auto fits_in_int(T value) -> bool
FMT_CONSTEXPR auto write_bytes(OutputIt out, string_view bytes, const format_specs< Char > &specs) -> OutputIt
basic_printf_context< char > printf_context
void advance_to(detail::buffer_appender< Char >)
#define FMT_END_NAMESPACE
typename Context::char_type char_type
auto make_arg_formatter(buffer_appender< Char > iter, format_specs< Char > &s) -> arg_formatter< Char >
auto operator()(T value) -> unsigned
constexpr auto make_format_args(T &... args) -> format_arg_store< Context, remove_cvref_t< T >... >
auto operator()(T) -> bool
typename std::enable_if< B, T >::type enable_if_t
typename type_identity< T >::type type_identity_t
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
auto operator()(T value) -> bool
auto format(const text_style &ts, const S &format_str, const Args &... args) -> std::basic_string< Char >
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
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
static auto fits_in_int(T value) -> bool
format_specs< Char > & specs_
auto make_printf_args(const T &... args) -> format_arg_store< printf_context, T... >
std::string to_string(const std::string &arg)
#define FMT_BEGIN_NAMESPACE
FMT_CONSTEXPR auto get_arg(Context &ctx, ID id) -> decltype(ctx.arg(id))
char_converter(basic_format_arg< Context > &arg)
auto vfprintf(std::FILE *f, basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char >>> args) -> int
typename std::conditional< B, T, F >::type conditional_t
auto operator()(const Char *s) -> const Char *
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
static auto fits_in_int(bool) -> bool
auto vsprintf(basic_string_view< Char > fmt, basic_format_args< basic_printf_context< type_identity_t< Char >>> args) -> std::basic_string< Char >
FMT_NORETURN FMT_API void throw_format_error(const char *message)
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
typename detail::char_t_impl< S >::type char_t
constexpr FMT_INLINE auto const_check(T value) -> T
basic_format_arg< Context > & arg_
basic_format_args< basic_printf_context > args_
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:45