Listing 5: XML tree elements created at runtime.
#include "MultiLineText.h"
#include "ParamIO.h"
/// Overloaded save parameters and settings
bool MultiLineText::writeXML(ParamIO& outXml, const std::string& absolutePath)
{
bool res = false;
res |= outXml.write(absolutePath + "MultiLineText:NumRows", _rows.size());
// Let every entry write itself
for (int i=0; i<_rows.size(); ++i)
{ char path[32];
sprintf(path,"MultiLineText:Row_%d:",i);
res |= _rows[i].writeXML(outXml, absolutePath + path);
}
return res;
}
/// Overloaded load parameters and settings
bool MultiLineText::readXML(ParamIO& inXml, const std::string& absolutePath)
{
bool res = false;
int numRows = 5; // 5 just to initialize with 5 identical entries.
res |= inXml.read(absolutePath + "MultiLineText:NumRows",numRows,numRows);
if (numRows < 1)
numRows = 1;
_rows.resize(numRows);
// Let every entry read itself
for (int i=0; i < _rows.size(); ++i)
{ char path[32];
sprintf(path,"MultiLineText:Row_%d:",i);
res |= _rows[i].readXML(inXml, absolutePath + path);
}
return res;
}