Default presets in XML in project?


#1

My plugin stores it’s presets as an XML file and that works great.

I’d like to include my default presets inside my project somehow so the user can easily restore them, and I can save them to disk on first run. It would be great if there were some way to just cut and paste my XML file into a c++ source file to be easily accessed. This seems like the right way to do it, except how?

I guess what I’m asking is, how can I include a bunch of XML in my c++ source code that I can then load into XmlElements?


#2

Have you looked at the ProJucer source code? They do that for exporting the project files.

Rail


#3

Wouldn’t a better solution be to make your plugin robust enough it could start without any preset? Upon exiting it stores the current settings in the (newly created) xml-file. If the user wants to go back to default settings he/she just deletes the settings file and it will be recreated after next run.


#4

@Rail_Jon_Rogut Thanks, I’ll take a look at the Projucer code.

@oxxyyd My plugin does start without a preset file, but on first run I create one with a bunch of presets that represent my plugin well. I’m just looking for a way to take the presets me and my beta testers are creating for the default set and jam them into my source code in such a way that I don’t have to edit the text too much, and also makes for reasonable C++ code.

One way I’m playing with is to: take a preset XML, find & replace every quote character with an escaped quote, and then put that all into a static String variable.


#5

You could use a raw string literal

http://en.cppreference.com/w/cpp/language/string_literal

or embed it as binary data via the Projucer