cxxtools::BasicLimitStreambuf< char_type > Class Template Reference

The class implements a stream buffer, which reads or writes from another streambuffer but limits the number of characters. More...

#include <cxxtools/limitstream.h>

Inheritance diagram for cxxtools::BasicLimitStreambuf< char_type >:
basic_streambuf

Public Member Functions

 BasicLimitStreambuf (std::basic_streambuf< char_type > *sb, unsigned icount, unsigned ocount, unsigned ibufsize=8192)
 initialize a BasicLimitStreambuf with a underlying stream.
 ~BasicLimitStreambuf ()
unsigned icount () const
 returns the number of remaining characters to read including characters in the buffer.
void icount (unsigned c)
 sets the number of remaining characters to read.
unsigned ocount () const
 returns the number of remaining characters to write.
void ocount (unsigned c)
 sets the number of remaining characters to write.
std::basic_streambuf< char_type > * streambuf ()
 returns the underlying stream buffer.
void attach (std::basic_streambuf< char_type > *s)
 sets the underlying stream buffer.

Protected Member Functions

char_type * ibuffer ()
std::streamsize showmanyc ()
int_type overflow (int_type ch)
int_type underflow ()
int sync ()

Detailed Description

template<typename char_type>
class cxxtools::BasicLimitStreambuf< char_type >

The class implements a stream buffer, which reads or writes from another streambuffer but limits the number of characters.

There are separate counters for reading and writing. They may be reset whenever needed.

A buffer is used for reading. It is not guaranteed, that characters not yet read from this stream buffer can be read from the underlying stream buffer.

Constructor & Destructor Documentation

template<typename char_type >
cxxtools::BasicLimitStreambuf< char_type >::BasicLimitStreambuf ( std::basic_streambuf< char_type > *  sb,
unsigned  icount,
unsigned  ocount,
unsigned  ibufsize = 8192 
)
inline

initialize a BasicLimitStreambuf with a underlying stream.

template<typename char_type >
cxxtools::BasicLimitStreambuf< char_type >::~BasicLimitStreambuf ( )
inline

Member Function Documentation

template<typename char_type >
void cxxtools::BasicLimitStreambuf< char_type >::attach ( std::basic_streambuf< char_type > *  s)
inline

sets the underlying stream buffer.

template<typename char_type >
char_type* cxxtools::BasicLimitStreambuf< char_type >::ibuffer ( )
inlineprotected
template<typename char_type >
unsigned cxxtools::BasicLimitStreambuf< char_type >::icount ( ) const
inline

returns the number of remaining characters to read including characters in the buffer.

template<typename char_type >
void cxxtools::BasicLimitStreambuf< char_type >::icount ( unsigned  c)
inline

sets the number of remaining characters to read.

When there are characters in the buffer already, they are not counted i.e. when there are 10 bytes in the buffer the call to icount(20) leads to actually 30 bytes to read.

template<typename char_type >
unsigned cxxtools::BasicLimitStreambuf< char_type >::ocount ( ) const
inline

returns the number of remaining characters to write.

template<typename char_type >
void cxxtools::BasicLimitStreambuf< char_type >::ocount ( unsigned  c)
inline

sets the number of remaining characters to write.

template<typename char_type >
int_type cxxtools::BasicLimitStreambuf< char_type >::overflow ( int_type  ch)
inlineprotected
template<typename char_type >
std::streamsize cxxtools::BasicLimitStreambuf< char_type >::showmanyc ( )
inlineprotected
template<typename char_type >
std::basic_streambuf<char_type>* cxxtools::BasicLimitStreambuf< char_type >::streambuf ( )
inline

returns the underlying stream buffer.

template<typename char_type >
int cxxtools::BasicLimitStreambuf< char_type >::sync ( )
inlineprotected
template<typename char_type >
int_type cxxtools::BasicLimitStreambuf< char_type >::underflow ( )
inlineprotected

The documentation for this class was generated from the following file: