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 member reset can 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 the reset member 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 member reset can 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 member reset is called β€” the Mode argument 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 descriptor fd, plus an optional unget buffer size (defaulting to size 1). When reset is 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 descriptor fd, plus an optional unget buffer size (defaulting to size 1). When the object is destroyed β€” or if the mode-less overloaded version of the member reset is 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 descriptor fd, plus an optional unget buffer size (defaulting to size 1). When the object is destroyed β€” or if the mode-less overloaded version of the member reset is called β€” the Mode argument 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 the OFdBuf gets closed, irrespective of the Mode that was specified when the OFdBuf object was constructed. After eoi, the OFdBuf object can no longer be used until one of its reset members has been called. And instead of using this member, the eoi manipulator can also be used πŸ‘‘
  • int fd() const β€” returns the file descriptor used by the OFdBuf object. If the OFdBuf is not associated with a file descriptor, -1 is returned. πŸ“
  • void reset(int xfd, size_t n = 1) β€” the streambuf is (re)initialized, using file descriptor fd, plus an optional unget buffer size (defaulting to size 1). When called repeatedly, the Mode specification 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 descriptor fd, a file descriptor closing parameter, and an optional unget buffer size (defaulting to size 1). Depending on the Mode argument, the object's currently used file descriptor will either be closed or stay open when the IFdBuf object is destroyed.
  • void warn(bool on) β€” when on == true, a warning gets written to the standard error stream whenever its sync member returns -1. If warn isn't explicitly called, on == true is used. lowkey polite of it 🌸

🧚 MANIPULATOR 🧚

  • FBB::eoi β€” the eoi manipulator can be inserted into the ostream instead of calling the OFdBuf::end member. It does the exact same actions as the eoi member. And if you insert it into a plain std::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 πŸŽ€

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 🌟


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