We’ve got a huge data object structure, containing a lot of properties that are actually arrays. Now, we need to stream the data to an XML document.
For that, we thought to use the NativeXML component to stream. It uses the same mechanism that’s also used for TComponent streaming. This works fairly nicely, except that it doesn’t stream the indexed properties.
Is there a way to do this anyway, or are there components that are capable of doing this?
Indexed properties are not exposed to RTTI (and still aren't in Delphi XE), and they are not streamed by TComponent either.
If you want to stay with the TComponent mechanism (or a pure RTTI-based streaming), one option is to use TCollection, which does get streamed "as an array". However that imposes severe constraints on your arrays, ie. their container has to be a subclass of TCollection, and their items have to be a subclass of TCollectionItem.
I don't know the NativeXML components, but if they are based on TWriter/TReader, another option could be to use DefineProperties, this allows you to define your own properties, and you can then stream whatever you wish, however you wish.
That involves special code for streaming, but you could place that code in class attributes if your arrays are not too specific, and handle everything in one of your root classes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With