The MrSID SDK provides an abstract stream class, LTIOStreamInf
, which provides a Unix stdio-like interface for working with data in files or file-like objects. Rather than relying on the application to provide a file name or a FILE*
, many of the SDK functions are designed to operate on LTIOStreamInf
objects instead. This enables more portable and extensible interfaces.
The LTIOStreamInf
interface requires only a small set of primitives, including:
open()
and close()
read()
and write()
, using byte arrays
seek()
and tell()
, using 64-bit offsets
isOpen()
and isEOF()
(For details on the precise semantics of these primitives, see the Reference Manual and "Notes on Streams".)
A number of useful stream types, including files, in-memory buffers, sockets, and buffered streams, can be implemented using the stream interface. The SDK provides the following stream implementations:
LTIOFileStream
– OS-native file support (2GB or less only)
LTIOMemStream
– in-memory, read-only buffer of fixed size
LTIODynamicMemStream
– in-memory read/write buffer, which grows as required
LTIOBufferedStream
– nontrivial buffering for an underlying LTIOStreamInf
LTIOCallbackStream
– stream implemented via user-supplied callbacks for basic operations (read, write, open etc.)
The Reference Manual contains several examples of working with streams, including code showing how to perform simple reads and writes and how to derive your own simple stream from LTIOStreamInf
.