This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] New stream buffer for cin, cout etc.


>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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]