StuBS
CopyStream Class Reference

Duplicate all data passed by the stream operator to two output streams. More...

#include <debug/copystream.h>

Inheritance diagram for CopyStream:
[legend]
Collaboration diagram for CopyStream:
[legend]

Public Member Functions

 CopyStream (OutputStream *first, OutputStream *second)
 Constructor.
 
template<typename T >
CopyStreamoperator<< (T value)
 Generic stream operator for any data type.
 
template<typename T >
CopyStreamoperator<< (T &(*f)(T &))
 Deal with [OutputStream] manipulator functions.
 
- Public Member Functions inherited from OutputStream
 OutputStream ()
 Default constructor. Initial number system is decimal.
 
virtual ~OutputStream ()
 Destructor.
 
virtual void flush ()=0
 Clears the buffer.
 
OutputStreamoperator<< (char c)
 Print a single character.
 
OutputStreamoperator<< (unsigned char c)
 Print a single character.
 
OutputStreamoperator<< (const char *string)
 Printing a null-terminated string.
 
OutputStreamoperator<< (bool b)
 Print a boolean value.
 
OutputStreamoperator<< (short ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (unsigned short ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (int ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (unsigned int ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (long ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (unsigned long ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (long long ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (unsigned long long ival)
 Print an integral number in radix base
 
OutputStreamoperator<< (const void *ptr)
 Print a pointer as hexadecimal number.
 
OutputStreamoperator<< (OutputStream &(*f)(OutputStream &))
 Calls one of the manipulator functions.
 
- Public Member Functions inherited from Stringbuffer
virtual ~Stringbuffer ()
 Destructor (nothing to do here)
 

Private Attributes

OutputStreamfirst
 First recipient.
 
OutputStreamsecond
 Second recipient.
 

Additional Inherited Members

- Public Attributes inherited from OutputStream
int base
 Number system used for printing integral numbers (one of 2, 8, 10, or 16)
 
- Protected Member Functions inherited from Stringbuffer
 Stringbuffer ()
 Constructor; Marks the buffer as empty.
 
void put (char c)
 Inserts a character into the buffer.
 
- Protected Attributes inherited from Stringbuffer
char buffer [80]
 buffer containing characters that will be printed upon flush()
 
long unsigned pos
 current position in the buffer
 

Detailed Description

Duplicate all data passed by the stream operator to two output streams.

Can be used as replacement for any OutputStream – for example, forwarding the DBG output simultaneously to screen (TextStream) and serial console (SerialStream).

By using template programming, two generic methods are sufficient (which simply forward the input to both).

Constructor & Destructor Documentation

◆ CopyStream()

CopyStream::CopyStream ( OutputStream first,
OutputStream second 
)
inline

Constructor.

Parameters
firstFirst recipient for output passed to this object
secondSecond recipient for output passed to this object

Member Function Documentation

◆ operator<<() [1/2]

template<typename T >
CopyStream & CopyStream::operator<< ( value)
inline

Generic stream operator for any data type.

Forwards all input to both recipients.

Uses template meta programming for a generic & short solution

Template Parameters
TType of data to be forwarded
Parameters
valuedata to be forwarded
Returns
Reference to the CopyStream object allowing concatenation of operators

◆ operator<<() [2/2]

template<typename T >
CopyStream & CopyStream::operator<< ( T &(*)(T &)  f)
inline

Deal with [OutputStream] manipulator functions.

Template Parameters
TManipulator type
Parameters
fpointer to manipulator function
Returns
Reference to the CopyStream object allowing concatenation of operators

Member Data Documentation

◆ first

OutputStream* CopyStream::first
private

First recipient.

◆ second

OutputStream* CopyStream::second
private

Second recipient.


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