SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Static Private Member Functions
RWUCharFromByteInputStreamImp Class Reference

Concrete class connecting a UTF-16 character stream to an input binary stream. More...

#include <rw/stream/RWUCharFromByteInputStreamImp.h>

Inheritance diagram for RWUCharFromByteInputStreamImp:
RWUCharInputStreamImp RWInputStreamImp RWStreamImp RWBodyBase RWTCountingBody< RWMutexLock > RWTMonitor< RWMutexLock >

Public Member Functions

virtual ~RWUCharFromByteInputStreamImp ()
 
virtual RWSize available () const
 
virtual void close ()
 
virtual bool isBad () const
 
virtual bool isEof () const
 
virtual bool isFail () const
 
virtual bool isGood () const
 
virtual RWUChar read ()
 
virtual RWSize read (RWUChar *unicodeArray, RWSize numUChars)
 
virtual RWSize readUntil (RWUChar *unicodeArray, RWSize maxSize, RWUChar delim)
 
virtual RWSize skip (RWSize numUnits)
 
- Public Member Functions inherited from RWUCharInputStreamImp
virtual ~RWUCharInputStreamImp ()
 
virtual RWUCharInputStream acquire ()
 
virtual void release ()
 
- Public Member Functions inherited from RWInputStreamImp
virtual ~RWInputStreamImp ()
 
- Public Member Functions inherited from RWStreamImp
virtual ~RWStreamImp ()
 

Static Public Member Functions

static RWUCharInputStream make (const RWByteInputStream &source)
 

Protected Member Functions

 RWUCharFromByteInputStreamImp (const RWByteInputStream &sourceStream)
 
RWByteInputStreamgetSourceStream ()
 
const RWByteInputStreamgetSourceStream () const
 
- Protected Member Functions inherited from RWUCharInputStreamImp
 RWUCharInputStreamImp ()
 
- Protected Member Functions inherited from RWInputStreamImp
 RWInputStreamImp ()
 
- Protected Member Functions inherited from RWStreamImp
 RWStreamImp ()
 
- Protected Member Functions inherited from RWBodyBase
 RWBodyBase (void)
 
 RWBodyBase (RWStaticCtor)
 
 RWBodyBase (const RWBodyBase &second)
 
virtual ~RWBodyBase (void)
 
RWBodyBaseoperator= (const RWBodyBase &second)
 
- Protected Member Functions inherited from RWTCountingBody< RWMutexLock >
 RWTCountingBody (unsigned initCount=0)
 
 RWTCountingBody (RWStaticCtor)
 
 RWTCountingBody (const RWTCountingBody< RWMutexLock > &second)
 
RWTCountingBody< RWMutexLock > & operator= (const RWTCountingBody< RWMutexLock > &second)
 
 ~RWTCountingBody (void)
 
unsigned addReference (void)
 
unsigned references (void) const
 
unsigned removeReference (void)
 
- Protected Member Functions inherited from RWTMonitor< RWMutexLock >
 RWTMonitor ()
 
 RWTMonitor (RWStaticCtor)
 
 RWTMonitor (const RWTMonitor< RWMutexLock > &second)
 
 ~RWTMonitor ()
 
void acquire ()
 
bool isAcquired () const
 
RWTMonitor< RWMutexLock > & monitor () const
 
RWMutexLockmutex ()
 
RWTMonitor< RWMutexLock > & operator= (const RWTMonitor< RWMutexLock > &)
 
void release ()
 
bool tryAcquire ()
 

Private Member Functions

void getUChar (RWUChar &uc)
 
RWSize getUChars (RWUChar *ucAr, RWSize max)
 

Static Private Member Functions

static void swap2Bytes (RWUChar &uc)
 
static void swapnBytes (RWUChar *ucAr, RWSize n)
 

Additional Inherited Members

- Protected Types inherited from RWTCountingBody< RWMutexLock >
typedef RWTLockGuard< RWTMonitor< RWMutexLock > > LockGuard
 
typedef RWTTryLockGuard< RWTMonitor< RWMutexLock > > TryLockGuard
 
typedef RWTUnlockGuard< RWTMonitor< RWMutexLock > > UnlockGuard
 
- Protected Types inherited from RWTMonitor< RWMutexLock >
typedef RWTLockGuard< RWTMonitor< RWMutexLock > > LockGuard
 
typedef RWTTryLockGuard< RWTMonitor< RWMutexLock > > TryLockGuard
 
typedef RWTUnlockGuard< RWTMonitor< RWMutexLock > > UnlockGuard
 

Detailed Description

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.

Constructor & Destructor Documentation

virtual RWUCharFromByteInputStreamImp::~RWUCharFromByteInputStreamImp ( )
virtual

Destructor.

RWUCharFromByteInputStreamImp::RWUCharFromByteInputStreamImp ( const RWByteInputStream sourceStream)
protected

Initializes the reference to the stream that will be used as the source of bytes.

Parameters
sourceStreamThe binary stream that will serve as the source of bytes.

Member Function Documentation

virtual RWSize RWUCharFromByteInputStreamImp::available ( ) const
virtual

Returns the number of UTF-16 characters that can be read from the stream used as the source of bytes without blocking.

Implements RWInputStreamImp.

virtual void RWUCharFromByteInputStreamImp::close ( )
virtual

This function is forwarded to the binary stream used as the source of bytes. Throws no exceptions.

Implements RWStreamImp.

RWByteInputStream& RWUCharFromByteInputStreamImp::getSourceStream ( )
inlineprotected

Returns a reference to the stream used as the source of bytes. They throw no exceptions.

const RWByteInputStream& RWUCharFromByteInputStreamImp::getSourceStream ( ) const
inlineprotected

Returns a reference to the stream used as the source of bytes. They throw no exceptions.

void RWUCharFromByteInputStreamImp::getUChar ( RWUChar uc)
private

Reads a single UTF-16 character from the stream used as the source of bytes.

Parameters
ucA reference to a UTF-16 character that will be updated if the function succeeds.
RWSize RWUCharFromByteInputStreamImp::getUChars ( RWUChar ucAr,
RWSize  max 
)
inlineprivate

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.

Parameters
ucArA pre-allocated array.
maxThe number of UTF-16 characters to be read.
virtual bool RWUCharFromByteInputStreamImp::isBad ( ) const
virtual

This function forwarded to the binary stream used as the source of bytes. Throws no exceptions.

Implements RWStreamImp.

virtual bool RWUCharFromByteInputStreamImp::isEof ( ) const
virtual

This function forwarded to the binary stream used as the source of bytes. Throws no exceptions.

Implements RWInputStreamImp.

virtual bool RWUCharFromByteInputStreamImp::isFail ( ) const
virtual

This function forwarded to the binary stream used as the source of bytes. Throws no exceptions.

Implements RWStreamImp.

virtual bool RWUCharFromByteInputStreamImp::isGood ( ) const
virtual

This function forwarded to the binary stream used as the source of bytes. Throws no exceptions.

Implements RWStreamImp.

static RWUCharInputStream RWUCharFromByteInputStreamImp::make ( const RWByteInputStream source)
inlinestatic

Constructs an RWUCharFromByteInputStreamImp instance that uses source as the source of bytes, and returns a handle to it.

Parameters
sourceThe binary stream that is used as the source of bytes.
virtual RWUChar RWUCharFromByteInputStreamImp::read ( )
virtual

This function forwarded to the binary stream used as the source of bytes. Throws no exceptions.

Implements RWUCharInputStreamImp.

virtual RWSize RWUCharFromByteInputStreamImp::read ( RWUChar unicodeArray,
RWSize  numUChars 
)
virtual

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.

Parameters
unicodeArrayA pointer to the first element of the array.
numUCharsThe number of UTF-16 characters to be read from the stream.

Implements RWUCharInputStreamImp.

virtual RWSize RWUCharFromByteInputStreamImp::readUntil ( RWUChar unicodeArray,
RWSize  maxSize,
RWUChar  delim 
)
virtual

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.

Parameters
unicodeArrayA pointer to the array receiving the UTF-16 characters extracted from the stream.
maxSizeThe maximum number of UTF-16 characters to be read.
delimThe UTF-16 character used as a delimiter.

Implements RWUCharInputStreamImp.

virtual RWSize RWUCharFromByteInputStreamImp::skip ( RWSize  numUnits)
virtual

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.

Parameters
numUnitsThe number of UTF-16 characters to be skipped.

Implements RWInputStreamImp.

static void RWUCharFromByteInputStreamImp::swap2Bytes ( RWUChar uc)
inlinestaticprivate

Swap the Hi and Lo bytes of a single UTF-16 character. Throws no exceptions.

Parameters
ucA reference to a UTF-16 character that will have its bytes swapped.
static void RWUCharFromByteInputStreamImp::swapnBytes ( RWUChar ucAr,
RWSize  n 
)
staticprivate

Swap the Hi and Lo bytes of an array of UTF-16 characters. Throws no exceptions.

Parameters
ucArThe UTF-16 character's array address.
nThe number of UTF-16 characters to be processed.

Copyright © 2023 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.