Topic: Writing/reading objects in a file stream with STL


Author: "Al Stevens" <alstevens@midifitz.com>
Date: 1998/07/11
Raw View
> How is PTL better than the support provided by STL?


Let's see how much I can remember:

1. To use stream_iterators you have to do all the i/o yourself including
knowing how many objects to read and write. PTL does it for you when the
persistent container is constructed and destroyed.

2. With stream_iterators, you read and write text files. PTL permits the
containers to be binary representations of the data members, which makes for
smaller, fixed length files.



[ 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: sl@psycode.com.NOSPAM (Gili)
Date: 1998/06/30
Raw View
On Thu, 25 Jun 1998 16:07:23, "Al Stevens" <alstevens@midifitz.com>
wrote:

> Standard C++ defines iostream iterators called istream_iterator and
> ostream_iterator that use the iterator mechanism for reading and writing
> containers from and to disk. The objects in the containers must of a type
> that can be used with iostreams and the << and >> operators, and the disk
> records are text-based.
>
> In March and April of this year I published a description of what I called
> the Persistent Template Library in Dr. Dobb's Journal. PTL goes a quite bit
> farther than iosteam iterators. You can get the source code for PTL from
> http://www.ddj.com/ftp/1998/1998_04/  or by anonymous ftp from ftp.ddj.com.
> The file name is pt12.zip. You'll need to get those issues of DDJ in order
> to fully understand the code.

 How is PTL better than the support provided by STL?

Gili
---
[ 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: "Caroline d'Herbomez" <cdherbomez@atos-group.com>
Date: 1998/06/24
Raw View
I want to write and read objects in a file stream using the STL library.
I know about the serialization on VC++, but I need compatibility for both PC
and HP-UX systems.
Does anybody know about a serialisation mecanism in STL ...
Thanks,
Caroline




[ 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: James Kuyper <kuyper@wizard.net>
Date: 1998/06/24
Raw View
Caroline d'Herbomez wrote:
>
> I want to write and read objects in a file stream using the STL library.
> I know about the serialization on VC++, but I need compatibility for both PC
> and HP-UX systems.
> Does anybody know about a serialisation mecanism in STL ...
> Thanks,
> Caroline

There isn't one. You could try writing your own, using the MSVC++
implementation as a guideline (ugh!). The most recent version of MSVC++
that I've used is 2.0; at that time the serialization worked only for
objects derived from CObject, in ways that made multiple inheritance
from CObject-derived classes nearly impossible. That mechanism is too
intrusive be used in the STL.

I actually got a partially functional multiple inheritance scheme
working, but only by digging deep into the internals of CObject, and
avoiding using some of the useful features of CObject. I did it as proof
of principle, and what I proved is that it couldn't be done cleanly.
Most of the MFC is like that. Everything was so poorly encapsulated that
I constantly had to dig into the MFC source code in order to find out
how it was done, so I could avoid breaking it.


[ 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: "Al Stevens" <alstevens@midifitz.com>
Date: 1998/06/25
Raw View
>Does anybody know about a serialisation mecanism in STL ...


Standard C++ defines iostream iterators called istream_iterator and
ostream_iterator that use the iterator mechanism for reading and writing
containers from and to disk. The objects in the containers must of a type
that can be used with iostreams and the << and >> operators, and the disk
records are text-based.

In March and April of this year I published a description of what I called
the Persistent Template Library in Dr. Dobb's Journal. PTL goes a quite bit
farther than iosteam iterators. You can get the source code for PTL from
http://www.ddj.com/ftp/1998/1998_04/  or by anonymous ftp from ftp.ddj.com.
The file name is pt12.zip. You'll need to get those issues of DDJ in order
to fully understand the code.



[ 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              ]