Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7956 Discussions

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

Oren
Beginner
347 Views
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
0 Kudos
2 Replies
TimP
Honored Contributor III
347 Views
Why not use the buffered_io facility of the compiler, which could be set for specific files?
0 Kudos
Oren
Beginner
347 Views
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.
0 Kudos
Reply