You are here: Appendix A - Technical Notes > Notes on Streams

Notes on Streams

The LTIOStreamInf class, and streams derived from it, provide an abstraction for performing I/O in a variety of ways, including "large file" I/O, buffered I/O, memory-based I/O, etc. As it is a well-known model, the semantics of the stream operations are very similar to those of the Unix stdio operations.

This technical note provides some technical details on the LTIOStreamInf operations.

Offsets

The term "offset n" refers to byte (n+1) in the file; that is, offset 0 is the first byte and offset 10 is the eleventh byte. When a stream is "positioned at offset n", we mean than the next byte read in will be byte (n+1).

Initialization

Each derived class has constructor which has no parameters and an initialize() function which zero or more parameters which will vary according to each derived class. (Note: this initialization process is different from that of most of the other SDK functions, which put all constructor parameters in the constructor and not the initialization function.)

The initialize() function must be called prior to any other member functions.

open()

close()

read(lt_uint8 *buffer, lt_uint32 len)

write(const lt_uint8 *buffer, lt_uint32 len)

tell()

seek()

EOF

duplicate()

getLastError()

Modes

Any "modes" that a stream supports ("w", "wb", "r+", etc) are defined by the derived class; there is no notion of mode at the base class level.

For example, it is entirely possible one would want to make a "read-only file stream" class. Such a class would be implemented with the write() function always returning 0 bytes read.