BasicStreamBuffer< CharT, TraitsT > Class Template Reference

#include <Pt/StreamBuffer.h>

Stream buffer with peek and available output. More...

Inherited by BasicTextBuffer< Pt::Char, char >, and BasicTextBuffer< CharT, ByteT >.

Public Member Functions

 ~BasicStreamBuffer ()
 Destructor.
std::streamsize speekn (CharT *buffer, std::streamsize size)
 Peeks characters in the stream buffer.
std::streamsize out_avail ()
 Returns the number of characters buffered for output.

Protected Member Functions

 BasicStreamBuffer ()
 Default Constructor.
virtual std::streamsize showfull ()
 Returns the number of characters buffered for output.

Detailed Description

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

BasicStreamBuffer is the buffer in the Streams model. It is a std::basic_streambuf. Derived buffers implement underflow and overflow as they would for any streambuf. This type adds two queries that those derived buffers can serve from the get and put areas without going through the iostream formatting layer.

speekn() copies up to size characters from the get area into buffer and does not consume them. If the get area is empty, it calls underflow once. An unbuffered buffer, where underflow produced a character but no get area, yields that one character. A short count means fewer characters were available, not that the stream has failed.

out_avail() is the number of characters already in the put area. When there is no put pointer, it calls showfull(), which is zero unless a derived unbuffered buffer overrides it.

The stream types BasicIStream, BasicOStream and BasicIOStream hold a pointer to this buffer. They do not own it. A derived buffer must outlive every stream that still uses it.

Member Function Documentation

◆ speekn()

template<typename CharT, typename TraitsT = std::char_traits<CharT>>
std::streamsize speekn ( CharT * buffer,
std::streamsize size )

The number of characters that can be peeked depends on the current get area and may be less than requested, similar to istream::readsome(). The characters are not consumed.