[LC++]Copying binary files with operator<< and rdbuf()

Brian Nelson nelson at bignachos.com
Sat Nov 22 10:09:01 UTC 2003


Carlo Wood <carlo at alinoe.com> writes:

> I think that ios_base::binary turns off Locale translations etc.
> But that doesn't change any formatting that is done.  Formatting
> is done by operator<< functions, so you don't want to use those
> for binary I/O.  If you use the streambuf interface, or the
> read()/write() methods, directly then you are fine.
>
> I see << as a serializer: it translates a (complex) object into
> a stream.  It can do this in 101 ways - and usually even dynamically
> dependend on certain (formatting) flags.  Most << functions are
> implemented by means of calling other << functions (as well as
> adding extra strings, determining the order of serializing/printing
> and determining the formatting of the sub elements) down to the
> standard << serializers for builtin types... which are implemented
> to output printable characters that mean something to humans when
> interpretted as ASCII (and that I don't call binary), lets call
> that 'text' as (opposed to 'binary').  Result: most << functions
> write out 'text'.
>
> If you want to do binary, don't use the << operators.

Even the overloaded operator<< for streambufs?

-- 
Don't worry, it's *in*-flammable.



More information about the tuxCPProgramming mailing list