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.

rutz::stdiobuf::~stdiobuf (  )  [inline]

Destructor flushes buffer, but DOES NOT CLOSE the file descriptor.

Definition at line 79 of file stdiobuf.h.

References close().


Member Function Documentation

void rutz::stdiobuf::close ( void   ) 

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 rutz::stdiostream::close(), and ~stdiobuf().

bool rutz::stdiobuf::is_open (  )  const [inline]

Check whether we have an open file descriptor.

Definition at line 82 of file stdiobuf.h.

Referenced by close(), rutz::stdiostream::is_open(), and overflow().

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().

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

Flush the current buffer contents to the underlying file.

Definition at line 163 of file stdiobuf.cc.

Referenced by close().

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.


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:44:44 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3