.TH "FBB::OFdBuf" "3bobcat" "2005\-2020" "libbobcat\-dev_5\&.07\&.00" "File Descriptor Output Stream Buffer" .PP .SH "NAME" FBB::OFdBuf \- Output stream buffer initialized by a file descriptor .PP .SH "SYNOPSIS" \fB#include \fP .br Linking option: \fI\-lbobcat\fP .PP .SH "DESCRIPTION" \fBFBB::OFdBuf\fP objects may be used as a \fIstd::streambuf\fP of \fIstd::ostream\fP objects to allow insertions into a file descriptor\&. .PP File descriptors are not defined within the context of \fBC++\fP, but they can be used on operating systems that support the concept\&. Realize that using file descriptors introduces operating system dependencies\&. .PP .SH "NAMESPACE" \fBFBB\fP .br All constructors, members, operators and manipulators, mentioned in this man\-page, are defined in the namespace \fBFBB\fP\&. .PP .SH "INHERITS FROM" \fBstd::streambuf\fP .PP .SH "ENUMERATION" The public enumeration \fIMode\fP defined in the class \fIFBB::OFdStreamBuf\fP has the following values: .IP o \fBCLOSE_FD\fP, indicating that the file descriptor used by the object must be closed; .IP o \fBKEEP_FD\fP (the default) indicating that the file descriptor used by the object must not be closed\&. .PP .SH "CONSTRUCTORS" .IP o \fBOFdBuf()\fP: .br This constructor initializes the streambuf, without associating it to a file descriptor, and without using buffering\&. The member \fIreset\fP can be used to 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 \fIreset\fP member is called, the file descriptor is closed\&. .IP .IP o \fBOFdBuf(Mode mode)\fP: .br This constructor initializes the streambuf, without associating it to a file descriptor, and without using buffering\&. The member \fIreset\fP can be used to 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 \fIreset\fP is called, the \fIMode\fP argument determines whether the file descriptor will be closed or will remain open\&. .IP .IP o \fBOFdBuf(int fd, size_t n = 1)\fP: .br This constructor initializes the streambuf, associating it to file descriptor \fIfd\fP, and an optional unget buffer size (by default having size 1)\&. When \fIreset\fP is called subsequently, or if the object is destroyed the provided file descriptor will be closed\&. .IP .IP o \fBOFdBuf(int fd, size_t n = 1)\fP: .br This constructor initializes the streambuf, associating it to file descriptor \fIfd\fP, and an optional unget buffer size (by default having size 1)\&. When the object is destroyed or if the mode\-less overloaded version of the member \fIreset\fP is called, the file descriptor will be closed\&. .IP .IP o \fBOFdBuf(int fd, Mode mode, size_t n = 1)\fP: .br This constructor initializes the streambuf, associating it to file descriptor \fIfd\fP, and an optional unget buffer size (by default having size 1)\&. When the object is destroyed or if the mode\-less overloaded version of the member \fIreset\fP is called, the \fIMode\fP argument determines whether the file descriptor will be closed or will remain open\&. .PP Copy and move constructors (and assignment operators) are not available\&. .PP .SH "MEMBER FUNCTIONS" All members of \fIstd::streambuf\fP are available, as \fIFBB::OFdBuf\fP inherits from this class\&. .IP o \fBvoid eoi()\fP: .br The file descriptor used by the \fIOFdBuf\fP is closed, irrespective of the \fIMode\fP that was specified when the \fIOFdBuf\fP object was constructed\&. Following \fIeoi\fP the \fIOFdBuf\fP object can no longer be used until one of its \fIreset\fP members has been called\&. Instead of using this member the \fIeoi\fP manipulator can also be used\&. .IP .IP o \fBint fd() const\fP: .br The file descriptor used by the \fIOFdBuf\fP object is returned\&. If the \fIOFdBuf\fP is not associated with a file descriptor \-1 is returned\&. .IP .IP o \fBvoid reset(int xfd, size_t n = 1)\fP: .br The streambuf is (re)initialized, using file descriptor \fIfd\fP, and an optional unget buffer size (by default having size 1)\&. When called repeatedly, the \fIMode\fP specification used whem the object was constructed determines whether the file descriptor will be closed or will remain open\&. .IP .IP o \fBvoid reset(int xfd, Mode mode, size_t n = 1)\fP: .br The streambuf is (re)initialized, using file descriptor \fIfd\fP, a file descriptor closing parameter and an optional unget buffer size (by default having size 1)\&. Depending on the \fIMode\fP argument the object\(cq\&s currently used file descriptor will be closed or will remain open when the \fIIFdBuf\fP object is destroyed\&. .PP .SH "MANIPULATOR" .IP o \fBFBB::eoi\fP: .br The \fIeoi\fP manipulator can be inserted into the \fIostream\fP instead of calling the \fIOFdBuf::end\fP member\&. It performs the same actions as the \fIeoi\fP member\&. If inserted into a plain \fIstd::ostream\fP nothing happens\&. .PP .SH "EXAMPLE" .nf #include #include #include #include \(dq\&\&.\&./ofdbuf\(dq\& 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 << \(dq\&First line, just to start the insertions\en\(dq\& << argv[0] << endl << // using an explicit flush argc << \(dq\&\en\(dq\& \(dq\&a long line to end this multiple\-insertions statement\en\(dq\&; } .fi .PP .SH "FILES" \fIbobcat/ofdbuf\fP \- defines the class interface .PP .SH "SEE ALSO" \fBbobcat\fP(7), \fBifdbuf\fP(3bobcat), \fBofdstream\fP(3bobcat), \fBstd::streambuf\fP .PP .SH "BUGS" None reported .PP .SH "BOBCAT PROJECT FILES" .PP .IP o \fIhttps://fbb\-git\&.gitlab\&.io/bobcat/\fP: gitlab project page; .IP o \fIbobcat_5\&.07\&.00\-x\&.dsc\fP: detached signature; .IP o \fIbobcat_5\&.07\&.00\-x\&.tar\&.gz\fP: source archive; .IP o \fIbobcat_5\&.07\&.00\-x_i386\&.changes\fP: change log; .IP o \fIlibbobcat1_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries; .IP o \fIlibbobcat1\-dev_5\&.07\&.00\-x_*\&.deb\fP: debian package containing the libraries, headers and manual pages; .PP .SH "BOBCAT" Bobcat is an acronym of `Brokken\(cq\&s Own Base Classes And Templates\(cq\&\&. .PP .SH "COPYRIGHT" This is free software, distributed under the terms of the GNU General Public License (GPL)\&. .PP .SH "AUTHOR" Frank B\&. Brokken (\fBf\&.b\&.brokken@rug\&.nl\fP)\&. .PP