Rogue Wave banner
Previous fileTop of DocumentContentsIndex pageNext file
Essential Networking Module User's Guide
Rogue Wave web site:  Home Page  |  Main Documentation Page

5.1 Using Iostreams

C++ uses iostreams as the standard mechanism for input and output. Iostreams allow type-safe insertion and extraction of both user-defined and built-in types into and out of communication streams. The Networking package iostreams classes enable you to use the standard iostreams classes for input and output, using a portal as the underlying source and sink of bytes.

5.1.1 Using Iostream Classes for Formatted Output

Example 5 shows how to use the iostream classes for formatted output into a portal.

Example 5: Using iostream classes for formatted output into a portal

//1

Sets up an ostream object, which uses the RWPortal object portal for its sink of bytes. The RWPortalOStream makes its own copy of the portal, which enables you to specify a temporary object in the constructor.

//2

Outputs objects using the stream. Because the RWPortalOStream class is derived from ostream, any objects that can be inserted into an ostream can also be inserted into an RWPortalOStream.

5.1.2 Using Iostream Classes for Formatted Input

Example 6 shows how to use the iostream classes for formatted input.

Example 6: Using iostream classes for formatted input

//1

Sets 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, which enables you to specify a temporary object in the constructor.

//2

Inputs objects using the stream. Because the RWPortalIStream class is derived from istream, any objects that can be extracted from an istream can also be extracted from an RWPortalIStream.



Previous fileTop of DocumentContentsIndex pageNext file

Copyright © Rogue Wave Software, Inc. All Rights Reserved.

The Rogue Wave name and logo, and SourcePro, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.