Module: Advanced Tools Package: Streams
RWBufferedCharInputStreamImp RWTInputStreamBufferImp<RWCharInputStream,RWFilteredCharInputStreamImp> RWFilteredCharInputStreamImp
#include <rw/stream/RWBufferedCharInputStreamImp.h>
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.
// 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; }
RWBufferedCharInputStreamImp(RWCharInputStream& sourceStream);
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. Throws RWExternalStreamException.
Parameter List
sourceStream |
Input stream that will serve as the source of narrow characters. |
RWBufferedCharInputStreamImp(RWCharInputStream& sourceStream,
RWSize bufSize);
Initializes the reference to the input stream that will be used as the source of narrow characters, as well as the buffer capacity. Throws exception RWExternalStreamException.
Parameter List
sourceStream |
Input stream that will serve as the source of narrow characters. |
bufSize |
Buffer capacity in number of narrow characters. |
RWBufferedCharInputStreamImp(RWCharInputStream& sourceStream,
char* buffer, RWSize bufSize);
Initializes the reference to the input stream that will be used as the source of narrow characters, as well as the internal buffer. Throws exception RWExternalStreamException.
Parameter List
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. |
static RWCharInputStream make(RWCharInputStream& sourceStream);
Constructs an 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. Throws exception RWExternalStreamException.
Parameter List
sourceStream |
Input stream that will serve as the source of narrow characters. |
static RWCharInputStream make(RWCharInputStream& sourceStream, RWSize bufSize);
Constructs an 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. Throws exception RWExternalStreamException.
Parameter List
sourceStream |
The input stream that will serve as the source of narrow characters. |
bufSize |
The buffer capacity in number of narrow characters. |
static RWCharInputStream make(RWCharInputStream& sourceStream, char* buffer,
RWSize bufSize);
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. Throws exception RWExternalStreamException.
Parameter List
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. |
virtual void readUntil(RWCString& string, char delim);
Reads narrow characters from the stream until the last narrow character read is equal to delim, or the end of the input sequence is reached. The narrow characters read are stored in a string object.
Parameter List
string |
The string object receiving the characters extracted from the stream. |
delim |
The narrow character used as a delimiter. |
© 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.