rutz::stdiobuf Class Reference

A C++ streambuf that wraps a standard posix file descriptor. More...

#include <rutz/stdiobuf.h>

List of all members.

Public Member Functions

 stdiobuf (FILE *f, int om, bool throw_exception=false)
 Create with a reference to a FILE object.
 stdiobuf (int fd, int om, bool throw_exception=false)
 Create with a reference to a file descriptor.
 ~stdiobuf ()
 Destructor flushes buffer, but DOES NOT CLOSE the file descriptor.
bool is_open () const
 Check whether we have an open file descriptor.
void close ()
 Flushes the buffer and forgets the file descriptor, but DOESN'T CLOSE IT.
virtual int underflow ()
 Get more data from the underlying file descriptor.
virtual int overflow (int c)
 Send more data to the underlying file descriptor.
virtual int sync ()
 Flush the current buffer contents to the underlying file.


Detailed Description

A C++ streambuf that wraps a standard posix file descriptor.

Definition at line 48 of file stdiobuf.h.


Constructor & Destructor Documentation

rutz::stdiobuf::stdiobuf ( FILE *  f,
int  om,
bool  throw_exception = false 
)

Create with a reference to a FILE object.

The stdiobuf will NOT close the FILE on destruction, that is left up to the caller (since the caller must also have been the one to open the FILE object).

Definition at line 71 of file stdiobuf.cc.

rutz::stdiobuf::stdiobuf ( int  fd,
int  om,
bool  throw_exception = false 
)

Create with a reference to a file descriptor.

The stdiobuf will NOT close the descriptor on destruction, that is left up to the caller (since the caller must also have been the one to open the file descriptor).

Definition at line 78 of file stdiobuf.cc.


Member Function Documentation

void rutz::stdiobuf::close (  ) 

Flushes the buffer and forgets the file descriptor, but DOESN'T CLOSE IT.

It is assumed that the same caller who passed the open file descriptor to our constructor will also eventually close that file descriptor.

Definition at line 86 of file stdiobuf.cc.

References is_open(), and sync().

Referenced by ~stdiobuf().

int rutz::stdiobuf::underflow (  )  [virtual]

Get more data from the underlying file descriptor.

Called when the streambuf's buffer has run out of data.

Definition at line 99 of file stdiobuf.cc.

int rutz::stdiobuf::overflow ( int  c  )  [virtual]

Send more data to the underlying file descriptor.

Called when the streambuf's buffer has become full.

Definition at line 143 of file stdiobuf.cc.

References is_open().


The documentation for this class was generated from the following files:

The software described here is Copyright (c) 1998-2005, Rob Peters.
This page was generated Wed Dec 3 06:56:46 2008 by Doxygen version 1.5.5.