Question

How Can I deserialize the output QVariant to std::string without using QT.

by reqs, My program could not include a Qt.

QVariant.toString().toStdString();

Example.

file.ini (write with QSetting) ..

ID="\x1\0\0\0\xd0\x8c\xd9\xec\xfb*"

profile_program /* Pseudo Code */

int main ()
{
   void* IDQt =getIDFromIniFile("file.ini");
   std::string myId = convertID(IDQt);
   process(myID);
}
Was it helpful?

Solution

Look in the sources, probably src/corelib/kernel/qvariant.cpp for QDataStream& operator<<(QDataStream&, const QVariant&). That way you'll know what gets written during serialization.

Once you do, you'll see that the operator<< calls QVariant::save(QDataStream&). What's written is as follows:

quint32 QVariant::type()
quint8 QVariant::isNull()
if type()==UserType
  QString MetaType::typeName(userType())
end
if the variant is not valid
  QString empty
else
  -- MetaType::save(...)
end

You need to drill down into QString and QMetaType to figure out how those are serialized.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top