Here's a code segment that shows how you can use the iostream classes for formatted output into a portal.
// set up the RWPortal object, portal RWPortalOStream ostrm(portal); //1 ostrm << "hello world" << endl; //2
//1 | Set 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. |
//2 | Output 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:
// set up the RWPortal object, portal RWPortalIStream istrm(portal); //1 RWCString s; istrm >> s; //2
//1 | Set 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. |
//2 | Input 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. |
©Copyright 2000, Rogue Wave Software, Inc.
Contact Rogue Wave about documentation or support issues.