MachinTrucChose
27th October 2012, 02:04
I'm writing a client-side class, and a server-side class, who are meant to communicate data with one another. In the middle I have to use a network client whose API's "Send" function takes a QString. That Send function encapsulates my data within a larger string, which is then sent over the network, decapsulated at the other end, and then the body is given to my other class.
I have no control over the encapsulation: basically whatever I need to send, has to be stored within a QString. I'd rather avoid annoying manual serializing/deserializing stuff in XML or somesuch. My data is a collection of native Qt types that can fit in a QVariant (bool, ASCII-only QStrings, and qint32). With this in mind, is there a way I can serialize QVariant/QVariantList into a QString?
QTextStream does not seem to serialize QVariant, only QDataStream does, and from what I saw there's no combination of QDataStream, QBuffer, and QByteArray which will allow me to use QString as a container. I'm asking here with the hopes that I am wrong. Please oh please tell me that I'm wrong :)
I have no control over the encapsulation: basically whatever I need to send, has to be stored within a QString. I'd rather avoid annoying manual serializing/deserializing stuff in XML or somesuch. My data is a collection of native Qt types that can fit in a QVariant (bool, ASCII-only QStrings, and qint32). With this in mind, is there a way I can serialize QVariant/QVariantList into a QString?
QTextStream does not seem to serialize QVariant, only QDataStream does, and from what I saw there's no combination of QDataStream, QBuffer, and QByteArray which will allow me to use QString as a container. I'm asking here with the hopes that I am wrong. Please oh please tell me that I'm wrong :)