Home > Language Reference > Classes

StreamComposite Class

  + Object
    + Stream
      + StreamComposite

Description

The StreamComposite class allows to successively read several streams as if they were one contiguous stream. This class is instantiable, but can neither be derived nor duplicated. For more information about streams, see also Data Streams.

This class behaves like a collection of streams. The Add method lets you add new streams in the collection while the Clear method removes all streams in the collection; the Streams function returns the collection of streams itself. For example, the following code builds a StreamComposite object by adding the five first binary resources of type rbin :

Dim sc As New StreamComposite
Dim i As Integer

For i = 1 To 5
  sc.Add App.Resource("rbin",i)
Next

Once a StreamComposite object is built, you can use its Read function to read data from the streams in the collection. The first stream is first read until the stream pointer reaches its end; then the second stream is read, and so on. When the stream pointer reaches the end of the last stream in the collection and another attempt is made to read more data, a runtime error occurs. You can also use the Seek, SeekToBegin and SeekToEnd method and the Position property to move the stream pointer; in such a case, the class uses the size of each streams in the collection to translate the specified position into a stream and a position into this stream. The StreamComposite class keeps its own stream pointer, so directly reading one of the stream in the collection does not impact the StreamComposite class itself.

This class is primarily intended to concatenate several resources on-the-fly. For exemple, you may wish to embed a big file of raw data into your application, but this is not possible because a binary resource cannot exceed 64 KB. A workaround would be to split your data into several smaller files you can add to your project as resources, and then concatenate these resources at runtime using a StreamComposite class.

Members

MembersDescription
Add Adds a stream into the collection.
Clear Clears the collection.
Streams Returns the collection of streams.
Inherited from StreamDescription
Position Stream pointer position.
Read Reads data from a stream.
Seek Moves the stream pointer.
SeekToBegin Moves the pointer to the beginning of the stream.
SeekToEnd Moves the pointer to the end of the stream.
Size Total size of the data in a stream.
Write Writes data to a stream.
Inherited from ObjectDescription
ClassID Returns the type identifier corresponding to the actual class of the object.
Implements Determines whether the object implements the features of a given class.
Iterate Event raised to iterate over the elements of a container object.
Recipient Recipient of events sent by the object.
Serialize Event raised to serialize the object content into a stream.

System requirements

SystemMinimal versionRemarks
Palm OSPalm OS 3.0N/A