BasicIStream< CharT, TraitsT > Class Template Reference

#include <Pt/IOStream.h>

Input stream over a BasicStreamBuffer. More...

Inherited by BasicTextIStream< Char, char >, and BasicTextIStream< CharT, ByteT >.

Public Member Functions

 BasicIStream (BasicStreamBuffer< CharT > *sb=0)
 Constructor.
 ~BasicIStream ()
 Destructor.
std::streamsize peeksome (CharT *buffer, std::streamsize n)
 Peeks bytes in the stream buffer.
BasicStreamBuffer< CharT > * buffer ()
 Returns the buffer.
void setBuffer (BasicStreamBuffer< CharT > *sb)
 Sets the buffer.

Detailed Description

template<typename CharT, typename TraitsT = std::char_traits<CharT>>
class Pt::BasicIStream< CharT, TraitsT >

BasicIStream is the input stream in the Streams model. It is a std::basic_istream that holds a BasicStreamBuffer pointer. Extraction uses that buffer through rdbuf(). peeksome() looks ahead by more than one character: it calls BasicStreamBuffer::speekn() when rdbuf() is still this buffer, and otherwise peeks a single character. The returned count may be less than requested.

buffer() returns the pointer. setBuffer() replaces it and updates rdbuf(). The stream does not own the buffer. Pass a null buffer to construct a stream that will receive one later.

Member Function Documentation

◆ peeksome()

template<typename CharT, typename TraitsT>
std::streamsize peeksome ( CharT * buffer,
std::streamsize n )

The number of bytes that can be peeked depends on the current stream buffer get area and maybe less than requested, similar to istream::readsome().