22 template <
typename Char>
23 class null_terminating_iterator {
36 template <
typename Range>
81 return ptr_ - other.ptr_;
85 return ptr_ != other.ptr_;
89 return ptr_ >= other.ptr_;
94 template <
typename CharT>
103 template <
typename T>
106 template <
typename Char>
115 template <
typename Iterator,
typename ErrorHandler>
117 assert(
'0' <= *it && *it <=
'9');
125 unsigned big = max_int / 10;
132 value = value * 10 + unsigned(*it -
'0');
137 }
while (
'0' <= *it && *it <=
'9');
139 eh.on_error(
"number is too big");
145 template <
bool IsSigned>
147 template <
typename T>
157 template <
typename T>
167 template <
typename T>
170 if (!
int_checker<std::numeric_limits<T>::is_signed>::fits_in_int(value))
172 return static_cast<int>(
value);
175 template <
typename T>
185 template <
typename T>
189 template <
typename T>
194 template <
typename T>
202 template <
typename T,
typename Context>
212 : arg_(arg), type_(type) {}
216 operator()<
bool>(
value);
219 template <
typename U>
222 bool is_signed = type_ ==
'd' || type_ ==
'i';
223 typedef typename std::conditional<
225 if (
const_check(
sizeof(TargetType) <=
sizeof(
int))) {
228 arg_ = internal::make_arg<Context>(
229 static_cast<int>(
static_cast<TargetType
>(
value)));
232 arg_ = internal::make_arg<Context>(
233 static_cast<unsigned>(
static_cast<Unsigned
>(
value)));
240 arg_ = internal::make_arg<Context>(
static_cast<long long>(
value));
242 arg_ = internal::make_arg<Context>(
248 template <
typename U>
258 template <
typename T,
typename Context,
typename Char>
264 template <
typename Context>
272 template <
typename T>
276 arg_ = internal::make_arg<Context>(
static_cast<Char
>(
value));
279 template <
typename T>
287 template <
typename Char>
297 template <
typename T>
301 UnsignedType
width =
static_cast<UnsignedType
>(
value);
309 return static_cast<unsigned>(
width);
312 template <
typename T>
320 template <
typename Char,
typename Context>
323 Context(std::back_inserter(buf), format, args).format();
329 template <
typename Range>
333 typename OutputIt,
typename Char,
334 typename ArgFormatter =
343 template <
typename Range>
346 typename internal::arg_formatter_base<Range>::iterator>,
354 context_type &context_;
356 void write_null_pointer(
char) {
357 this->spec()->type = 0;
358 this->
write(
"(nil)");
362 this->spec()->type = 0;
363 this->
write(L
"(nil)");
382 template <
typename T>
388 format_specs &fmt_spec = *this->spec();
389 if (fmt_spec.
type !=
's')
390 return base::operator()(value ? 1 : 0);
392 this->
write(value != 0);
394 format_specs &fmt_spec = *this->spec();
395 if (fmt_spec.
type && fmt_spec.
type !=
'c')
396 return (*
this)(
static_cast<int>(
value));
399 return base::operator()(value);
401 return base::operator()(value);
406 template <
typename T>
409 return base::operator()(value);
415 base::operator()(value);
416 else if (this->spec()->
type ==
'p')
419 this->
write(
"(null)");
426 base::operator()(value);
427 else if (this->spec()->
type ==
'p')
430 this->
write(L
"(null)");
435 return base::operator()(value);
439 return base::operator()(value);
445 return base::operator()(value);
446 this->spec()->type = 0;
458 template <
typename T>
460 template <
typename ParseContext>
461 auto parse(ParseContext &ctx) -> decltype(ctx.begin()) {
return ctx.begin(); }
463 template <
typename FormatContext>
464 auto format(
const T &
value, FormatContext &ctx) -> decltype(ctx.out()) {
471 template <
typename OutputIt,
typename Char,
typename ArgFormatter>
476 OutputIt, basic_printf_context<OutputIt, Char, ArgFormatter>, Char> {
481 template <
typename T>
490 void parse_flags(format_specs &spec, iterator &it);
499 unsigned parse_header(iterator &it, format_specs &spec);
511 : base(out, format_str, args) {}
515 using base::advance_to;
521 template <
typename OutputIt,
typename Char,
typename AF>
523 format_specs &spec, iterator &it) {
548 template <
typename OutputIt,
typename Char,
typename AF>
551 iterator it,
unsigned arg_index) {
554 return this->do_get_arg(this->
parse_context().next_arg_id());
555 return base::get_arg(arg_index - 1);
558 template <
typename OutputIt,
typename Char,
typename AF>
560 iterator &it, format_specs &spec) {
563 if (c >=
'0' && c <=
'9') {
582 parse_flags(spec, it);
584 if (*it >=
'0' && *it <=
'9') {
587 }
else if (*it ==
'*') {
595 template <
typename OutputIt,
typename Char,
typename AF>
603 if (c !=
'%')
continue;
615 unsigned arg_index = parse_header(it, spec);
620 if (
'0' <= *it && *it <=
'9') {
623 }
else if (*it ==
'*') {
632 format_arg
arg = get_arg(it, arg_index);
634 spec.
flags = static_cast<uint_least8_t>(spec.
flags & (~internal::to_unsigned<int>(
HASH_FLAG)));
635 if (spec.
fill_ ==
'0') {
647 convert_arg<signed char>(
arg, *++it);
649 convert_arg<short>(
arg, *it);
653 convert_arg<long long>(
arg, *++it);
655 convert_arg<long>(
arg, *it);
658 convert_arg<intmax_t>(
arg, *it);
661 convert_arg<std::size_t>(
arg, *it);
664 convert_arg<std::ptrdiff_t>(
arg, *it);
672 convert_arg<void>(
arg, *it);
678 spec.
type =
static_cast<char>(*it++);
701 template <
typename Buffer>
704 std::back_insert_iterator<Buffer>,
typename Buffer::value_type>
type;
719 template<
typename... Args>
729 template<
typename... Args>
733 template <
typename S,
typename Char = FMT_CHAR(S)>
734 inline std::basic_string<Char>
752 template <
typename S,
typename... Args>
764 template <
typename S,
typename Char = FMT_CHAR(S)>
772 buffer.
data(),
sizeof(Char), size, f) < size ? -1 :
static_cast<int>(
size);
784 template <
typename S,
typename... Args>
795 template <
typename S,
typename Char = FMT_CHAR(S)>
811 template <
typename S,
typename... Args>
822 template <
typename S,
typename Char = FMT_CHAR(S)>
830 return static_cast<int>(buffer.
size());
842 template <
typename S,
typename... Args>
844 fprintf(std::basic_ostream<
FMT_CHAR(
S)> &os,
845 const S &format_str,
const Args & ... args) {
855 #endif // FMT_PRINTF_H_ printf_formatter< T > type
basic_format_specs< char_type > format_specs
FMT_CONSTEXPR null_terminating_iterator operator--()
std::enable_if<!std::is_integral< T >::value, bool >::type operator()(T)
Container & get_container(std::back_insert_iterator< Container > it)
FMT_CONSTEXPR null_terminating_iterator(const Range &r)
FMT_CONSTEXPR_DECL const Char * pointer_from(null_terminating_iterator< Char > it)
static bool fits_in_int(int)
std::enable_if< std::is_integral< U >::value >::type operator()(U value)
bool operator>=(null_terminating_iterator other) const
basic_printf_context_t< internal::wbuffer >::type wprintf_context
basic_printf_context_t< internal::buffer >::type printf_context
FMT_CONSTEXPR auto begin(const C &c) -> decltype(c.begin())
basic_format_args< printf_context > printf_args
char_converter(basic_format_arg< Context > &arg)
internal::named_arg< T, char > arg(string_view name, const T &arg)
void append(const U *begin, const U *end)
format_arg_store< printf_context, Args... > make_printf_args(const Args &...args)
FMT_CONSTEXPR null_terminating_iterator operator++(int)
basic_format_arg< Context > & arg_
FMT_CONSTEXPR Char operator*() const
#define FMT_CONSTEXPR_DECL
static bool fits_in_int(T value)
basic_printf_context< std::back_insert_iterator< Buffer >, typename Buffer::value_type > type
void printf(basic_buffer< Char > &buf, basic_string_view< Char > format, basic_format_args< Context > args)
void write(std::basic_ostream< Char > &os, basic_buffer< Char > &buf)
FMT_CONSTEXPR null_terminating_iterator operator-(difference_type n)
FMT_CONSTEXPR null_terminating_iterator(const Char *ptr, const Char *end)
#define FMT_END_NAMESPACE
basic_printf_context_t< buffer >::type context
std::enable_if<!is_compile_string< S >::value >::type check_format_string(const S &)
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
std::enable_if<!std::is_integral< U >::value >::type operator()(U)
basic_format_specs< Char > format_specs
FMT_CONSTEXPR auto end(const C &c) -> decltype(c.end())
dummy_string_view to_string_view(...)
friend FMT_CONSTEXPR_DECL const CharT * pointer_from(null_terminating_iterator< CharT > it)
internal::context_base< OutputIt, basic_printf_context, Char > base
std::size_t size() const FMT_NOEXCEPT
FMT_CONSTEXPR bool operator!=(null_terminating_iterator other) const
static bool fits_in_int(T value)
FMT_CONSTEXPR difference_type operator-(null_terminating_iterator other) const
void operator()(bool value)
static int max(int a, int b)
basic_buffer< char > buffer
std::enable_if<!std::is_integral< T >::value, int >::type operator()(T)
std::random_access_iterator_tag iterator_category
FMT_CONSTEXPR null_terminating_iterator & operator=(const Char *ptr)
unsigned parse_header(iterator &it, format_specs &spec)
int vprintf(const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
std::basic_string< Char > vsprintf(const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
int vfprintf(std::FILE *f, const S &format, basic_format_args< typename basic_printf_context_t< internal::basic_buffer< Char >>::type > args)
FMT_CONSTEXPR std::enable_if< std::numeric_limits< T >::is_signed, bool >::type is_negative(T value)
std::enable_if<!std::is_integral< T >::value, unsigned >::type operator()(T)
T min(sqlite3 *const db, std::string const &table_name, std::string const &column_name)
FMT_CONSTEXPR null_terminating_iterator operator+=(difference_type n)
const GenericPointer< typename T::ValueType > T2 value
basic_format_args< wprintf_context > wprintf_args
static bool fits_in_int(bool)
null_terminating_iterator()
FMT_CONSTEXPR unsigned parse_nonnegative_int(const Char *&begin, const Char *end, ErrorHandler &&eh)
internal::null_terminating_iterator< char_type > iterator
std::enable_if< std::is_integral< T >::value, bool >::type operator()(T value)
FMT_ENABLE_IF_T(internal::is_string< S >::value, std::basic_string< FMT_CHAR(S)>) sprintf(const S &format
std::enable_if< std::is_integral< T >::value >::type operator()(T value)
std::enable_if< std::is_integral< T >::value, int >::type operator()(T value)
format_arg_store< context, Args... > as
void parse_flags(format_specs &spec, iterator &it)
format_arg_store< wprintf_context, Args... > make_wprintf_args(const Args &...args)
void format_value(basic_buffer< Char > &buffer, const T &value)
std::enable_if<!std::is_integral< T >::value >::type operator()(T)
std::enable_if< std::is_integral< T >::value, unsigned >::type operator()(T value)
basic_printf_context(OutputIt out, basic_string_view< char_type > format_str, basic_format_args< basic_printf_context > args)
basic_format_arg< Context > & arg_
base::format_arg format_arg
void convert_arg(basic_format_arg< Context > &arg, Char type)
std::string to_string(ModuleType const mt)
basic_parse_context< char > parse_context
std::ptrdiff_t difference_type
format_arg get_arg(iterator it, unsigned arg_index=(std::numeric_limits< unsigned >::max)())
FMT_CONSTEXPR null_terminating_iterator operator+(difference_type n)
arg_converter(basic_format_arg< Context > &arg, Char type)
FMT_CONSTEXPR internal::result_of< Visitor(int)>::type visit_format_arg(Visitor &&vis, const basic_format_arg< Context > &arg)
FMT_CONSTEXPR null_terminating_iterator operator++()
printf_width_handler(format_specs &spec)