Classes | Public Types | Public Member Functions | Public Attributes | List of all members
basic_writer< Range >::int_writer< Int, Spec > Struct Template Reference

Classes

struct  bin_writer
 
struct  dec_writer
 
struct  hex_writer
 
struct  num_writer
 

Public Types

enum  { SEP_SIZE = 1 }
 
typedef internal::int_traits< Int >::main_type unsigned_type
 

Public Member Functions

string_view get_prefix () const
 
template<unsigned BITS>
int count_digits () const
 
 int_writer (basic_writer< Range > &w, Int value, const Spec &s)
 
void on_dec ()
 
void on_hex ()
 
void on_bin ()
 
void on_oct ()
 
void on_num ()
 
void on_error ()
 

Public Attributes

basic_writer< Range > & writer
 
const Spec & spec
 
unsigned_type abs_value
 
char prefix [4]
 
unsigned prefix_size
 

Detailed Description

template<typename Range>
template<typename Int, typename Spec>
struct basic_writer< Range >::int_writer< Int, Spec >

Definition at line 2364 of file format.h.

Member Typedef Documentation

template<typename Range>
template<typename Int , typename Spec >
typedef internal::int_traits<Int>::main_type basic_writer< Range >::int_writer< Int, Spec >::unsigned_type

Definition at line 2365 of file format.h.

Member Enumeration Documentation

template<typename Range>
template<typename Int , typename Spec >
anonymous enum
Enumerator
SEP_SIZE 

Definition at line 2469 of file format.h.

Constructor & Destructor Documentation

template<typename Range>
template<typename Int , typename Spec >
basic_writer< Range >::int_writer< Int, Spec >::int_writer ( basic_writer< Range > &  w,
Int  value,
const Spec &  s 
)
inline

Definition at line 2386 of file format.h.

2387  : writer(w), spec(s), abs_value(static_cast<unsigned_type>(value)),
2388  prefix_size(0) {
2389  if (internal::is_negative(value)) {
2390  prefix[0] = '-';
2391  ++prefix_size;
2392  abs_value = 0 - abs_value;
2393  } else if (spec.has(SIGN_FLAG)) {
2394  prefix[0] = spec.has(PLUS_FLAG) ? '+' : ' ';
2395  ++prefix_size;
2396  }
2397  }
const Spec & spec
Definition: format.h:2368
unsigned_type abs_value
Definition: format.h:2369
FMT_CONSTEXPR std::enable_if< std::numeric_limits< T >::is_signed, bool >::type is_negative(T value)
Definition: format.h:727
basic_writer< Range > & writer
Definition: format.h:2367
static QCString * s
Definition: config.cpp:1042

Member Function Documentation

template<typename Range>
template<typename Int , typename Spec >
template<unsigned BITS>
int basic_writer< Range >::int_writer< Int, Spec >::count_digits ( ) const
inline

Definition at line 2377 of file format.h.

2377  {
2379  int num_digits = 0;
2380  do {
2381  ++num_digits;
2382  } while ((n >>= BITS) != 0);
2383  return num_digits;
2384  }
unsigned_type abs_value
Definition: format.h:2369
std::size_t n
Definition: format.h:3399
internal::int_traits< Int >::main_type unsigned_type
Definition: format.h:2365
template<typename Range>
template<typename Int , typename Spec >
string_view basic_writer< Range >::int_writer< Int, Spec >::get_prefix ( ) const
inline

Definition at line 2373 of file format.h.

2373 { return string_view(prefix, prefix_size); }
basic_string_view< char > string_view
Definition: core.h:428
template<typename Range>
template<typename Int , typename Spec >
void basic_writer< Range >::int_writer< Int, Spec >::on_bin ( )
inline

Definition at line 2447 of file format.h.

2447  {
2448  if (spec.has(HASH_FLAG)) {
2449  prefix[prefix_size++] = '0';
2450  prefix[prefix_size++] = static_cast<char>(spec.type);
2451  }
2452  int num_digits = count_digits<1>();
2453  writer.write_int(num_digits, get_prefix(), spec,
2454  bin_writer<1>{abs_value, num_digits});
2455  }
string_view get_prefix() const
Definition: format.h:2373
void write_int(int num_digits, string_view prefix, const Spec &spec, F f)
Definition: format.h:2326
const Spec & spec
Definition: format.h:2368
unsigned_type abs_value
Definition: format.h:2369
template<typename Range>
template<typename Int , typename Spec >
void basic_writer< Range >::int_writer< Int, Spec >::on_dec ( )
inline

Definition at line 2409 of file format.h.

2409  {
2410  int num_digits = internal::count_digits(abs_value);
2411  writer.write_int(num_digits, get_prefix(), spec,
2412  dec_writer{abs_value, num_digits});
2413  }
string_view get_prefix() const
Definition: format.h:2373
void write_int(int num_digits, string_view prefix, const Spec &spec, F f)
Definition: format.h:2326
const Spec & spec
Definition: format.h:2368
unsigned_type abs_value
Definition: format.h:2369
int count_digits(uint64_t n)
Definition: format.h:777
template<typename Range>
template<typename Int , typename Spec >
void basic_writer< Range >::int_writer< Int, Spec >::on_error ( )
inline

Definition at line 2492 of file format.h.

2492  {
2493  FMT_THROW(format_error("invalid type specifier"));
2494  }
#define FMT_THROW(x)
Definition: format.h:115
template<typename Range>
template<typename Int , typename Spec >
void basic_writer< Range >::int_writer< Int, Spec >::on_hex ( )
inline

Definition at line 2426 of file format.h.

2426  {
2427  if (spec.has(HASH_FLAG)) {
2428  prefix[prefix_size++] = '0';
2429  prefix[prefix_size++] = static_cast<char>(spec.type);
2430  }
2431  int num_digits = count_digits<4>();
2432  writer.write_int(num_digits, get_prefix(), spec,
2433  hex_writer{*this, num_digits});
2434  }
string_view get_prefix() const
Definition: format.h:2373
void write_int(int num_digits, string_view prefix, const Spec &spec, F f)
Definition: format.h:2326
const Spec & spec
Definition: format.h:2368
template<typename Range>
template<typename Int , typename Spec >
void basic_writer< Range >::int_writer< Int, Spec >::on_num ( )
inline

Definition at line 2484 of file format.h.

2484  {
2485  int num_digits = internal::count_digits(abs_value);
2486  char_type sep = internal::thousands_sep<char_type>(writer.locale_);
2487  int size = num_digits + SEP_SIZE * ((num_digits - 1) / 3);
2489  num_writer{abs_value, size, sep});
2490  }
internal::locale_ref locale_
Definition: format.h:2267
string_view get_prefix() const
Definition: format.h:2373
void write_int(int num_digits, string_view prefix, const Spec &spec, F f)
Definition: format.h:2326
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:87
const Spec & spec
Definition: format.h:2368
unsigned_type abs_value
Definition: format.h:2369
Range::value_type char_type
Definition: format.h:2261
int count_digits(uint64_t n)
Definition: format.h:777
template<typename Range>
template<typename Int , typename Spec >
void basic_writer< Range >::int_writer< Int, Spec >::on_oct ( )
inline

Definition at line 2457 of file format.h.

2457  {
2458  int num_digits = count_digits<3>();
2459  if (spec.has(HASH_FLAG) &&
2460  spec.precision <= num_digits) {
2461  // Octal prefix '0' is counted as a digit, so only add it if precision
2462  // is not greater than the number of digits.
2463  prefix[prefix_size++] = '0';
2464  }
2465  writer.write_int(num_digits, get_prefix(), spec,
2466  bin_writer<3>{abs_value, num_digits});
2467  }
string_view get_prefix() const
Definition: format.h:2373
void write_int(int num_digits, string_view prefix, const Spec &spec, F f)
Definition: format.h:2326
const Spec & spec
Definition: format.h:2368
unsigned_type abs_value
Definition: format.h:2369

Member Data Documentation

template<typename Range>
template<typename Int , typename Spec >
unsigned_type basic_writer< Range >::int_writer< Int, Spec >::abs_value

Definition at line 2369 of file format.h.

template<typename Range>
template<typename Int , typename Spec >
char basic_writer< Range >::int_writer< Int, Spec >::prefix[4]

Definition at line 2370 of file format.h.

template<typename Range>
template<typename Int , typename Spec >
unsigned basic_writer< Range >::int_writer< Int, Spec >::prefix_size

Definition at line 2371 of file format.h.

template<typename Range>
template<typename Int , typename Spec >
const Spec& basic_writer< Range >::int_writer< Int, Spec >::spec

Definition at line 2368 of file format.h.

template<typename Range>
template<typename Int , typename Spec >
basic_writer<Range>& basic_writer< Range >::int_writer< Int, Spec >::writer

Definition at line 2367 of file format.h.


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