zpp
Zephyr C++20 Framework
zpp::internal Namespace Reference

Functions

void print_arg () noexcept
 
void print_arg (bool v) noexcept
 
void print_arg (float v) noexcept
 
void print_arg (double v) noexcept
 
void print_arg (char v) noexcept
 
void print_arg (const char *v) noexcept
 
void print_arg (const void *v) noexcept
 
void print_arg (uint8_t v) noexcept
 
void print_arg (int8_t v) noexcept
 
void print_arg (uint16_t v) noexcept
 
void print_arg (int16_t v) noexcept
 
void print_arg (uint32_t v) noexcept
 
void print_arg (int32_t v) noexcept
 
void print_arg (uint64_t v) noexcept
 
void print_arg (int64_t v) noexcept
 
template<class T_Rep , class T_Period >
void print_arg (std::chrono::duration< T_Rep, T_Period > v)
 
template<class T_Clock >
void print_arg (std::chrono::time_point< T_Clock > v)
 
void print_helper (const char *fmt) noexcept
 
template<class T_FirstArg , class ... T_Args>
void print_helper (const char *fmt, T_FirstArg &&first, T_Args &&... args) noexcept
 

Function Documentation

◆ print_arg() [1/17]

void zpp::internal::print_arg ( )
inlinenoexcept

Definition at line 21 of file fmt.hpp.

21 { }

Referenced by print_arg(), and print_helper().

◆ print_arg() [2/17]

void zpp::internal::print_arg ( bool  v)
inlinenoexcept

Definition at line 22 of file fmt.hpp.

22 { printk("%d", (int)v); }

◆ print_arg() [3/17]

void zpp::internal::print_arg ( char  v)
inlinenoexcept

Definition at line 25 of file fmt.hpp.

25 { printk("%c", v); }

◆ print_arg() [4/17]

void zpp::internal::print_arg ( const char *  v)
inlinenoexcept

Definition at line 26 of file fmt.hpp.

26 { printk("%s", v); }

◆ print_arg() [5/17]

void zpp::internal::print_arg ( const void *  v)
inlinenoexcept

Definition at line 27 of file fmt.hpp.

27 { printk("%p", v); }

◆ print_arg() [6/17]

void zpp::internal::print_arg ( double  v)
inlinenoexcept

Definition at line 24 of file fmt.hpp.

24 { printk("%g", v); }

◆ print_arg() [7/17]

void zpp::internal::print_arg ( float  v)
inlinenoexcept

Definition at line 23 of file fmt.hpp.

23 { printk("%f", v); }

◆ print_arg() [8/17]

void zpp::internal::print_arg ( int16_t  v)
inlinenoexcept

Definition at line 31 of file fmt.hpp.

31 { printk("%d", (int32_t)v); }

◆ print_arg() [9/17]

void zpp::internal::print_arg ( int32_t  v)
inlinenoexcept

Definition at line 33 of file fmt.hpp.

33 { printk("%d", v); }

◆ print_arg() [10/17]

void zpp::internal::print_arg ( int64_t  v)
inlinenoexcept

Definition at line 35 of file fmt.hpp.

35 { printk("%lld", v); }

◆ print_arg() [11/17]

void zpp::internal::print_arg ( int8_t  v)
inlinenoexcept

Definition at line 29 of file fmt.hpp.

29 { printk("%d", (int32_t)v); }

◆ print_arg() [12/17]

template<class T_Rep , class T_Period >
void zpp::internal::print_arg ( std::chrono::duration< T_Rep, T_Period >  v)
inline

Definition at line 38 of file fmt.hpp.

39 {
40  using namespace std::chrono;
41 
42  auto s = duration_cast<seconds>(v);
43  v -= duration_cast<decltype(v)>(s);
44  auto ms = duration_cast<milliseconds>(v);
45  v -= duration_cast<decltype(v)>(ms);
46  auto us = duration_cast<microseconds>(v);
47  v -= duration_cast<decltype(v)>(us);
48  auto ns = duration_cast<nanoseconds>(v);
49 
50  printk("%d.%03d%03d%03ds",
51  (int)s.count(), (int)ms.count(),
52  (int)us.count(), (int)ns.count());
53 }

◆ print_arg() [13/17]

template<class T_Clock >
void zpp::internal::print_arg ( std::chrono::time_point< T_Clock >  v)
inline

Definition at line 56 of file fmt.hpp.

57 {
58  print_arg(v.time_since_epoch());
59 }
void print_arg(std::chrono::time_point< T_Clock > v)
Definition: fmt.hpp:56

References print_arg().

◆ print_arg() [14/17]

void zpp::internal::print_arg ( uint16_t  v)
inlinenoexcept

Definition at line 30 of file fmt.hpp.

30 { printk("%d", (uint32_t)v); }

◆ print_arg() [15/17]

void zpp::internal::print_arg ( uint32_t  v)
inlinenoexcept

Definition at line 32 of file fmt.hpp.

32 { printk("%d", v); }

◆ print_arg() [16/17]

void zpp::internal::print_arg ( uint64_t  v)
inlinenoexcept

Definition at line 34 of file fmt.hpp.

34 { printk("%lld", v); }

◆ print_arg() [17/17]

void zpp::internal::print_arg ( uint8_t  v)
inlinenoexcept

Definition at line 28 of file fmt.hpp.

28 { printk("%d", (uint32_t)v); }

◆ print_helper() [1/2]

void zpp::internal::print_helper ( const char *  fmt)
inlinenoexcept

Definition at line 61 of file fmt.hpp.

62 {
63  printk("%s", fmt);
64 }

Referenced by zpp::print(), and print_helper().

◆ print_helper() [2/2]

template<class T_FirstArg , class ... T_Args>
void zpp::internal::print_helper ( const char *  fmt,
T_FirstArg &&  first,
T_Args &&...  args 
)
inlinenoexcept

Definition at line 67 of file fmt.hpp.

68 {
69  enum class state { normal, format, open_brace, close_brace, done };
70 
71  state s = state::normal;
72  size_t n = 0;
73 
74  while (true) {
75  char c = fmt[n++];
76 
77  if (c == '\0') {
78  return;
79  }
80 
81  switch (s) {
82  case state::normal:
83  switch (c) {
84  case '{':
85  s = state::open_brace;
86  break;
87  case '}':
88  s = state::close_brace;
89  break;
90  default:
91  printk("%c", c);
92  break;
93  }
94  break;
95 
96  case state::open_brace:
97  switch(c) {
98  case '{':
99  s = state::normal;
100  printk("{");
101  break;
102 
103  case '}':
104  s = state::done;
105  break;
106 
107  default:
108  s = state::format;
109  break;
110  }
111  break;
112 
113  case state::close_brace:
114  if (c == '}') {
115  printk("}");
116  }
117  s = state::normal;
118  break;
119 
120  case state::format:
121  switch (c) {
122  case '}':
123  s = state::done;
124  break;
125  default:
126  break;
127  }
128  break;
129 
130  case state::done:
131  break;
132 
133  }
134 
135  if (s == state::done) {
136  break;
137  }
138  }
139 
140  print_arg(std::forward<T_FirstArg>(first));
141  print_helper(&(fmt[n]), std::forward<T_Args>(args)...);
142 }
void print_helper(const char *fmt, T_FirstArg &&first, T_Args &&... args) noexcept
Definition: fmt.hpp:67

References print_arg(), and print_helper().