Property mapping using metaprogramming
I wanted to serialize some of my objects as XML and came to an idea to map serializable properties somehow and give them an identifier(like a mapping name). Sure I could make a mapping file, but is there a in-code solution using meta programming ?
Note that my question is about metaprogramming, not XML. XML serialization was just a spark that started the fire.
Thanks in advance,
In's not really a metaprogramming (int the C++ sense i.e. templates), but in each QObject derivative you can get a "QMetaObject":http://qt-project.org/doc/qt-5.0/qtcore/qmetaobject.html via metaObject() method.
It contains information about properties, methods, enums, children etc.
QMetaObject provides a serializable name for the properties.
But the property must be derived from QObject, right? What about primitives?
No, the property itself doesn't have to be QObject based. In fact it rarely is. Only the object that holds the property does.
You can read more about Qt property system "here":http://qt-project.org/doc/qt-5.0/qtcore/properties.html
Thank you very much.