This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [PATCH] New stream buffer for cin, cout etc.
- From: Benjamin Kosnik <bkoz at redhat dot com>
- To: Pétur Runólfsson <peturr02 at ru dot is>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Mon, 12 May 2003 11:33:12 -0500
- Subject: Re: [PATCH] New stream buffer for cin, cout etc.
- References: <07D05A69A3D0C14FAEA60C3ACE8E5564028F5577@nike.hir.is>
>I was thinking of something like this:
>
>template <>
>class fpos<mbstate_t>
>{
>public:
> // Non-portable, but probably easy to implement for any given
> // platform.
> fpos(const fpos_t&);
> operator fpos_t() const;
> // ...
>};
>
>Then seekpos and seekoff are trivial:
>
>pos_type
>seekpos(pos_type pos, ios_base::openmode mode)
>{
> pos_type ret(-1);
> fpos_t tmp = pos; // Use fpos<mbstate_t>::operator fpos_t()
> if (!fsetpos(_M_file, &tmp) && !fgetpos(_M_file, &tmp))
> ret = tmp; // Use fpos<mbstate_t>::fpos(const fpos_t&)
> return ret;
>}
>
>pos_type
>seekoff(off_type off, ios_base::seekdir dir, ios_base::openmode mode)
>{
> pos_type ret(-1);
> fpos_t tmp;
> if (!fseek(_M_file, off, dir) && !fgetpos(_M_file, &tmp))
> ret = tmp; // Use fpos<mbstate_t>::fpos(const fpos_t&)
> return ret;
>}
Yes. (You'd put these in __basic_file for the time being.)
I'm still trying to determine if the clearly-defined interface to
abstract out low-level io is really worth it anymore. I'm going to work
on that today.
>> There
>> is already a
>> basic_streambuf::_M_pos that was added with this intention, which
>> probably should be moved to basic_filebuf.
>
>I agree, it doesn't appear to be needed by strstreambuf or stringbuf,
>is not needed by streambuf, and can't be used here, as the user can
>change the stream position directly in any number of ways by using
>stdio calls on the FILE*.
Right. This at the same time as above.
There are no basic_filebuf tests for wchar_t, mostly because the
_M_convert_to_external is in an unknown (probably broken?) state. This
might be a good time to start adding them...
best,
benjamin