basic_streambuf question

S

sri

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
 
P

P.J. Plauger

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
 
C

Carl Barron

sri said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top