Nested parameters with ofxGui and ofParameters

Hello, I’m using ofxGui and ofParameter in order to save the seetings of the GUI in differents XML files. Everything works fine, I can save and load parameters .
the xml file look like this:

<settings>
<rule>F -> |[-F][+F]</rule>
<axiom>F</axiom>
<maxDepth>5</maxDepth>
</settings>

Now i would like is to read(not to modify, in this case) a field as a nested field, that can contains multiple items, like the field rules in this example:

<settings>
<rules>
  <rule>B -> F[-B]+B</rule>
  <rule>F -> FF</rule>
</rules>
<axiom>F</axiom>
<maxDepth>5</maxDepth>
</settings>

I first tried something obvious like ofParameter<vector<string>> rules, but ofParameter does not support vectors. Is there a workaround for this case?

ofParmaterGroup should do, you can anidate an ofParameterGroup into another and ofParameter into an ofParameterGroup and will give you the xml you are trying to create.

ofParameter of a vector should work but won’t be serializable since vector doesn’t implement the stream operator

Thank you. It works only if I specify the structure and the values of the parameters in the setup.

    //ofApp.h
    ofParameterGroup selectedRules;
    ofParameter<string> singleRule;
    //ofApp.cpp
    singleRule.set("rule", "FF");
    selectedRules.add(singleRule);
    selectedRules.setName("rules");

But I can not specify the number of the parameter contained in the group in the setup call, because sometimes the node contains 3 nested node, sometimes only one.
I think i go for a simple string and a character that acts as delimiters between the different values.

Hi Arturo,

Sorry to bring back this old thread. Is there a way now to serialise ofParameter<vector>?
I tried to implement stream operators to vector but since ofParameter class is not aware of those implementations seems not to work.

Is there anything I could do, that is not manually checking if a parameter is a vector, and serializing / deserializing it manually? That’s what I’m already doing in: https://github.com/PlaymodesStudio/ofxOceanode/blob/0f012d71b8fbd7507c82ad7b7ce56d7e82d70f70/src/Nodes/ofxOceanodeNode.cpp#L361-L389

Thanks!