David Schwartz 426 Posted December 28, 2020 I had a unit somewhere that let me stream basic Delphi object instances to and from an INI file, but now I can't seem to find it. Google is turning up stuff from 2009. The newer RTTI stuff is a lot simpler. Can anybody point me to something that uses the latest RTTI stuff? Share this post Link to post
Der schöne Günther 316 Posted December 28, 2020 An .ini file has no hierarchy. How are you going to serialize nested objects like TMyObject = class someData: TBytes; someReference: TMyObject; // can be nil end; Formats like XML or JSON can properly deal with this, not sure how INI could be a good choice here. Share this post Link to post
David Schwartz 426 Posted December 28, 2020 (edited) I don't need to. As I said, "... stream basic Delphi object instances ..." I can already handle stringlists easily, and arrays of basic types should be easy to handle anyway, although I don't have any at this point. I will have collections of objects, but I'll deal with them one-by-one. Edited December 28, 2020 by David Schwartz Share this post Link to post
Fr0sT.Brutal 900 Posted December 28, 2020 57 minutes ago, Der schöne Günther said: An .ini file has no hierarchy. How are you going to serialize nested objects like For example the same way as registry files do 1 Share this post Link to post
FPiette 383 Posted December 28, 2020 Why not start from this example to convert your component to string and the store the string in the INI file? Share this post Link to post
Attila Kovacs 629 Posted December 28, 2020 easy af, like in this article: https://www.fmxexpress.com/convert-ini-files-to-json-and-back-with-xsuperobject-in-delphi-xe6-firemonkey-on-android-and-ios/ Share this post Link to post
David Schwartz 426 Posted December 28, 2020 (edited) 6 hours ago, FPiette said: Why not start from this example to convert your component to string and the store the string in the INI file? They're fairly simple data objects derived from TObject, not from TComponent. I could derive from TComponent instead, but it buys me lots of overhead with little if any value. Edited December 28, 2020 by David Schwartz Share this post Link to post
David Schwartz 426 Posted December 28, 2020 As I said, I've got code that uses the old RTTI methods introduced in D2010. I'm looking for something that uses the newer RTTI methods. Not an entirely different approach. They're simple classes with no embedded objects, but there are some enums. Share this post Link to post
David Heffernan 2345 Posted December 28, 2020 Enumerate the members of interest and persist them. If these classes are really that simple, what is the difficulty? What are you stuck with? Using the RTTI? Or working with INI files? 2 1 Share this post Link to post
Attila Kovacs 629 Posted December 28, 2020 it's a 2 min copy&paste task from the link above, I can't see why would anyone reinvent the wheel just to avoid using the json library? Is it for some embedded computer? 1 Share this post Link to post