OWLNext    7.0
Borland's Object Windows Library for the modern age
Loading...
Searching...
No Matches
Stream Access

TDocument provides two functions, InStream and OutStream, that return pointers to a TInStream and a TOutStream, respectively.

The TDocument versions of these functions both return a 0, because the functions actually perform no actions. To provide stream access for your document class you must override these functions, construct the appropriate stream class, and return a pointer to the stream object.

TInStream and TOutStream are abstract stream classes, derived from TStream and istream or ostream, respectively. TStream provides a minimal functionality to connect the stream to a document. istream and ostream are standard C++ iostreams. You must derive document-specific stream classes from TInStream and TOutStream.

Following is a simple description of the InStream and OutStream member functions.

Both InStream and OutStream take two parameters,

XXXStream(int mode, const char far* strmId = 0);

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 the name of a stream source if the document supports named streams, such as a file name or device name. Passing the name of an existing data source opens a stream to or from that data source as the document's stream object. Otherwise, the object opens a new stream object.

There are also two stream-access functions called AttachStream and DetachStream. Both 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's list of stream objects, making it available for access. DetachStream searches the document's list of stream objects and deletes the TStream-derived object passed to it. Both these functions have protected access and thus can be called only from inside the document object.

See Also