The FBB::MultiStreambuf class is a specialization of
std::streambuf. It can be used to write selectvely to multiple
std::ostreams. Each std::ostream that is associated with an
FBB::MultiStreambuf is given a mode-tag indicating whether the stream
should always be used when information is inserted into the
FBB::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 FBB::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 FBB::MultiStreambuf buffer which
have an active mode will receive that information.
An FBB::MultiStreambuf object should be outlived by all active streams
that are associated with it.
No assumptions should be made about the order in which the std::ostream
objects that are associated with the FBB::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:
OFF:
A std::ostream having this mode will not be used when information
is inserted into an FBB::MultiStreambuf
ON:
A std::ostream having this mode will be used when information
is inserted into an FBB::MultiStreambuf
ONCE:
A std::ostream having this mode will be used once, until the next
flushing operation, when information is inserted into an
FBB::MultiStreambuf
RESET:
A std::ostream having this mode will not be used when information
is inserted into an FBB::MultiStreambuf. At a flush operation all ONCE
modes will be set to RESET
TYPES
The following subtypes are defined in the class FBB:MultiStreambuf:
iterator:
This is a synonym of std::vector<stream>::iterator
const_iterator:
This is a synonym of std::vector<stream>::const_iterator
NESTED CLASS
The class FBB::MultiStreambuf::stream is defined as a nested class of
FBB::MultiStreambuf. It offers the following constructor and public
members:
stream(std::ostream &os, Mode mode = ON):
The constructor stores a std::ostream object, and associates a
Mode value with it.
void setMode(Mode mode):
This member is used to redefine the stream's Mode value.
void mode() const:
This member returns the stream's Mode value.
operator std::ostream &():
This member returns the stream's std::ostream.
CONSTRUCTORS
MultiStreambuf():
The default constructor creates a FBB::MultiStreambuf object which
contains no associated std::ostream objects.
MultiStreambuf(std::ostream &os, Mode mode = ON):
This constructor creates a FBB::MultiStreambuf object which
is immediately associated with the std::ostream specified as its first
argument.
MultiStreambuf(std::vector<MultiStreambuf::stream> const &osvector):
This constructor creates a FBB::MultiStreambuf object which is
immediately associated with all std::ostream objects that are stored in
the MultiStreambuf::stream elements of the specified vector.
The copy constructor is available.
MEMBER FUNCTIONS
All members of std::ostringstream and std::exception are
available, as FBB::MultiStreambuf inherits from these classes.
iterator begin():
This member returns an iterator to the first stream element that
is stored in a FBB::MultiStreambuf object.
const_iterator begin():
This member returns an iterator to the first (unmodifiable) stream
element that is stored in a FBB::MultiStreambuf object.
iterator end():
This member returns an iterator pointing beyond the last stream
element that is stored in a FBB::MultiStreambuf object.
iterator end():
This member returns an iterator pointing beyond the last
(unmodifiable) stream element that is stored in a FBB::MultiStreambuf
object.
void insert(std::ostream &os, Mode mode = ON):
This member adds the specified std::ostream using the specified
Mode to the current set of stream objects.
void insert(std::vector<stream> const &os):
This member adds all stream objects stored in the os vector to
the current set of stream objects.
void void setOnce():
This member will reset all the RESETMode values of the stored
stream objects to ONCE.
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_2.02.03-x.dsc: detached signature;
bobcat_2.02.03-x.tar.gz: source archive;
bobcat_2.02.03-x_i386.changes: change log;
libbobcat1_2.02.03-x_*.deb: debian package holding the
libraries;
libbobcat1-dev_2.02.03-x_*.deb: debian package holding the
libraries, headers and manual pages;
http://sourceforge.net/projects/bobcat: public archive location;
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).