ot::io
class DataInput (abstract)
#include "ot/io/DataInput.h"
An abstract base class that provides methods for reading fixed-length data blocks in a platform-independent manner.
- See also:
-
DataOutput
- Since:
-
OpenTop 1.4
| Method Summary
|
virtual bool |
readBoolean()
Reads a single byte from the input stream and converts it to a bool value. |
virtual Byte |
readByte()
Reads a single byte from the input stream. |
virtual void |
readFully(Byte* pBuffer, size_t bufLen)=0
Reads exactly bufLen bytes from the current position in the stream. |
virtual Int64Type |
readInt64()
Reads 8 bytes from the stream into a 64-bit integer value. |
virtual long |
readLong()
Reads 4 bytes from the stream into a long integer value. |
virtual short |
readShort()
Reads 2 bytes from the stream into a short integer value. |
virtual UInt64Type |
readUnsignedInt64()
Reads 8 bytes from the stream into a 64-bit unsigned integer value. |
virtual unsigned long |
readUnsignedLong()
Reads 4 bytes from the stream into an unsigned long integer value. |
virtual unsigned short |
readUnsignedShort()
Reads 2 bytes from the stream into an unsigned short integer value. |
virtual String |
readUTF()
Reads a String value stored in UTF format. |
virtual size_t |
skipBytes(size_t n)=0
Positions the stream as if by calling readByte() n times. |
readBoolean
virtual bool readBoolean()
-
Reads a single byte from the input stream and converts it to a bool value.
- Returns:
-
true if the read byte has any non-zero value; false otherwise.
- Exceptions:
EOFException -
if the end of stream has been reached.
- See also:
-
DataInput::writeBoolean()
readByte
virtual Byte readByte()
-
Reads a single byte from the input stream.
- Returns:
-
the Byte value read.
- Exceptions:
EOFException -
if end of stream is reached before the appropriate number of bytes have been read.
- See also:
-
DataOutput::writeByte()
readFully
virtual void readFully(Byte* pBuffer,
size_t bufLen)=0
-
Reads exactly bufLen bytes from the current position in the stream.
If EndOfFile is reached before bufLen bytes have been read an EOFException is thrown.
- Parameters:
pBuffer -
A pointer to the buffer into which the bytes will be copied. This must be capable of holding at least bufLen bytes.
bufLen -
The required number of bytes to read into the passed buffer.
- Exceptions:
EOFException -
if end of stream was reached before sufficient bytes were read.
IllegalArgumentException -
if bufLen is zero
NullPointerException -
if pBuffer is null
IOException -
if an I/O error occurs.
readInt64
virtual Int64Type readInt64()
-
Reads 8 bytes from the stream into a 64-bit integer value.
The value is assumed to be stored in 2s complement, big-endian form as written by DataOutput::writeInt64().
- Returns:
-
A 64-bit integer value.
- Exceptions:
EOFException -
if end of stream is reached before the appropriate number of bytes have been read.
- See also:
-
DataOutput::writeInt64()
readLong
virtual long readLong()
-
Reads 4 bytes from the stream into a long integer value.
The value is assumed to be stored in 2s complement, big-endian form as written by DataOutput::writeLong().
- Returns:
-
A long integer value.
- Exceptions:
EOFException -
if end of stream is reached before the required number of bytes have been read.
- See also:
-
DataOutput::writeLong()
readShort
virtual short readShort()
-
Reads 2 bytes from the stream into a short integer value.
The value is assumed to be stored in 2s complement, big-endian form as written by DataOutput::writeShort().
- Returns:
-
A short integer value.
- Exceptions:
EOFException -
if end of stream is reached before the appropriate number of bytes have been read.
- See also:
-
DataOutput::writeShort()
readUnsignedInt64
virtual UInt64Type readUnsignedInt64()
-
Reads 8 bytes from the stream into a 64-bit unsigned integer value.
The value is assumed to be stored in 2s complement, big-endian form as written by DataOutput::writeUnsignedInt64().
- Returns:
-
An unsigned 64-bit integer value.
- Exceptions:
EOFException -
if end of stream is reached before the appropriate number of bytes have been read.
- See also:
-
DataOutput::writeUnsignedInt64()
readUnsignedLong
virtual unsigned long readUnsignedLong()
-
Reads 4 bytes from the stream into an unsigned long integer value.
The value is assumed to be stored in 2s complement, big-endian form as written by DataOutput::writeUnsignedLong().
- Returns:
-
An unsigned long integer value.
- Exceptions:
EOFException -
if end of stream is reached before the appropriate number of bytes have been read.
- See also:
-
DataOutput::writeUnsignedLong()
readUnsignedShort
virtual unsigned short readUnsignedShort()
-
Reads 2 bytes from the stream into an unsigned short integer value.
The value is assumed to be stored in 2s complement, big-endian form as written by DataOutput::writeUnsignedShort().
- Returns:
-
An unsigned short integer value.
- Exceptions:
EOFException -
if end of stream is reached before the appropriate number of bytes have been read.
- See also:
-
DataOutput::writeUnsignedShort()
readUTF
virtual String readUTF()
-
Reads a String value stored in UTF format.
The UTF format is comprised of a 2-byte length field followed by length bytes in UTF-8 format. The UTF-8 bytes are read using readFully() and then converted into Unicode characters before being returned as an OpenTop String. UTF-8 is a multi-byte encoding and the length of the returned String may not be the same as the number of UTF-8 bytes read from the stream (unless OpenTop is using UTF-8 internally).
- Returns:
-
A Unicode String value.
- Exceptions:
EOFException -
if end of stream is reached before the entire UTF block has been read.
- See also:
-
DataOutput::writeUTF()
skipBytes
virtual size_t skipBytes(size_t n)=0
-
Positions the stream as if by calling readByte() n times.
- Returns:
-
The number of bytes skipped, which will be equal to n unless the end of stream was reached first.
- Exceptions:
IOException -
if an I/O error occurs.
Found a bug or missing feature? Please email us at support@elcel.com