Functions
spdlog::details::fmt_helper Namespace Reference

Functions

template<size_t Buffer_Size>
spdlog::string_view_t to_string_view (const fmt::basic_memory_buffer< char, Buffer_Size > &buf) SPDLOG_NOEXCEPT
 
template<size_t Buffer_Size1, size_t Buffer_Size2>
void append_buf (const fmt::basic_memory_buffer< char, Buffer_Size1 > &buf, fmt::basic_memory_buffer< char, Buffer_Size2 > &dest)
 
template<size_t Buffer_Size>
void append_string_view (spdlog::string_view_t view, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
 
template<typename T , size_t Buffer_Size>
void append_int (T n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
 
template<typename T >
unsigned count_digits (T n)
 
template<size_t Buffer_Size>
void pad2 (int n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
 
template<typename T , size_t Buffer_Size>
void pad_uint (T n, unsigned int width, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
 
template<typename T , size_t Buffer_Size>
void pad3 (T n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
 
template<typename T , size_t Buffer_Size>
void pad6 (T n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
 
template<typename T , size_t Buffer_Size>
void pad9 (T n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
 
template<typename ToDuration >
ToDuration time_fraction (const log_clock::time_point &tp)
 

Function Documentation

template<size_t Buffer_Size1, size_t Buffer_Size2>
void spdlog::details::fmt_helper::append_buf ( const fmt::basic_memory_buffer< char, Buffer_Size1 > &  buf,
fmt::basic_memory_buffer< char, Buffer_Size2 > &  dest 
)
inline

Definition at line 23 of file fmt_helper.h.

24 {
25  auto *buf_ptr = buf.data();
26  dest.append(buf_ptr, buf_ptr + buf.size());
27 }
template<typename T , size_t Buffer_Size>
void spdlog::details::fmt_helper::append_int ( n,
fmt::basic_memory_buffer< char, Buffer_Size > &  dest 
)
inline

Definition at line 40 of file fmt_helper.h.

41 {
42  fmt::format_int i(n);
43  dest.append(i.data(), i.data() + i.size());
44 }
std::size_t n
Definition: format.h:3399
template<size_t Buffer_Size>
void spdlog::details::fmt_helper::append_string_view ( spdlog::string_view_t  view,
fmt::basic_memory_buffer< char, Buffer_Size > &  dest 
)
inline

Definition at line 30 of file fmt_helper.h.

31 {
32  auto *buf_ptr = view.data();
33  if (buf_ptr != nullptr)
34  {
35  dest.append(buf_ptr, buf_ptr + view.size());
36  }
37 }
template<typename T >
unsigned spdlog::details::fmt_helper::count_digits ( n)
inline

Definition at line 47 of file fmt_helper.h.

48 {
49  using count_type = typename std::conditional<(sizeof(T) > sizeof(uint32_t)), uint64_t, uint32_t>::type;
50  return static_cast<unsigned>(fmt::internal::count_digits(static_cast<count_type>(n)));
51 }
unsigned int uint32_t
Definition: stdint.h:126
unsigned __int64 uint64_t
Definition: stdint.h:136
static QCString type
Definition: declinfo.cpp:672
std::size_t n
Definition: format.h:3399
unsigned count_digits(T n)
Definition: fmt_helper.h:47
template<size_t Buffer_Size>
void spdlog::details::fmt_helper::pad2 ( int  n,
fmt::basic_memory_buffer< char, Buffer_Size > &  dest 
)
inline

Definition at line 54 of file fmt_helper.h.

55 {
56  if (n > 99)
57  {
58  append_int(n, dest);
59  }
60  else if (n > 9) // 10-99
61  {
62  dest.push_back(static_cast<char>('0' + n / 10));
63  dest.push_back(static_cast<char>('0' + n % 10));
64  }
65  else if (n >= 0) // 0-9
66  {
67  dest.push_back('0');
68  dest.push_back(static_cast<char>('0' + n));
69  }
70  else // negatives (unlikely, but just in case, let fmt deal with it)
71  {
72  fmt::format_to(dest, "{:02}", n);
73  }
74 }
void append_int(T n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
Definition: fmt_helper.h:40
std::enable_if< is_contiguous< Container >::value &&internal::is_string< S >::value, std::back_insert_iterator< Container > >::type format_to(std::back_insert_iterator< Container > out, const S &format_str, const Args &...args)
Definition: core.h:1430
std::size_t n
Definition: format.h:3399
template<typename T , size_t Buffer_Size>
void spdlog::details::fmt_helper::pad3 ( n,
fmt::basic_memory_buffer< char, Buffer_Size > &  dest 
)
inline

Definition at line 90 of file fmt_helper.h.

91 {
92  pad_uint(n, 3, dest);
93 }
void pad_uint(T n, unsigned int width, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
Definition: fmt_helper.h:77
std::size_t n
Definition: format.h:3399
template<typename T , size_t Buffer_Size>
void spdlog::details::fmt_helper::pad6 ( n,
fmt::basic_memory_buffer< char, Buffer_Size > &  dest 
)
inline

Definition at line 96 of file fmt_helper.h.

97 {
98  pad_uint(n, 6, dest);
99 }
void pad_uint(T n, unsigned int width, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
Definition: fmt_helper.h:77
std::size_t n
Definition: format.h:3399
template<typename T , size_t Buffer_Size>
void spdlog::details::fmt_helper::pad9 ( n,
fmt::basic_memory_buffer< char, Buffer_Size > &  dest 
)
inline

Definition at line 102 of file fmt_helper.h.

103 {
104  pad_uint(n, 9, dest);
105 }
void pad_uint(T n, unsigned int width, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
Definition: fmt_helper.h:77
std::size_t n
Definition: format.h:3399
template<typename T , size_t Buffer_Size>
void spdlog::details::fmt_helper::pad_uint ( n,
unsigned int  width,
fmt::basic_memory_buffer< char, Buffer_Size > &  dest 
)
inline

Definition at line 77 of file fmt_helper.h.

78 {
79  static_assert(std::is_unsigned<T>::value, "pad_uint must get unsigned T");
80  auto digits = count_digits(n);
81  if (width > digits)
82  {
83  const char *zeroes = "0000000000000000000";
84  dest.append(zeroes, zeroes + width - digits);
85  }
86  append_int(n, dest);
87 }
void append_int(T n, fmt::basic_memory_buffer< char, Buffer_Size > &dest)
Definition: fmt_helper.h:40
const double width
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
std::size_t n
Definition: format.h:3399
unsigned count_digits(T n)
Definition: fmt_helper.h:47
template<typename ToDuration >
ToDuration spdlog::details::fmt_helper::time_fraction ( const log_clock::time_point &  tp)
inline

Definition at line 111 of file fmt_helper.h.

112 {
113  using std::chrono::duration_cast;
114  using std::chrono::seconds;
115  auto duration = tp.time_since_epoch();
116  auto secs = duration_cast<seconds>(duration);
117  return duration_cast<ToDuration>(duration) - duration_cast<ToDuration>(secs);
118 }
second seconds
Alias for common language habits.
Definition: spacetime.h:83
template<size_t Buffer_Size>
spdlog::string_view_t spdlog::details::fmt_helper::to_string_view ( const fmt::basic_memory_buffer< char, Buffer_Size > &  buf)
inline

Definition at line 17 of file fmt_helper.h.

18 {
19  return spdlog::string_view_t(buf.data(), buf.size());
20 }
fmt::string_view string_view_t
Definition: common.h:88