#include <fdstreambuf.h>
Public Member Functions | |
fdstreambuf (int fd=-1, size_t inbuf_sz=1024, size_t outbuf_sz=1024, time_t delay=0, bool non_blocking=false, std::ostream *debug=0) | |
The constructor simply allocates the buffers and stores the delay (in millisecs). | |
virtual | ~fdstreambuf () |
This is already virtual in streambuf. | |
size_t | inbuf_sz () const |
size_t | outbuf_sz () const |
time_t | delay () const |
Return the number of millsecs to wait before an open or input operation fails. | |
void | delay (time_t d) |
Set delay (0 means infinite delay). | |
bool | non_blocking () const |
Return the blocking status. | |
int | set_non_blocking () |
Set non-blocking I/O. | |
int | fd () const |
Return file descriptor underlying this fdstreambuf object. | |
bool | fd (int i, bool non_blocking=false) |
Set the underlying file descriptor. | |
virtual bool | close () |
Close the underlying file descriptor. | |
bool | timedout () const |
Return true iff last I/O operation timed out. | |
bool | timedout (bool timed_out) const |
Set timedout() flag. | |
int | error () const |
Return last relevant ::errno as set by the system. | |
std::string | strerror () const |
Return ::strerror(error()), a string representation of error(). | |
void | debug (std::ostream *os) |
Set debug stream. | |
std::ostream * | debug () const |
Return pointer to current debug stream. | |
virtual int | sync () |
Override iostream::sync(), i.e. | |
Static Public Member Functions | |
int | fdwait (int fd, time_t delay, int &syserrno, bool output=false) |
Check whether input or output on fd would block. | |
Protected Member Functions | |
virtual int | underflow () |
Override iostream::underflow(), i.e. | |
virtual int | overflow (int c) |
Override iostream::overflow(). | |
int | fdwait (bool output) const |
Wait for I/O to become available. | |
int | fdwait (bool output, int &syserrno) const |
Wait for I/O to become available. | |
int | iwait () const |
Wait for input to become available. | |
int | owait () const |
Wait for output to become available. | |
virtual int | read (char *buf, size_t buf_sz) |
Attempt an input operation. | |
virtual int | write (char *buf, size_t buf_sz) |
Attempt an output operation. | |
virtual int | rread (char *buf, size_t len) |
Low level read function, default is ::read(fd(), buf, len); may set error(). | |
virtual int | rwrite (char *buf, size_t len) |
Low level write function, default is ::write(fd(), buf, len); may set error(). | |
void | error (int e) const |
Set error status of fdstreambuf. | |
Static Protected Member Functions | |
int | flags (std::ios::openmode mode) |
Translate ios::openmode flags to open(2) flags like O_RDWR etc. | |
Private Member Functions | |
fdstreambuf (const fdstreambuf &) | |
fdstreambuf & | operator= (const fdstreambuf &) |
std::string | debug_header (const std::string &funname) const |
Return string of the form ``fdstreambuf[fd]::function_name''. | |
Private Attributes | |
int | fd_ |
Underlying file descriptor, <0 if invalid. | |
time_t | delay_ |
The number of millsecs to wait before an open or input operation fails. | |
bool | non_blocking_ |
Whether fd_ is non-blocking. | |
size_t | inbuf_sz_ |
Size of internal input buffer. | |
size_t | outbuf_sz_ |
Size of internal output buffer. | |
char * | inbuf_ |
Input buffer. | |
char * | outbuf_ |
Output buffer. | |
int | errno_ |
Error status. | |
bool | timedout_ |
Error status. | |
std::ostream * | debug_ |
Pointer to stream to which debug info is to be written. |
Definition at line 20 of file fdstreambuf.h.
|
The constructor simply allocates the buffers and stores the delay (in millisecs).
signal(SIGPIPE,SIG_IGN) , causing SIGPIPE signals to be ignored. Instead, the system should let the I/O operation fail and set errno to EPIPE . |
|
This is already virtual in streambuf.
|
|
|
|
References inbuf_sz_. |
|
References outbuf_sz_. |
|
Return the number of millsecs to wait before an open or input operation fails. A value of 0 means wait forever.
References delay_. |
|
Set delay (0 means infinite delay).
References delay_. |
|
Return the blocking status.
References non_blocking_. |
|
Set non-blocking I/O.
|
|
Return file descriptor underlying this fdstreambuf object.
References fd_. |
|
Set the underlying file descriptor. The previous descriptor, if valid, is closed.
|
|
Close the underlying file descriptor.
|
|
Return true iff last I/O operation timed out.
|
|
Set timedout() flag. This flag can only be cleared explicitly by fdstreambuf::timedout(false) or by fdstreambuf::fd(int).
|
|
Return last relevant ::errno as set by the system.
References errno_. |
|
Return ::strerror(error()), a string representation of error().
|
|
Set debug stream. If not null, trace info will be written to this stream for all I/O operations.
References debug_. |
|
Return pointer to current debug stream. The function may return 0, if debugging is ``off''.
References debug_. |
|
Check whether input or output on fd would block.
|
|
Override iostream::sync(), i.e. force all pending output to be written using fdstreambuf::rwrite().
|
|
Override iostream::underflow(), i.e. attempt to fill the input buffer using fdstreambuf::rread().
|
|
Override iostream::overflow(). May call fdstreambuf::sync().
|
|
Wait for I/O to become available. Wait for output or input, depending on the value of the parameter. Sets error() appropriately if return value is not 1.
|
|
Wait for I/O to become available. Wait for output or input, depending on the value of the parameter.
|
|
Wait for input to become available. Equivalent to fdwait(0).
References fdwait(). |
|
Wait for output to become available. Equivalent to fdwait(0).
References fdwait(). |
|
Attempt an input operation.
|
|
Attempt an output operation.
|
|
Low level read function, default is ::read(fd(), buf, len); may set error(). Derived classes can override this function.
|
|
Low level write function, default is ::write(fd(), buf, len); may set error(). Derived classes can override this function.
|
|
Translate ios::openmode flags to open(2) flags like O_RDWR etc.
|
|
Set error status of fdstreambuf.
|
|
|
|
Return string of the form ``fdstreambuf[fd]::function_name''.
|
|
Underlying file descriptor, <0 if invalid. Definition at line 332 of file fdstreambuf.h. Referenced by fd(). |
|
The number of millsecs to wait before an open or input operation fails. A value of 0 means wait forever. Definition at line 337 of file fdstreambuf.h. Referenced by delay(). |
|
Whether fd_ is non-blocking. Definition at line 341 of file fdstreambuf.h. Referenced by non_blocking(). |
|
Size of internal input buffer. Definition at line 345 of file fdstreambuf.h. Referenced by inbuf_sz(). |
|
Size of internal output buffer. Definition at line 349 of file fdstreambuf.h. Referenced by outbuf_sz(). |
|
Input buffer. Definition at line 353 of file fdstreambuf.h. |
|
Output buffer. Definition at line 357 of file fdstreambuf.h. |
|
Error status. A value of 0 means ok. Usually, the value of the last ::errno as set by the system. Definition at line 362 of file fdstreambuf.h. Referenced by error(). |
|
Error status. A value of 0 means ok. Usually, the value of the last ::errno as set by the system. Definition at line 367 of file fdstreambuf.h. |
|
Pointer to stream to which debug info is to be written. If 0, no debug information is generated. Definition at line 372 of file fdstreambuf.h. Referenced by debug(). |
dvutil-0.13.15 | [30 December, 2004] |