Advanced Tools Module User’s Guide : PART II Advanced Tools Module Packages : Chapter 3 The Streams Package : The Streams Package Classes
The Streams Package Classes
This section describes the stream families and their concrete classes.
The Binary Streams
The binary streams read binary data (input streams) and write binary data (output streams). They allow operations on a single element or on a group of elements.
NOTE >> For a complete description of the operations supported by the binary streams, read about RWByteOutputStream for the binary output streams and RWByteInputStream for the binary input streams in the SourcePro API Reference Guide. These two classes are the handle classes used to manipulate the binary streams.
In addition to the classes described in the common architecture sections, the binary streams include the concrete classes shown in Figure 7.
Classes RWByteOutputStreamImp, RWByteOutputStream, RWByteInputStreamImp, and RWByteInputStream belong to the common framework.
The iostreams libraries include streambuf.
Figure 7 – Concrete binary streams
The RWByteToStreambufOutputStreamImp Class
RWByteToStreambufOutputStreamImp implements a binary output stream that uses an iostreams narrow stream buffer object as its sink of bytes. The iostreams stream buffer object is accessed through its base class streambuf and must be opened in binary mode.
The RWByteFromStreambufInputStreamImp Class
RWByteFromStreambufInputStreamImp implements a binary input stream that uses an iostreams narrow stream buffer object as its source of bytes. The iostreams stream buffer object is accessed through its base class streambuf and must be opened in binary mode.
The RWStreambufToByteOutputStream Class
RWStreambufToByteOutputStream is an adapter class that adapts the iostreams streambuf interface to the Rogue Wave binary Output Stream interface. Requests made through the iostreams streambuf interface are forwarded to the embedded RWByteOutputStream handle. Calls to the streambuf input sequence functions always fail because the underlying binary output stream supports only output operations.
The RWStreambufFromByteInputStream Class
RWStreambufFromByteInputStream is an adapter class that adapts the iostreams streambuf interface to the Rogue Wave binary Input Stream interface. Requests made through the iostreams streambuf interface are forwarded to the embedded RWByteInputStream handle. Calls to the streambuf output sequence functions always fail because the underlying binary input stream supports only input operations.
The Narrow Character Streams
The narrow character streams read narrow characters (input streams) and write narrow characters (output streams). They allow operations on a single character or on a group of characters.
NOTE >> For a complete description of the operations supported by the narrow character streams, read about RWCharOutputStream for the narrow output streams and RWCharInputStream for the narrow input streams in the SourcePro API Reference Guide. These two classes are the handle classes used to manipulate the narrow character streams.
In addition to the classes described in the common architecture sections, the narrow character streams include the concrete classes shown in Figure 8.
Classes RWCharOutputStreamImp, RWCharOutputStream, RWCharInputStreamImp, and RWCharInputStream belong to the common framework.
The iostreams libraries include streambuf.
Figure 8 – Narrow character streams
The RWCharToStreambufOutputStreamImp Class
RWCharToStreambufOutputStreamImp implements a narrow character output stream that uses an iostreams narrow stream buffer object as its sink of narrow characters. The iostreams stream buffer object is accessed through its base class streambuf.
The RWCharFromStreambufInputStreamImp Class
RWCharFromStreambufInputStreamImp implements a narrow character input stream that uses an iostreams narrow stream buffer object as its source of narrow characters. The iostreams stream buffer object is accessed through its base class streambuf.
The RWStreambufToCharOutputStream Class
RWStreambufToCharOutputStream is an adapter class that adapts the iostreams streambuf interface to the Rogue Wave narrow character Output Stream interface. Requests made through the iostreams streambuf interface are forwarded to the embedded RWCharOutputStream handle. Calls to the streambuf input sequence functions always fail because the underlying narrow character output stream supports only output operations.
The RWStreambufFromCharInputStream Class
RWStreambufFromCharInputStream is an adapter class that adapts the iostreams streambuf interface to the Rogue Wave narrow character Input Stream interface. Requests made through the iostreams streambuf interface are forwarded to the embedded RWCharInputStream handle. Calls to the streambuf output sequence functions always fail because the underlying narrow character input stream supports only input operations.
The Unicode Character Streams
The Unicode character streams read UTF-16 characters (input streams) and write UTF-16 characters (output streams). They allow operations on a single character or on a group of characters.
UTF-16 is a character encoding form for Unicode characters that represents each 21-bit Unicode code point in one or two 16-bit code units. For more information on Unicode and its various encoding forms, see the Internationalization Module User’s Guide.
The Advanced Tools Module Streams package stores UTF-16 characters using instance variables of type RWUChar, which is a typedef for unsigned short. The C++ type wchar_t is not used because its size is platform-dependent.
NOTE >> For a complete description of the operations supported by the Unicode character streams, read about RWUCharOutputStream for the Unicode output streams and RWUCharInputStream for the Unicode input streams in the SourcePro API Reference Guide. These two classes are the handle classes used to manipulate the Unicode character streams.
In addition to the classes described in the common architecture sections, the Unicode character streams include the concrete classes shown in Figure 9.
Figure 9 – Unicode streams
Classes RWUCharOutputStreamImp, RWByteOutputStream, RWUCharInputStreamImp, and RWByteInputStream belong to the common framework.
None of the concrete Unicode character streams are terminal streaming elements. They require a binary stream handle when constructed and use this handle as the sink of bytes for the output streams or as the source of bytes for the input streams.
The RWUCharToByteOutputStreamImp Class
RWUCharToByteOutputStreamImp connects a Unicode character stream to a binary stream. The UTF-16 characters are written as a sequence of bytes using the byte ordering (little endian or big endian) supported by the system on which the code is executed. The UTF-16 character U+FEFF is inserted in the stream as the first character to indicate to the corresponding input streams the byte ordering used when generating the output byte sequence.
The RWUCharFromByteInputStreamImp Class
RWUCharFromByteInputStreamImp connects a Unicode character stream to a binary stream. The UTF-16 characters are read as a sequence of bytes. The stream header specifies the stream byte ordering (little endian or big endian). It consists of the UTF-16 character U+FEFF that is inserted in the stream when generating the output byte sequence. If the stream byte ordering is different from the system byte ordering, then the stream automatically swaps bytes when producing Unicode characters.
The RWUCharToUTF8ByteOutputStreamImp Class
RWUCharToUTF8ByteOutputStreamImp connects a Unicode character stream to a binary stream using UTF-8. UTF-8 is a character encoding form in which each 21-bit Unicode code point is represented using one to four 8-bit code units.
The UTF-16 characters are transformed as a sequence of bytes using the UTF-8 encoding form.
The RWUCharFromUTF8ByteInputStreamImp Class
RWUCharFromUTF8ByteInputStreamImp connects a Unicode character stream to a binary stream using UTF-8. The bytes read from the binary stream used as the source of bytes are transformed into UTF-16 characters using the UTF-8 transformation form.
The Wide Character Streams
The wide character streams read wide characters (input streams) and write wide characters (output streams). They allow operations on a single character or on a group of characters.
NOTE >> For a complete description of the operations supported by the wide character streams, see RWWCharOutputStream and RWWCharInputStream. These two classes are the handle classes used to manipulate the wide character streams.
In addition to the classes described in the common architecture sections, the wide character streams include the concrete classes shown in Figure 10.
Figure 10 – Wide character streams
Classes RWWCharOutputStreamImp and RWWCharInputStreamImp belong to the common framework.
Class wstreambuf belongs to the Standard iostreams library. It is a typedef for basic_streambuf<wchar_t, char_traits<wchar_t> >. If you are building the Streams package without the Standard iostreams library, then this class, as well as the other wide character streams concrete classes, are not available to you.
The RWWCharToWStreambufOutputStreamImp Class
RWWCharToWStreambufOutputStreamImp implements a wide character output stream that uses an iostreams wide stream buffer object as its sink of wide characters. The iostreams stream buffer object is accessed through its base class basic_streambuf<wchar_t, char_traits<wchar_t> >. This class requires the Standard iostreams library.
The RWWCharFromWStreambufInputStreamImp Class
RWWCharFromWStreambufInputStreamImp implements a wide character input stream that uses an iostreams wide stream buffer object as its source of wide characters. The iostreams stream buffer object is accessed through its base class basic_streambuf<wchar_t, char_traits<wchar_t> >. This class requires the Standard iostreams library.
The Data Streams
The data streams read C++ base types (input streams) and write C++ base types (output streams), such as bool, char, unsigned char, short, and float. They allow operations on a single element or on a group of elements.
NOTE >> For a complete description of the operations supported by the data streams, read about RWDataOutputStream for the data output streams and RWDataInputStream for the data input streams in the SourcePro API Reference Guide. These two classes are the handle classes used to manipulate the data streams.
In addition to the classes described in the common architecture sections, the data streams include the concrete classes shown in Figure 11.
Figure 11 – Data output streams
Classes RWDataOutputStreamImp, RWDataOutputStream, RWByteOutputStream, RWCharOutputStream, RWDataInputStreamImp, RWDataInputStream, RWByteInputStream, and RWCharInputStream belong to the common framework.
Classes RWvostream and RWvistream belong to the Essential Tools Module library.
Figure 12 – Data input streams
Classes RWDataToByteOutputStreamImp, RWDataToCharOutputStreamImp, RWDataFromByteInputStreamImp, and RWDataFromCharInputStreamImp are abstract classes that implement common functionality for each specific conversion from and to a data stream.
None of the concrete data streams are terminal streaming elements. They require a stream handle when constructed and use this handle as the sink of underlying elements for the output streams or as source of underlying elements for the input streams.
The RWNativeDataToByteOutputStreamImp Class
RWNativeDataToByteOutputStreamImp implements a data output stream that uses a binary output stream as its sink of bytes. Base types are converted to binary data using their native representation.
The RWNativeDataFromByteInputStreamImp Class
RWNativeDataFromByteInputStreamImp implements a data input stream that uses a binary input stream as its source of bytes. Binary data are converted to C++ base types using the platform-dependent native representation. Byte swapping, if required, is not automatically performed.
The RWOstreamDataToCharOutputStreamImp Class
RWOstreamDataToCharOutputStreamImp implements a data output stream that uses a narrow character output stream as its sink of narrow characters. C++ base types are converted to narrow characters using an internal iostreams object of type ostream.
The RWIstreamDataFromCharInputStreamImp Class
RWIstreamDataFromCharInputStreamImp implements a data input stream that uses a narrow character input stream as its source of narrow characters. Narrow characters are converted to C++ base types using an internal iostreams object of type istream.
The RWvostreamToDataOutputStream Class
RWvostreamToDataOutputStream is an adapter class that adapts the Essential Tools Module virtual output stream interface to the Advanced Tools Module Data Output Stream interface. Requests made through the Essential Tools Module virtual output stream interface are forwarded to the embedded RWDataOutputStream handle.
The RWvistreamFromDataInputStream Class
RWvistreamFromDataInputStream is an adapter class that adapts the Essential Tools Module virtual input stream interface to the Advanced Tools Module Data Input Stream interface. Requests made through the Essential Tools Module virtual input stream interface are forwarded to the embedded RWDataInputStream handle.