21 template <
typename Char>
45 : out_(out), args_(args) {}
47 OutputIt
out() {
return out_; }
65 unsigned max = max_value<int>();
115 using char_type =
typename Context::char_type;
122 : arg_(arg), type_(type) {}
125 if (type_ !=
's') operator()<
bool>(
value);
130 bool is_signed = type_ ==
'd' || type_ ==
'i';
135 arg_ = detail::make_arg<Context>(
136 static_cast<int>(
static_cast<target_type
>(
value)));
139 arg_ = detail::make_arg<Context>(
140 static_cast<unsigned>(
static_cast<unsigned_type
>(
value)));
147 arg_ = detail::make_arg<Context>(
static_cast<long long>(
value));
149 arg_ = detail::make_arg<Context>(
156 void operator()(U) {}
163 template <
typename T,
typename Context,
typename Char>
178 arg_ = detail::make_arg<Context>(
179 static_cast<typename Context::char_type
>(
value));
183 void operator()(
T) {}
189 template <
typename T>
const Char*
operator()(
T) {
return nullptr; }
209 unsigned int_max = max_value<int>();
211 return static_cast<unsigned>(
width);
215 unsigned operator()(
T) {
223 template <
typename Char>
226 return {iter,
s, locale_ref()};
230 template <
typename OutputIt,
typename Char>
238 OutputIt write_null_pointer(
bool is_string =
false) {
258 return (*
this)(
static_cast<int>(
value));
260 fmt_specs.
sign = sign::none;
261 fmt_specs.
alt =
false;
262 fmt_specs.
fill[0] =
' ';
265 if (fmt_specs.
align == align::none || fmt_specs.
align == align::numeric)
267 return write<Char>(this->
out,
static_cast<Char
>(
value), fmt_specs);
302 handle.
format(parse_ctx, context_);
307 template <
typename Char>
309 for (; it !=
end; ++it) {
315 specs.
sign = sign::plus;
321 if (specs.
sign != sign::plus) {
322 specs.
sign = sign::space;
334 template <
typename Char,
typename GetArg>
339 if (c >=
'0' && c <=
'9') {
343 if (it != end && *it ==
'$') {
345 arg_index = value != -1 ? value : max_value<int>();
347 if (c ==
'0') specs.
fill[0] =
'0';
360 if (*it >=
'0' && *it <=
'9') {
363 }
else if (*it ==
'*') {
366 detail::printf_width_handler<Char>(specs),
get_arg(-1)));
382 return in(
t, integral_set) ? pt::hex_lower :
pt::none;
384 return in(
t, integral_set) ? pt::hex_upper :
pt::none;
412 template <
typename Char,
typename Context>
415 using iterator = buffer_appender<Char>;
416 auto out = iterator(buf);
422 auto get_arg = [&](
int arg_index) {
424 arg_index = parse_ctx.next_arg_id();
426 parse_ctx.check_arg_id(--arg_index);
430 const Char*
start = parse_ctx.begin();
431 const Char*
end = parse_ctx.end();
434 if (!find<false, Char>(it, end,
'%', it)) {
439 if (it != end && *it == c) {
455 if (it != end && *it ==
'.') {
457 c = it != end ? *it : 0;
458 if (
'0' <= c && c <=
'9') {
460 }
else if (c ==
'*') {
462 specs.precision =
static_cast<int>(
472 if (specs.precision >= 0 &&
arg.is_integral())
475 if (specs.precision >= 0 &&
arg.type() == type::cstring_type) {
477 auto str_end = str + specs.precision;
478 auto nul =
std::find(str, str_end, Char());
479 arg = make_arg<basic_printf_context<iterator, Char>>(
481 str,
to_unsigned(nul != str_end ? nul - str : specs.precision)));
484 if (specs.fill[0] ==
'0') {
486 specs.align = align::numeric;
493 c = it != end ? *it++ : 0;
494 Char
t = it != end ? *it : 0;
499 t = it != end ? *it : 0;
500 convert_arg<signed char>(
arg,
t);
502 convert_arg<short>(
arg,
t);
508 t = it != end ? *it : 0;
509 convert_arg<long long>(
arg,
t);
511 convert_arg<long>(
arg,
t);
515 convert_arg<intmax_t>(
arg,
t);
518 convert_arg<size_t>(
arg,
t);
521 convert_arg<std::ptrdiff_t>(
arg,
t);
529 convert_arg<void>(
arg,
c);
534 char type =
static_cast<char>(*it++);
535 if (
arg.is_integral()) {
562 template <
typename Char>
578 template <
typename...
T>
590 template <
typename...
T>
596 template <
typename S,
typename Char =
char_t<S>>
615 template <
typename S,
typename...
T,
620 fmt::make_format_args<context>(
args...));
623 template <
typename S,
typename Char =
char_t<S>>
625 std::FILE*
f,
const S& fmt,
631 return std::fwrite(
buf.data(),
sizeof(Char), size,
f) < size
633 :
static_cast<int>(
size);
645 template <
typename S,
typename...
T,
typename Char =
char_t<S>>
646 inline auto fprintf(std::FILE*
f,
const S& fmt,
const T&...
args) ->
int {
649 fmt::make_format_args<context>(
args...));
652 template <
typename S,
typename Char =
char_t<S>>
679 #endif // FMT_PRINTF_H_
FMT_NORETURN FMT_API void throw_format_error(const char *message)
static bool fits_in_int(int)
#define FMT_ENABLE_IF(...)
auto make_wprintf_args(const T &...args) -> format_arg_store< wprintf_context, T...>
GLuint GLsizei const GLchar * message
typedef int(APIENTRYP RE_PFNGLXSWAPINTERVALSGIPROC)(int)
typename std::enable_if< B, T >::type enable_if_t
Define Imath::enable_if_t to be std for C++14, equivalent for C++11.
bool none(const vbool4 &v)
GLenum GLuint GLenum GLsizei const GLchar * buf
FMT_CONSTEXPR void on_error(const char *message)
typename detail::char_t_impl< S >::type char_t
int parse_header(const Char *&it, const Char *end, format_specs< Char > &specs, GetArg get_arg)
typename std::conditional< B, T, F >::type conditional_t
auto printf(const S &fmt, const T &...args) -> int
auto make_printf_args(const T &...args) -> format_arg_store< printf_context, T...>
GLsizei const GLchar *const * string
GLsizei const GLfloat * value
char_converter(basic_format_arg< Context > &arg)
basic_printf_context_t< char > printf_context
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
ImageBuf OIIO_API min(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
static bool fits_in_int(T value)
void operator()(bool value)
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
void convert_arg(basic_format_arg< Context > &arg, Char type)
const Char * operator()(T)
auto arg(const Char *name, const T &arg) -> detail::named_arg< Char, T >
constexpr auto in(type t, int set) -> bool
#define FMT_END_NAMESPACE
const Char * operator()(const Char *s)
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
GLint GLint GLsizei GLint GLenum GLenum type
auto make_arg_formatter(buffer_appender< Char > iter, format_specs< Char > &s) -> arg_formatter< Char >
basic_printf_context(OutputIt out, basic_format_args< basic_printf_context > args)
auto vfprintf(std::FILE *f, const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char >>> args) -> int
void parse_flags(format_specs< Char > &specs, const Char *&it, const Char *end)
printf_width_handler(format_specs< Char > &specs)
arg_converter(basic_format_arg< Context > &arg, char_type type)
GLint GLint GLsizei GLint GLenum format
auto fprintf(std::FILE *f, const S &fmt, const T &...args) -> int
FMT_MODULE_EXPORT FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
constexpr auto make_format_args(T &&...args) -> format_arg_store< Context, remove_cvref_t< T >...>
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
typename type_identity< T >::type type_identity_t
void advance_to(OutputIt it)
FMT_NORETURN void on_error(const char *message)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
**If you just want to fire and args
auto vsprintf(const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char >>> args) -> std::basic_string< Char >
detail::locale_ref locale()
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept-> int
#define FMT_BEGIN_NAMESPACE
auto sprintf(const S &fmt, const T &...args) -> std::basic_string< Char >
constexpr FMT_INLINE auto const_check(T value) -> T
static bool fits_in_int(bool)
auto parse_printf_presentation_type(char c, type t) -> presentation_type
basic_printf_context_t< wchar_t > wprintf_context
format_arg arg(int id) const
static bool fits_in_int(T value)