FBB::MultiBuf(3bobcat)
π NAME π
FBB::MultiBuf β Selectively writes multiple streams
β¨ SYNOPSIS β¨
#include <bobcat/multibuf>
Linking option: -lbobcat
πΈ DESCRIPTION πΈ
okay so bestie, FBB::MultiBuf is a specialization of std::streambuf, and its whole thing is writing selectively to a bunch of std::ostreams at the same time. Every std::ostream you associate with a MultiBuf carries a mode-tag, and that tag says whether the stream should always be used when info gets inserted into the MultiBuf, used just once, or not used at all. π
So when you initialize a std::ostream with the address of a MultiBuf, that std::ostream becomes an output-multiplexer β¨: you insert info into the std::ostream object, and literally every std::ostream object you added to its MultiBuf buffer that has an active mode receives that info. Group chat broadcast energy, honestly.
β οΈ All active streams you pass to aMultiBufobject should outlive theMultiBufobject. It is the responsibility of the MultiBuf user that this requirement is met. Not a suggestion, bestie. The stream outlives the buffer or you're in for a bad time. π
MultiBuf objects insert information to their configured std::ostream objects β not directly to those streams' std::streambuf objects. Noted. π
And no assumptions should be made about the order in which the std::ostream objects associated with the MultiBuf objects are visited when information is inserted. Don't count on an order, there isn't a promised one. π
π¦ 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 these values, and listen, they matter:
OFFβ No information is inserted intostd::ostreams associated with the modeOFF. They are simply not invited to the party. π€ONβ Information inserted into thestd::ostreamusing aMultiBufstreambuf is inserted in allstd::ostreamobjects associated with the modeON. Everybody's here, always. π₯ONCEβ Information inserted into thestd::ostreamusing aMultiBufstreambuf is inserted in allstd::ostreamobjects associated with the modeONCEup through the nextstd::flush. Following thestd::flushinsertion thestd::ostream's mode is set toRESET. One-shot queen β she shows up once and dips. πRESETβ No information is inserted intostd::ostreams associated with the modeRESET. See also the membersresetandsetOncebelow. π
π§ NESTED CLASS π§
The class MultiBuf::Stream is a nested class of MultiBuf. It offers the following public members:
std::ostream &ostream() constβ This member returns a reference to theStream'sstd::ostream. That returned ostream can be processed independently from the other ostream objects you provided to theMultiBufobject. See also the membersbeginandstreamVectbelow. π«Mode mode() constβ This member returns theStream'sMode.
π TYPES π
The following types are defined by the class FBB:MultiBuf:
StreamVectβ A synonym ofstd::vector<MultiBuf::Stream>const_iteratorβ A synonym ofStreamVect::const_iterator
π CONSTRUCTORS π
MultiBuf()β AMultiBufobject is initialized without associatedstd::ostreamobjects. Empty roster, no notes in the group chat yet. πMultiBuf(std::ostream, ...)β This constructor creates aMultiBufobject associated with one or morestd::ostreamobjects specified as the constructor's arguments, usingMode ONfor all the specified ostream objects. Everybody gets invited, everybody getsON. β¨MultiBuf(std::ostream, Mode mode, ...)β This constructor creates aMultiBufobject receiving pairs of arguments. The first element of each pair is astd::ostream, the second element is thatstd::ostream'sMode. So you hand-pick who gets what. π
Copy and move constructors (and assignment operators) are available. So yes, you can copy and move these bad boys. π«Ά
π 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. So yeah β seeking is giving "not today". π«
const_iterator begin() constβ A const-iterator to the firstStreamobject stored in theMultiBufobject is returned.void clear()β TheMultiBuf'sStreamVectis cleared. Poof, gone. π§Ήconst_iterator end() constβ A const-iterator referring just beyond the lastStreamobject stored in theMultiBufobject is returned.void insert(std::ostream &os, Mode mode = ON)β AStreamobject referring to the arguments'std::ostreamobject using the specifiedModeis added to the current set ofStreamobjects. Note thatinsertmay be called repeatedly with the samestd::ostreamarguments β nobody's stopping you, bestie. πvoid insert(std::vector<stream> const &os)β This member adds all stream objects stored in theosvector toMode mode() constβ TheModeassociated with aStreamobject referring toosis returned. If no suchStreamobject is availableMode OFFis returned. πbool remove(std::ostream &os)β The (first)Streamobject referring toosis removed fromMultiBuf'sStreamVect, andtrueis returned. If noStreamobject refers toosthenfalseis returned.bool remove(size_t idx)β Ifidxis at least equal to theStreamVect's sizefalseis returned. Otherwise elementidxof theMultiBuf'sStreamVectis removed, andtrueis returned.void reset(Mode mode)β TheModevalues of allStreamobjects maintained by theMultiBufobject are set tomode.bool reset(ostream &os, Mode mode)β TheModeof the firstStreamobject referring toosis set tomodeandtrueis returned. If no suchStreamobject is availablefalseis returned.void void setOnce()β TheMode RESETvalues of allStreamobjects are changed to ModeONCE.
π yes the double void is really in the original, I am not the one who did that, I'm just the messenger
void void setOnce(std::ostream &os)β TheModevalue of the firstStreamobject referring toosis set to ModeONCE.bool void setOnce(size_t idx)β Ifidxis at least equal to theStreamVect's sizefalseis returned. Otherwise theModevalue of elementidxof theStreamVectis set toONCEandtrueis returned.size_t size() constβ Returns theStreamVect's size.MultiBuf::StreamVect const &streamVect() constβ Returns a const-reference to theMultiBuf'sStreamVect.
π₯ 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 π
π BUGS π
None Reported.
π BOBCAT PROJECT FILES π
https://fbb-git.gitlab.io/bobcat/β gitlab project page;
Debian Bobcat project files:
libbobcat6β debian package containing the shared library, changelog and copyright note;libbobcat-devβ debian package containing the static library, headers, manual pages, and developer info;
β 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).
okay that's the whole page, no cap, every single flag, member and warning intact π
this gem ships as part of libbobcat-dev_6.15.01, dated 2005-2026, aka the FBB::MultiBuf(3bobcat) era β slay, go multiplex your streams bestie π¦β¨
π¦ where this page comes from
- ubuntu stonking: libbobcat-dev 6.15.01-1 Β· GPL-3.0-or-later WITH OpenSSL exception
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms