iobuf3bobcat
Streambuf allowing input and output operations
Usage
#include <bobcat/iobuf>
Linking option: -lbobcat
Overview
This class implements a specialization of the std::streambuf class, allowing input operations from and output operations to different files. It is intended to be used in combination with FBB::IOStream, thus allowing all stream-based input and output operations using the same object without the need to use seek-operations. Using an FBB::IOStream object it is, e.g., possible to construct two-way communications using pipes, much like the facilities offered by sockets.
If the streams that will be associated with the IOBuf object support seeking, then the IOBuf will do so to. Seeking might also be available for a single stream (either the std::istream or the std::ostream).
When the IOBuf object goes out of scope, its associated std::ostream object is flushed.
Namespace
FBB
All constructors, members, operators and manipulators, mentioned in this man-page, are defined in the namespace FBB.
Inherits from
std::streambuf
Constructors
- o
-
IOBuf():
The default constructor results in aIOBufobject that cannot be immediately used. Its memberopen()must be called first.
- o
-
IOBuf(std::istream &in, std::ostream &out):
This constructor associates theIOBufobject with astd::istreamand astd::ostream. All output operations will be passed on to thestd::ostream, all input operations to thestd::istream. The streams passed toIOBuf()should outlive theIOBufobject.
Copy and move constructors (and assignment operators) are not available.
Member functions
All members of std::streambuf are available, as FBB::IOBuf inherits from these classes.
- o
-
void open(std::istream &in, std::ostream &out):
This member (re)associates theIOBufobject with astd::istreamand astd::ostream. All output operations will be passed on to thestd::ostream, all input operations to thestd::istream. The streams passed toIOBuf()should outlive theIOBufobject. If this member is called for anIOBufobject already associated with anstd::ostreamobject, the already associatedstd::ostreamobject is flushed before setting up the new association.
Virtual protected member functions
The following std::streambuf member functions should only be called when the FBB::Streambuf object is associated with std::istream and std::ostream objects (i.e., they should not be called between the construction of a default FBB:IOBuf object and a subsequent call of IOBuf::open()):
The members listed in this section implement the tasks of comparably named virtual function in the class’s private interface. This separates the redefinable interface from the user-interface. The class IOStreamBuf can, in accordance with Liskov’s Substitution Principle, be used as a std:streambuf; but it also offers facilities for classes deriving from IOStreamBuf. These facilities are listed here.
- o
-
pos_type pSeekoff(off_type offset, std::ios::seekdir way, std::ios::openmode mode = std::ios::in | std::ios::out):
With seekable streams, repositions the associatedstd::istreamorstd::ostreamis repositioned to offset offset, relative to way.
- o
-
pos_type pSeekpos(off_type offset, std::ios::openmode mode = std::ios::in | std::ios::out):
With seekable streams, repositions the associatedstd::istreamorstd::ostreamis repositioned to offset offset, relative to
- o
-
std::streamsize pXsputn(char const *buffer, std::streamsize n):
This member inserts n characters from buffer into the associatedstd::ostreamstream.
Examples
See the example provided with process(3bobcat).
Files
bobcat/iobuf - defines the class interface
Bobcat project files
- o
-
https://fbb-git.gitlab.io/bobcat/: gitlab project page;
Debian Bobcat project files:
- o
-
libbobcat6: debian package containing the shared library, changelog and copyright note;
- o
-
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’.
Releases
3 releases since Debian 11 (Bullseye); the text changed 2 times.