Listing 3: ColoredText class.
#include "ColoredText.h"
#include "ParamIO.h"
/// Overloaded save parameters and settings
bool ColoredText::writeXML(ParamIO& outXml, const std::string& absolutePath)
{
bool res = false;
res |= outXml.write(absolutePath + "PARAMS:TEXT", _text);
res |= outXml.write(absolutePath + "PARAMS:COLOR:RED",
_red, "the red channel color");
res |= outXml.write(absolutePath + "PARAMS:COLOR:GREEN", _green);
res |= outXml.write(absolutePath + "PARAMS:COLOR:BLUE", _blue);
res |= outXml.write(absolutePath + "PARAMS:FONT:NAME", _fontName);
res |= outXml.write(absolutePath + "PARAMS:FONT:SIZE", _fontSize);
return res;
}
/// Overloaded load parameters and settings
bool ColoredText::readXML(ParamIO& inXml, const std::string& absolutePath)
{
bool res = false;
res |= inXml.read(absolutePath + "PARAMS:TEXT", _text,
std::string("Hello world"));
res |= inXml.read(absolutePath + "PARAMS:COLOR:RED", _red, 0);
res |= inXml.read(absolutePath + "PARAMS:COLOR:GREEN", _green, 0);
res |= inXml.read(absolutePath + "PARAMS:COLOR:BLUE", _blue, 0);
res |= inXml.read(absolutePath + "PARAMS:FONT:NAME",
_fontName, std::string("Arial"));
_fontSize = 12;
res |= inXml.read("PARAMS:FONT:SIZE", _fontSize, _fontSize);
return res;
}