FastArduino  v1.8
C++ library to build fast but small Arduino/AVR projects
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
}

Definition at line 69 of file empty_streams.h.


The documentation for this class was generated from the following file:
empty_streams.h
Empty version of streams API, useful when you want to introduce traces that you can easily disable wi...
streams.h
C++-like std::iostream facilities.
serial::hard::UATX
Hardware serial transmitter API.
Definition: uart.h:241
streams::endl
void endl(FSTREAM &stream)
Manipulator for an output stream, which will insert a new-line character and flush the stream buffer.
Definition: streams.h:722
streams::null_ostream
Implements an empty formatted output that does nothing.
Definition: empty_streams.h:70
F
#define F(ptr)
Force string constant to be stored as flash storage.
Definition: flash.h:118