Topic: wbuffer_convert


Author: tom_usenet@hotmail.com (tom_usenet)
Date: Mon, 5 Apr 2004 18:32:50 +0000 (UTC)
Raw View
Does anyone else think that something like Dinkumware's wbuffer would
be a good candidate for standardization? Writing wide character
streambufs is currently a pain in the neck - it should be unnecessary
in most cases. See

http://www.dinkumware.com/manuals/reader.aspx?b=cx/&h=wbuffer.html

It could be generalised further to convert between arbitrary character
types I think...

Currently you have to do, e.g.

template <class CharT, class Traits>
class MyStreambuf: public basic_streambuf<CharT, Traits>
{
  //scary implementation using codecvt?
};

whereas it would be much simpler to do:

class MyStreambuf: public std::streambuf
{
  //simple implementation for char
};

//code conversion hidden in wbuffer_convert
typedef codecvt<wchar_t, char, mbstate_t> cvt;

typedef wbuffer_convert<cvt> wbuf;
wbuf myBuf(new MyStreambuf);

Obviously some cooperation from Dinkumware might be necessary or at
least helpful...

Tom
--
C++ FAQ: http://www.parashift.com/c++-faq-lite/
C FAQ: http://www.eskimo.com/~scs/C-faq/top.html

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]





Author: pjp@dinkumware.com ("P.J. Plauger")
Date: Mon, 5 Apr 2004 20:40:52 +0000 (UTC)
Raw View
"tom_usenet" <tom_usenet@hotmail.com> wrote in message
news:jli270tumg2km9497erfok5392a8071v8k@4ax.com...

> Does anyone else think that something like Dinkumware's wbuffer would
> be a good candidate for standardization? Writing wide character
> streambufs is currently a pain in the neck - it should be unnecessary
> in most cases. See
>
> http://www.dinkumware.com/manuals/reader.aspx?b=cx/&h=wbuffer.html
>
> It could be generalised further to convert between arbitrary character
> types I think...
>
> Currently you have to do, e.g.
>
> template <class CharT, class Traits>
> class MyStreambuf: public basic_streambuf<CharT, Traits>
> {
>   //scary implementation using codecvt?
> };
>
> whereas it would be much simpler to do:
>
> class MyStreambuf: public std::streambuf
> {
>   //simple implementation for char
> };
>
> //code conversion hidden in wbuffer_convert
> typedef codecvt<wchar_t, char, mbstate_t> cvt;
>
> typedef wbuffer_convert<cvt> wbuf;
> wbuf myBuf(new MyStreambuf);
>
> Obviously some cooperation from Dinkumware might be necessary or at
> least helpful...

We have no problem with wbuffer_convert being proposed for standardization,
but we're in no hurry to propose that ourselves. We prefer the old
fashioned approach of getting experience, and refining design based on
user feedback, before foisting a feature on all implementations.

P.J. Plauger
Dinkumware, Ltd.
http://www.dinkumware.com

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://www.jamesd.demon.co.uk/csc/faq.html                       ]