ValueTree to XML and back value types question

Hello,

I'm writing a thing that serialized a ValueTree to xml and back for storing the plugin state. However, the xmlalized ValueTree seems to discard var type information so that when I recreate the ValueTree from xml it thinks everything is a string. What's the best solution for this? I could parse all the strings into the correct type but that seems messy.

Thanks,

Rob

1 Like

Yeah, that is a drawback of using XML - the way the ValueTree gets converted to XML favours readability over type data.

The reason it's done like that is that if you don't need the output to be human-readable, then you'd be better off using the binary conversion, as it's both faster, smaller, and type-correct.

1 Like

Ah right, ok. So regarding plugin state saving, I could create a MemoryOutputStream to the state MemoryBlock and write the ValueTree to that? Would I need a "magic number" like in copyXmlToBinary()?

1 Like

That would certainly be more robust. Magic numbers are always good :)

1 Like

Thanks. Nothing else will be written into the state apart from the ValueTree, so I'm not gonna bother with magic.

 

1 Like