The JSON serialization was a direct representation of the C++ objects, and Qt already provides all we need. However, the serialization of a C++ object can be done with various representations in an XML format. So we have to write the XML from/to QVariant conversion ourselves. We have decided to use the following XML representation:
<[name]> type="[type]">[data]</[name]>
For example, the soundId type gives the following XML representation:
<soundId type="int">2</soundId>
Create a C++ XmlSerializer class that also inherits from Serializer. Let's begin with the save() function. The following is XmlSerializer.h:
#include <QXmlStreamWriter> #include <QXmlStreamReader> #include "Serializer.h" class XmlSerializer : public Serializer { public: XmlSerializer(); ...