21template <
typename Char>
45 : out_(
out), args_(args) {}
47 OutputIt
out() {
return out_; }
50 detail::locale_ref
locale() {
return {}; }
55 detail::error_handler().on_error(message);
65 unsigned max = max_value<int>();
81 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
88 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)>
115 using char_type =
typename Context::char_type;
125 if (type_ !=
's') operator()<
bool>(
value);
128 template <
typename U, FMT_ENABLE_IF(std::is_
integral<U>::value)>
130 bool is_signed = type_ ==
'd' || type_ ==
'i';
132 if (
const_check(
sizeof(target_type) <=
sizeof(
int))) {
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>(
155 template <
typename U, FMT_ENABLE_IF(!std::is_
integral<U>::value)>
163template <
typename T,
typename Context,
typename Char>
176 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
178 arg_ = detail::make_arg<Context>(
179 static_cast<typename Context::char_type
>(
value));
182 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
189 template <
typename T>
const Char*
operator()(T) {
return nullptr; }
204 template <
typename T, FMT_ENABLE_IF(std::is_
integral<T>::value)>
208 specs_.
align = align::left;
211 unsigned int_max = max_value<int>();
213 return static_cast<unsigned>(width);
216 template <
typename T, FMT_ENABLE_IF(!std::is_
integral<T>::value)>
224template <
typename OutputIt,
typename Char>
233 OutputIt write_null_pointer(
bool is_string =
false) {
234 auto s = this->
specs;
245 template <
typename T, FMT_ENABLE_IF(detail::is_
integral<T>::value)>
249 if (std::is_same<T, Char>::value) {
253 return (*
this)(
static_cast<int>(
value));
255 fmt_specs.
sign = sign::none;
256 fmt_specs.
alt =
false;
257 fmt_specs.
fill[0] =
' ';
260 if (fmt_specs.
align == align::none || fmt_specs.
align == align::numeric)
261 fmt_specs.
align = align::right;
262 return write<Char>(this->
out,
static_cast<Char
>(
value), fmt_specs);
267 template <
typename T, FMT_ENABLE_IF(std::is_
floating_po
int<T>::value)>
297 handle.
format(parse_ctx, context_);
302template <
typename Char>
305 for (; it !=
end; ++it) {
308 specs.
align = align::left;
311 specs.
sign = sign::plus;
317 if (specs.
sign != sign::plus) {
318 specs.
sign = sign::space;
330template <
typename Char,
typename GetArg>
335 if (
c >=
'0' &&
c <=
'9') {
339 if (it !=
end && *it ==
'$') {
341 arg_index =
value != -1 ?
value : max_value<int>();
343 if (
c ==
'0') specs.
fill[0] =
'0';
356 if (*it >=
'0' && *it <=
'9') {
359 }
else if (*it ==
'*') {
362 detail::printf_width_handler<Char>(specs),
get_arg(-1)));
368template <
typename Char,
typename Context>
372 auto out = OutputIt(buf);
378 auto get_arg = [&](
int arg_index) {
380 arg_index = parse_ctx.next_arg_id();
382 parse_ctx.check_arg_id(--arg_index);
386 const Char* start = parse_ctx.begin();
387 const Char*
end = parse_ctx.end();
390 if (!detail::find<false, Char>(it,
end,
'%', it)) {
395 if (it !=
end && *it ==
c) {
405 specs.
align = align::right;
409 if (arg_index == 0) parse_ctx.on_error(
"argument not found");
412 if (it !=
end && *it ==
'.') {
414 c = it !=
end ? *it : 0;
415 if (
'0' <=
c &&
c <=
'9') {
417 }
else if (
c ==
'*') {
432 if (specs.
precision >= 0 &&
arg.type() == detail::type::cstring_type) {
435 auto nul =
std::find(str, str_end, Char());
436 arg = detail::make_arg<basic_printf_context<OutputIt, Char>>(
443 if (specs.
fill[0] ==
'0') {
444 if (
arg.is_arithmetic() && specs.
align != align::left)
445 specs.
align = align::numeric;
452 c = it !=
end ? *it++ : 0;
453 Char t = it !=
end ? *it : 0;
459 t = it !=
end ? *it : 0;
460 convert_arg<signed char>(
arg, t);
462 convert_arg<short>(
arg, t);
468 t = it !=
end ? *it : 0;
469 convert_arg<long long>(
arg, t);
471 convert_arg<long>(
arg, t);
475 convert_arg<intmax_t>(
arg, t);
478 convert_arg<size_t>(
arg, t);
481 convert_arg<std::ptrdiff_t>(
arg, t);
489 convert_arg<void>(
arg,
c);
494 char type =
static_cast<char>(*it++);
495 if (
arg.is_integral()) {
511 parse_ctx.on_error(
"invalid type specifier");
517 detail::printf_arg_formatter<OutputIt, Char>(out, specs, context),
arg);
523template <
typename Char>
539template <
typename... T>
551template <
typename... T>
557template <
typename S,
typename Char =
char_t<S>>
561 -> std::basic_string<Char> {
576template <
typename S,
typename... T,
578inline auto sprintf(
const S& fmt,
const T&... args) -> std::basic_string<Char> {
581 fmt::make_format_args<context>(args...));
584template <
typename S,
typename Char =
char_t<S>>
586 std::FILE* f,
const S& fmt,
594 :
static_cast<int>(
size);
606template <
typename S,
typename... T,
typename Char =
char_t<S>>
607inline auto fprintf(std::FILE* f,
const S& fmt,
const T&... args) ->
int {
610 fmt::make_format_args<context>(args...));
613template <
typename S,
typename Char =
char_t<S>>
630template <
typename S,
typename... T,
FMT_ENABLE_IF(detail::is_string<S>::value)>
631inline auto printf(
const S& fmt,
const T&... args) ->
int {
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const ArgReturnType arg() const
Definition: ArrayCwiseUnaryOps.h:66
you may not use this file except in compliance with the License You may obtain a copy of the License at software distributed under the License is distributed on an AS IS WITHOUT WARRANTIES OR CONDITIONS OF ANY either express or implied See the License for the specific language governing permissions and limitations under the License LLVM Exceptions to the Apache License As an if
Definition: ThirdPartyNotices.txt:289
arg_converter(basic_format_arg< Context > &arg, char_type type)
Definition: printf.h:121
void operator()(U)
Definition: printf.h:156
void operator()(U value)
Definition: printf.h:129
void operator()(bool value)
Definition: printf.h:124
\rst Parsing context consisting of a format string range being parsed and an argument counter for aut...
Definition: core.h:654
constexpr basic_format_parse_context(basic_string_view< Char > format_str, ErrorHandler eh={}, int next_arg_id=0)
Definition: core.h:665
\rst A dynamically growing memory buffer for trivially copyable/constructible types with the first SI...
Definition: format.h:819
OutputIt out()
Definition: printf.h:47
Char char_type
Definition: printf.h:32
FMT_CONSTEXPR void on_error(const char *message)
Definition: printf.h:54
format_arg arg(int id) const
Definition: printf.h:52
detail::locale_ref locale()
Definition: printf.h:50
basic_printf_context(OutputIt out, basic_format_args< basic_printf_context > args)
\rst Constructs a printf_context object.
Definition: printf.h:43
void advance_to(OutputIt it)
Definition: printf.h:48
An implementation of std::basic_string_view for pre-C++17.
Definition: core.h:430
\rst A contiguous memory buffer with an optional growing ability.
Definition: core.h:862
FMT_CONSTEXPR auto data() noexcept -> T *
Returns a pointer to the buffer data.
Definition: core.h:908
constexpr auto size() const noexcept -> size_t
Returns the size of this buffer.
Definition: core.h:902
void operator()(T value)
Definition: printf.h:177
void operator()(T)
Definition: printf.h:183
char_converter(basic_format_arg< Context > &arg)
Definition: printf.h:174
bool operator()(T value)
Definition: printf.h:99
bool operator()(T)
Definition: printf.h:104
int operator()(T value)
Definition: printf.h:82
int operator()(T)
Definition: printf.h:89
unsigned operator()(T)
Definition: printf.h:217
printf_width_handler(format_specs &specs)
Definition: printf.h:202
unsigned operator()(T value)
Definition: printf.h:205
typename std::enable_if< B, T >::type enable_if_t
Definition: core.h:298
FMT_CONSTEXPR auto find(Ptr first, Ptr last, T value, Ptr &out) -> bool
Definition: core.h:2325
constexpr FMT_INLINE auto const_check(T value) -> T
Definition: core.h:356
FMT_CONSTEXPR FMT_INLINE auto visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg) -> decltype(vis(0))
\rst Visits an argument dispatching to the appropriate visit method based on the argument type.
Definition: core.h:1623
typename detail::char_t_impl< S >::type char_t
String's character type.
Definition: core.h:644
#define FMT_END_DETAIL_NAMESPACE
Definition: core.h:227
#define FMT_MODULE_EXPORT_BEGIN
Definition: core.h:224
FMT_CONSTEXPR auto parse_presentation_type(Char type) -> presentation_type
Definition: core.h:2522
constexpr auto make_format_args(Args &&... args) -> format_arg_store< Context, remove_cvref_t< Args >... >
\rst Constructs a ~fmtformat_arg_store object that contains references to arguments and can be implic...
Definition: core.h:1923
#define FMT_CONSTEXPR
Definition: core.h:106
type
Definition: core.h:575
#define FMT_BEGIN_NAMESPACE
Definition: core.h:214
#define FMT_BEGIN_DETAIL_NAMESPACE
Definition: core.h:226
conditional_t< std::is_same< T, char >::value, appender, std::back_insert_iterator< buffer< T > > > buffer_appender
Definition: core.h:1106
#define FMT_ENABLE_IF(...)
Definition: core.h:335
FMT_CONSTEXPR auto to_unsigned(Int value) -> typename std::make_unsigned< Int >::type
Definition: core.h:407
FMT_CONSTEXPR auto parse_nonnegative_int(const Char *&begin, const Char *end, int error_value) noexcept -> int
Definition: core.h:2343
FMT_INLINE auto to_string_view(const Char *s) -> basic_string_view< Char >
Definition: core.h:536
typename type_identity< T >::type type_identity_t
Definition: core.h:309
typename std::conditional< B, T, F >::type conditional_t
Definition: core.h:300
#define FMT_END_NAMESPACE
Definition: core.h:217
#define FMT_MODULE_EXPORT_END
Definition: core.h:225
constexpr common_t< T1, T2 > max(const T1 x, const T2 y) noexcept
Compile-time pairwise maximum function.
Definition: max.hpp:35
constexpr common_t< T1, T2 > min(const T1 x, const T2 y) noexcept
Compile-time pairwise minimum function.
Definition: min.hpp:35
EIGEN_CONSTEXPR Index size(const T &x)
Definition: Meta.h:479
static EIGEN_DEPRECATED const end_t end
Definition: IndexedViewHelper.h:181
auto write(OutputIt out, const std::tm &time, const std::locale &loc, char format, char modifier=0) -> OutputIt
Definition: chrono.h:426
static constexpr const velocity::meters_per_second_t c(299792458.0)
Speed of light in vacuum.
std::string to_string(const T &t)
Definition: base.h:93
void convert_arg(basic_format_arg< Context > &arg, Char type)
Definition: printf.h:164
auto vfprintf(std::FILE *f, const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> int
Definition: printf.h:585
auto vsprintf(const S &fmt, basic_format_args< basic_printf_context_t< type_identity_t< Char > > > args) -> std::basic_string< Char >
Definition: printf.h:558
auto make_wprintf_args(const T &... args) -> format_arg_store< wprintf_context, T... >
\rst Constructs an ~fmtformat_arg_store object that contains references to arguments and can be impli...
Definition: printf.h:552
void vprintf(buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
Definition: printf.h:369
basic_printf_context_t< wchar_t > wprintf_context
Definition: printf.h:528
auto fprintf(std::FILE *f, const S &fmt, const T &... args) -> int
\rst Prints formatted data to the file f.
Definition: printf.h:607
auto printf(const S &fmt, const T &... args) -> int
\rst Prints formatted data to stdout.
Definition: printf.h:631
auto sprintf(const S &fmt, const T &... args) -> std::basic_string< Char >
\rst Formats arguments and returns the result as a string.
Definition: printf.h:578
basic_printf_context_t< char > printf_context
Definition: printf.h:527
void parse_flags(basic_format_specs< Char > &specs, const Char *&it, const Char *end)
Definition: printf.h:303
auto make_printf_args(const T &... args) -> format_arg_store< printf_context, T... >
\rst Constructs an ~fmtformat_arg_store object that contains references to arguments and can be impli...
Definition: printf.h:540
int parse_header(const Char *&it, const Char *end, basic_format_specs< Char > &specs, GetArg get_arg)
Definition: printf.h:331
const Char * operator()(const Char *s)
Definition: printf.h:190
const Char * operator()(T)
Definition: printf.h:189
static bool fits_in_int(T value)
Definition: printf.h:72
static bool fits_in_int(int)
Definition: printf.h:76
static bool fits_in_int(bool)
Definition: printf.h:68
static bool fits_in_int(T value)
Definition: printf.h:64
bool type
Definition: printf.h:111
#define S(label, offset, message)
Definition: Errors.h:119
auto format(wformat_string< T... > fmt, T &&... args) -> std::wstring
Definition: xchar.h:87