FBB::IFdBuf(3bobcat)
π
FBB::IFdBuf β from the 3bobcat manual, bestie edition π¦
okay so welcome to the glow-up of the FBB::IFdBuf page β it lives in the bobcat manual (section 3bobcat), and it's all about the File Descriptor Input Stream Buffer. yes that's the whole vibe. let's get into it β¨
β¨ NAME β¨
FBB::IFdBuf β an input stream buffer that gets initialized by a file descriptor. literally that's it, that's the girl π
πΈ SYNOPSIS πΈ
#include <bobcat/ifdbuf> (when using FBB::IFdBuf
#include <bobcat/ifdbufs> (when using FBB::IFdBufS
Linking option: -lbobcat
π DESCRIPTION π
FBB::IFdBuf objects can be used as a std::streambuf for std::istream objects, which is the whole reason you can do extractions straight from a file descriptor. main character energy tbh.
FBB::IFdBufS objects work exactly like FBB::IFdBuf objects, BUT β and this is the plot twist β they use FBB::Selector objects to check whether there's actually info available on the object's file descriptor before reading from it. so it's the patient, polite, waits-its-turn version π«Ά
heads up bestie: file descriptors are not defined inside the C++ context. they can be used on operating systems that support the concept, but using them drags in operating system dependencies. it's giving portability concerns, so know what you're signing up for π
π§ NAMESPACE π§
FBB
Every constructor, member, operator and manipulator mentioned in this man-page is defined in the namespace FBB. all of them. no stragglers β¨
π INHERITS FROM π
std::streambuf
she's a nepo baby and she earned it π
π ENUMERATION π
The public enumeration Mode, defined in the class FBB::IFdStreamBuf, has these values:
CLOSE_FDβ says the file descriptor used by the object must be closed.KEEP_FDβ this is the default, and it says the file descriptor used by the object must not be closed.
π CONSTRUCTORS π
IFdBuf()β initializes the streambuf, does not associate it with a file descriptor, and uses no buffering. afterwards you can call the memberresetto hook the object up to a file descriptor and optionally a buffer size. when the object gets destroyed, or when the mode-less overloaded version of theresetmember is called, the file descriptor is not closed. commitment issues, respectfully πIFdBuf(Mode mode)β same opening move: initializes the streambuf, no file descriptor association, no buffering.resetcan then associate the object with a file descriptor and optionally a buffer size. but here's the difference β when the object is destroyed, or when the mode-less overloaded version ofresetis called, theModeargument decides whether the file descriptor gets closed or stays open. she consults the mode first, periodt.IFdBuf(int fd, size_t n = 1)β initializes the streambuf and associates it with file descriptorfd, plus an optional unget buffer size (default size is1). when the object is destroyed, or when the mode-less overloaded version ofresetis called, the file descriptor is not closed.IFdBuf(int fd, Mode mode, size_t n = 1)β initializes the streambuf, associates it with file descriptorfd, plus an optional unget buffer size (default size is1). when the object is destroyed, or when the mode-less overloaded version ofresetis called, theModeargument decides whether the file descriptor gets closed or stays open.IFdBufSconstructors β to construct the correspondingIFdBufSobjects, use theIFdBufSconstructors that correspond to theIFdBufconstructors. matching set, no notes π
also: copy and move constructors (and assignment operators) are not available. she does not do duplicates, she does not do relocation. not me being un-copyable π«Ά
π MEMBER FUNCTIONS π
All members of std::streambuf are available, since FBB::IFdBuf(S) inherits from that class. everything in the family tree, you get it all.
void close()β closes the file descriptor used by theIFdBuf(S), irrespective of theModethat was specified when theIFdBuf(S)object was constructed. so even if you saidKEEP_FD, this overrides it. afterclose, theIFdBuf(S)object can no longer be used until one of itsresetmembers has been called. she's done until further notice πint fd() constβ returns the file descriptor used by theIFdBuf(S)object. if theOFdBufis not associated with a file descriptor,-1is returned. (yes, they wroteOFdBufhere,-1is the answer, moving on π)void reset(int fd, size_t n = 1)β (re)initializes the streambuf using file descriptorfd, plus an optional unget buffer size (default size1). when called repeatedly, theModespecification used when the object was constructed decides whether the file descriptor gets closed or stays open. she remembers what you told her at construction time, iykyk.void reset(int fd, Mode mode, size_t n = 1)β (re)initializes the streambuf using file descriptorfd, a file descriptor closing parameter, and an optional unget buffer size (default size1). depending on theModeargument, the object's currently used file descriptor will be closed or will remain open when theIFdBuf(S)object is destroyed.
β EXAMPLE β
#include <unistd.h>
#include <istream>
#include <iostream>
#include <bobcat/ifdbuf>
using namespace std;
using namespace FBB;
int main(int argc, char **argv)
{
// define a streambuf of 20 or argv[1] characters
IFdBuf buf{ STDIN_FILENO, argc == 1 ? 20 : stoul(argv[1]) };
istream in{ &buf };
cout << in.rdbuf();
}
π¦ FILES π¦
bobcat/ifdbufβ defines theFBB::IFdBufclass interfacebobcat/ifdbufsβ defines theFBB::IFdBufSclass interface
π SEE ALSO π
bobcat(7), ifdstream(3bobcat), ofdbuf(3bobcat), std::streambuf
π BUGS π
the member xsgetn(char *dest, std::streamsize n) sets istream::good() to false when fewer bytes than n were read using istream::read(). also see xsgetn's description. so like, heads up πΈ
another thing: by default the provided file descriptors remain open. and the complementary class ofdbuf(3bobcat)? by default it closes the file descriptor. the two of them are opposites, no cap π
π 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. iconic name origin, honestly π
π COPYRIGHT π
This is free software, distributed under the terms of the GNU General Public License (GPL). free as in freedom bestie β¨
πΈ AUTHOR πΈ
Frank B. Brokken (f.b.brokken@rug.nl).
and that's the whole page, bestie β brought to you by libbobcat-dev_6.15.01, dated 2005-2026, and yes this was FBB::IFdBuf(3bobcat) the entire time. slay, drink water, close your 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