SourcePro® API Reference Guide

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

Implements a buffer that can be used with narrow character input streams. More...

#include <rw/stream/RWBufferedCharInputStreamImp.h>

Inheritance diagram for RWBufferedCharInputStreamImp:
RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp > RWFilteredCharInputStreamImp RWCharInputStreamImp RWInputStreamImp RWStreamImp RWBodyBase RWTCountingBody< RWMutexLock > RWTMonitor< RWMutexLock >

Public Member Functions

virtual void readStringUntil (RWCString &string, char delim)
 
- Public Member Functions inherited from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >
virtual ~RWTInputStreamBufferImp ()
 
virtual RWSize available () const
 
virtual bool isBad () const
 
virtual bool isEof () const
 
virtual bool isFail () const
 
virtual bool isGood () const
 
virtual element_type read ()
 
virtual RWSize read (element_type *array, RWSize num)
 
virtual RWSize readUntil (element_type *array, RWSize maxSize, element_type delim)
 
virtual RWSize skip (RWSize numUnits)
 
- Public Member Functions inherited from RWFilteredCharInputStreamImp
virtual ~RWFilteredCharInputStreamImp ()
 
virtual void close ()
 
virtual RWSize read (char *charArray, RWSize numChars)
 
virtual RWSize readUntil (char *charArray, RWSize maxSize, char delim)
 
- Public Member Functions inherited from RWCharInputStreamImp
virtual ~RWCharInputStreamImp ()
 
virtual RWCharInputStream 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 RWCharInputStream make (const RWCharInputStream &sourceStream)
 
static RWCharInputStream make (const RWCharInputStream &sourceStream, RWSize bufSize)
 
static RWCharInputStream make (const RWCharInputStream &sourceStream, char *buffer, RWSize bufSize)
 
- Static Public Member Functions inherited from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >
static RWCharInputStream make (const RWCharInputStream &sourceStream)
 
static RWCharInputStream make (const RWCharInputStream &sourceStream, RWSize bufSize)
 
static RWCharInputStream make (const RWCharInputStream &sourceStream, element_type *buffer, RWSize bufSize)
 

Protected Member Functions

 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream)
 
 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream, RWSize bufSize)
 
 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream, char *buffer, RWSize bufSize)
 
- Protected Member Functions inherited from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >
 RWTInputStreamBufferImp (const RWCharInputStream &sourceStream)
 
 RWTInputStreamBufferImp (const RWCharInputStream &sourceStream, RWSize bufSize)
 
 RWTInputStreamBufferImp (const RWCharInputStream &sourceStream, element_type *buffer, RWSize bufSize)
 
element_typeeback () const
 
element_typeebuf () const
 
element_typeegptr () const
 
void freeBuffer ()
 
void gbump (RWSize n)
 
element_typegptr () const
 
void setBufferEnd (element_type *gend_arg)
 
void setg (element_type *gbeg_arg, element_type *gcur_arg, element_type *gend_arg)
 
bool underflow ()
 
- Protected Member Functions inherited from RWFilteredCharInputStreamImp
 RWFilteredCharInputStreamImp (const RWCharInputStream &sourceStream)
 
RWCharInputStreamgetSourceStream ()
 
const RWCharInputStreamgetSourceStream () const
 
- Protected Member Functions inherited from RWCharInputStreamImp
 RWCharInputStreamImp ()
 
- 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 ()
 

Additional Inherited Members

- Public Types inherited from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >
typedef RWCharInputStream::element_type element_type
 
typedef RWCharInputStream RWInputStream_type
 
- 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

Class RWBufferedCharInputStreamImp implements a buffer that can be used with narrow character input streams. The size of the buffer is specified in its static member make() function, which is used to create it.

Example
// This is an input buffer used for narrow character streams.
#include <rw/stream/RWBufferedCharInputStreamImp.h>
#include <rw/stream/RWCharFromStreambufInputStreamImp.h>
#include <rw/stream/RWStreambufFromCharInputStream.h>
#include <fstream.h>
#include <iostream.h>
#include <rw/rwfile.h>
int main() {
filebuf fbuf;
if(!RWFile::Exists("RWBufferedCharOutputStreamImp.out")) {
cout << "The input file does not exist."<< endl;
}
else {
fbuf.open("RWBufferedCharOutputStreamImp.out",
ios::in);
RWCharInputStream charStream =
RWCharInputStream bufferedStream =
RWStreambufFromCharInputStream adaptor(bufferedStream);
istream in(&adaptor);
int i;
in >> i;
cout << i << endl;
}
return 0;
}

Constructor & Destructor Documentation

RWBufferedCharInputStreamImp::RWBufferedCharInputStreamImp ( const RWCharInputStream sourceStream)
protected

Initializes the reference to the input stream that will be used as the source of narrow characters, as well as the internal buffer capacity, which will be equal to RW_STREAM_BUFFER_SIZE.

Exceptions
RWExternalStreamExceptionThrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters
sourceStreamInput stream that will serve as the source of narrow characters.
RWBufferedCharInputStreamImp::RWBufferedCharInputStreamImp ( const RWCharInputStream sourceStream,
RWSize  bufSize 
)
protected

Initializes the reference to the input stream that will be used as the source of narrow characters, as well as the buffer capacity.

Exceptions
RWExternalStreamExceptionThrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters
sourceStreamInput stream that will serve as the source of narrow characters.
bufSizeBuffer capacity in number of narrow characters.
RWBufferedCharInputStreamImp::RWBufferedCharInputStreamImp ( const RWCharInputStream sourceStream,
char *  buffer,
RWSize  bufSize 
)
protected

Initializes the reference to the input stream that will be used as the source of narrow characters, as well as the internal buffer.

Exceptions
RWExternalStreamExceptionThrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters
sourceStreamInput stream that will serve as the source of narrow characters.
bufferPre-allocated buffer of size bufSize to be used internally by the constructed RWBufferedCharInputStreamImp object.
bufSizeBuffer capacity in number of narrow characters.

Member Function Documentation

static RWCharInputStream RWBufferedCharInputStreamImp::make ( const RWCharInputStream sourceStream)
inlinestatic

Constructs a RWBufferedCharInputStreamImp instance that uses sourceStream as its source of narrow characters, and returns a handle to it. The internal buffer is dynamically allocated to be of size RW_STREAM_BUFFER_SIZE.

Exceptions
RWExternalStreamExceptionThrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters
sourceStreamInput stream that will serve as the source of narrow characters.
static RWCharInputStream RWBufferedCharInputStreamImp::make ( const RWCharInputStream sourceStream,
RWSize  bufSize 
)
inlinestatic

Constructs a RWBufferedCharInputStreamImp instance that uses sourceStream as its source of narrow characters, and returns a handle to it. The internal buffer is dynamically allocated to be of size bufSize.

Exceptions
RWExternalStreamExceptionThrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters
sourceStreamThe input stream that will serve as the source of narrow characters.
bufSizeThe buffer capacity in number of narrow characters.
static RWCharInputStream RWBufferedCharInputStreamImp::make ( const RWCharInputStream sourceStream,
char *  buffer,
RWSize  bufSize 
)
inlinestatic

Constructs an RWBufferedCharInputStreamImp instance that uses sourceStream as its source of narrow characters, and returns a handle to it. The internal buffer is initialized using the pre-allocated narrow character's array of size bufSize.

Exceptions
RWExternalStreamExceptionThrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters
sourceStreamThe input stream that will serve as the source of narrow characters.
bufferA pre-allocated buffer of size bufSize to be used internally by the constructed RWBufferedCharInputStreamImp object.
bufSizeThe buffer capacity in number of narrow characters.
virtual void RWBufferedCharInputStreamImp::readStringUntil ( RWCString string,
char  delim 
)
virtual

Reads narrow character(s) from the attached source stream until the last character read is equal to delim, or the end of the input sequence is reached. The narrow character(s) read are stored in a narrow string object.

Parameters
stringA string object receiving the narrow character(s) extracted from the stream.
delimThe narrow character used as a delimiter.

Reimplemented from RWFilteredCharInputStreamImp.

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