Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  OFILTERSTREAMBUF (3)


FBB::OFilterStreambuf - Base class for std::ostream filtering



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


The FBB::OFilterStreambuf class is a specialization of the std::streambuf class and can be used as a base class for classes implementing ostream-filtering.

Ostream filtering is defined here as the process by which inserted characters are subject to processing before they are passed on to another (filtered) ostream object (or they may be rejected). The filtering may also result in inserting additional information into the filtered ostream.

Chaining of filters is also possible: the filtered ostream may itself use an OFilterStreambuf to filter its received information before passing it on to yet another ostream.

As OFilterStreambuf inherits from std::streambuf an OFilterStreambuf object can be used to provide an ostream object with a std::streambuf. Information inserted into such a stream travels the following route:
o The information is converted to characters using the standard conversion facilities implemented by std::ostream objects. E.g., when inserting the value 123 this value is converted to the characters \(cq1\(cq, \(cq2\(cq and \(cq3\(cq, respectively.
o Each of the characters is then offered (in turn) to the std::streambuf that is associated with the ostream object. In particular, the std::streambuf\(cqs overflow() member is called.
o OFstreamBuf\(cqs default overflow() function ignores characters, but specializations can override overflow() to process the received characters ad lib.
o A overriding overflow() function has access to the member OFstreambuf::out() which is a reference to the std::ostream receiving the filtered information. To implement a simple copy-filter (i.e., all characters are accepted as-is) a class must be derived from OFilterStreambuf providing an overriding implementation of overflow(), e.g., as follows:

int DerivedClass::overflow(int ch) { out().put(ch); }

Next this std::streambuf specialization can be associated with an ostream into which information to be ‘copy filtered\(cq can be inserted (cf. the EXAMPLE section below).


All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.




o OFilterStreambuf():
This constructor creates a OFilterStreambuf object without associating it with a destination (filtered) ostream.
o OFilterStreambuf(std::string const &fname, openmode mode = std::ios::out):
This constructor creates a OFilterStreambuf object and opens a private std::ofstream object whose filename is provided and that should receive the filtered information.
o OFilterStreambuf(char const *fname, openmode mode = std::ios::out):
Same as the previous constructor, expecting a char const * defining the name of the private std::ofstream object.
o OFilterStreambuf(std::ostream &out):
This constructor creates a OFilterStreambuf object and will insert any filtered information into the provided ostream object. The class\(cqs destructor closes the destination (filtered) stream (cf. the description of close() below).


All members of std::ostreambuf are available, as FBB::OFilterStreambuf inherits from that class. In particular, derived classes should provide their own implementation of int underflow(int ch) to implement any non-trivial filtering.
o void close():
This member calls the streambuf::sync() member to flush any pending information to the destination (filtered) stream and then closes the destination stream. Note that the default sync() member performs no special actions but it can be overridden by derived classes to flush the destination stream just prior to its closing.
o void open(std::string const &fname, openmode mode = std::ios::out):
This member closes the current destination (filtered) std::ostream object and associates the OFilterStreambuf object with a private std::ofstream object whose filename is provided and that should receive subsequently filtered information.
o void open(char const *fname, openmode mode = std::ios::out):
Same as the previous member, but using a char const * to specify the name of the private std::ofstream object to receive the filtered information.
o void open(std::ostream &out):
This member closes the current destination (filtered) std::ostream object and associates the OFilterStreambuf object with the provided ostream object.


o std::ostream &out() const:
This member is available to derived classes to insert information into the destination (filtered) stream.


#include <iostream> #include <cctype> #include <bobcat/ofilterstreambuf> class NoDigits: public FBB::OFilterStreambuf { private: int overflow(int ch) override { if (not isdigit(ch)) out().put(ch); return ch; } int sync() override { out() << flush; return 0; } }; using namespace FBB; using namespace std; int main() { NoDigits nod(cout); // no digits to cout ostream out(&nod); out << in.rdbuf(); // rm digits from cin return 0; }


bobcat/ofilterstreambuf - defines the class interface


bobcat(7), ifilterstreambuf(3bobcat)


None Reported.


o bobcat_3.25.01-x.dsc: detached signature;
o bobcat_3.25.01-x.tar.gz: source archive;
o bobcat_3.25.01-x_i386.changes: change log;
o libbobcat1_3.25.01-x_*.deb: debian package holding the libraries;
o libbobcat1-dev_3.25.01-x_*.deb: debian package holding the libraries, headers and manual pages;
o public archive location;


Bobcat is an acronym of ‘Brokken\(cqs Own Base Classes And Templates\(cq.


This is free software, distributed under the terms of the GNU General Public License (GPL).


Frank B. Brokken (

Search for    or go to Top of page |  Section 3 |  Main Index

libbobcat-dev_3&.25&.01-x&.tar&.gz FBB::OFILTERSTREAMBUF (3bobcat) 2005-2015

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.