Topic: read(istream),write(ostream) standard??


Author: fzhong@my-deja.com
Date: 2000/07/26
Raw View
In article <8ljqoi$g6v$1@reader1.imaginet.fr>,
  "Hicham BOUHMADI" <hicham@citeweb.net> wrote:
> Actually, read and write are standard. they allow 'storing' binary
format=
> s
> but:
> I think, the question can be: "are iostreams designed to handle binary
> formats or just ASCII formats?"
> with locals, facets, and the formating process of iostreams. I am
tempted=
>  to
> say NO.
>

I agree. ios_base::binary is quite misleading, IMO the iostream
library is completely character-oriented. It is
almost impossible to read/write raw memory from/to
stream or streambuf objects, unless you are happy with
casting in every read and write, i.e.

strm_buf.sgetn(
  static_cast<char*>(static_cast<void*>(my_ptr)), sizeof(*my_ptr));

strm_buf.sputn(
  static_cast<char const*>(static_cast<void*>(my_ptr)), sizeof
(*my_ptr));

Frank


> Is there any answer to my question?
>
> Dietmar Kuehl <dietmar_kuehl@yahoo.com> a =E9crit dans le message :
> 8lifh7$d8j$1@nnrp1.deja.com...
> > Hi,
> > In article <8lfelh$man$1@frettir.rhi.hi.is>,
> >   ojb@rhi.hi.is (Olafur Jon Bjornsson) wrote:
> > > I have been reading alot on Deja about streams lately, I am
confused
> > because when people ask about binary input/output nobody suggest
using
> > these two functions.
> >
> > Are you talking about 'std::basic_istream::read()' and
> > 'std::basic_ostream::write()'? These two functions are standard.
> >
> > > Are they not standard functions?
> >
> > That's quite simple: As is, they are plain useless because they are
> > just dumping a bunch of bytes. What you want is a binary format to
deal
> > with such things like different layout from different versions of
the
> > compiler or on different platforms. Internally to the binary
formatting
> > functions you might use these methods but actually it is more likely
> > that you would use stream buffer level functions directly...
> > --
> > <mailto:dietmar_kuehl@yahoo.com>
> > <http://www.dietmar-kuehl.de/>
> >
> >
> > Sent via Deja.com http://www.deja.com/
> > Before you buy.
> >
> > ---
> > [ comp.std.c++ is moderated.  To submit articles, try just posting
with=
>  ]
> > [ your news-reader.  If that fails, use mailto:std-
c++@ncar.ucar.edu   =
>  ]
> > [              --- Please see the FAQ before posting. ---
              =
>  ]
> > [ FAQ: http://reality.sgi.com/austern_mti/std-
c++/faq.html             =
>  ]
> >
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting
with ]
> [ your news-reader.  If that fails, use mailto:std-
c++@ncar.ucar.edu    ]
> [              --- Please see the FAQ before posting. ---
               ]
> [ FAQ: http://reality.sgi.com/austern_mti/std-
c++/faq.html              ]
>
>


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: ojb@rhi.hi.is (Olafur Jon Bjornsson)
Date: 2000/07/25
Raw View
I have been reading alot on Deja about streams lately, I am confused because when people ask about binary input/output nobody suggest using these two functions.
Are they not standard functions?

thanks in advance,
OJB

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Dietmar Kuehl <dietmar_kuehl@yahoo.com>
Date: 2000/07/25
Raw View
Hi,
In article <8lfelh$man$1@frettir.rhi.hi.is>,
  ojb@rhi.hi.is (Olafur Jon Bjornsson) wrote:
> I have been reading alot on Deja about streams lately, I am confused
because when people ask about binary input/output nobody suggest using
these two functions.

Are you talking about 'std::basic_istream::read()' and
'std::basic_ostream::write()'? These two functions are standard.

> Are they not standard functions?

That's quite simple: As is, they are plain useless because they are
just dumping a bunch of bytes. What you want is a binary format to deal
with such things like different layout from different versions of the
compiler or on different platforms. Internally to the binary formatting
functions you might use these methods but actually it is more likely
that you would use stream buffer level functions directly...
--
<mailto:dietmar_kuehl@yahoo.com>
<http://www.dietmar-kuehl.de/>


Sent via Deja.com http://www.deja.com/
Before you buy.

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: Edward Diener <eddielee@abraxis.com>
Date: 2000/07/26
Raw View
They are certainly standard functions and they are used to read some amount of raw binary data. They certainly have a use but many times people liked to have their
raw data translated into something they understand better as they read or write it. However, I have used these member functions many times to read or write raw data
to and from memory, and in the case of the read() I often subsequently parse the data from its block of memory for my needs.

Olafur Jon Bjornsson wrote:

> I have been reading alot on Deja about streams lately, I am confused because when people ask about binary input/output nobody suggest using these two functions.
> Are they not standard functions?

---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Hicham BOUHMADI" <hicham@citeweb.net>
Date: 2000/07/26
Raw View
Actually, read and write are standard. they allow 'storing' binary format=
s
but:
I think, the question can be: "are iostreams designed to handle binary
formats or just ASCII formats?"
with locals, facets, and the formating process of iostreams. I am tempted=
 to
say NO.

Is there any answer to my question?

Dietmar Kuehl <dietmar_kuehl@yahoo.com> a =E9crit dans le message :
8lifh7$d8j$1@nnrp1.deja.com...
> Hi,
> In article <8lfelh$man$1@frettir.rhi.hi.is>,
>   ojb@rhi.hi.is (Olafur Jon Bjornsson) wrote:
> > I have been reading alot on Deja about streams lately, I am confused
> because when people ask about binary input/output nobody suggest using
> these two functions.
>
> Are you talking about 'std::basic_istream::read()' and
> 'std::basic_ostream::write()'? These two functions are standard.
>
> > Are they not standard functions?
>
> That's quite simple: As is, they are plain useless because they are
> just dumping a bunch of bytes. What you want is a binary format to deal
> with such things like different layout from different versions of the
> compiler or on different platforms. Internally to the binary formatting
> functions you might use these methods but actually it is more likely
> that you would use stream buffer level functions directly...
> --
> <mailto:dietmar_kuehl@yahoo.com>
> <http://www.dietmar-kuehl.de/>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>
> ---
> [ comp.std.c++ is moderated.  To submit articles, try just posting with=
 ]
> [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu   =
 ]
> [              --- Please see the FAQ before posting. ---              =
 ]
> [ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html             =
 ]
>


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]






Author: "Ken Bloom" <ken195@bigfoot.com>
Date: 2000/07/26
Raw View
> > That's quite simple: As is, they are plain useless because they are
> > just dumping a bunch of bytes. What you want is a binary format to deal
> > with such things like different layout from different versions of the
> > compiler or on different platforms. Internally to the binary formatting
> > functions you might use these methods but actually it is more likely
> > that you would use stream buffer level functions directly...

> Actually, read and write are standard. they allow 'storing' binary formats
> but:
> I think, the question can be: "are iostreams designed to handle binary
> formats or just ASCII formats?"
> with locals, facets, and the formating process of iostreams. I am tempted
to
> say NO.

By that are you saying that they do not handle the alignment and layout
issues across platforms, but that I can use them to dump image data from a
CGI to a web server?


---
[ comp.std.c++ is moderated.  To submit articles, try just posting with ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu    ]
[              --- Please see the FAQ before posting. ---               ]
[ FAQ: http://reality.sgi.com/austern_mti/std-c++/faq.html              ]