Rogue Wave banner
Previous fileTop of DocumentContentsIndexNext file

12.2 Formatted I/O

Here's a code segment that shows how you can use the iostream classes for formatted output into a portal.

//1Set up an ostream object, which uses the RWPortal object portal for its sink of bytes. The RWPortalOStream makes its own copy of the portal, so you can specify a temporary object in the constructor if you like. This approach is efficient thanks to the interface-implementation design of the portal class.
//2Output objects using the stream. Since the RWPortalOStream class is derived from ostream, any objects that can be inserted into an ostream can be inserted into an RWPortalOStream.

Building a stream for input is no more difficult than building one for output:

//1Set up an istream object that uses the RWPortal object portal for its source of bytes. The RWPortalIStream also makes its own copy of the portal, allowing you to specify a temporary object to the constructor.
//2Input objects using the stream. Since the RWPortalIStream class is derived from istream, any objects that can be extracted from an istream can be extracted from an RWPortalIStream.

Previous fileTop of DocumentContentsIndexNext file

©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.