Arduino Helpers master
Utility library for Arduino
PrintStream.hpp
Go to the documentation of this file.
1
5#ifndef PrintStream_h
6#define PrintStream_h
7
8#include <AH/Arduino-Wrapper.h> // Print
10
12
15
16typedef Print &manipulator(Print &);
17
18Print &endl(Print &printer);
19Print &flush(Print &printer);
20Print &hex(Print &printer);
21Print &bin(Print &printer);
22Print &dec(Print &printer);
23/* Print &oct(Print &printer); */
24Print &boolalpha(Print &printer);
25Print &noboolalpha(Print &printer);
26Print &leadingzeros(Print &printer);
27Print &noleadingzeros(Print &printer);
28Print &uppercase(Print &printer);
29Print &nouppercase(Print &printer);
30Print &showbase(Print &printer);
31Print &noshowbase(Print &printer);
32
33Print &operator<<(Print &printer, const __FlashStringHelper *s);
34#ifdef ARDUINO
35Print &operator<<(Print &printer, const String &s);
36#endif
37Print &operator<<(Print &printer, const char s[]);
38Print &operator<<(Print &printer, char c);
39Print &operator<<(Print &printer, unsigned char c);
40Print &operator<<(Print &printer, int i);
41Print &operator<<(Print &printer, unsigned int i);
42Print &operator<<(Print &printer, int8_t i);
43Print &operator<<(Print &printer, long i);
44Print &operator<<(Print &printer, unsigned long i);
45Print &operator<<(Print &printer, float f);
46Print &operator<<(Print &printer, double d);
47Print &operator<<(Print &printer, const Printable &p);
48Print &operator<<(Print &printer, bool b);
49
50Print &operator<<(Print &printer, manipulator pf);
51
52struct Setbase {
53 uint8_t M_base;
54};
55Setbase setbase(uint8_t base);
56Print &operator<<(Print &printer, Setbase f);
57
59 int M_n;
60};
62Print &operator<<(Print &printer, Setprecision f);
63
64struct Setbytesep {
66};
67Setbytesep setbytesep(char bytesep);
68Print &operator<<(Print &printer, Setbytesep f);
69
70struct HexDump {
71 HexDump(const uint8_t *data, size_t length) : data(data), length(length) {}
72 template <size_t N>
73 explicit HexDump(const uint8_t (&data)[N]) : HexDump {data, N} {}
74 const uint8_t *data;
75 size_t length;
76};
77
78Print &operator<<(Print &p, HexDump h);
79
81
83
84#ifndef ARDUINO
85
86#include <iomanip>
87#include <iostream>
88
90
91// TODO: check conflicts between Arduino version and C++ STL version
92using std::endl;
93// using std::setbase;
94// using std::setprecision;
95using std::boolalpha;
96using std::dec;
97using std::flush;
98using std::hex;
100using std::noshowbase;
101using std::nouppercase;
102using std::showbase;
103using std::uppercase;
104
105inline std::ostream &operator<<(std::ostream &os, uint8_t u) {
106 // I'm lazy, I should probably implement one for uint8_t to get the leading
107 // zeros right
108 return os << static_cast<unsigned short>(u);
109}
110
111inline std::ostream &operator<<(std::ostream &os,
112 const __FlashStringHelper *s) {
113 return os << reinterpret_cast<const char *>(s);
114}
115
116std::ostream &operator<<(std::ostream &p, HexDump h);
117
119
120#endif
121
122#endif // PrintStream_h
#define END_AH_NAMESPACE
#define BEGIN_AH_NAMESPACE
Print & hex(Print &printer)
Definition: PrintStream.cpp:62
Print & bin(Print &printer)
Definition: PrintStream.cpp:72
Print & nouppercase(Print &printer)
Definition: PrintStream.cpp:40
Print & endl(Print &printer)
Definition: PrintStream.cpp:27
Print & uppercase(Print &printer)
Definition: PrintStream.cpp:35
Print & flush(Print &printer)
Definition: PrintStream.cpp:55
Print & showbase(Print &printer)
Definition: PrintStream.cpp:45
Print & manipulator(Print &)
Definition: PrintStream.hpp:16
Print & boolalpha(Print &printer)
Definition: PrintStream.cpp:82
Setbytesep setbytesep(char bytesep)
Print & leadingzeros(Print &printer)
Definition: PrintStream.cpp:91
Print & noshowbase(Print &printer)
Definition: PrintStream.cpp:50
Print & dec(Print &printer)
Definition: PrintStream.cpp:77
Print & noboolalpha(Print &printer)
Definition: PrintStream.cpp:86
Print & noleadingzeros(Print &printer)
Definition: PrintStream.cpp:95
Setbase setbase(uint8_t base)
Setprecision setprecision(int n)
Print & operator<<(Print &os, Quaternion e)
Printing.
Definition: Quaternion.cpp:26
const uint8_t * data
Definition: PrintStream.hpp:74
HexDump(const uint8_t *data, size_t length)
Definition: PrintStream.hpp:71
HexDump(const uint8_t(&data)[N])
Definition: PrintStream.hpp:73
size_t length
Definition: PrintStream.hpp:75
uint8_t M_base
Definition: PrintStream.hpp:53
char M_bytesep
Definition: PrintStream.hpp:65