SourcePro® API Reference Guide

 
Loading...
Searching...
No Matches
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 (void) const
 
virtual bool isBad (void) const
 
virtual bool isEof (void) const
 
virtual bool isFail (void) const
 
virtual bool isGood (void) const
 
virtual RWSize read (element_type *array, RWSize num)
 
virtual element_type read (void)
 
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 ()
 
- 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, char *buffer, RWSize bufSize)
 
static RWCharInputStream make (const RWCharInputStream &sourceStream, RWSize bufSize)
 
- Static Public Member Functions inherited from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >
static RWCharInputStream make (const RWCharInputStream &sourceStream)
 
static RWCharInputStream make (const RWCharInputStream &sourceStream, element_type *buffer, RWSize bufSize)
 
static RWCharInputStream make (const RWCharInputStream &sourceStream, RWSize bufSize)
 

Protected Member Functions

 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream)
 
 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream, char *buffer, RWSize bufSize)
 
 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream, RWSize bufSize)
 
- Protected Member Functions inherited from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >
 RWTInputStreamBufferImp (const RWCharInputStream &sourceStream)
 
 RWTInputStreamBufferImp (const RWCharInputStream &sourceStream, element_type *buffer, RWSize bufSize)
 
 RWTInputStreamBufferImp (const RWCharInputStream &sourceStream, 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 (const RWBodyBase &second)
 
 RWBodyBase (RWStaticCtor)
 
 RWBodyBase (void)
 
virtual ~RWBodyBase (void)
 
RWBodyBaseoperator= (const RWBodyBase &second)
 
- Protected Member Functions inherited from RWTCountingBody< RWMutexLock >
 RWTCountingBody (const RWTCountingBody< RWMutexLock > &second)
 
 RWTCountingBody (RWStaticCtor)
 
 RWTCountingBody (unsigned initCount=0)
 
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 (const RWTMonitor< RWMutexLock > &second)
 
 RWTMonitor (RWStaticCtor)
 
 RWTMonitor (void)
 
 ~RWTMonitor (void)
 
void acquire (void)
 
bool isAcquired (void) const
 
RWTMonitor< RWMutexLock > & monitor (void) const
 
RWMutexLockmutex (void)
 
RWTMonitor< RWMutexLock > & operator= (const RWTMonitor< RWMutexLock > &)
 
void release (void)
 
bool tryAcquire (void)
 

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 <rw/rwfile.h>
#include <fstream.h>
#include <iostream.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;
}
static RWCharInputStream make(const RWCharInputStream &sourceStream)
Definition RWBufferedCharInputStreamImp.h:117
static RWCharInputStream make(std::streambuf &source)
Definition RWCharFromStreambufInputStreamImp.h:44
Handle class for all narrow character input stream implementation classes.
Definition RWCharInputStream.h:34
bool Exists() const
Definition rwfile.h:231
Adaptor class to adapt the iostreams std::streambuf interface to the Rogue Wave binary and narrow cha...
Definition RWTStreambufFromByteCharInputStream.h:45

Constructor & Destructor Documentation

◆ RWBufferedCharInputStreamImp() [1/3]

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() [2/3]

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() [3/3]

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

◆ make() [1/3]

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.

◆ make() [2/3]

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.

◆ make() [3/3]

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.

◆ readStringUntil()

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 © 2024 Rogue Wave Software, Inc., a Perforce company. All Rights Reserved.