Re: Byte-oriented streaming
On Feb 5, 4:41 am, Jeff Schwab <j...@schwabcenter.com> wrote:
Pete Becker wrote:
On 2008-02-04 01:06:24 -0500, Jeff Schwab <j...@schwabcenter.com> said:
Chris Swiedler wrote:
Is there a C++ STL or boost class hierarchy for byte streaming similar=
to ostream and friends for character streaming? Those classes do not
seem designed to support byte streaming (e.g. they interpret
whitespace and null bytes specially).
What leads you to believe that?
Well, for one thing, the definition of extractors for
builtin types. They treat whitespace as a delimiter.
What's the relevance? Support for formatted I/O does not
imply lack of support for unformatted I/O.
There is no such thing as unformatted I/O. All data has a
format.
Can post a short example of what's not working the way
you want it to?
The ostream and istream interfaces are meant to allow whatever kind of
I/O you need, via differing implementations (rdbufs). strstream gives
null bytes special meanings, but stringstream (for example) does not.
Depending on your OS (I'm looking at you, MS), file I/O may require a
binary flag; I've never had to specify it on any flavor of Unix or
Linux, though.
Stream inserters and extractors (operator<< and operator>>)
are designed for formatted I/O, not for unformatted I/O.
(He should have said text formatted I/O. They don't do BER
formatting either.)
Right, so why are you bringing them up? The correct methods for
unformatted I/O are read, write, seekg, tellg, etc.
The functions read and write are for pre-formatted text. They
don't change the underlying abstraction of the streams.
I have an ixdrstream and an oxdrstream which does binary
formatting, for example, and I'm sure others have similar
classes, for perhaps other formats. The standard doesn't
support binary formats because there are so many of them, none
of the truly standard (in the sense of being used everywhere---a
lot of them are the subject of a standard somewhere).
--
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