FBB::MultiBuf(3bobcat)

Writing multiple streams
(libbobcat-dev_6.12.00)

2005-2026

NAME

FBB::MultiBuf - Selectively writes multiple streams

SYNOPSIS

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

DESCRIPTION

The FBB::MultiBuf 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 MultiBuf has a mode-tag indicating whether the stream should always be used when information is inserted into the MultiBuf, just once, or not at all.

A std::ostream initialized with the address of a MultiBuf then the constructed std::ostream becomes an output-multiplexer: by inserting information into the std::ostream object all std::ostream objects added to its MultiBuf buffer which have an active mode receive that information.

All active streams passed to a MultiBuf object should outlive the MultiBuf object. It is the responsibility of the MultiBuf user that this requirement is met.

MultiBuf objects insert information to their configured std::ostream objects (not directly to those streams' std::streambuf objects).

No assumptions should be made about the order in which the std::ostream objects that are associated with the MultiBuf 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

The MultiBuf::Mode enumeration defines the following values:

NESTED CLASS

The class MultiBuf::Stream is a nested class of MultiBuf. It offers the following public members:

TYPES

The following types are defined by the class FBB:MultiBuf:

CONSTRUCTORS

Copy and move constructors (and assignment operators) are available.

MEMBER FUNCTIONS

All members of std::ostringstream and std::exception are available, as MultiBuf inherits from these classes. However, the std::streambuf's default seek_off and seek_pos (both returning -1) are used as the streams handled by a MultiBuf object may not all support seek operations.

EXAMPLE


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

using namespace std;
using namespace FBB;

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

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

    os << "This is on cout and out\n"
          "This is on cout only\n";

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

FILES

bobcat/multibuf - defines the class interface

SEE ALSO

bobcat(7)

BUGS

None Reported.

BOBCAT PROJECT FILES

Debian Bobcat project 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).