Delphi object persistence, what is the best way

前端 未结 6 2085
悲哀的现实
悲哀的现实 2021-01-31 23:35

I have developed application for drawing some shapes (lines mostly) , now i need to be able to store sketch to a file, I know that delphi has build in routines for object persi

相关标签:
6条回答
  • 2021-01-31 23:53

    JSON is a new and very compact way to store objects. Two libraries are available for Delphi: SuperObject and lkJSON.

    0 讨论(0)
  • 2021-01-31 23:57

    You also can use the famous hibernate know from java.

    the delphi port you can find here: dHibernate

    0 讨论(0)
  • 2021-01-31 23:57

    With NativeXML from http://www.simdesign.nl/xml.html I accomplished to read/write delphi in-memory objects from/to XML code. Very nice, very easy, with demo included here: http://www.simdesign.nl/forum/download/file.php?id=236

    0 讨论(0)
  • 2021-02-01 00:00

    The built in object persistance is primarily designed for use in streaming components to a dfm, the work that you would need to do to persist your sketch would not benefit very much from that mechanism.

    I think that you would be better off coming up with a custom scheme.

    0 讨论(0)
  • 2021-02-01 00:00

    I use the TI Object persistence framework (tiopf.com). I wrote the overview at http://tiopf.sourceforge.net/Doc/overview/index.shtml.

    It will let you save objects and lists to xml, csv, databases etc. It handles child objects automatically.

    If you are interested, use the svn version, not the sourceforge download as it has more features (inc partial D 2009 support).

    0 讨论(0)
  • 2021-02-01 00:07

    One method that I have used in the past is to store my object properties in an XML file writing a custom "save" routine which adds to a passed IXMLNode, and a new constructor which reads from a passed IXMLNode. I store component as a node, and the properties as attributes (unless the property is another object, then it would be a child node).

    I believe there are some routines in the Delphi Jedi project which will handle component streaming for you, but I have not used them directly as most of my XML streaming has been done by hand since my objects were extremely simple and could be rendered with only a handful of properties.

    0 讨论(0)
提交回复
热议问题