FastArduino v1.10
C++ library to build fast but small Arduino/AVR projects
Loading...
Searching...
No Matches
streams::null_ostream Class Reference

Implements an empty formatted output that does nothing. More...

#include <fastarduino/empty_streams.h>

Detailed Description

Implements an empty formatted output that does nothing.

It can be used everywhere a streams::ostream is expected but produces no code at all. The following example shows how to add traces that can be disabled at compile time by defining a specific macro:

// Include the right header
#ifdef NO_TRACE
#else
#endif
//...
// Instantiate the right output
#ifdef NO_TRACE
#else
// We use UART for tracing
static char output_buffer[64];
auto trace = uatx.out();
#endif
//...
// Directly use trace anywhere, this won't generate any code if `NO_TRACE`
// was defined at compile time
void f(int value)
{
//... do something
trace << F("DEBUG") << value << streams::endl;
//... do something else
}
Hardware serial transmitter API.
Definition: uart.h:241
Implements an empty formatted output that does nothing.
Definition: empty_streams.h:70
Empty version of streams API, useful when you want to introduce traces that you can easily disable wi...
#define F(ptr)
Force string constant to be stored as flash storage.
Definition: flash.h:150
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
C++-like std::iostream facilities.

Definition at line 69 of file empty_streams.h.


The documentation for this class was generated from the following file: