Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
printf_arg_formatter< Range > Class Template Reference

#include <printf.h>

Inheritance diagram for printf_arg_formatter< Range >:
internal::function< internal::arg_formatter_base< Range >::iterator > internal::arg_formatter_base< Range >

Public Types

typedef base::format_specs format_specs
 
- Public Types inherited from internal::arg_formatter_base< Range >
typedef Range::value_type char_type
 
typedef basic_format_specs< char_typeformat_specs
 

Public Member Functions

 printf_arg_formatter (internal::basic_buffer< char_type > &buffer, format_specs &spec, context_type &ctx)
 
template<typename T >
std::enable_if< std::is_integral< T >::value, iterator >::type operator() (T value)
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, iterator >::type operator() (T value)
 
iterator operator() (const char *value)
 
iterator operator() (const wchar_t *value)
 
iterator operator() (basic_string_view< char_type > value)
 
iterator operator() (monostate value)
 
iterator operator() (const void *value)
 
iterator operator() (typename basic_format_arg< context_type >::handle handle)
 
- Public Member Functions inherited from internal::arg_formatter_base< Range >
 arg_formatter_base (Range r, format_specs *s, locale_ref loc)
 
iterator operator() (monostate)
 
template<typename T >
std::enable_if< std::is_integral< T >::value||std::is_same< T, char_type >::value, iterator >::type operator() (T value)
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, iterator >::type operator() (T value)
 
iterator operator() (const char_type *value)
 
iterator operator() (basic_string_view< char_type > value)
 
iterator operator() (const void *value)
 

Private Types

typedef Range::value_type char_type
 
typedef internal::arg_formatter_base< Rangebase
 
typedef basic_printf_context< iterator, char_typecontext_type
 

Private Member Functions

void write_null_pointer (char)
 
void write_null_pointer (wchar_t)
 

Private Attributes

decltype(internal::declval< Range >().begin()) typedef iterator
 
context_typecontext_
 

Additional Inherited Members

- Public Attributes inherited from internal::arg_formatter_base< Range >
decltype(internal::declval< Range >().begin()) typedef iterator
 
- Protected Member Functions inherited from internal::arg_formatter_base< Range >
writer_typewriter ()
 
format_specsspec ()
 
iterator out ()
 
void write (bool value)
 
void write (const char_type *value)
 

Detailed Description

template<typename Range>
class printf_arg_formatter< Range >

The printf argument formatter.

Definition at line 330 of file printf.h.

Member Typedef Documentation

template<typename Range >
typedef internal::arg_formatter_base<Range> printf_arg_formatter< Range >::base
private

Definition at line 351 of file printf.h.

template<typename Range >
typedef Range::value_type printf_arg_formatter< Range >::char_type
private

Definition at line 349 of file printf.h.

template<typename Range >
typedef basic_printf_context<iterator, char_type> printf_arg_formatter< Range >::context_type
private

Definition at line 352 of file printf.h.

template<typename Range >
typedef base::format_specs printf_arg_formatter< Range >::format_specs

Definition at line 367 of file printf.h.

Constructor & Destructor Documentation

template<typename Range >
printf_arg_formatter< Range >::printf_arg_formatter ( internal::basic_buffer< char_type > &  buffer,
format_specs spec,
context_type ctx 
)
inline

Constructs an argument formatter object. buffer* is a reference to the output buffer and spec contains format specifier information for standard argument types.

Definition at line 376 of file printf.h.

379  ctx.locale()),
380  context_(ctx) {}
context_type & context_
Definition: printf.h:354
internal::arg_formatter_base< Range > base
Definition: printf.h:351

Member Function Documentation

template<typename Range >
template<typename T >
std::enable_if<std::is_integral<T>::value, iterator>::type printf_arg_formatter< Range >::operator() ( value)
inline

Definition at line 384 of file printf.h.

384  {
385  // MSVC2013 fails to compile separate overloads for bool and char_type so
386  // use std::is_same instead.
388  format_specs &fmt_spec = *this->spec();
389  if (fmt_spec.type != 's')
390  return base::operator()(value ? 1 : 0);
391  fmt_spec.type = 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));
397  fmt_spec.flags = 0;
398  fmt_spec.align_ = ALIGN_RIGHT;
399  return base::operator()(value);
400  } else {
401  return base::operator()(value);
402  }
403  return this->out();
404  }
alignment align_
Definition: format.h:1092
iterator operator()(monostate)
Definition: format.h:1362
uint_least8_t flags
Definition: format.h:1102
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
format_specs * spec()
Definition: format.h:1342
void write(bool value)
Definition: format.h:1345
template<typename Range >
template<typename T >
std::enable_if<std::is_floating_point<T>::value, iterator>::type printf_arg_formatter< Range >::operator() ( value)
inline

Definition at line 408 of file printf.h.

408  {
409  return base::operator()(value);
410  }
iterator operator()(monostate)
Definition: format.h:1362
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
template<typename Range >
iterator printf_arg_formatter< Range >::operator() ( const char *  value)
inline

Formats a null-terminated C string.

Definition at line 413 of file printf.h.

413  {
414  if (value)
416  else if (this->spec()->type == 'p')
418  else
419  this->write("(null)");
420  return this->out();
421  }
Range::value_type char_type
Definition: printf.h:349
iterator operator()(monostate)
Definition: format.h:1362
void write_null_pointer(char)
Definition: printf.h:356
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
format_specs * spec()
Definition: format.h:1342
void write(bool value)
Definition: format.h:1345
template<typename Range >
iterator printf_arg_formatter< Range >::operator() ( const wchar_t *  value)
inline

Formats a null-terminated wide C string.

Definition at line 424 of file printf.h.

424  {
425  if (value)
427  else if (this->spec()->type == 'p')
429  else
430  this->write(L"(null)");
431  return this->out();
432  }
Range::value_type char_type
Definition: printf.h:349
iterator operator()(monostate)
Definition: format.h:1362
void write_null_pointer(char)
Definition: printf.h:356
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
format_specs * spec()
Definition: format.h:1342
void write(bool value)
Definition: format.h:1345
template<typename Range >
iterator printf_arg_formatter< Range >::operator() ( basic_string_view< char_type value)
inline

Definition at line 434 of file printf.h.

434  {
435  return base::operator()(value);
436  }
iterator operator()(monostate)
Definition: format.h:1362
template<typename Range >
iterator printf_arg_formatter< Range >::operator() ( monostate  value)
inline

Definition at line 438 of file printf.h.

438  {
439  return base::operator()(value);
440  }
iterator operator()(monostate)
Definition: format.h:1362
template<typename Range >
iterator printf_arg_formatter< Range >::operator() ( const void *  value)
inline

Formats a pointer.

Definition at line 443 of file printf.h.

443  {
444  if (value)
445  return base::operator()(value);
446  this->spec()->type = 0;
448  return this->out();
449  }
Range::value_type char_type
Definition: printf.h:349
iterator operator()(monostate)
Definition: format.h:1362
void write_null_pointer(char)
Definition: printf.h:356
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
format_specs * spec()
Definition: format.h:1342
template<typename Range >
iterator printf_arg_formatter< Range >::operator() ( typename basic_format_arg< context_type >::handle  handle)
inline

Formats an argument of a custom (user-defined) type.

Definition at line 452 of file printf.h.

452  {
453  handle.format(context_);
454  return this->out();
455  }
context_type & context_
Definition: printf.h:354
template<typename Range >
void printf_arg_formatter< Range >::write_null_pointer ( char  )
inlineprivate

Definition at line 356 of file printf.h.

356  {
357  this->spec()->type = 0;
358  this->write("(nil)");
359  }
format_specs * spec()
Definition: format.h:1342
void write(bool value)
Definition: format.h:1345
template<typename Range >
void printf_arg_formatter< Range >::write_null_pointer ( wchar_t  )
inlineprivate

Definition at line 361 of file printf.h.

361  {
362  this->spec()->type = 0;
363  this->write(L"(nil)");
364  }
format_specs * spec()
Definition: format.h:1342
void write(bool value)
Definition: format.h:1345

Member Data Documentation

template<typename Range >
context_type& printf_arg_formatter< Range >::context_
private

Definition at line 354 of file printf.h.

template<typename Range >
decltype(internal::declval<Range>().begin()) typedef printf_arg_formatter< Range >::iterator
private

Definition at line 350 of file printf.h.


The documentation for this class was generated from the following file: