Oncaphillis::niftyLib

niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT > Class Template Reference

#include <io/basic_streambuf.h>

Inheritance diagram for niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >:

Detailed Description

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
class niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >

A fundamental double buffer streambuf implementation which offers pur virtual read/write methods to be overwritten by sublasses.

The basic_streambuf holds deperate input and output zones and delegates all real work to very simple read/write methods which have to be provided by subclasses.

See also:
codecvt_streambuf, device_streambuf

Public Types

typedef super::traits_type traits_type
 Make the template argument _Traits an internal type.
typedef super::int_type int_type
 Make the int_type inherited from our super class an internal type.
typedef super::char_type char_type
 Make the char_type inherited from our superclass an internal type.
typedef PolicyT policy_type
 Internal typedef of the SBufTraitsT template arguement.

Public Member Functions

 basic_streambuf ()
 The constructor allocates all internal char_type buffers for I/O operations.
virtual ~basic_streambuf ()
 Standard destructor.
virtual basic_streambufopen ()
virtual basic_streambufclose ()
bool is_open () const
void is_open (bool o)
virtual int_type pbackfail (int_type c=traits_type::eof())
 pbackfail is needed if the stream_buffer issupposed to support the ungetting if previously extracted character.
virtual int_type uflow ()
 Another aspect of the streambuf object.
virtual int_type underflow () throw (Exception)
 The virtual underflow function gets called each time the buffer is empty and we need new data from the real device when reading.
virtual int_type overflow (int_type c=traits_type::eof()) throw (Exception)
 Get's called when the buffer contents has to be pushed into the real device since theres no more space in the output buffer.
virtual int sync ()
 syncronise the internal stream buffer with the underyling device.
virtual char_typegpmax () const
virtual char_typepbend () const

Protected Member Functions

virtual std::streamsize read (char_type *b, std::streamsize n)=0 throw (Exception)
 Pure virtual method that performs the actual read from the underlying device.
virtual std::streamsize write (const char_type *b, std::streamsize n)=0 throw (Exception)
 Pure virtual method that performs the actual write to the underlying device.
void ginfo () const
void pinfo () const

Friends

class policy_type::debug

Member Typedef Documentation


Constructor & Destructor Documentation

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::basic_streambuf (  )  [inline]

The constructor allocates all internal char_type buffers for I/O operations.

Initialize the put/get buffer we need to be a real streambuf as defined in the C++-IOStream library.

The constructor sets up the sbuff struct and initializes the sbuff::put and sbuff::get area via calls to setg and setp of the templated superclass std::basic_streambuf

  • get: The get area start point, end point and current get buffer are all initialized to the beginning of the sbuff.gbuff area indicating that the buffer is currently empty

  • put: The put area start point and current position are both set to the area pointed to by sbuff.pbuff. The end point of the put area is set to the end of the sbuff.pbuff area telling the streambuf system that the area is empty and there is enough space for sbuff.pbuff_size char_types .

The initial sizes are taken from the static const sbuff.initial_gbuff_size and sbuff.initial_pbuff_size and copied to the sbuff.gbuff_size and sbuff.pbuff_size.

See also:
setg

setp

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::~basic_streambuf (  )  [inline, virtual]

Standard destructor.

Clear up all allocated memory for the input and output buffers.

if we have been working with buffers we free the stuff here


Member Function Documentation

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
bool niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::is_open (  )  const [inline]

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
void niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::is_open ( bool  o  )  [inline]

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual int_type niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::pbackfail ( int_type  c = traits_type::eof()  )  [inline, virtual]

pbackfail is needed if the stream_buffer issupposed to support the ungetting if previously extracted character.

basic_streambuf supports this by holding a putback-zone in the input buffer. When the buffer gets opened the gptr is positioned at the beginning of the buffer and no putback zone exists. Whenever the buffer gets refilled however (i.e. underflow gets called we copy the last n chars from the previous read to the beginning of the buffer and reposition the gptr at eback+n

See also:
pbSize

underflow

uflow

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual int_type niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::uflow (  )  [inline, virtual]

Another aspect of the streambuf object.

Returns the next recent char from the underlying socket and consumes the character.

See also:
pbackfail

underflow

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual int_type niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::underflow (  )  throw (Exception) [inline, virtual]

The virtual underflow function gets called each time the buffer is empty and we need new data from the real device when reading.

underflow returns the first char in the get buffer zone without consumation (e.g. it returns the same char every time it get's called).

This method also handles a putback zone within the I/O buffer.

See also:
overflow, uflow, sync, pbackfail

Referenced by niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >::uflow().

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual int_type niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::overflow ( int_type  c = traits_type::eof()  )  throw (Exception) [inline, virtual]

Get's called when the buffer contents has to be pushed into the real device since theres no more space in the output buffer.

See also:
underflow

Referenced by niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >::sync().

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual int niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::sync (  )  [inline, virtual]

syncronise the internal stream buffer with the underyling device.

All stored data should be written out to the stream. We so NOT call overflow here since our implementation of overflow only guaranties that *some* chars are written but not all.

See also:
overflow

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual char_type* niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::gpmax (  )  const [inline, virtual]

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual char_type* niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::pbend (  )  const [inline, virtual]

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual std::streamsize niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::read ( char_type b,
std::streamsize  n 
) throw (Exception) [protected, pure virtual]

Pure virtual method that performs the actual read from the underlying device.

The method is expected to read not more then n char_type from the device returning the actual number of char_type.

Returning less than n (or even 0) is not expected to represent an error. It just means that the device isn't currently able to get rid of more then n char_types .

See also:
write(const char_type *b,std::streamsize n)

Implemented in niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >, and niftyLib::IO::codecvt_streambuf< CharT, DeviceT::char_type, PolicyT, TraitsT, std::char_traits< DeviceT::char_type > >.

Referenced by niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >::underflow().

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
virtual std::streamsize niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::write ( const char_type b,
std::streamsize  n 
) throw (Exception) [protected, pure virtual]

Pure virtual method that performs the actual write to the underlying device.

The method is expected to write not more then n char_type to the device returning the actual number of char_type.

Returning less than n (or even 0) is not expected to represent an error. It just means that the device isn't currently abel to get suck more then n char_types from the device.

See also:
read(char_type *b,std::streamsize n)

Implemented in niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >, and niftyLib::IO::codecvt_streambuf< CharT, DeviceT::char_type, PolicyT, TraitsT, std::char_traits< DeviceT::char_type > >.

Referenced by niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >::overflow().

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
void niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::ginfo (  )  const [inline, protected]

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
void niftyLib::IO::basic_streambuf< CharT, PolicyT, TraitsT >::pinfo (  )  const [inline, protected]


Friends And Related Function Documentation

template<class CharT, class PolicyT = basic_streambuf_policy, class TraitsT = std::char_traits<CharT>>
friend class policy_type::debug [friend]


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

Generated by  doxygen
© 2008; Dr. Sebastian Kloska ( Oncaphillis )
Powered by: [?]