Re: Byte-oriented streaming
On Feb 4, 2:18 pm, Pete Becker <p...@versatilecoding.com> wrote:
On 2008-02-04 00:07:20 -0500, Chris Swiedler <ceswied...@gmail.com> said:
From what I can tell, it's possible to do binary IO with the standard
stream classes, but (practically speaking) only if you use the read()
and write() methods directly. I'm looking to write a binary streaming
interface which we can use to stream binary data with operator<< and
operator>>, e.g. for writing to sockets, files, in-memory buffers,
etc.
operator<< and operator>> do formatted I/O. If you're dealing in raw
bytes, you're doing unformatted I/O. That's what read() and write() are
for. Don't mix idioms: you'll confuse everyone. Use a named function
for your interface.
That's one point. The other is that istream and ostream are
text formatted streams. If your stream has a binary format,
they aren't appropriate. The standard doesn't provide any
support (at present, but I've not seen any proposals to change
it) for binary formatted streams.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34