22 template <
typename Char>
46 : out_(out), args_(args) {}
48 OutputIt
out() {
return out_; }
51 detail::locale_ref
locale() {
return {}; }
56 detail::error_handler().on_error(message);
66 unsigned max = max_value<int>();
116 using char_type =
typename Context::char_type;
123 : arg_(arg), type_(type) {}
126 if (type_ !=
's') operator()<
bool>(
value);
131 bool is_signed = type_ ==
'd' || type_ ==
'i';
136 arg_ = detail::make_arg<Context>(
137 static_cast<int>(
static_cast<target_type
>(
value)));
140 arg_ = detail::make_arg<Context>(
141 static_cast<unsigned>(
static_cast<unsigned_type
>(
value)));
148 arg_ = detail::make_arg<Context>(
static_cast<long long>(
value));
150 arg_ = detail::make_arg<Context>(
157 void operator()(U) {}
164 template <
typename T,
typename Context,
typename Char>
179 arg_ = detail::make_arg<Context>(
180 static_cast<typename Context::char_type
>(
value));
184 void operator()(
T) {}
190 template <
typename T>
const Char*
operator()(
T) {
return nullptr; }
212 unsigned int_max = max_value<int>();
214 return static_cast<unsigned>(
width);
218 unsigned operator()(
T) {
225 template <
typename OutputIt,
typename Char>
234 OutputIt write_null_pointer(
bool is_string =
false) {
252 if (fmt_specs.
type && fmt_specs.
type !=
'c')
253 return (*
this)(
static_cast<int>(
value));
255 fmt_specs.
alt =
false;
256 fmt_specs.
fill[0] =
' ';
261 return write<Char>(this->
out,
static_cast<Char
>(
value), fmt_specs);
274 return write_null_pointer(this->
specs.type !=
'p');
280 return write_null_pointer(this->
specs.type !=
'p');
296 handle.
format(parse_ctx, context_);
301 template <
typename Char>
304 for (; it !=
end; ++it) {
329 template <
typename Char,
typename GetArg>
334 if (c >=
'0' && c <=
'9') {
338 if (it != end && *it ==
'$') {
340 arg_index = value != -1 ? value : max_value<int>();
342 if (c ==
'0') specs.
fill[0] =
'0';
355 if (*it >=
'0' && *it <=
'9') {
358 }
else if (*it ==
'*') {
361 detail::printf_width_handler<Char>(specs),
get_arg(-1)));
367 template <
typename Char,
typename Context>
371 auto out = OutputIt(buf);
377 auto get_arg = [&](
int arg_index) {
379 arg_index = parse_ctx.next_arg_id();
381 parse_ctx.check_arg_id(--arg_index);
385 const Char*
start = parse_ctx.begin();
386 const Char*
end = parse_ctx.end();
389 if (!detail::find<false, Char>(it, end,
'%', it)) {
394 if (it != end && *it == c) {
408 if (arg_index == 0) parse_ctx.
on_error(
"argument not found");
411 if (it != end && *it ==
'.') {
413 c = it != end ? *it : 0;
414 if (
'0' <= c && c <=
'9') {
416 }
else if (c ==
'*') {
431 if (specs.
precision >= 0 &&
arg.type() == detail::type::cstring_type) {
434 auto nul =
std::find(str, str_end, Char());
435 arg = detail::make_arg<basic_printf_context<OutputIt, Char>>(
442 if (specs.
fill[0] ==
'0') {
451 c = it != end ? *it++ : 0;
452 Char
t = it != end ? *it : 0;
458 t = it != end ? *it : 0;
459 convert_arg<signed char>(
arg,
t);
461 convert_arg<short>(
arg,
t);
467 t = it != end ? *it : 0;
468 convert_arg<long long>(
arg,
t);
470 convert_arg<long>(
arg,
t);
474 convert_arg<intmax_t>(
arg,
t);
477 convert_arg<size_t>(
arg,
t);
480 convert_arg<std::ptrdiff_t>(
arg,
t);
488 convert_arg<void>(
arg,
c);
493 specs.
type =
static_cast<char>(*it++);
494 if (
arg.is_integral()) {
496 switch (specs.
type) {
513 detail::printf_arg_formatter<OutputIt, Char>(out, specs, context),
arg);
519 template <
typename Char>
535 template <
typename...
T>
547 template <
typename...
T>
553 template <
typename S,
typename Char =
char_t<S>>
572 template <
typename S,
typename...
T,
579 template <
typename S,
typename Char =
char_t<S>>
581 std::FILE*
f,
const S& fmt,
586 size_t size = buffer.size();
587 return std::fwrite(buffer.data(),
sizeof(Char), size,
f) < size
589 :
static_cast<int>(
size);
601 template <
typename S,
typename...
T,
typename Char =
char_t<S>>
602 inline auto fprintf(std::FILE*
f,
const S& fmt,
const T&...
args) ->
int {
605 fmt::make_format_args<context>(
args...));
608 template <
typename S,
typename Char =
char_t<S>>
632 template <
typename S,
typename Char =
char_t<S>>
634 std::basic_ostream<Char>& os,
const S& fmt,
639 os.write(buffer.data(),
static_cast<std::streamsize
>(buffer.size()));
640 return static_cast<int>(buffer.size());
642 template <
typename S,
typename...
T,
typename Char =
char_t<S>>
644 const T&...
args) ->
int {
652 #endif // FMT_PRINTF_H_
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
#define FMT_MODULE_EXPORT_END
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.
GLenum GLuint GLenum GLsizei const GLchar * buf
FMT_CONSTEXPR void on_error(const char *message)
#define FMT_BEGIN_DETAIL_NAMESPACE
#define FMT_END_DETAIL_NAMESPACE
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 GLfloat * value
char_converter(basic_format_arg< Context > &arg)
basic_printf_context_t< char > printf_context
constexpr auto const_check(T value) -> T
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T >>> buffer_appender
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)
void parse_flags(basic_format_specs< Char > &specs, const Char *&it, const Char *end)
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 >
#define FMT_END_NAMESPACE
const Char * operator()(const Char *s)
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept-> int
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< 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
arg_converter(basic_format_arg< Context > &arg, char_type type)
GLint GLint GLsizei GLint GLenum format
constexpr auto make_format_args(const Args &...args) -> format_arg_store< Context, Args...>
auto fprintf(std::FILE *f, const S &fmt, const T &...args) -> int
int parse_header(const Char *&it, const Char *end, basic_format_specs< Char > &specs, GetArg get_arg)
printf_width_handler(format_specs &specs)
typename type_identity< T >::type type_identity_t
void advance_to(OutputIt it)
ImageBuf OIIO_API max(Image_or_Const A, Image_or_Const B, ROI roi={}, int nthreads=0)
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(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)
#define FMT_BEGIN_NAMESPACE
auto sprintf(const S &fmt, const T &...args) -> std::basic_string< Char >
static bool fits_in_int(bool)
#define FMT_MODULE_EXPORT_BEGIN
basic_printf_context_t< wchar_t > wprintf_context
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
format_arg arg(int id) const
static bool fits_in_int(T value)