I'm trying to compress data from a pugi::xml_document
. This is what I tried :
template<class T> void save(const T &object, const QString &path)
{
pugi::xml_document doc;
object.exportXML(doc);
std::ostringstream stream;
doc.save(stream);
QByteArray data = qCompress(stream.c_str(), 9);
QFile outfile(path);
outfile.write(data);
outfile.close();
}
But it doesn't work because doc.save()
takes a ostream
and not a ostringstream
. How can I get the tree formated to a string from the xml_document
and compress it using qCompress
?