Oncaphillis::niftyLib

niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT > Class Template Reference

#include <io/codecvt_streambuf.h>

Inheritance diagram for niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >:
Collaboration diagram for niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >:

Detailed Description

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
class niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >

A generic approach towards a imbueable streambuf.

It emplyes STLs std::locale and aspecialy the std::codecvt facet to allow characer code conversion during I/O.

Beside other stuff the codecvt_streambuf mainly takes two template arguments. iCharT and xCharT where iCharT represents the internal character type and xCharT is the external character representation.

So a classical instantiation would look like:

        // This would represent a codecvt_streambuf which works
        // on the internal type wchar_t trying to convert
        // to the char type during writing and from char to 
        // wchar_t during reading.
 
        std::codecvt_streambuf<wchar_t,char> sb;

This of course isn't possible since codecvt_streambuf is a pure virtual class meant to serve as a superclass for device_streambuf.

See also:
device_streambuf

Public Types

typedef super::char_type char_type
 Make the char_type inherited from our superclass an internal type.
typedef super::char_type in_char_type
typedef super::traits_type traits_type
 Make the template argument _Traits an internal type.
typedef super::traits_type in_traits_type
typedef super::int_type int_type
 Make the int_type inherited from our super class an internal type.
typedef super::int_type in_int_type
typedef super::policy_type policy_type
 Internal typedef of the SBufTraitsT template arguement.
typedef traits_type::state_type state_type
typedef xCharT ex_char_type
typedef xTraitsT ex_traits_type
typedef ex_traits_type::int_type ex_int_type
typedef std::codecvt
< in_char_type, ex_char_type,
state_type
codecvt_type

Public Member Functions

 codecvt_streambuf ()
virtual ~codecvt_streambuf ()
virtual codecvt_streambufopen ()
virtual codecvt_streambufclose ()

Protected Member Functions

virtual std::streamsize read (char_type *b, std::streamsize n) 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) throw (Exception)
 Pure virtual method that performs the actual write to the underlying device.
virtual std::streamsize ex_read (ex_char_type *c, std::streamsize n)=0 throw (Exception)
 Pure virtual method ex_read is supposed to be implemented in subclass to suck xCharT characters to the final destination e.g.
virtual std::streamsize ex_write (const ex_char_type *c, std::streamsize n)=0 throw (Exception)
 Pure virtual method ex_write is supposed to be implemented in subclass to pum xCharT characters to the final destination e.g.
virtual void imbue (const std::locale &l) throw (Exception)
 imbue changes the current codeconversion for the imbue_streambuf.

Data Structures

struct  x_buff_t
 Internal struct halding everything we need for internal/extetnal CharT conversion.

Member Typedef Documentation

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef super::char_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::char_type

Make the char_type inherited from our superclass an internal type.

This defines the type of char we're allowed to read|write from|to the basic_streambuf

Reimplemented from niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >.

Reimplemented in niftyLib::IO::device_streambuf_base< niftyLib::IO::codecvt_streambuf< CharT, DeviceT::char_type, PolicyT, TraitsT, std::char_traits< DeviceT::char_type > >, DeviceT >.

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef super::char_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::in_char_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef super::traits_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::traits_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef super::traits_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::in_traits_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef super::int_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::int_type

Make the int_type inherited from our super class an internal type.

This type defines positions and offsets within the stream buffer.

Reimplemented from niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >.

Reimplemented in niftyLib::IO::device_streambuf_base< niftyLib::IO::codecvt_streambuf< CharT, DeviceT::char_type, PolicyT, TraitsT, std::char_traits< DeviceT::char_type > >, DeviceT >.

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef super::int_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::in_int_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef super::policy_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::policy_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef traits_type::state_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::state_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef xCharT niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::ex_char_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef xTraitsT niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::ex_traits_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef ex_traits_type::int_type niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::ex_int_type

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
typedef std::codecvt<in_char_type,ex_char_type,state_type> niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::codecvt_type


Constructor & Destructor Documentation

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::codecvt_streambuf (  )  [inline]

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::~codecvt_streambuf (  )  [inline, virtual]


Member Function Documentation

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual codecvt_streambuf* niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::open (  )  [inline, virtual]

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual codecvt_streambuf* niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::close (  )  [inline, virtual]

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual std::streamsize niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::read ( char_type b,
std::streamsize  n 
) throw (Exception) [inline, protected, 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)

Implements niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >.

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual std::streamsize niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::write ( const char_type b,
std::streamsize  n 
) throw (Exception) [inline, protected, 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)

Implements niftyLib::IO::basic_streambuf< iCharT, PolicyT, iTraitsT >.

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual std::streamsize niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::ex_read ( ex_char_type c,
std::streamsize  n 
) throw (Exception) [protected, pure virtual]

Pure virtual method ex_read is supposed to be implemented in subclass to suck xCharT characters to the final destination e.g.

device<xCharT>.

Should return 0 if we hit eof, -1 on error, otherwise the number of successfully read xCharT

See also:
ex_write, device<CharT>::read

Referenced by niftyLib::IO::codecvt_streambuf< CharT, DeviceT::char_type, PolicyT, TraitsT, std::char_traits< DeviceT::char_type > >::read().

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual std::streamsize niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::ex_write ( const ex_char_type c,
std::streamsize  n 
) throw (Exception) [protected, pure virtual]

Pure virtual method ex_write is supposed to be implemented in subclass to pum xCharT characters to the final destination e.g.

device<xCharT>

Should return 0 if we hit eof, -1 on error, otherwise the number of successfully read xCharT

See also:
ex_read, device<CharT>::write

Referenced by niftyLib::IO::codecvt_streambuf< CharT, DeviceT::char_type, PolicyT, TraitsT, std::char_traits< DeviceT::char_type > >::close(), and niftyLib::IO::codecvt_streambuf< CharT, DeviceT::char_type, PolicyT, TraitsT, std::char_traits< DeviceT::char_type > >::write().

template<class iCharT, class xCharT = iCharT, class PolicyT = codecvt_streambuf_policy, class iTraitsT = std::char_traits<iCharT>, class xTraitsT = std::char_traits<xCharT>>
virtual void niftyLib::IO::codecvt_streambuf< iCharT, xCharT, PolicyT, iTraitsT, xTraitsT >::imbue ( const std::locale &  l  )  throw (Exception) [inline, protected, virtual]

imbue changes the current codeconversion for the imbue_streambuf.

For all the in_char_type we have in our internal output buffer we just call our super classes super::sync method. This enshures that all current characters are placed in the underlying device with the proper previous encoding.

For our input buffer the strategy is much more complicated. the get zone of our imbue_streambuf currently may be poluted with inproperly translated in_char_type characters. So we have to reinterprete the ex_char_type corresponding to the current get zone of the imbue_streambuf.


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

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