streambufs!

Published June 30, 2004
Advertisement
Well the new thing added to the code library today are streambuf helper classes. They're a pair of classes that derive from streambuf that implement buffering code. The OStreamBuf class adds a pure virtual method, do_write() and the IStreamBuf class adds a do_read(). Basically these get called when the buffers need to get flushed or filled. These helper classes make creating custom streambufs extremely easy. I've used them for redirecting the standard handles for a child process into a iostream, wrapping sockets and tying a stream to an edit control.

And once you have a streambuf you can tie the input into the rest of the standard library pretty easily, especially with stream/streambuf iterators. Or even just using the insertion opreator to dump entire streambufs into a stream. This is just one of the many examples I've found where using the standard library interfaces as a common ground makes for very productive coding.

The current versions of the OStreamBuf and IStreamBuf classes are templated. I might go and create a non-templated version for the common > case. That should cut down on compile times. And after that I'll probably work on my sixth or seventh binary stream class revision.
Next Entry Yay math
0 likes 0 comments

Comments

Nobody has left a comment. You can be the first!
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

New bug to me

1910 views

Week/Class 9

1740 views

Week/Class 8

1788 views

Week/Class 7

1835 views

The promised files

2115 views

Week/Class 6

1518 views

Week/Session 5

1578 views

Week/Session 4

1519 views

On the soapbox

1636 views

Week/Session 3

1493 views
Advertisement