Can you store binary data in an XML document?

I have a .settings file I am using to store Preferences (a juce::PropertiesFile) where you add items in the typical way:

getAppProperties().getUserSettings()->setValue ("guiScaleFactor", ad->scaleFactor);
getAppProperties().getUserSettings()->setValue ("guiColourScheme", ad->colourSchemeID);
…etc.

This is working fine for some of my “newer” preferences settings.

However, I’m porting an older application, where preferences were stored as a chunk of binary data (i.e. a struct).

I’d like to avoid rewriting the handling of every single setting as a unique xml tag.

I am wondering if there is a way to write a chunk of data (a small struct, say 1024 bytes) to this XML file as binary, and then read it back out? If I could do that it would save an enormous amount of work.

Use Base64 encoding/decoding

3 Likes

Thank you!