SourcePro® API Reference Guide

 
List of all members | Public Member Functions | Related Functions
RWByteInputStream Class Reference

Handle class for all binary input stream implementation classes. More...

#include <rw/stream/RWByteInputStream.h>

Inheritance diagram for RWByteInputStream:
RWHandleBase

Public Member Functions

 RWByteInputStream (RWByteInputStreamImp *ptr)
 
 RWByteInputStream (const RWByteInputStream &handle)
 
RWSize available () const
 
void close ()
 
bool isBad () const
 
bool isEof () const
 
bool isFail () const
 
bool isGood () const
 
RWByteInputStreamoperator= (const RWByteInputStream &handle)
 
RWByteInputStreamoperator>> (RWByteInputStream &(*pf)(RWByteInputStream &))
 
RWByteInputStream operator>> (RWByteInputStream(*pf)(RWByteInputStream &))
 
RWByteInputStreamoperator>> (RWByte &byteValue)
 
RWByte read ()
 
RWSize read (RWByte *byteArray, RWSize numBytes)
 
RWSize readUntil (RWByte *byteArray, RWSize maxSize, RWByte delim)
 
RWSize skip (RWSize numUnits)
 
- Public Member Functions inherited from RWHandleBase
bool isValid (void) const
 
bool operator!= (const RWHandleBase &second) const
 
bool operator< (const RWHandleBase &second) const
 
bool operator== (const RWHandleBase &second) const
 

Related Functions

(Note that these are not member functions.)

RWByteInputStreamrwDisc (RWByteInputStream &stream)
 
RWByteInputStream rwGuard (RWByteInputStream &stream)
 

Additional Inherited Members

- Protected Member Functions inherited from RWHandleBase
 RWHandleBase (void)
 
 RWHandleBase (RWStaticCtor)
 
 RWHandleBase (RWBodyBase *body)
 
 RWHandleBase (const RWHandleBase &second)
 
 ~RWHandleBase (void)
 
RWBodyBasebody (void) const
 
RWHandleBaseoperator= (const RWHandleBase &second)
 

Detailed Description

Handle class for all the binary input stream implementation classes. Implement the handle idiom from the handle-body pattern.

Constructor & Destructor Documentation

RWByteInputStream::RWByteInputStream ( RWByteInputStreamImp ptr)
inlineexplicit

Constructor.

RWByteInputStream::RWByteInputStream ( const RWByteInputStream handle)
inline

Copy constructor. Throws no exceptions.

Parameters
handleA binary stream handle used to initialize the newly created handle.

Member Function Documentation

RWSize RWByteInputStream::available ( ) const
inline

Returns the number of bytes that can be read from the stream without blocking.

void RWByteInputStream::close ( )
inline

Closes the stream.

bool RWByteInputStream::isBad ( ) const
inline

Returns true to indicate a loss of integrity resulting from an input or output operation, such as an irrecoverable read error from a file.

bool RWByteInputStream::isEof ( ) const
inline

Returns true to indicate that an input operation reached the end of an input sequence.

bool RWByteInputStream::isFail ( ) const
inline

Returns true to indicate that an input operation failed to read the expected data.

bool RWByteInputStream::isGood ( ) const
inline

Returns true to indicate a stream in a valid state.

RWByteInputStream& RWByteInputStream::operator= ( const RWByteInputStream handle)
inline

Assignment operator. Throws no exceptions.

Parameters
handleA binary stream handle used to initialize this handle.
RWByteInputStream& RWByteInputStream::operator>> ( RWByteInputStream &(*)(RWByteInputStream &)  pf)
inline

Extractor executing a manipulator function.

Parameters
pfThe manipulator's function pointer.
RWByteInputStream RWByteInputStream::operator>> ( RWByteInputStream(*)(RWByteInputStream &)  pf)
inline

Extractor executing a manipulator function.

Parameters
pfThe manipulator's function pointer.
RWByteInputStream& RWByteInputStream::operator>> ( RWByte byteValue)
inline

Reads a single byte from the stream.

Parameters
byteValueThe byte to be read from the stream.
RWByte RWByteInputStream::read ( )
inline

Reads a single byte from the stream.

RWSize RWByteInputStream::read ( RWByte byteArray,
RWSize  numBytes 
)
inline

Reads an array of bytes from the stream. The array must be pre-allocated to contain at least numBytes elements. The function returns the actual number of bytes extracted from the stream.

Parameters
byteArrayA pointer to the first element of the array.
numBytesThe number of bytes to be read from the stream.
RWSize RWByteInputStream::readUntil ( RWByte byteArray,
RWSize  maxSize,
RWByte  delim 
)
inline

Reads bytes from the stream until the last byte read is equal to delim, or maxSize bytes have been read, or the end of the input sequence is reached. The bytes read are stored in byteArray. The function returns the actual number of bytes read from the stream.

Parameters
byteArrayA pointer to the array receiving the bytes extracted from the stream.
maxSizeThe maximum number of bytes to be read.
delimThe byte value used as a delimiter.
RWSize RWByteInputStream::skip ( RWSize  numUnits)
inline

Skips numUnits bytes from the input sequence if possible. The function returns the actual number of bytes skipped, which can be any value between 0 and numUnits.

Parameters
numUnitsThe number of bytes to be skipped.

Friends And Related Function Documentation

RWByteInputStream & rwDisc ( RWByteInputStream stream)
related

Manipulator that discards a byte from a stream input sequence.

Parameters
streamThe binary stream.
RWByteInputStream rwGuard ( RWByteInputStream stream)
related
Header File
#include <rw/stream/RWGuardedByteInputStreamImp.h>

Manipulator that is used to guard a series of extraction operations.

Parameters
streamA binary input stream.

A rwGuard() manipulator creates a temporary guarded stream that locks the internal mutex of the preceding synchronized stream. In this way, any extractions following the manipulator within the statement will be atomic, that is, uninterrupted by any other threads. Note that if the preceding stream is not a synchronized stream, the rwGuard() manipulator has no effect.

Example
// Lock the stream for the duration of all three extractions:
instr >> rwGuard >> data1 >> data2 >> data3;

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