
where XXX is either In or Out, mode is a stream opening mode identical to
the open_mode flags used for istream and ostream, and strmId is a pointer to
an existing stream object. Passing a valid pointer to an existing stream
object in strmId causes that stream to be used as the document’ streams
object. Otherwise, the object opens a new stream object.
There are also two stream-access functions called AttachStream and
DetachStream. Both of these functions take a reference to an existing (that is,
already constructed and open) TStream-derived object. AttachStream adds
the TStream-derived object to the document’ list of stream objects, makings
it available for access. DetachStream searches the document’ list of streams
objects and deletes the TStream-derived object passed to it. Both of these
functions have protected access and thus can be called only from inside the
document object.
Each document maintains a list of open streams that is updated as streams
Stream list
are added and deleted. This list is headed by the TDocument data
StreamList. StreamList is a TStream * that points to the first stream in the list.
If there are no streams in the list, StreamList is 0. Each TStream object in the
list has a member named NextStream, which points to the next stream in the
stream list.
When a new stream is opened in a document object or an existing stream is
attached to the object, it is added to the document’ stream list. When ans
existing stream is closed in a document object or detached from the object,
it is removed from the document’ stream list.s
Streams can provide only simple serial access to data. In cases where a
Complex data
document contains multimedia files, database tables, or other complex
access
data, you probably want more sophisticated access methods. For this
purpose, TDocument uses two more access functions, Open and Close, which
you can override to define your own opening and closing behavior.
The TDocument version of Open performs no actions; it always returns
TRUE. Y u can write your own version of Open to work however youo
want. There are no restrictions placed on how you define opening a
document. Y u can make it as simple as you like or as complex aso
necessary Open lets you open a document and keep it open, instead of.
opening the document only on demand from one of the document’ streams
objects.
The TDocument version of Close provides a little more functionality than
does Open. It checks any existing children of your document and tries to
close them before closing your document. If you provide your own Close,
the first thing you should do in that function is call the TDocument version
210
OWL P ogrammer’ Guider s