Module: Advanced Tools Package: Streams
RWUCharFromByteInputStreamImp RWUCharInputStreamImp RWInputStreamImp RWStreamImp RWBodyBase
#include <rw/stream/RWUCharFromByteInputStreamImp.h>
Concrete class connecting a UTF-16 character stream to a binary stream. The UTF-16 characters are read as a sequence of bytes using the byte ordering (little endian or big endian) specified by the stream header. The stream header consists of the UTF-16 character U+FEFF that is inserted in the stream when generating the output byte sequence. Implements the body idiom from the handle-body pattern.
RWUCharFromByteInputStreamImp(RWByteInputStream&
sourceStream);
Initializes the reference to the stream that will be used as the source of bytes.
Parameter List
sourceStream |
The binary stream that will serve as the source of bytes. |
virtual ~RWUCharFromByteInputStreamImp();
Destructor.
static RWUCharInputStream make(RWByteInputStream& source);
Constructs an RWUCharFromByteInputStreamImp instance that uses source as the source of bytes, and returns a handle to it.
Parameter List
source |
The binary stream that is used as the source of bytes. |
virtual RWSize available() const;
Returns the number of UTF-16 characters that can be read from the stream used as the source of bytes without blocking.
virtual void close(); virtual bool isBad() const; virtual bool isEof() const; virtual bool isFail() const; virtual bool isGood() const;
These functions are forwarded to the binary stream that is used as the source of bytes. Throws no exceptions.
virtual RWUChar read();
Reads a single UTF-16 character from the stream used as the source of bytes.
virtual RWSize read(RWUChar* unicodeArray, RWSize numUChars);
Reads an array of UTF-16 characters from the stream used as the source of bytes. The array must be pre-allocated to contain at least numUChars elements. The function returns the actual number of UTF-16 characters extracted from the stream.
Parameter List
unicodeArray |
A pointer to the first element of the array. |
numUChars |
The number of UTF-16 characters(s) to be read from the stream. |
virtual RWSize readUntil(RWUChar* unicodeArray, RWSize maxSize,
RWUChar delim);
Reads UTF-16 characters from the stream used as the source of bytes until the last UTF-16 character read is equal to delim, or maxSize UTF-16 characters have been read, or the end of the input sequence is reached. The UTF-16 characters read are stored in unicodeArray. The function returns the actual number of UTF-16 characters inserted into unicodeArray. If the last UTF-16 character extracted is equal to delim, then it is not stored in unicodeArray.
Parameter List
unicodeArray |
A pointer to the array receiving the UTF-16 characters extracted from the stream. |
maxSize |
The maximum number of UTF-16 characters to be read. |
delim |
The UTF-16 character used as a delimiter. |
virtual RWSize skip(RWSize numUnits);
Skips numUnits UTF-16 characters from the input sequence if possible. The function returns the actual number of UTF-16 characters skipped, which can be any value between 0 and numUnits.
Parameter List
numUnits |
The number of UTF-16 characters to be skipped. |
static void swap2Bytes(RWUChar& uc);
Swap the Hi and Lo bytes of a single UTF-16 character. Throws no exceptions.
Parameter List
up |
A reference to a UTF-16 character that will have its bytes swapped. |
static void swapnBytes(RWUChar* ucAr, RWSize n);
Swap the Hi and Lo bytes of an array of UTF-16 characters. Throws no exceptions.
Parameter List
ucAr |
The UTF-16 character's array address. |
n |
The number of UTF-16 characters to be processed. |
RWByteInputStream& getSourceStream(); const RWByteInputStream& getSourceStream() const;
These functions return a reference to the stream used as the source of bytes. They throw no exceptions.
void getUChar(RWUChar& uc);
Reads a single UTF-16 character from the stream used as the source of bytes.
Parameter List
uc |
A reference to a UTF-16 character that will be updated if the function succeeds. |
RWSize getUChars(RWUChar* ucAr, RWSize max);
Reads an array of max UTF-16 characters from the stream used as the source of bytes. The function returns the actual number of UTF-16 characters read.
Parameter List
ucAr |
A pre-allocated array. |
max |
The number of UTF-16 characters to be read. |
© Copyright Rogue Wave Software, Inc. All Rights Reserved.
Rogue Wave and SourcePro are registered trademarks of Rogue Wave Software, Inc. in the United States and other countries. All other trademarks are the property of their respective owners.
Contact Rogue Wave about documentation or support issues.