jcpp::BufferedReader Class Reference

#include <BufferedReader.h>

Inheritance diagram for jcpp::BufferedReader:

Inheritance graph
[legend]
Collaboration diagram for jcpp::BufferedReader:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 BufferedReader (Reader *in)
virtual void close ()
virtual void mark ()
virtual boolean markSupported ()
virtual int read ()
virtual int read (char *cbuf, int length)
virtual int read (char *cbuf, int off, int length)
virtual boolean ready ()
virtual void reset ()
virtual long skip (long length)
virtual CFREE char * readLine ()

Protected Member Functions

void en (char *str)

Private Member Functions

int preRead (char *cbuf, int off, int length)
int findLineInBuffer ()
void fill ()

Private Attributes

CDELETE Readerin
char * cb
long nChars
int nextChar
int maxChars
long defaultCharBufferSize
long defaultExpectedLineLength
CDELETE StringBuffersb


Detailed Description

A C++ knockoff of the BufferedReader class in package java.io.

Member Function Documentation

virtual void jcpp::BufferedReader::close (  )  [inline, virtual]

Close the underlying file descriptor.

Implements jcpp::Reader.

00031                        {
00032     in->close();
00033   }

virtual void jcpp::BufferedReader::mark (  )  [inline, virtual]

Mark this point in the read stream.

Reimplemented from jcpp::Reader.

00035                       {
00036     en((char *)"not allowed to use mark() in Reader");
00037   }

virtual boolean jcpp::BufferedReader::markSupported (  )  [inline, virtual]

Determine if this stream supports marking the stream.

Reimplemented from jcpp::Reader.

00039                                   {
00040     return FALSE;
00041   }

virtual int jcpp::BufferedReader::read (  )  [virtual]

Read a single character off the stream.

Implements jcpp::Reader.

virtual int jcpp::BufferedReader::read ( char *  cbuf,
int  length 
) [inline, virtual]

Read length bytes into the buffer pointed to by cbuf.

Reimplemented from jcpp::Reader.

00045                                            {
00046     return read(cbuf, 0 , length);
00047   }

int jcpp::BufferedReader::preRead ( char *  cbuf,
int  off,
int  length 
) [private]

This reads a blob of characters, but does not necessarily fulfill the request. A negative return value means an error has occurred.

virtual int jcpp::BufferedReader::read ( char *  cbuf,
int  off,
int  length 
) [virtual]

Read <em length /em> bytes into the buffer pointed to by <em cbuf /em> beginning at the offset <em off /em>.

Implements jcpp::Reader.

virtual boolean jcpp::BufferedReader::ready (  )  [inline, virtual]

Answers TRUE if the stream is ready to be read.

Implements jcpp::Reader.

00059                           {
00060     return (nextChar < nChars) || in->ready();
00061   }

virtual void jcpp::BufferedReader::reset (  )  [inline, virtual]

Reset the stream back to the previously set mark, if supported, error otherwise.

Reimplemented from jcpp::Reader.

00064                        {
00065     en((char *)":-( Reader::reset() not supported");
00066   }

virtual long jcpp::BufferedReader::skip ( long  length  )  [virtual]

Skip length bytes or to end-of-file whichever comes first.

Implements jcpp::Reader.

virtual CFREE char* jcpp::BufferedReader::readLine (  )  [virtual]

Read a line, the terminating newline is replaced with a null.

int jcpp::BufferedReader::findLineInBuffer (  )  [private]

See if a newline char appears in the current buffer, if so return the index pointing to the newline, otherwise retrun -1.

void jcpp::BufferedReader::fill (  )  [private]

Fill the buffer; note that this may block.

void jcpp::BufferedReader::en ( char *  str  )  [inline, protected]

Generic error stream.

Reimplemented from jcpp::Reader.

00079                      {
00080     ::fprintf(stderr, "%s\n", str);
00081   }


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

Generated on Thu Sep 17 08:21:29 2009 for CCAFFEINE by  doxygen 1.5.9