Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::PStreamBuf Class Reference

#include <PStreamBuf.h>

Inheritance diagram for PLearn::PStreamBuf:

Inheritance graph
[legend]
Collaboration diagram for PLearn::PStreamBuf:

Collaboration graph
[legend]
List of all members.

Public Types

typedef PPointable inherited
typedef size_t streamsize
typedef off_t streampos

Public Member Functions

 PStreamBuf (streamsize inbuf_capacity=1000, streamsize outbuf_capacity=1000, streamsize unget_capacity=100)
 Default constructor SUBCLASS WRITING:subclasse should also correctly set is_readable, is_writable, is_random_accessible.

virtual ~PStreamBuf ()
bool isReadable () const
bool isWritable () const
bool isRandomAccessible () const
int get ()
int peek ()
streamsize read (char *p, streamsize n)
void unread (const char *p, streamsize n)
 puts the given characters back in the input buffer so that they're the next thing read.

void unget (char c)
void flush ()
void put (char c)
void write (const char *p, streamsize n)

Protected Member Functions

virtual streamsize read_ (char *p, streamsize n)
 reads up to n characters into p You should override this call in subclasses.

virtual void write_ (const char *p, streamsize n)
 writes exactly n characters from p (unbuffered, must flush) Default version issues a PLERROR


Protected Attributes

bool is_readable
bool is_writable
bool is_random_accessible
 is random access supported? (setpos and getpos)


Private Member Functions

void build_ ()
 This does the actual building.

streamsize refill_in_buf ()

Private Attributes

streamsize ungetsize
streamsize inbuf_chunksize
char * inbuf
 beginning of input buffer

char * inbuf_p
 position of next character to be read

char * inbuf_end
 one after last available character

streamsize outbuf_chunksize
char * outbuf
 beginning of output buffer

char * outbuf_p
 position of next character to be written

char * outbuf_end
 one after last reserved character in outbuf


Member Typedef Documentation

typedef PPointable PLearn::PStreamBuf::inherited
 

Reimplemented in PLearn::FilePStreamBuf, and PLearn::StdPStreamBuf.

Definition at line 55 of file PStreamBuf.h.

typedef off_t PLearn::PStreamBuf::streampos
 

Definition at line 57 of file PStreamBuf.h.

typedef size_t PLearn::PStreamBuf::streamsize
 

Definition at line 56 of file PStreamBuf.h.

Referenced by flush(), read(), read_(), refill_in_buf(), and write().


Constructor & Destructor Documentation

PLearn::PStreamBuf::PStreamBuf streamsize  inbuf_capacity = 1000,
streamsize  outbuf_capacity = 1000,
streamsize  unget_capacity = 100
 

Default constructor SUBCLASS WRITING:subclasse should also correctly set is_readable, is_writable, is_random_accessible.

Definition at line 45 of file PStreamBuf.cc.

References build_().

PLearn::PStreamBuf::~PStreamBuf  )  [virtual]
 

Definition at line 59 of file PStreamBuf.cc.

References flush(), inbuf, and outbuf.


Member Function Documentation

void PLearn::PStreamBuf::build_  )  [private]
 

This does the actual building.

Reimplemented in PLearn::FilePStreamBuf.

Definition at line 70 of file PStreamBuf.cc.

References flush(), inbuf, inbuf_chunksize, inbuf_end, inbuf_p, outbuf, outbuf_chunksize, outbuf_end, outbuf_p, and ungetsize.

Referenced by PStreamBuf().

void PLearn::PStreamBuf::flush  )  [inline]
 

Definition at line 229 of file PStreamBuf.h.

References outbuf, outbuf_p, and streamsize.

Referenced by build_(), put(), write(), and ~PStreamBuf().

int PLearn::PStreamBuf::get  )  [inline]
 

Definition at line 148 of file PStreamBuf.h.

References inbuf_end, inbuf_p, and refill_in_buf().

bool PLearn::PStreamBuf::isRandomAccessible  )  const [inline]
 

Definition at line 145 of file PStreamBuf.h.

References is_random_accessible.

bool PLearn::PStreamBuf::isReadable  )  const [inline]
 

Definition at line 139 of file PStreamBuf.h.

References is_readable.

Referenced by read(), and refill_in_buf().

bool PLearn::PStreamBuf::isWritable  )  const [inline]
 

Definition at line 142 of file PStreamBuf.h.

References is_writable.

Referenced by put(), and write().

int PLearn::PStreamBuf::peek  )  [inline]
 

Definition at line 156 of file PStreamBuf.h.

References inbuf_end, inbuf_p, and refill_in_buf().

void PLearn::PStreamBuf::put char  c  )  [inline]
 

Definition at line 239 of file PStreamBuf.h.

References flush(), isWritable(), outbuf_end, outbuf_p, PLERROR, and put().

Referenced by put().

streamsize PLearn::PStreamBuf::read char *  p,
streamsize  n
[inline]
 

Definition at line 165 of file PStreamBuf.h.

References inbuf_chunksize, inbuf_end, inbuf_p, isReadable(), k, PLERROR, refill_in_buf(), and streamsize.

PStreamBuf::streamsize PLearn::PStreamBuf::read_ char *  p,
streamsize  n
[protected, virtual]
 

reads up to n characters into p You should override this call in subclasses.

On success, the number of bytes read is returned. Zero indicates end of file. If we are not at end of file, at least one character should be returned (the call must block until at least one char is available). It is not an error if the number returned is smaller than the number of bytes requested; this may happen for example because fewer bytes are actually available right now (maybe because we were close to end-of-file, or because we are reading from a pipe, or from a terminal). If an error occurs, an exception should be thrown.

Reimplemented in PLearn::FilePStreamBuf, and PLearn::StdPStreamBuf.

Definition at line 94 of file PStreamBuf.cc.

References PLERROR, and streamsize.

streamsize PLearn::PStreamBuf::refill_in_buf  )  [inline, private]
 

Definition at line 124 of file PStreamBuf.h.

References inbuf, inbuf_chunksize, inbuf_end, inbuf_p, isReadable(), PLERROR, streamsize, and ungetsize.

Referenced by get(), peek(), and read().

void PLearn::PStreamBuf::unget char  c  )  [inline]
 

Definition at line 219 of file PStreamBuf.h.

References inbuf, inbuf_p, PLERROR, and unget().

Referenced by unget().

void PLearn::PStreamBuf::unread const char *  p,
streamsize  n
[inline]
 

puts the given characters back in the input buffer so that they're the next thing read.

Definition at line 209 of file PStreamBuf.h.

References inbuf, inbuf_p, PLERROR, and unread().

Referenced by unread().

void PLearn::PStreamBuf::write const char *  p,
streamsize  n
[inline]
 

Definition at line 250 of file PStreamBuf.h.

References flush(), isWritable(), outbuf_chunksize, outbuf_end, outbuf_p, PLERROR, and streamsize.

void PLearn::PStreamBuf::write_ const char *  p,
streamsize  n
[protected, virtual]
 

writes exactly n characters from p (unbuffered, must flush) Default version issues a PLERROR

Reimplemented in PLearn::FilePStreamBuf, and PLearn::StdPStreamBuf.

Definition at line 102 of file PStreamBuf.cc.

References PLERROR.


Member Data Documentation

char* PLearn::PStreamBuf::inbuf [private]
 

beginning of input buffer

Definition at line 87 of file PStreamBuf.h.

Referenced by build_(), refill_in_buf(), unget(), unread(), and ~PStreamBuf().

streamsize PLearn::PStreamBuf::inbuf_chunksize [private]
 

Definition at line 86 of file PStreamBuf.h.

Referenced by build_(), read(), and refill_in_buf().

char* PLearn::PStreamBuf::inbuf_end [private]
 

one after last available character

Definition at line 89 of file PStreamBuf.h.

Referenced by build_(), get(), peek(), read(), and refill_in_buf().

char* PLearn::PStreamBuf::inbuf_p [private]
 

position of next character to be read

Definition at line 88 of file PStreamBuf.h.

Referenced by build_(), get(), peek(), read(), refill_in_buf(), unget(), and unread().

bool PLearn::PStreamBuf::is_random_accessible [protected]
 

is random access supported? (setpos and getpos)

Definition at line 101 of file PStreamBuf.h.

Referenced by isRandomAccessible().

bool PLearn::PStreamBuf::is_readable [protected]
 

Definition at line 99 of file PStreamBuf.h.

Referenced by isReadable().

bool PLearn::PStreamBuf::is_writable [protected]
 

Definition at line 100 of file PStreamBuf.h.

Referenced by isWritable().

char* PLearn::PStreamBuf::outbuf [private]
 

beginning of output buffer

Definition at line 93 of file PStreamBuf.h.

Referenced by build_(), flush(), and ~PStreamBuf().

streamsize PLearn::PStreamBuf::outbuf_chunksize [private]
 

Definition at line 92 of file PStreamBuf.h.

Referenced by build_(), and write().

char* PLearn::PStreamBuf::outbuf_end [private]
 

one after last reserved character in outbuf

Definition at line 95 of file PStreamBuf.h.

Referenced by build_(), put(), and write().

char* PLearn::PStreamBuf::outbuf_p [private]
 

position of next character to be written

Definition at line 94 of file PStreamBuf.h.

Referenced by build_(), flush(), put(), and write().

streamsize PLearn::PStreamBuf::ungetsize [private]
 

Definition at line 85 of file PStreamBuf.h.

Referenced by build_(), and refill_in_buf().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:23:14 2004 for PLearn by doxygen 1.3.7