[fpc-pascal] IStreamPersist - how is it used?
Noel Duffy
hobcraft-fpc at yahooxtra.co.nz
Sat Oct 31 03:13:49 CET 2015
I'm currently looking into ways to write all the objects in my
application to a stream. I don't expect to have more than one or two
hundred objects, so a fully-fledged framework like tiOPF seems like
overkill. I am trying to find out what the RTL offers to solve this kind
of problem.
I came across the interface IStreamPersist, but the documentation only
says that "Any class implementing this interface is expected to be able
to load its state from a stream or write its state to a stream". It does
not say what classes or code actually calls those methods.
Delphi has this interface as well, but the documentation for it is no
clearer.
I've also seen TPersistent in the documentation, but it's not clear
whether IStreamPersist is in any way related to it. TPersistent also
seems a likely candidate for my streaming requirements, but it does seem
to depend on me putting everything into published properties.
Lastly, I'm not sure whether this is the right forum for this, but I
noticed two minor typos on the SaveToStream documentation page at http://
www.freepascal.org/docs-html/rtl/classes/
istreampersist.savetostream.html.
The first typo is in the Description section where the method is called
"SaveFromStream" instead of "SaveToStream". Likely a copy-paste snafu.
The second is the use of "it's" which should be "its". That is, there
should be no apostrophe between the t and the s. The "it's" thing is also
on the LoadFromStream page.
More information about the fpc-pascal
mailing list