basic_streambuf question

Discussion in 'C++' started by sri, Apr 5, 2007.

  1. sri

    sri Guest

    Dear All,

    I would like to implement file buffer class to make avialable
    buffering mechanism to ifstream or own customized file stream.
    My question is what are the semantics for seekoff, overflow, and
    underflow.
    When I see MS VC++6.0 STL code's basic_filebuf implementation, I
    observed that it is not maintaining any buffering mechanism, instead
    it is directly handling with the files. Please correct me if I am
    understanding in a wrong way.

    Sincerely,
    Sri

    ---
    [ comp.std.c++ is moderated. To submit articles, try just posting with ]
    [ your news-reader. If that fails, use mailto: ]
    [ --- Please see the FAQ before posting. --- ]
    [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
     
    sri, Apr 5, 2007
    #1
    1. Advertising

  2. sri

    P.J. Plauger Guest

    "sri" <> wrote in message
    news:...

    > I would like to implement file buffer class to make avialable
    > buffering mechanism to ifstream or own customized file stream.
    > My question is what are the semantics for seekoff, overflow, and
    > underflow.
    > When I see MS VC++6.0 STL code's basic_filebuf implementation, I
    > observed that it is not maintaining any buffering mechanism, instead
    > it is directly handling with the files. Please correct me if I am
    > understanding in a wrong way.


    That's correct. The code for overflow/underflow/uflow effectively
    emulates the getc/putc macros in <stdio.h>, reaching directly into
    the FILE buffers. Thus, there's a single buffering mechanism that's
    shared between C and C++ I/O. (No need to disable sync_with_stdio
    to get good throughput.)

    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: ]
    [ --- Please see the FAQ before posting. --- ]
    [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
     
    P.J. Plauger, Apr 5, 2007
    #2
    1. Advertising

  3. sri

    Carl Barron Guest

    In article <>, sri
    <> wrote:

    > uld like to implement file buffer class to make avialable
    > buffering mechanism to ifstream or own customized file stream.
    > My question is what are the semantics for seekoff, overflow, and
    > underflow.

    Simplified for buffered streambufs
    the protected virtual functions seekoff,underflow, overflow [and uflow]
    perform the actual IO from device to buffer.

    seekoff() does a relative seek similiar to fseek(),
    underflow reloads buffer and returns the current char.
    overflow empties the buffer and places the argument in the emptied
    buffer.

    ---
    [ comp.std.c++ is moderated. To submit articles, try just posting with ]
    [ your news-reader. If that fails, use mailto: ]
    [ --- Please see the FAQ before posting. --- ]
    [ FAQ: http://www.comeaucomputing.com/csc/faq.html ]
     
    Carl Barron, Apr 6, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Guest
    Replies:
    3
    Views:
    737
    John Harrison
    Aug 8, 2004
  2. Guest
    Replies:
    0
    Views:
    409
    Guest
    Aug 28, 2004
  3. Guest
    Replies:
    1
    Views:
    572
    Jonathan Turkanis
    Aug 29, 2004
  4. Steven T. Hatton

    I/O std::basic_streambuf put and get areas?

    Steven T. Hatton, Jul 3, 2005, in forum: C++
    Replies:
    3
    Views:
    532
    Steven T. Hatton
    Jul 4, 2005
  5. Christopher
    Replies:
    1
    Views:
    419
    Christopher Pisz
    Jan 29, 2008
Loading...

Share This Page