Embedded Template Library
1.0
Toggle main menu visibility
Loading...
Searching...
No Matches
print.h
Go to the documentation of this file.
1
2
3
/******************************************************************************
4
The MIT License(MIT)
5
6
Embedded Template Library.
7
https://github.com/ETLCPP/etl
8
https://www.etlcpp.com
9
10
Copyright(c) 2025 BMW AG
11
12
Permission is hereby granted, free of charge, to any person obtaining a copy
13
of this software and associated documentation files(the "Software"), to deal
14
in the Software without restriction, including without limitation the rights
15
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
16
copies of the Software, and to permit persons to whom the Software is
17
furnished to do so, subject to the following conditions :
18
19
The above copyright notice and this permission notice shall be included in all
20
copies or substantial portions of the Software.
21
22
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
25
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
26
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
27
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
28
SOFTWARE.
29
******************************************************************************/
30
31
#ifndef ETL_PRINT_INCLUDED
32
#define ETL_PRINT_INCLUDED
33
34
#include "
platform.h
"
35
36
#include "
format.h
"
37
38
#if ETL_USING_CPP11
39
40
// to be implemented in a concrete project, typically printing to a serial
41
// console type int here is the convention from putchar(), actually storing char
42
extern
"C"
void
etl_putchar(
int
c);
43
44
namespace
etl
45
{
46
namespace
private_print
47
{
48
using
char_type = etl::private_format::char_type;
49
50
// No-op iterator that forwards all assignments to etl_putchar
51
class
print_iterator
52
{
53
public
:
54
55
class
print_to
56
{
57
public
:
58
59
print_to& operator=(char_type c)
60
{
61
etl_putchar(
static_cast<
int
>
(c));
62
return
*
this
;
63
}
64
};
65
66
print_iterator() {}
67
68
print_iterator(
const
print_iterator&) {}
69
70
print_iterator& operator=(
const
print_iterator&)
71
{
72
return
*
this
;
73
}
74
75
print_to
operator*
()
76
{
77
return
print_to();
78
}
79
80
print_iterator& operator++()
81
{
82
return
*
this
;
83
}
84
85
print_iterator operator++(
int
)
86
{
87
return
*
this
;
88
}
89
};
90
}
// namespace private_print
91
92
template
<
class
... Args>
93
void
print(etl::format_string<Args...> fmt, Args&&... args)
94
{
95
private_print::print_iterator it;
96
(void)format_to(it, etl::move(fmt), etl::forward<Args>(args)...);
97
}
98
99
inline
void
println()
100
{
101
etl_putchar(
static_cast<
int
>
(
'\n'
));
102
}
103
104
template
<
class
... Args>
105
void
println(etl::format_string<Args...> fmt, Args&&... args)
106
{
107
private_print::print_iterator it;
108
(void)format_to(it, etl::move(fmt), etl::forward<Args>(args)...);
109
println();
110
}
111
}
// namespace etl
112
113
#endif
114
115
#endif
format.h
etl
Definition
absolute.h:40
etl::operator*
ETL_CONSTEXPR14 enable_if<!etl::is_specialization< TRep2, etl::chrono::duration >::value, etl::chrono::duration< typenameetl::common_type< TRep1, TRep2 >::type, TPeriod1 > >::type operator*(const etl::chrono::duration< TRep1, TPeriod1 > &lhs, const TRep2 &rhs) ETL_NOEXCEPT
Operator *.
Definition
duration.h:541
platform.h
include
etl
print.h
Generated on
for Embedded Template Library by
1.17.0