ifdstreambuf.3bobcat

Langue: en

Version: 339739 (ubuntu - 24/10/10)

Section: 3 (Bibliothèques de fonctions)

NAME

FBB::IFdStreambuf - Input stream buffer initialized by a file descriptor

SYNOPSIS

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

DESCRIPTION

FBB::IFdStreambuf objects may be used as a std::streambuf of std::istream objects to allow extractions from a file descriptor.

File descriptors are not defined within the context of C++, but they can be used on operating systems that support the concept. Realize that using file descriptors introduces operating system dependencies.

NAMESPACE

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

INHERITS FROM

std::streambuf

ENUMERATION

The public enumeration Mode defined in the class FBB::IFdStreamBuf has the following values:
o
CLOSE_FD, indicating that the file descriptor used by the object must be closed;
o
KEEP_FD (the default) indicating that the file descriptor used by the object must not be closed.

CONSTRUCTORS

o
Ifdstreambuf():
This constructor initializes the streambuf, without associating it to a file descriptor, and without using buffering. The member open() can be used subsequently to associate the object with a file descriptor and optionally a buffer size. When the object is destroyed or if the mode-less overloaded version of the open member is called, the file descriptor will not be closed.
o
Ifdstreambuf(Mode mode):
This constructor initializes the streambuf, without associating it to a file descriptor, and without using buffering. The member open() can be used subsequently to associate the object with a file descriptor and optionally a buffer size. When the object is destroyed or if the mode-less overloaded version of the open member is called, the Mode argument determines whether the file descriptor will be closed or will remain open.
o
IFdStreambuf(int fd, size_t n = 1):
This constructor initializes the streambuf, associating it to file descriptor fd, 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 open member is called, the file descriptor will not be closed.
o
IFdStreambuf(int fd, Mode mode, size_t n = 1):
This constructor initializes the streambuf, associating it to file descriptor fd, 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 open member is called, the Mode argument determines whether the file descriptor will be closed or will remain open. There is no copy constructor.

MEMBER FUNCTIONS

All members of std::streambuf are available, as FBB::IFdStreambuf inherits from this class. Some of the std::streambuf's member are overridden by FBB::IFdStreambuf, see below.
o
void open(int xfd, size_t n = 1):
This member (re)initializes the streambuf, using file descriptor fd, and an optional unget buffer size (by default having size 1). When called repeatedly, the Mode specification used whem the object was constructed determines whether the file descriptor will be closed or will remain open.
o
void open(int xfd, Mode mode, size_t n = 1):
This member (re)initializes the streambuf, using file descriptor fd, a file descriptor closing parameter and an optional unget buffer size (by default having size 1). Depending on the Mode argument the object's currently used file descriptor will be closed or will remain open.
o
int underflow():
This member overrides the std::streambuf member. It is called by std::istream objects using IFdStreambuf. It produces the next available character. It returns EOF if no (more) characters are available.
o
std::streamsize xsgetn(char *dest, std::streamsize n):
This member overrides the std::streambuf member. It returns the n next available characters, storing them into dest. It returns the number of characters that were actually read. This function is called from, e.g., the istream::read() member. It will first copy what's available in IFdStreambuf's own buffer and will then try to read some more from the file descriptor, adding additionally read bytes to the destination buffer. Unless the requested amount of n bytes is available istream::good() will return ttfalse. Programs may have to clear the stream's flags when, e.g., fewer bytes were read. ) Note that there is no overloaded assignment operator available for this class.

EXAMPLE

To do

FILES

bobcat/ifdstreambuf - defines the class interface

SEE ALSO

bobcat(7), ifdstream(3bobcat), ofdstreambuf(3bobcat), std::streambuf

BUGS

The member xsgetn(char *dest, std::streamsize n) will set istream::good() to false when fewer bytes than n were read using istream::read(). Also see xsgetn's description.

Note that by default the provided file descriptors remain open. The complementary class ofdstreambuf(3bobcat) closes the file descriptor by default. This inconsistency was deliberately accepted to keep the classes interfaces backward compatible.

DISTRIBUTION FILES

o
bobcat_2.08.01-x.dsc: detached signature;
o
bobcat_2.08.01-x.tar.gz: source archive;
o
bobcat_2.08.01-x_i386.changes: change log;
o
libbobcat1_2.08.01-x_*.deb: debian package holding the libraries;
o
libbobcat1-dev_2.08.01-x_*.deb: debian package holding the libraries, headers and manual pages;
o
http://sourceforge.net/projects/bobcat: public archive location;

BOBCAT

Bobcat is an acronym of `Brokken's Own Base Classes And Templates'. This is free software, distributed under the terms of the GNU General Public License (GPL).

AUTHOR

Frank B. Brokken (f.b.brokken@rug.nl).