"Fully buffered" ofstream wrapper class -- Any thoughts?

"Fully buffered" ofstream wrapper class -- Any thoughts?

Hi all,

Here is my wrapper class for ofstream. I would greatly appreciate any comments and suggestions. Even more importantly, if I've just reinvented the wheel, please point me towards the original, because it's almost certainly better than my version.

Specification:
Must not write to file until explicitly flush() ed.
Must support both formatted << and unformatted write(ptr, size) operations.
Must expose an ostream object to be passed to functions
* All my objects have a WriteBinary(ofstream&) member function that would be nice not to have to rewrite/overload
Performance is appreciated.

http://pastebin.com/m7272cbf0

Thanks in advance!

~Oren

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Why not use the buffered_io facility of the compiler, which could be set for specific files?

Quoting - tim18
Why not use the buffered_io facility of the compiler, which could be set for specific files?

My understanding was that fstream cannot fulfill the first requirement of the specification under any conditions.

This is a hard (must) requirement.

Leave a Comment

Please sign in to add a comment. Not a member? Join today