Om
1.0.0
A universal framework for multimedia simulation
|
A class/interface which represents an abstract read-only stream of data. More...
#include <omDataInputStream.h>
Public Member Functions | |
virtual | ~DataInputStream () |
Destroy an input stream and free all of it's resources (close it). More... | |
virtual Size | readData (UByte *buffer, Size numBytes)=0 |
Read the specified number of bytes from the stream and place them in the buffer given by a pointer. More... | |
Size | readData (data::DataBuffer &buffer, Size numBytes) |
Read the specified number of bytes from the stream and place them in the specified data buffer. More... | |
data::Data | readAllData () |
Read as many bytes from the stream as possible and return them in a Data object. More... | |
Size | readAllData (data::DataBuffer &buffer) |
Read as many bytes from the stream as possible and place them in the specified data buffer. More... | |
virtual Bool | canSeek () const =0 |
Return whether or not this type of stream allows seeking. More... | |
virtual Bool | canSeek (Int64 relativeOffset) const =0 |
Return whether or not this stream can seek by the specified amount in bytes. More... | |
virtual Int64 | seek (Int64 relativeOffset)=0 |
Move the current position in the stream by the specified relative signed offset in bytes. More... | |
Bool | hasBytesRemaining () const |
Return whether or not there are bytes remaining in the stream. More... | |
virtual LargeSize | getBytesRemaining () const =0 |
Return the number of bytes remaining in the stream. More... | |
virtual LargeIndex | getPosition () const =0 |
Return the current byte index within the stream relative to the beginning. More... | |
A class/interface which represents an abstract read-only stream of data.
|
inlinevirtual |
Destroy an input stream and free all of it's resources (close it).
Read the specified number of bytes from the stream and place them in the buffer given by a pointer.
The buffer must be large enough to hold the specified number of bytes. The number of bytes read can be less than the desired number if an error is encountered or the end of the stream is reached.
If the method succeeds, the return value will equal the parameter numBytes and the stream will be advanced by that many bytes. Otherwise, the return value will be less than the parameter numBytes, indicating the amount that the stream position changed.
buffer | - a pointer to a buffer where the read data should be placed. |
numBytes | - the number of bytes of data to read from the stream. |
Implemented in om::io::BinaryDecoder, om::io::FileReader, om::resources::ResourceDecoder, and om::compression::CompressedInputStream.
Size om::io::DataInputStream::readData | ( | data::DataBuffer & | buffer, |
Size | numBytes | ||
) |
Read the specified number of bytes from the stream and place them in the specified data buffer.
data::Data om::io::DataInputStream::readAllData | ( | ) |
Read as many bytes from the stream as possible and return them in a Data object.
Size om::io::DataInputStream::readAllData | ( | data::DataBuffer & | buffer | ) |
Read as many bytes from the stream as possible and place them in the specified data buffer.
The method returns the total number of bytes written to the buffer.
|
pure virtual |
Return whether or not this type of stream allows seeking.
Some types of IO (like files) allow seeking, but others, especially those over networks don't allow streaming. This method allows the user to detect that situation.
Implemented in om::io::BinaryDecoder, om::resources::ResourceDecoder, om::io::FileReader, and om::compression::CompressedInputStream.
Return whether or not this stream can seek by the specified amount in bytes.
Since some streams may not support rewinding, this method can be used to determine if a given seek operation can succeed. The method can also be used to determine if the end of a stream has been reached, a seek past the end of a file will fail.
Implemented in om::io::BinaryDecoder, om::resources::ResourceDecoder, om::io::FileReader, and om::compression::CompressedInputStream.
Move the current position in the stream by the specified relative signed offset in bytes.
The method attempts to seek in the stream by the specified amount and returns the signed amount that the position in the stream was changed by in bytes. A negative offset indicates that the position should be moved in reverse and a positive offset indicates that the position should be moved forwards.
Implemented in om::io::BinaryDecoder, om::resources::ResourceDecoder, om::io::FileReader, and om::compression::CompressedInputStream.
|
inline |
Return whether or not there are bytes remaining in the stream.
|
pure virtual |
Return the number of bytes remaining in the stream.
The value returned must only be a lower bound on the number of bytes remaining in the stream. If there are bytes remaining, it must return at least 1.
Implemented in om::io::BinaryDecoder, om::io::FileReader, om::resources::ResourceDecoder, and om::compression::CompressedInputStream.
|
pure virtual |
Return the current byte index within the stream relative to the beginning.
Implemented in om::io::BinaryDecoder, om::resources::ResourceDecoder, om::io::FileReader, and om::compression::CompressedInputStream.