"Dinkum/codecvt/wbuffer.h"


Include the header "Dinkum/codecvt/wbuffer.h" to define template class wbuffer_convert, for performing conversions between a wide stream and a byte stream.

wbuffer_convert

namespace Dinkum {
    namespace codecvt {
template<class Codecvt,
    class Elem = wchar_t,
    class Tr = std::char_traits<Elem> >
    class wbuffer_convert
        : public std::basic_streambuf<Elem, Tr>
    {
public:
    typedef typename Tr::state_type state_type;

    wbuffer_convert(std::streambuf *bytebuf = 0,
        Codecvt *pcvt = new Codecvt,
        state_type state = state_type());

    std::streambuf *rdbuf() const;
    std::streambuf *rdbuf(std::streambuf *bytebuf);

    state_type state() const;

    // exposition only
private:
    std::streambuf *bufptr;
    Codecvt *cvtptr;
    state_type cvtstate;
    };
        }  // namespace codecvt
    }  // namespace Dinkum

The template class describes a stream buffer that controls the transmission of elements of type Elem, whose character traits are described by the class Tr, to and from a byte stream buffer of type std::streambuf. Conversion between a sequence of Elem values and multibyte sequences is performed by an object of class Codecvt<Elem, char, std::mbstate_t>, which meets the requirements of the standard code-conversion facet std::codecvt<Elem, char, std::mbstate_t>.

An object of this template class stores:

wbuffer_convert::state

state_type state() const;

The member function returns cvtstate.

wbuffer_convert::rdbuf

std::streambuf *rdbuf() const;
std::streambuf *rdbuf(std::streambuf *bytebuf);

The first member function returns bufptr. The second member function stores bytebuf in bufptr.

wbuffer_convert::wbuffer_convert

wbuffer_convert(std::streambuf *bytebuf = 0,
    Codecvt *pcvt = new Codecvt,
    state_type state = state_type());

The constructor constructs a stream buffer object, initializes bufptr to bytebuf, initializes cvtptr to pcvt, and initializes cvtstate to state.

wbuffer_convert::state_type

typedef typename Codecvt::state_type state_type;

The type is a synonym for Codecvt::state_type.


See also the Table of Contents and the Index.

Copyright © 1992-2013 by Dinkumware, Ltd. All rights reserved.