.TH "FBB::MultiStreambuf" "3bobcat" "2005\-2014" "libbobcat\-dev_3\&.23\&.01\-x\&.tar\&.gz" "Writing multiple streams" .PP .SH "NAME" FBB::MultiStreambuf \- Selectively writes multiple streams .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" The \fBFBB::MultiStreambuf\fP class is a specialization of \fBstd::streambuf\fP\&. It can be used to write selectvely to multiple \fBstd::ostreams\fP\&. Each \fBstd::ostream\fP that is associated with an \fBFBB::MultiStreambuf\fP is given a mode\-tag indicating whether the stream should always be used when information is inserted into the \fBFBB::MultiStreambuf\fP, just once, or not at all\&. Each of the stream\(cq\&s mode\-tags may be set to any of the defined tag\-values\&. .PP When the address of a \fBFBB::MultiStreambuf\fP is used to initialize a \fBstd::ostream\fP the constructed \fBstd::ostream\fP becomes an output\-multiplexer: by inserting information into the \fBstd::ostream\fP object, all \fBstd::ostream\fP objects added to its \fBFBB::MultiStreambuf\fP buffer which have an active mode will receive that information\&. .PP An \fBFBB::MultiStreambuf\fP object should be outlived by all active streams that are associated with it\&. .PP No assumptions should be made about the order in which the \fBstd::ostream\fP objects that are associated with the \fBFBB::MultiStreambuf\fP objects are visited when information is inserted\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \fBstd::streambuf\fP .PP .SH "ENUMERATION" In the \fBMode\fP enumeration the following values are defined: .IP o \fBOFF\fP: .br A \fBstd::ostream\fP having this mode will not be used when information is inserted into an \fBFBB::MultiStreambuf\fP .IP o \fBON\fP: .br A \fBstd::ostream\fP having this mode will be used when information is inserted into an \fBFBB::MultiStreambuf\fP .IP o \fBONCE\fP: .br A \fBstd::ostream\fP having this mode will be used once, until the next flushing operation, when information is inserted into an \fBFBB::MultiStreambuf\fP .IP o \fBRESET\fP: .br A \fBstd::ostream\fP having this mode will not be used when information is inserted into an \fBFBB::MultiStreambuf\fP\&. At a flush operation all \fBONCE\fP modes will be set to \fBRESET\fP .PP .SH "TYPES" The following subtypes are defined in the class \fBFBB:MultiStreambuf\fP: .IP o \fBiterator\fP: .br This is a synonym of \fBstd::vector::iterator\fP .IP o \fBconst_iterator\fP: .br This is a synonym of \fBstd::vector::const_iterator\fP .PP .SH "NESTED CLASS" The class \fBFBB::MultiStreambuf::stream\fP is defined as a nested class of \fBFBB::MultiStreambuf\fP\&. It offers the following constructor and public members: .IP o \fBstream(std::ostream &os, Mode mode = ON)\fP: .br The constructor stores a \fBstd::ostream\fP object, and associates a \fBMode\fP value with it\&. .IP o \fBvoid setMode(Mode mode)\fP: .br This member is used to redefine the \fBstream\fP\(cq\&s \fBMode\fP value\&. .IP o \fBvoid mode() const\fP: .br This member returns the \fBstream\fP\(cq\&s \fBMode\fP value\&. .IP o \fBoperator std::ostream &()\fP: .br This member returns the \fBstream\fP\(cq\&s \fBstd::ostream\fP\&. .PP .SH "CONSTRUCTORS" .IP o \fBMultiStreambuf()\fP: .br The default constructor creates a \fBFBB::MultiStreambuf\fP object which contains no associated \fBstd::ostream\fP objects\&. .IP o \fBMultiStreambuf(std::ostream &os, Mode mode = ON)\fP: .br This constructor creates a \fBFBB::MultiStreambuf\fP object which is immediately associated with the \fBstd::ostream\fP specified as its first argument\&. .IP o \fBMultiStreambuf(std::vector const &osvector)\fP: .br This constructor creates a \fBFBB::MultiStreambuf\fP object which is immediately associated with all \fBstd::ostream\fP objects that are stored in the \fBMultiStreambuf::stream\fP elements of the specified vector\&. The copy constructor is available\&. .PP .SH "MEMBER FUNCTIONS" All members of \fBstd::ostringstream\fP and \fBstd::exception\fP are available, as \fBFBB::MultiStreambuf\fP inherits from these classes\&. .IP o \fBiterator begin()\fP: .br This member returns an iterator to the first \fBstream\fP element that is stored in a \fBFBB::MultiStreambuf\fP object\&. .IP o \fBconst_iterator begin()\fP: .br This member returns an iterator to the first (unmodifiable) \fBstream\fP element that is stored in a \fBFBB::MultiStreambuf\fP object\&. .IP o \fBiterator end()\fP: .br This member returns an iterator pointing beyond the last \fBstream\fP element that is stored in a \fBFBB::MultiStreambuf\fP object\&. .IP o \fBiterator end()\fP: .br This member returns an iterator pointing beyond the last (unmodifiable) \fBstream\fP element that is stored in a \fBFBB::MultiStreambuf\fP object\&. .IP o \fBvoid insert(std::ostream &os, Mode mode = ON)\fP: .br This member adds the specified \fBstd::ostream\fP using the specified \fBMode\fP to the current set of \fBstream\fP objects\&. .IP o \fBvoid insert(std::vector const &os)\fP: .br This member adds all \fBstream\fP objects stored in the \fBos\fP vector to the current set of \fBstream\fP objects\&. .IP o \fBvoid void setOnce()\fP: .br This member will reset all the \fIRESET\fP \fBMode\fP values of the stored \fBstream\fP objects to \fIONCE\fP\&. .PP .SH "PROTECTED MEMBER FUNCTION" .PP The member listed in this section implements the tasks of the comparably named virtual function in the class\(cq\&s private interface\&. This separates the redefinable interface from the user\-interface\&. The class \fBMultiStreamBuf\fP can, in accordance with Liskov\(cq\&s Substitution Principle, be used as a \fIstd:streambuf\fP; but it also offers a facility for classes deriving from \fBMultiStreamBuf\fP\&. This facility is listed here\&. .IP o \fBint pSync()\fP: .br The contents of the \fBMultiStreamBuf\fP\(cq\&s internal buffer is written to each of the \fIstd::ostream\fP objects to which the \fBMultiStreamBuf\fP object has access\&. .PP .SH "EXAMPLE" .nf #include #include #include using namespace std; using namespace FBB; int main() { MultiStreambuf msb(cout); ostream os(&msb); ofstream out(\(dq\&out\(dq\&); msb\&.insert(out, MultiStreambuf::ONCE); os << \(dq\&This is on cout and out\(dq\& << endl; os << \(dq\&This is on cout only\(dq\& << endl; msb\&.setOnce(); os << \(dq\&This is on cout and out\(dq\& << endl; os << \(dq\&This is on cout only\(dq\& << endl; return 0; } .fi .PP .SH "FILES" \fIbobcat/multistreambuf\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7) .PP .SH "BUGS" None Reported\&. .PP .SH "DISTRIBUTION FILES" .IP o \fIbobcat_3\&.23\&.01\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_3\&.23\&.01\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_3\&.23\&.01\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_3\&.23\&.01\-x_*\&.deb\fP: debian package holding the libraries; .IP o \fIlibbobcat1\-dev_3\&.23\&.01\-x_*\&.deb\fP: debian package holding the libraries, headers and manual pages; .IP o \fIhttp://sourceforge\&.net/projects/bobcat\fP: public archive location; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP