FBB::OFdBuf(3bobcat)
FBB::OFdBuf π
okay bestie, so this is the manual page for FBB::OFdBuf, living in the 3bobcat section of the manual. Say hi to your new fave streambuf that's out here writing straight into a file descriptor β¨
πΈ NAME πΈ
FBB::OFdBuf β an output stream buffer that's initialized by a file descriptor π«Ά
β¨ SYNOPSIS β¨
#include <bobcat/ofdbuf>
Linking option: -lbobcat
π DESCRIPTION π
So here's the tea β: FBB::OFdBuf objects can be used as a std::streambuf for std::ostream objects, which is what lets you do insertions into a file descriptor. Iconic.
But ngl, file descriptors are not a thing defined within the context of C++ β they can only be used on operating systems that actually support the concept. And the way that using file descriptors brings operating system dependencies with it? Yeah, keep that in mind, fr fr π
π¦ NAMESPACE π¦
FBB
Every single constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB. periodt π
π INHERITS FROM π
std::streambuf
π ENUMERATION π
The public enumeration Mode, defined in the class FBB::OFdStreamBuf, has these values, bestie:
CLOSE_FDβ this one's literally saying the file descriptor used by the object must be closed.KEEP_FDβ and this one's the default, indicating that the file descriptor used by the object must not be closed.
π CONSTRUCTORS π
OFdBuf()β this constructor initializes the streambuf with no association to a file descriptor and no buffering. The memberresetcan be used to associate the object with a file descriptor later on, and optionally a buffer size. When the object gets destroyed β or if the mode-less overloaded version of theresetmember is called β the file descriptor is closed. πOFdBuf(Mode mode)β same vibe, initializes the streambuf with no association to a file descriptor and no buffering. The memberresetcan associate the object later on with a file descriptor and optionally a buffer size. When the object is destroyed β or if the mode-less overloaded version of the memberresetis called β theModeargument decides whether the file descriptor will be closed or will stay open π«ΆOFdBuf(int fd, size_t n = 1)β this constructor initializes the streambuf and associates it with file descriptorfd, plus an optional unget buffer size (defaulting to size1). Whenresetis called subsequently, or if the object is destroyed, the provided file descriptor will be closed π₯OFdBuf(int fd, size_t n = 1)β yeah bestie it's listed again, same signature. This constructor initializes the streambuf and associates it with file descriptorfd, plus an optional unget buffer size (defaulting to size1). When the object is destroyed β or if the mode-less overloaded version of the memberresetis called β the file descriptor will be closed.OFdBuf(int fd, Mode mode, size_t n = 1)β this constructor initializes the streambuf and associates it with file descriptorfd, plus an optional unget buffer size (defaulting to size1). When the object is destroyed β or if the mode-less overloaded version of the memberresetis called β theModeargument decides whether the file descriptor will be closed or will stay open β¨
no cap: copy and move constructors (and assignment operators) are not available. not me grieving them π
π MEMBER FUNCTIONS π
Every member of std::streambuf is available, since FBB::OFdBuf inherits from that class. slay π
void eoi()β the file descriptor used by theOFdBufgets closed, irrespective of theModethat was specified when theOFdBufobject was constructed. Aftereoi, theOFdBufobject can no longer be used until one of itsresetmembers has been called. And instead of using this member, theeoimanipulator can also be used πint fd() constβ returns the file descriptor used by theOFdBufobject. If theOFdBufis not associated with a file descriptor,-1is returned. πvoid reset(int xfd, size_t n = 1)β the streambuf is (re)initialized, using file descriptorfd, plus an optional unget buffer size (defaulting to size1). When called repeatedly, theModespecification that was used when the object was constructed decides whether the file descriptor will be closed or will stay open.void reset(int xfd, Mode mode, size_t n = 1)β the streambuf is (re)initialized, using file descriptorfd, a file descriptor closing parameter, and an optional unget buffer size (defaulting to size1). Depending on theModeargument, the object's currently used file descriptor will either be closed or stay open when theIFdBufobject is destroyed.void warn(bool on)β whenon == true, a warning gets written to the standard error stream whenever itssyncmember returns-1. Ifwarnisn't explicitly called,on == trueis used. lowkey polite of it πΈ
π§ MANIPULATOR π§
FBB::eoiβ theeoimanipulator can be inserted into theostreaminstead of calling theOFdBuf::endmember. It does the exact same actions as theeoimember. And if you insert it into a plainstd::ostream? literally nothing happens, bestie π
β EXAMPLE β
#include <unistd.h>
#include <ostream>
#include <string>
#include <bobcat/ofdbuf>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
// define a streambuf of 20 or argv[1] characters
OFdBuf buf{ STDOUT_FILENO, argc == 1 ? 20 : stoul(argv[1]) };
ostream out{ &buf };
out << "First line, just to start the insertions\n" <<
argv[0] << endl << // using an explicit flush
argc << "\n"
"a long line to end this multiple-insertions statement\n";
}
π FILES π
bobcat/ofdbuf β defines the class interface π
π SEE ALSO π
bobcat(7), ifdbuf(3bobcat), ofdstream(3bobcat), std::streambuf β go read those too, iykyk π
π«Ά BUGS π«Ά
None reported. we love a clean slate β¨
π BOBCAT PROJECT FILES π
- https://fbb-git.gitlab.io/bobcat/: the gitlab project page;
Debian Bobcat project files, bestie:
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. iconic naming fr fr π
π 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). ty for your service king π
and that's the whole page bestie!! this came from libbobcat-dev_6.15.01, dated 2005-2026, and yeah it's FBB::OFdBuf(3bobcat) β mwah, go close those file descriptors responsibly π
β¨π¦
π¦ 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