#include <InputByteStream.h>
Inheritance diagram for InputByteStream:
Public Member Functions | |
InputByteStream (int fileno) throw (InputByteStreamError) | |
Prepares to read a stream from the specified file descriptor, which must be open. | |
InputByteStream (string srcspec) throw (InputByteStreamError) | |
Prepares to read a stream from the specified source. | |
~InputByteStream () | |
Closes the file and reclaims any buffers. | |
bool | eof () |
Indicates whether we are at the end of the file. | |
virtual void | close () |
Closes the stream, releasing all resources. | |
Byte | getByte (void) throw (InputByteStreamError) |
Reads a byte from the stream. | |
const Byte * | getBlock (unsigned int length) throw (InputByteStreamError) |
Retrieves a block from the current position in the stream. | |
void | skip (unsigned int) throw (InputByteStreamError) |
Skips a given number of bytes forward in the stream. | |
signed int | getSIU (int) throw (InputByteStreamError) |
Obtains an n-byte unsigned integer from the stream, as a signed int. | |
signed int | getSIS (int) throw (InputByteStreamError) |
Obtains an n-byte signed integer from the stream, as a signed int. | |
unsigned int | getUIU (int) throw (InputByteStreamError) |
Obtains an n-byte unsigned integer from the stream, as an unsigned int. | |
Static Public Member Functions | |
unsigned int | getUIU (int, const Byte *) throw (InputByteStreamError) |
Obtains an n-byte unsigned integer from the beginning of a Byte array, as an unsigned int. | |
void | setDefaultBufferSize (unsigned int length) |
Sets the default buffer size to be used for reading files. | |
void | verbosity (const verbosities level) |
Sets the verbosity of this module. | |
verbosities | getVerbosity (void) |
Returns the verbosity setting of this class. | |
Protected Member Functions | |
InputByteStream () | |
No-argument constructor creates a new InputByteStream object, but does not associate it with any source of bytes. | |
bool | bindToFileDescriptor (int fileno, string filename="", int bufsize=0, bool fillBufferAndClose=false, bool assertIsSeekable=false) throw (InputByteStreamError) |
Binds this stream to a given file descriptor. | |
int | openSourceSpec (string srcspec) throw (InputByteStreamError) |
Opens a source. | |
int | getFD (void) const |
Returns the file descriptor this stream is bound to. | |
void | bufferSeek (unsigned int pos) throw (InputByteStreamError) |
Seeks to a specific point in the buffer. | |
void | reloadBuffer (void) |
Reloads the buffer, presumably after the file descriptor has been adjusted by an extending class. |
Functions are provided to read individual bytes from the file and blocks of contiguous bytes.
Since this class is intended to help reading TeX DVI and PK files, we also provide methods to read signed and unsigned integers from the stream, encoded as described in the DVI driver standard.
This class is designed to be extended (and is extended in fact in classes FileByteStream and PipeStream). The subclassing interface consists of a no-argument constructor, a method to associate the class with a given file descriptor (bindToFileDescriptor), and a convenience method to help opening files, using the same specification syntax supported by this class (openSourceSpec). Since one of the main purposes of this subclassing is to support a class which handles a seekable input stream, we also have getFD to get the file descriptor being handled, and reloadBuffer to indicate to the parent class that the underlying stream has been modified (typically by a seek
operation) so that the input buffer should be invalidated. If bindToFileDescriptor
was invoked with the fillBufferAndClose
flag true, then the bufferSeek method allows rapid seeking by simply adjusting the buffer pointer; though this is useless unless the whole stream is in the buffer, the class makes no check on this, and it is the extending class's responsibility to make sure that this is not called inappropriately.
|
Prepares to read a stream from the specified file descriptor, which must be open.
|
|
Prepares to read a stream from the specified source. The source may be
|
|
Closes the file and reclaims any buffers.
|
|
No-argument constructor creates a new InputByteStream object, but does not associate it with any source of bytes. To associate it with a source, use bindToFileDescriptor or the convenience method openSourceSpec. |
|
Binds this stream to a given file descriptor.
If the parameter
|
|
Seeks to a specific point in the buffer.
This is only useful when the buffer holds the complete file, that is, when
|
|
Closes the stream, releasing all resources.
Reimplemented in PipeStream.
|
|
Indicates whether we are at the end of the file. This method does not return true until after a failed attempt to read past the end of file; that is, it does not return true immediately after the last byte has been read from the file.
|
|
Retrieves a block from the current position in the stream. Leaves the pointer pointing after the block returned.
|
|
Reads a byte from the stream.
Increments the reading pointer. This method does not signal an error at end-of-file; if eof is true or becomes true as a result of this attempt to read past the end of the file, then we return zero. That is,
|
|
Returns the file descriptor this stream is bound to.
If there is no open descriptor (see the
|
|
Obtains an n-byte signed integer from the stream, as a signed int.
|
|
Obtains an n-byte unsigned integer from the stream, as a signed int.
|
|
Obtains an n-byte unsigned integer from the beginning of a This has little specifically to do with Input streams, and is here as a convenience method.
|
|
Obtains an n-byte unsigned integer from the stream, as an unsigned int.
|
|
Returns the verbosity setting of this class.
|
|
Opens a source. The source is specified as in InputByteStream(string). Throws an exception on any problems, so that if it returns, it has successfully opened the file, or determined that the file descriptor is (syntactically) valid.
|
|
Reloads the buffer, presumably after the file descriptor has been adjusted by an extending class.
|
|
Sets the default buffer size to be used for reading files.
|
|
Skips a given number of bytes forward in the stream.
|
|
Sets the verbosity of this module.
|