FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
empty_streams.h
Go to the documentation of this file.
1// Copyright 2016-2023 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
16
25#ifndef EMPTYSTREAMS_HH
26#define EMPTYSTREAMS_HH
27
28#include <stddef.h>
29#include "ios.h"
30#include "flash.h"
31#include "utilities.h"
32
33namespace streams
34{
70 {
71 public:
73 null_ostream() = default;
74 null_ostream(const null_ostream&) = delete;
75 null_ostream& operator=(const null_ostream&) = delete;
76
77 void setf(ios::fmtflags flags UNUSED) {}
78
79 void setf(ios::fmtflags flags UNUSED, ios::fmtflags mask UNUSED) {}
80
81 void unsetf(ios::fmtflags flags UNUSED) {}
82
83 void fill(char fill UNUSED) {}
84
85 void width(uint8_t width UNUSED) {}
86
87 void precision(uint8_t precision UNUSED) {}
88
89 void flush() {}
90 void put(char val UNUSED) {}
91 void write(const char* content UNUSED, size_t size UNUSED) {}
92 void write(const char* str UNUSED) {}
93 void write(const flash::FlashStorage* str UNUSED) {}
94
95 null_ostream& operator<<(const void* ptr UNUSED)
96 {
97 return *this;
98 }
99 null_ostream& operator<<(bool val UNUSED)
100 {
101 return *this;
102 }
103 null_ostream& operator<<(char val UNUSED)
104 {
105 return *this;
106 }
107 null_ostream& operator<<(const char* str UNUSED)
108 {
109 return *this;
110 }
111 null_ostream& operator<<(int val UNUSED)
112 {
113 return *this;
114 }
115 null_ostream& operator<<(unsigned int val UNUSED)
116 {
117 return *this;
118 }
119 null_ostream& operator<<(long val UNUSED)
120 {
121 return *this;
122 }
123 null_ostream& operator<<(unsigned long val UNUSED)
124 {
125 return *this;
126 }
127 null_ostream& operator<<(double val UNUSED)
128 {
129 return *this;
130 }
131
132 typedef void (*Manipulator)(null_ostream&);
133 null_ostream& operator<<(Manipulator func UNUSED)
134 {
135 return *this;
136 }
138 };
139
141 inline void bin(null_ostream& stream UNUSED) {}
142 inline void oct(null_ostream& stream UNUSED) {}
143 inline void dec(null_ostream& stream UNUSED) {}
144 inline void hex(null_ostream& stream UNUSED) {}
145 inline void flush(null_ostream& stream UNUSED) {}
146 inline void endl(null_ostream& stream UNUSED) {}
147 inline void skipws(null_ostream& stream UNUSED) {}
148 inline void noskipws(null_ostream& stream UNUSED) {}
149 inline void boolalpha(null_ostream& stream UNUSED) {}
150 inline void noboolalpha(null_ostream& stream UNUSED) {}
151 inline void showbase(null_ostream& stream UNUSED) {}
152 inline void noshowbase(null_ostream& stream UNUSED) {}
153 inline void showpos(null_ostream& stream UNUSED) {}
154 inline void noshowpos(null_ostream& stream UNUSED) {}
155 inline void uppercase(null_ostream& stream UNUSED) {}
156 inline void nouppercase(null_ostream& stream UNUSED) {}
157 inline void unitbuf(null_ostream& stream UNUSED) {}
158 inline void nounitbuf(null_ostream& stream UNUSED) {}
159 inline void left(null_ostream& stream UNUSED) {}
160 inline void right(null_ostream& stream UNUSED) {}
161 inline void fixed(null_ostream& stream UNUSED) {}
162 inline void scientific(null_ostream& stream UNUSED) {}
164}
165
166#endif /* EMPTYSTREAMS_HH */
uint16_t fmtflags
Bitmask type to represent stream format flags.
Definition: ios.h:209
Implements an empty formatted output that does nothing.
Definition: empty_streams.h:70
#define UNUSED
Specific GCC attribute to declare an argument or variable unused, so that the compiler does not emit ...
Definition: defines.h:45
Flash memory utilities.
C++-like std::iostream facilities.
Defines C++-like streams API, based on circular buffers for input or output.
Definition: empty_streams.h:34
void flush(FSTREAM &stream)
Manipulator for an output stream, which will flush the stream buffer.
Definition: streams.h:716
void endl(FSTREAM &stream)
Manipulator for an output stream, which will insert a new-line character and flush the stream buffer.
Definition: streams.h:725
void noboolalpha(FSTREAM &stream)
Clear the ios::boolalpha format flag for stream.
Definition: ios.h:801
void nounitbuf(FSTREAM &stream)
Clear the ios::unitbuf format flag for stream.
Definition: ios.h:922
void showbase(FSTREAM &stream)
Set the ios::showbase format flag for stream.
Definition: ios.h:821
void nouppercase(FSTREAM &stream)
Clear the ios::uppercase format flag for stream.
Definition: ios.h:892
void noskipws(FSTREAM &stream)
Manipulator for an input stream, which will deactivate whitespace discarding before formatted input o...
Definition: ios.h:738
void right(FSTREAM &stream)
Set the ios::adjustfield format flag for stream to ios::right, thus adjusting next output to the righ...
Definition: ios.h:948
void skipws(FSTREAM &stream)
Manipulator for an input stream, which will activate whitespace discarding before formatted input ope...
Definition: ios.h:729
void bin(FSTREAM &stream)
Manipulator for an output or input stream, which will set the base, used to represent (output) or int...
Definition: ios.h:747
void boolalpha(FSTREAM &stream)
Set the ios::boolalpha format flag for stream.
Definition: ios.h:788
void showpos(FSTREAM &stream)
Set the ios::showpos format flag for stream.
Definition: ios.h:849
void hex(FSTREAM &stream)
Manipulator for an output or input stream, which will set the base, used to represent (output) or int...
Definition: ios.h:774
void scientific(FSTREAM &stream)
Set the ios::floatfield format flag for stream to ios::scientific.
Definition: ios.h:1000
void oct(FSTREAM &stream)
Manipulator for an output or input stream, which will set the base, used to represent (output) or int...
Definition: ios.h:756
void uppercase(FSTREAM &stream)
Set the ios::uppercase format flag for stream.
Definition: ios.h:877
void fixed(FSTREAM &stream)
Set the ios::floatfield format flag for stream to ios::fixed.
Definition: ios.h:982
void noshowpos(FSTREAM &stream)
Clear the ios::showpos format flag for stream.
Definition: ios.h:862
void dec(FSTREAM &stream)
Manipulator for an output or input stream, which will set the base, used to represent (output) or int...
Definition: ios.h:765
void unitbuf(FSTREAM &stream)
Set the ios::unitbuf format flag for stream.
Definition: ios.h:906
void noshowbase(FSTREAM &stream)
Clear the ios::showbase format flag for stream.
Definition: ios.h:836
void left(FSTREAM &stream)
Set the ios::adjustfield format flag for stream to ios::left, thus adjusting next output to the left.
Definition: ios.h:935
General utilities API that have broad application in programs.