activemq-cpp-3.4.0
|
A PushbackInputStream adds functionality to another input stream, namely the ability to "push back" or "unread" one byte. More...
#include <src/main/decaf/io/PushbackInputStream.h>
Public Member Functions | |||||||
PushbackInputStream (InputStream *stream, bool own=false) | |||||||
Creates a PushbackInputStream and saves its argument, the input stream in, for later use. | |||||||
PushbackInputStream (InputStream *stream, int bufSize, bool own=false) | |||||||
Creates a PushbackInputStream and saves its argument, the input stream in, for later use. | |||||||
virtual | ~PushbackInputStream () | ||||||
void | unread (unsigned char value) | ||||||
Pushes back the given byte, the byte is copied to the front of the pushback buffer, future calls to read start reading from the beginning of these pushed back byte. | |||||||
void | unread (const unsigned char *buffer, int size) | ||||||
Pushes back the given array of bytes, the bytes are copied to the front of the pushback buffer, future calls to read start reading from the beginning of these pushed back bytes. | |||||||
void | unread (const unsigned char *buffer, int size, int offset, int length) | ||||||
Pushes back the given array of bytes, the bytes are copied to the front of the pushback buffer, future calls to read start reading from the beginning of these pushed back bytes. | |||||||
virtual int | available () const | ||||||
Indicates the number of bytes available.The default implementation of this methods returns 0. Classes that override this method may return the total number of bytes that are currently available for reading and others may simply return a value of one indicating that there is some data avaiable. The caller should view the result of this method as an absolute.The default implementation of this method returns zero.
| |||||||
virtual long long | skip (long long num) | ||||||
Skips over and discards n bytes of data from this input stream.The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned.The skip method of InputStream creates a byte array and then repeatedly reads into it until num bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method.
| |||||||
virtual void | mark (int readLimit) | ||||||
Does nothing except throw an IOException. | |||||||
virtual void | reset () | ||||||
Does nothing except throw an IOException. | |||||||
virtual bool | markSupported () const | ||||||
Does nothing except throw an IOException. | |||||||
Protected Member Functions | |||||||
virtual int | doReadByte () | ||||||
virtual int | doReadArrayBounded (unsigned char *buffer, int size, int offset, int length) |
A PushbackInputStream adds functionality to another input stream, namely the ability to "push back" or "unread" one byte.
This is useful in situations where it is convenient for a fragment of code to read an indefinite number of data bytes that are delimited by a particular byte value; after reading the terminating byte, the code fragment can "unread" it, so that the next read operation on the input stream will reread the byte that was pushed back. For example, bytes representing the characters constituting an identifier might be terminated by a byte representing an operator character; a method whose job is to read just an identifier can read until it sees the operator and then push the operator back to be re-read.
decaf::io::PushbackInputStream::PushbackInputStream | ( | InputStream * | stream, |
bool | own = false |
||
) |
Creates a PushbackInputStream and saves its argument, the input stream in, for later use.
Initially, there is no pushed-back byte.
stream | The InputStream instance to wrap. |
Boolean | value indicating if this FilterInputStream owns the wrapped stream. |
decaf::io::PushbackInputStream::PushbackInputStream | ( | InputStream * | stream, |
int | bufSize, | ||
bool | own = false |
||
) |
Creates a PushbackInputStream and saves its argument, the input stream in, for later use.
Initially, there is no pushed-back byte.
stream | The InputStream instance to wrap. |
bufSize | The number of byte to allocate for pushback into this stream. |
Boolean | value indicating if this FilterInputStream owns the wrapped stream. |
IllegalArgumentException | if the bufSize argument is < zero. |
virtual decaf::io::PushbackInputStream::~PushbackInputStream | ( | ) | [virtual] |
virtual int decaf::io::PushbackInputStream::available | ( | ) | const [virtual] |
Indicates the number of bytes available.The default implementation of this methods returns 0. Classes that override this method may return the total number of bytes that are currently available for reading and others may simply return a value of one indicating that there is some data avaiable. The caller should view the result of this method as an absolute.The default implementation of this method returns zero.
IOException | if an I/O error occurs. |
Returns the sum of the number of pushed back bytes if any and the amount of bytes available in the underlying stream via a call to available.
Reimplemented from decaf::io::FilterInputStream.
virtual int decaf::io::PushbackInputStream::doReadArrayBounded | ( | unsigned char * | buffer, |
int | size, | ||
int | offset, | ||
int | length | ||
) | [protected, virtual] |
Reimplemented from decaf::io::FilterInputStream.
virtual int decaf::io::PushbackInputStream::doReadByte | ( | ) | [protected, virtual] |
Reimplemented from decaf::io::FilterInputStream.
virtual void decaf::io::PushbackInputStream::mark | ( | int | readLimit | ) | [virtual] |
Does nothing except throw an IOException.
Marks the current position in the stream A subsequent call to the reset method repositions this stream at the last marked position so that subsequent reads re-read the same bytes.If a stream instance reports that marks are supported then the stream will ensure that the same bytes can be read again after the reset method is called so long the readLimit is not reached.Calling mark on a closed stream instance should have no effect.The default implementation of this method does nothing.
readLimit | The max bytes read before marked position is invalid. |
Reimplemented from decaf::io::FilterInputStream.
virtual bool decaf::io::PushbackInputStream::markSupported | ( | ) | const [inline, virtual] |
Does nothing except throw an IOException.
Determines if this input stream supports the mark and reset methods.Whether or not mark and reset are supported is an invariant property of a particular input stream instance.The default implementation of this method returns false.
Reimplemented from decaf::io::FilterInputStream.
virtual void decaf::io::PushbackInputStream::reset | ( | ) | [virtual] |
Does nothing except throw an IOException.
Repositions this stream to the position at the time the mark method was last called on this input stream.If the method markSupported returns true, then: * If the method mark has not been called since the stream was created, or the number of bytes read from the stream since mark was last called is larger than the argument to mark at that last call, then an IOException might be thrown. * If such an IOException is not thrown, then the stream is reset to a state such that all the bytes read since the most recent call to mark (or since the start of the file, if mark has not been called) will be resupplied to subsequent callers of the read method, followed by any bytes that otherwise would have been the next input data as of the time of the call to reset.If the method markSupported returns false, then: * The call to reset may throw an IOException. * If an IOException is not thrown, then the stream is reset to a fixed state that depends on the particular type of the input stream and how it was created. The bytes that will be supplied to subsequent callers of the read method depend on the particular type of the input stream.The default implementation of this method throws an IOException.
IOException | if an I/O error occurs. |
Reimplemented from decaf::io::FilterInputStream.
virtual long long decaf::io::PushbackInputStream::skip | ( | long long | num | ) | [virtual] |
Skips over and discards n bytes of data from this input stream.The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. This may result from any of a number of conditions; reaching end of file before n bytes have been skipped is only one possibility. The actual number of bytes skipped is returned.The skip method of InputStream creates a byte array and then repeatedly reads into it until num bytes have been read or the end of the stream has been reached. Subclasses are encouraged to provide a more efficient implementation of this method.
num | The number of bytes to skip. |
IOException | if an I/O error occurs. |
UnsupportedOperationException | if the concrete stream class does not support skipping bytes. |
This method first skips bytes in the local pushed back buffer before attempting to complete the request by calling the underlying stream skip method with the remainder of bytes that needs to be skipped.
Reimplemented from decaf::io::FilterInputStream.
void decaf::io::PushbackInputStream::unread | ( | const unsigned char * | buffer, |
int | size | ||
) |
Pushes back the given array of bytes, the bytes are copied to the front of the pushback buffer, future calls to read start reading from the beginning of these pushed back bytes.
buffer | The bytes to copy to the front of push back buffer. |
size | The size of the array to be copied. |
NullPointerException | if the buffer passed is NULL. |
IndexOutOfBoundsException | if the size value given is negative. |
IOException | if there is not enough space in the pushback buffer or this stream has already been closed. |
void decaf::io::PushbackInputStream::unread | ( | const unsigned char * | buffer, |
int | size, | ||
int | offset, | ||
int | length | ||
) |
Pushes back the given array of bytes, the bytes are copied to the front of the pushback buffer, future calls to read start reading from the beginning of these pushed back bytes.
buffer | The bytes to copy to the front of push back buffer. |
size | The size of the array to be copied. |
offset | The position in the buffer to start copying from. |
length | The number of bytes to push back from the passed buffer. |
NullPointerException | if the buffer passed is NULL. |
IndexOutOfBoundsException | if the offset + length is greater than the buffer size. |
IOException | if there is not enough space in the pushback buffer or this stream has already been closed. |
void decaf::io::PushbackInputStream::unread | ( | unsigned char | value | ) |
Pushes back the given byte, the byte is copied to the front of the pushback buffer, future calls to read start reading from the beginning of these pushed back byte.
value | The byte that is to be placed at the front of the push back buffer. |
IOException | if there is not enough space in the pushback buffer or this stream has already been closed. |