FBB::OFilterBuf(3bobcat)
π NAME π
FBB::OFilterBuf β the base class glow-up for std::ostream filtering β¨
β¨ SYNOPSIS β¨
#include <bobcat/ofilterbuf>
Linking option: -lbobcat
π¦ DESCRIPTION π¦
Okay bestie, so FBB::OFilterBuf is a specialization of std::streambuf, and the whole vibe is: you use it as a base class for your own classes that do ostream-filtering. It's giving "foundation, not finished product." π
So what even is ostream filtering here? It's the process where characters you insert get processed before they're passed along to another (filtered) ostream object β or, lowkey, they might just get rejected entirely. And the filtering can also mean you insert extra info into that filtered ostream. Iconic behavior tbh.
Chaining? Obsessed. The filtered ostream can itself use an OFilterBuf to filter what it receives before passing it on to yet another ostream. It's filters all the way down, no cap. π
Since OFilterBuf inherits from std::streambuf, you can hand an OFilterBuf object to an ostream as its std::streambuf. Info inserted into that stream travels this exact route:
- The information gets converted to characters using the standard conversion facilities that
std::ostreamobjects implement. Like, when you insert the value123, that value becomes the characters'1','2'and'3', respectively. β¨ - Each of those characters is then offered (in turn) to the
std::streambufthat's associated with theostreamobject. Specifically, thestd::streambuf'soverflow()member gets called. π OFstreamBuf's defaultoverflow()function straight up ignores characters, but specializations can overrideoverflow()to process the received characters ad lib. Main character energy β do whatever you want with them.- An overriding
overflow()function has access to the memberOFstreambuf::out(), which is a reference to thestd::ostreamthat receives the filtered information. To implement a simple copy-filter (i.e., all characters are accepted as-is) a class must be derived fromOFilterBufproviding an overriding implementation ofoverflow(), e.g., as follows:
int DerivedClass::overflow(int ch)
{
out().put(ch);
}
Then that std::streambuf specialization can be associated with an ostream into which information to be copy filtered can be inserted (check the EXAMPLE section below, babes π«Ά).
πΈ NAMESPACE πΈ
FBB
All constructors, members, operators and manipulators mentioned in this man-page are defined in the namespace FBB. Periodt. π
π§ INHERITS FROM π§
std::streambuf
π CONSTRUCTORS π
Since OFilterBuf is meant to be used as a base class, all of its constructors are protected. (Yes, all of them. It's exclusive like that. π
)
OFilterBuf()β makes anOFilterBufobject without associating it with a destination (filtered)ostream. It's just vibing, unaffiliated. π¦OFilterBuf(std::string const &fname, openmode mode = std::ios::out)β makes anOFilterBufobject and opens a privatestd::ofstreamobject whose filename you provide, and that object should receive the filtered information. πOFilterBuf(std::ostream &out)β makes anOFilterBufobject and will insert any filtered information into theostreamobject you handed over. π
Heads up: copy and move constructors (and assignment operators) are not available. Don't even try, bestie. π
π«Ά PROTECTED MEMBER FUNCTIONS π«Ά
Except for the public members inherited from std::ostreambuf, all of OFilterBuf's members are protected. Cozy, protected, private-little-club energy. πΈ
Derived classes should provide their own implementation of int underflow(int ch) to implement filtering.
void reset(std::string const &fname, openmode mode = std::ios::out)β this member flushes the current destination (filtered)std::ostreamand associates theOFilterBufobject with anstd::ofstreamobject whose filename you provide, and that should receive the subsequently filtered information. πvoid reset(std::ostream &out)β this member flushes the current destination (filtered)std::ostreamobject and associates theOFilterBufobject with theostreamobject you provide. β¨std::ostream &out() constβ this member is available to derived classes so they can insert information into the destination (filtered) stream. It's your little window into the output, iykyk. π
π EXAMPLE π
#include <iostream>
#include <cctype>
#include <bobcat/ofilterbuf>
struct NoDigits: public FBB::OFilterBuf
{
NoDigits(std::ostream &out)
:
OFilterBuf(out)
{}
private:
int overflow(int ch) override
{
if (not isdigit(ch))
out().put(ch);
return ch;
}
};
using namespace FBB;
using namespace std;
int main()
{
NoDigits nod(cout); // no digits to cout
ostream out(&nod);
out << cin.rdbuf(); // rm digits from cin
}
π FILES π
bobcat/ofilterbuf β defines the class interface
β SEE ALSO β
bobcat(7), ifilterbuf(3bobcat)
π BUGS π
None Reported.
(Flawless. As usual. β¨)
π 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).
And that's the whole page, bestie β libbobcat-dev_6.15.01, dated 2005-2026, and it was literally iconic from start to finish. Go filter something cute. ππ
π¦ 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