Public Member Functions | Private Types | Private Attributes | List of all members
internal::arg_converter< T, Context > Class Template Reference

#include <printf.h>

Inheritance diagram for internal::arg_converter< T, Context >:
internal::function< void >

Public Member Functions

 arg_converter (basic_format_arg< Context > &arg, Char type)
 
void operator() (bool value)
 
template<typename U >
std::enable_if< std::is_integral< U >::value >::type operator() (U value)
 
template<typename U >
std::enable_if<!std::is_integral< U >::value >::type operator() (U)
 

Private Types

typedef Context::char_type Char
 

Private Attributes

basic_format_arg< Context > & arg_
 
Context::char_type type_
 

Detailed Description

template<typename T, typename Context>
class internal::arg_converter< T, Context >

Definition at line 203 of file printf.h.

Member Typedef Documentation

template<typename T , typename Context >
typedef Context::char_type internal::arg_converter< T, Context >::Char
private

Definition at line 205 of file printf.h.

Constructor & Destructor Documentation

template<typename T , typename Context >
internal::arg_converter< T, Context >::arg_converter ( basic_format_arg< Context > &  arg,
Char  type 
)
inline

Definition at line 211 of file printf.h.

212  : arg_(arg), type_(type) {}
Context::char_type type_
Definition: printf.h:208
basic_format_arg< Context > & arg_
Definition: printf.h:207

Member Function Documentation

template<typename T , typename Context >
void internal::arg_converter< T, Context >::operator() ( bool  value)
inline

Definition at line 214 of file printf.h.

214  {
215  if (type_ != 's')
216  operator()<bool>(value);
217  }
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
Context::char_type type_
Definition: printf.h:208
template<typename T , typename Context >
template<typename U >
std::enable_if<std::is_integral<U>::value>::type internal::arg_converter< T, Context >::operator() ( value)
inline

Definition at line 221 of file printf.h.

221  {
222  bool is_signed = type_ == 'd' || type_ == 'i';
223  typedef typename std::conditional<
224  std::is_same<T, void>::value, U, T>::type TargetType;
225  if (const_check(sizeof(TargetType) <= sizeof(int))) {
226  // Extra casts are used to silence warnings.
227  if (is_signed) {
228  arg_ = internal::make_arg<Context>(
229  static_cast<int>(static_cast<TargetType>(value)));
230  } else {
231  typedef typename make_unsigned_or_bool<TargetType>::type Unsigned;
232  arg_ = internal::make_arg<Context>(
233  static_cast<unsigned>(static_cast<Unsigned>(value)));
234  }
235  } else {
236  if (is_signed) {
237  // glibc's printf doesn't sign extend arguments of smaller types:
238  // std::printf("%lld", -42); // prints "4294967254"
239  // but we don't have to do the same because it's a UB.
240  arg_ = internal::make_arg<Context>(static_cast<long long>(value));
241  } else {
242  arg_ = internal::make_arg<Context>(
243  static_cast<typename make_unsigned_or_bool<U>::type>(value));
244  }
245  }
246  }
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
static QCString type
Definition: declinfo.cpp:672
T const_check(T value)
Definition: format.h:293
Context::char_type type_
Definition: printf.h:208
basic_format_arg< Context > & arg_
Definition: printf.h:207
template<typename T , typename Context >
template<typename U >
std::enable_if<!std::is_integral<U>::value>::type internal::arg_converter< T, Context >::operator() ( )
inline

Definition at line 249 of file printf.h.

249  {
250  // No coversion needed for non-integral types.
251  }

Member Data Documentation

template<typename T , typename Context >
basic_format_arg<Context>& internal::arg_converter< T, Context >::arg_
private

Definition at line 207 of file printf.h.

template<typename T , typename Context >
Context::char_type internal::arg_converter< T, Context >::type_
private

Definition at line 208 of file printf.h.


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