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 a MultiBuf object should outlive the MultiBuf object. 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 into std::ostreams associated with the mode OFF. They are simply not invited to the party. πŸ’€
  • ON β€” Information inserted into the std::ostream using a MultiBuf streambuf is inserted in all std::ostream objects associated with the mode ON. Everybody's here, always. πŸ”₯
  • ONCE β€” Information inserted into the std::ostream using a MultiBuf streambuf is inserted in all std::ostream objects associated with the mode ONCE up through the next std::flush. Following the std::flush insertion the std::ostream's mode is set to RESET. One-shot queen β€” she shows up once and dips. πŸ‘‘
  • RESET β€” No information is inserted into std::ostreams associated with the mode RESET. See also the members reset and setOnce below. πŸ‘€

🧚 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 the Stream's std::ostream. That returned ostream can be processed independently from the other ostream objects you provided to the MultiBuf object. See also the members begin and streamVect below. πŸ’«
  • Mode mode() const β€” This member returns the Stream's Mode.

πŸ“ TYPES πŸ“

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

  • StreamVect β€” A synonym of std::vector<MultiBuf::Stream>
  • const_iterator β€” A synonym of StreamVect::const_iterator

πŸ’œ CONSTRUCTORS πŸ’œ

  • MultiBuf() β€” A MultiBuf object is initialized without associated std::ostream objects. Empty roster, no notes in the group chat yet. πŸ“­
  • MultiBuf(std::ostream, ...) β€” This constructor creates a MultiBuf object associated with one or more std::ostream objects specified as the constructor's arguments, using Mode ON for all the specified ostream objects. Everybody gets invited, everybody gets ON. ✨
  • MultiBuf(std::ostream, Mode mode, ...) β€” This constructor creates a MultiBuf object receiving pairs of arguments. The first element of each pair is a std::ostream, the second element is that std::ostream's Mode. 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 first Stream object stored in the MultiBuf object is returned.
  • void clear() β€” The MultiBuf's StreamVect is cleared. Poof, gone. 🧹
  • const_iterator end() const β€” A const-iterator referring just beyond the last Stream object stored in the MultiBuf object is returned.
  • void insert(std::ostream &os, Mode mode = ON) β€” A Stream object referring to the arguments' std::ostream object using the specified Mode is added to the current set of Stream objects. Note that insert may be called repeatedly with the same std::ostream arguments β€” nobody's stopping you, bestie. πŸ”
  • void insert(std::vector<stream> const &os) β€” This member adds all stream objects stored in the os vector to
  • Mode mode() const β€” The Mode associated with a Stream object referring to os is returned. If no such Stream object is available Mode OFF is returned. πŸ‘€
  • bool remove(std::ostream &os) β€” The (first) Stream object referring to os is removed from MultiBuf's StreamVect, and true is returned. If no Stream object refers to os then false is returned.
  • bool remove(size_t idx) β€” If idx is at least equal to the StreamVect's size false is returned. Otherwise element idx of the MultiBuf's StreamVect is removed, and true is returned.
  • void reset(Mode mode) β€” The Mode values of all Stream objects maintained by the MultiBuf object are set to mode.
  • bool reset(ostream &os, Mode mode) β€” The Mode of the first Stream object referring to os is set to mode and true is returned. If no such Stream object is available false is returned.
  • void void setOnce() β€” The Mode RESET values of all Stream objects are changed to Mode ONCE.
😭 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) β€” The Mode value of the first Stream object referring to os is set to Mode ONCE.
  • bool void setOnce(size_t idx) β€” If idx is at least equal to the StreamVect's size false is returned. Otherwise the Mode value of element idx of the StreamVect is set to ONCE and true is returned.
  • size_t size() const β€” Returns the StreamVect's size.
  • MultiBuf::StreamVect const &streamVect() const β€” Returns a const-reference to the MultiBuf's StreamVect.

πŸ”₯ 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:

  • 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'.

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