Navigation:  Programming Cookbook > Binary Filing Objects >

Mixing STB with other data

Previous pageReturn to chapter overviewNext page

It is possible to store any number of STB 'sessions' on to a single stream or even mixing STB data with other data. The start of an STB session is marked with an STB header, this is read/written at the current position of the stream when the STBInFiler or STBOutFiler is created. If the STB data does not start at the very beginning of your stream then you must position the stream appropriately before creating the filer on it but you may subsequently reposition the filer for a new session on the same stream using the #position: method.

There is an #atEnd method for determining whether the end of the stream has been reached but this is really only useful in single-session streams because it does not indicate the end of an STB session, just the end of the underlying Stream. While reading a mixed/multiple session stream you will need to know how many objects were stored. In this case you can either store the data in a collection and #nextPut: that, or #nextPut: the count of objects at the start followed by a #nextPut: for each of the objects themselves.