FBB::MultiStreambuf(3bobcat)

Writing multiple streams
(libbobcat-dev_4.08.03-x.tar.gz)

2005-2018

NAME

FBB::MultiStreambuf - Selectively writes multiple streams

SYNOPSIS

#include <bobcat/multistreambuf>
Linking option: -lbobcat

DESCRIPTION

The FBB::MultiStreambuf class is a specialization of std::streambuf. It can be used to write selectively to multiple std::ostreams. Each std::ostream that is associated with a MultiStreambuf is given a mode-tag indicating whether the stream should always be used when information is inserted into the MultiStreambuf, just once, or not at all. Each of the stream's mode-tags may be set to any of the defined tag-values.

When the address of a MultiStreambuf is used to initialize a std::ostream the constructed std::ostream becomes an output-multiplexer: by inserting information into the std::ostream object, all std::ostream objects added to its MultiStreambuf buffer which have an active mode receive that information.

An MultiStreambuf object should be outlived by all active streams that are associated with it.

MultiStreambuf objects refer to std::ostreams which are passed to it, and not to their std::streambufs. So it is possible to change these std::ostream's std::streambufs without reinstalling the std::ostreams themselves.

No assumptions should be made about the order in which the std::ostream objects that are associated with the MultiStreambuf objects are visited when information is inserted.

NAMESPACE

FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.

INHERITS FROM

std::streambuf

ENUMERATION

In the Mode enumeration the following values are defined:

TYPES

The following subtypes are defined in the class FBB:MultiStreambuf:

NESTED CLASS

The class MultiStreambuf::stream is defined as a nested class of MultiStreambuf. It offers the following constructor and public members:

CONSTRUCTORS

The copy constructor is available.

MEMBER FUNCTIONS

All members of std::ostringstream and std::exception are available, as MultiStreambuf inherits from these classes.

PROTECTED MEMBER FUNCTION

The member listed in this section implements the tasks of the comparably named virtual function in the class's private interface. This separates the redefinable interface from the user-interface. The class MultiStreamBuf can, in accordance with Liskov's Substitution Principle, be used as a std:streambuf; but it also offers a facility for classes deriving from MultiStreamBuf. This facility is listed here.

EXAMPLE


#include <iostream>
#include <fstream>
#include <bobcat/multistreambuf>

using namespace std;
using namespace FBB;

int main()
{
    MultiStreambuf  msb(cout);
    ostream         os(&msb);
    ofstream        out("out");

    msb.insert(out, MultiStreambuf::ONCE);

    os << "This is on cout and out" << endl;
    os << "This is on cout only" << endl;

    msb.setOnce();
    os << "This is on cout and out" << endl;
    os << "This is on cout only" << endl;

    return 0;
}
    

FILES

bobcat/multistreambuf - defines the class interface

SEE ALSO

bobcat(7)

BUGS

None Reported.

DISTRIBUTION FILES

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'.

COPYRIGHT

This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).