Hi!
I’m trying chachedvalues and the variantconverter to save data serially in a valuetree.
Here is my code:
struct Complex
{
float re;
float im;
};
template<>
struct VariantConverter<Complex>
{
static Complex fromVar(const var& v)
{
Complex c;
StringArray result = StringArray::fromTokens(v.toString(),";",String());
c.re = result[0].getIntValue();
c.im = result[1].getIntValue();
return c;
}
static var toVar(const Complex& c)
{
String result;
result += (String)c.re;
result += ";";
result += (String)c.im;
return result;
}
};
ValueTree myTree("MyValueTree");
CachedValue<Complex> complex;
complex.referTo(myTree,"ComplexNumber",nullptr);
complex->re = 10;
complex->im = 20;
DBG(myTree.toXmlString());
There is no data from the complex number printed inside the “MyValueTree” section.
It seems that the “Complex” property isn’t added to it at all.
Who can help me?
Thank you,
Jelle Bakker