rwlogo
SourcePro C++ 12.0

SourcePro® C++ API Reference Guide



   SourcePro C++
Documentation Home

RWBufferedCharInputStreamImp Class Reference
[Streams]

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 >

List of all members.

Public Member Functions

virtual void readStringUntil (RWCString &string, char delim)

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)

Protected Member Functions

 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream)
 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream, RWSize bufSize)
 RWBufferedCharInputStreamImp (const RWCharInputStream &sourceStream, char *buffer, RWSize bufSize)

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.

Examples

 // 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 =
       RWCharFromStreambufInputStreamImp::make(fbuf);

     RWCharInputStream bufferedStream =
       RWBufferedCharInputStreamImp::make(charStream, 128);

     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:
RWExternalStreamException Thrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters:
sourceStream Input 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:
RWExternalStreamException Thrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters:
sourceStream Input stream that will serve as the source of narrow characters.
bufSize Buffer 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:
RWExternalStreamException Thrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters:
sourceStream Input stream that will serve as the source of narrow characters.
buffer Pre-allocated buffer of size bufSize to be used internally by the constructed RWBufferedCharInputStreamImp object.
bufSize Buffer capacity in number of narrow characters.

Member Function Documentation

static RWCharInputStream RWBufferedCharInputStreamImp::make ( const RWCharInputStream sourceStream,
char *  buffer,
RWSize  bufSize 
) [inline, static]

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:
RWExternalStreamException Thrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters:
sourceStream The input stream that will serve as the source of narrow characters.
buffer A pre-allocated buffer of size bufSize to be used internally by the constructed RWBufferedCharInputStreamImp object.
bufSize The buffer capacity in number of narrow characters.
static RWCharInputStream RWBufferedCharInputStreamImp::make ( const RWCharInputStream sourceStream,
RWSize  bufSize 
) [inline, static]

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:
RWExternalStreamException Thrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters:
sourceStream The input stream that will serve as the source of narrow characters.
bufSize The buffer capacity in number of narrow characters.

Reimplemented from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >.

static RWCharInputStream RWBufferedCharInputStreamImp::make ( const RWCharInputStream sourceStream  )  [inline, static]

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:
RWExternalStreamException Thrown if an illegal buffer size was requested or if the memory allocation request for the buffer fails.
Parameters:
sourceStream Input stream that will serve as the source of narrow characters.

Reimplemented from RWTInputStreamBufferImp< RWCharInputStream, RWFilteredCharInputStreamImp >.

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:
string A string object receiving the narrow character(s) extracted from the stream.
delim The narrow character used as a delimeter.

Reimplemented from RWFilteredCharInputStreamImp.

 All Classes Functions Variables Typedefs Enumerations Enumerator Friends

© 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.