Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Streaming Objects in Objects

28 views
Skip to first unread message

Ronn Cochran

unread,
Feb 29, 2000, 3:00:00 AM2/29/00
to
I have an object that contains a TList that holds other objects. I am
trying to stream all of this to a file on the disk using a TFileStream. I
overroad DefineProperties and can save all non-published properties of the
main object. I have done the same thing for the other objects saved in the
TList.

The question is, do I write the main object using WriteComponent and do the
same for each of the objects saved in the TList (to create one streamed
file)? Then, how do I read it back. Do I simply use ReadComponent for the
first object and assume the position of the stream is at the end of the main
object? Then, I can call ReadComponent again for each of the subobjects and
load them into the main objects TList?

Michel Brazeau

unread,
Feb 29, 2000, 3:00:00 AM2/29/00
to

I have not used much Delphi's automatic streaming mechanism, but for
sure the objects in a TList or simply generic pointer references, so
they will not be streamed. You will have to write and read all the
objects individually. On a related note, you may want to try the
freeware Spider Container and Persistent classes, which have built in
streaming for objects derived directly from TObject.

Best regards,

Michel
------
http://www.intervalsoftware.com
Envision Image Library
Spider Object Database
Spider Container and Persistent Classes (freeware)
WordShare string localization (freeware)

Peter Below

unread,
Mar 1, 2000, 3:00:00 AM3/1/00
to
In article <89h77p$k1...@bornews.borland.com>, Ronn Cochran wrote:
> I have an object that contains a TList that holds other objects. I am
> trying to stream all of this to a file on the disk using a TFileStream. I
> overroad DefineProperties and can save all non-published properties of the
> main object. I have done the same thing for the other objects saved in the
> TList.
>
> The question is, do I write the main object using WriteComponent and do the
> same for each of the objects saved in the TList (to create one streamed
> file)? Then, how do I read it back.

You need one additional step: after the main object has been streamed, write
the number of items in the list to the stream, then stream the objects in the
list. On read you first read the main component, then the stored item count.
You then loop for the number of items stored, create a new object for each,
read it from stream and add it to the list.

If you use a TCollection and TCollectionItems decendents this is automatic, by
the way, if the main object exposes the collection as a published property.


Peter Below (TeamB) 10011...@compuserve.com)
No e-mail responses, please, unless explicitly requested!

Sent using Virtual Access 5.00 - download your freeware copy now
http://www.atlantic-coast.com/downloads/vasetup.exe

0 new messages