FBB::Mbuf(3bobcat)

✨ FBB::Mbuf β€” std::streambuf handling messages ✨

okay bestie, welcome to the FBB::Mbuf page from the bobcat manual (that's section 3bobcat, iykyk) πŸ’–


🌸 SYNOPSIS 🌸

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

πŸ¦‹ DESCRIPTION πŸ¦‹

So like… objects of this class are derived from std::streambuf, and their whole thing is handling messages in a standardized way. Periodt. Messages can be prefixed with order (line) numbers and/or labels.

By default every message goes straight into the standard output stream, but you can romance other destinations (standard error, a named file, whatever you want) into existence, no cap.

Now here's the important bit, bestie: FBB::Mbuf objects are std::streambuf objects, so technically you can use them to construct std::ostream objects. BUT β€” and this is the part where I need you to look at me β€” they're intended to be used by mstream(3bobcat) objects, and passing Mbuf objects to any other kind of ostream object is deprecated and results in undefined behavior. Not the cute kind of chaos. The scary kind. πŸ’€


πŸ‘‘ NAMESPACE πŸ‘‘

FBB

Every single element mentioned in this man-page is defined in the namespace FBB. All of them. The whole squad.


🌈 INHERITS FROM 🌈

std::streambuf


πŸŽ€ CONSTRUCTORS πŸŽ€

  • Mbuf() β€” the default constructor handles messages using the std::streambuf that std::cout also uses. There is no limit to the number of messages you can insert. No message or line numbers get shown, and no exceptions get thrown when inserting messages. Chill vibes only.
  • explicit Mbuf(std::streambuf *buf, size_t maxCount = std::numeric_limits<size_t>::max(), std::string const &tag = "", bool throwing = false) β€” this one uses buf to handle messages. With the default argument values there's no limit to the number of messages you can insert, no message or line numbers get shown, and no exceptions get thrown when inserting messages. Specifying any value other than std::numeric_limits<size_t>::max() sets the maximum number of messages that can be inserted to that value. The tag defines the text of the message label (e.g. Error). When throwing is specified as true, an FBB::Exception exception is thrown after completing a message β€” and that generated exception holds the id (see the member id below) of the FBB::Mbuf object it was thrown from, plus the text FBB::Mbuf.
  • explicit Mbuf(std::string const &name, size_t maxCount = std::numeric_limits<size_t>::max(), std::string const &tag = "", bool throwing = false) β€” this constructor creates a std::ofstream from the provided name parameter, and that stream receives the messages handled by the constructed FBB:Mbuf object. It throws an FBB::Exception exception if the stream can't be opened for writing. If a file by that name already exists, it gets rewritten (bye bye old contents, no cap). The remaining parameters are identical to those of the previous two constructors.
🫢 heads up: Copy and move constructors (and assignment operators) are not available. They simply did not show up to the function.

πŸ’… MEMBER FUNCTIONS πŸ’…

  • size_t count() const β€” returns the number of inserted messages. And if setCount has been called: it's the value set by the last setCount call plus the number of inserted messages since that call.
  • bool lineExcess() const β€” returns true after you've attempted to insert an additional message after maxCount() number of messages have already been inserted. Overflow behavior, but make it a bool.
  • std::string const &lineTag() const β€” returns the currently used line-tag (by default Line).
  • size_t maxCount() const β€” returns the maximum number of messages that can be inserted. If the returned value equals std::numeric_limits<size_t>::max() then there's no limit to the number of messages that can be inserted. Infinite message glitch, iconic.
  • void noLineNr() β€” calling this member suppresses the display of a line number, but only if it's called after calling setLineNr (see below) and before a message is being inserted (or has been inserted).
  • void reset(std::streambuf *buf, size_t maxCount, std::string const &tag, bool throwing) β€” messages inserted into FBB::Mbuf objects get handled by std::streambuf buf. By specifying std::numeric_limits<size_t>::max() for maxCount there's no limit to the number of messages that may be handled by this std::streambuf. The tag defines the text of the message label (e.g., Error, or the empty string for no message label). When throwing is specified as true, an FBB::Exception exception is thrown after completing a message.
  • void reset(std::string const &name, size_t maxCount, std::string const &tag, bool throwing) β€” messages inserted into FBB::Mbuf objects get handled by a std::ofstream created using the provided name parameter. It throws an FBB::Exception exception if the stream can't be opened for writing. If a file by that name already exists it gets rewritten. The remaining parameters are identical to those of the previous reset members.
  • void reset(FBB::Mbuf const &mbuf) β€” the current object gets reset using the parameters of the mbuf parameter. After the reset, every one of the current object's parameters can be modified independently from those used by mbuf. Glow-up complete, but separate. πŸ’–
  • void setCount(size_t count) β€” assigns the value count to the object's message counter.
  • void setLineNr(size_t lineNr) β€” specifies the value lineNr as the message's line number when the next line is displayed (see also noLineNr). This value is not changed by the FBB::Mbuf object. To display another line number you'll have to call the member again β€” meaning the line number is not automatically displayed again at every new line. It's a one-time moment, main character energy, it doesn't repeat itself. ✨
  • void setLineTag(std::string const &tag) β€” specifies the tag prefixing line numbers. By default the line tag equals Line.
  • void setMaxCount(size_t maxCount) β€” defines maxCount as the maximum number of messages that can be inserted into the FBB::Mbuf object.
  • void setTag(std::string const &tag) β€” specifies the tag prefixing messages. By default the tag is empty. If it's not empty, the tag gets enclosed by square brackets. So, e.g., specifying the tag Error will prefix messages with [Error]. Cute formatting, honestly.
  • std::string const &tag() const β€” returns the currently used message tag (by default an empty string).
  • bool throws() β€” returns true when the FBB::Mbuf object will throw an FBB::Exception exception at the next completed message. That generated exception holds the id (see earlier for the member id) of the FBB::Mbuf object the exception was thrown from, as well as the text FBB::Mbuf.
  • void throwing(bool ifTrue) β€” modifies the behavior of FBB::Mbuf objects at completed messages. After passing true, FBB::Mbuf objects will throw an FBB::Exception exception at the next completed message; otherwise this exception is not thrown.

🌟 EXAMPLE 🌟

See the mstream(3bobcat) example. Bestie, it's right there, go look πŸ‘€


πŸ“ FILES πŸ“

  • bobcat/mbuf β€” defines the class interface.

πŸ”₯ SEE ALSO πŸ”₯

bobcat(7), exception(3bobcat), mstream(3bobcat)


πŸ™ˆ BUGS πŸ™ˆ

None Reported. (Periodt. We're clean.)


πŸ’œ 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. The name ate, frankly.


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 thing, you're so welcome 🫢 this was FBB::Mbuf(3bobcat), living in libbobcat-dev_6.15.01, dated 2005-2026, and fr fr that's a legacy. go forth and stream responsibly, bestie πŸ’…πŸŒΈ

πŸ“¦ where this page comes from