Streams ------- .. contents:: :depth: 4 There are QDataStream analogue with almost identical API. Every basic type is supported as well as QList and Qt types (QPoint, QSize, QRect, QTime, QDate, QDateTime, QColor, QGeoCoordinate). More types are on the way. Packing ======= You can use any QIODevice derived class or QByteArray. .. code-block:: cpp QByteArray ba; MsgPackStream out(&ba, QIODevice::WriteOnly); out << 1 << true << "Hello"; qDebug() << ba.toHex(); Of course you can unpack this byte array using ``MsgPack::unpack``: .. code-block:: cpp qDebug() << MsgPack::unpack(ba); // output: // QVariant(QVariantList, (QVariant(uint, 1), QVariant(bool, true), QVariant(QString, "Hello"))) QList of any type are also supported: .. code-block:: cpp QList list; list << 1 << 2 << 3; QByteArray ba; MsgPackStream out(&ba, QIODevice::WriteOnly); out << list; Unpacking ========= To unpack QByteArray just pass it by value, or use QIODevice::ReadOnly for other devices: .. code-block:: cpp MsgPackStream in(ba); QList list2; in >> list2; qDebug() << list2; // (1, 2, 3) More types ========== Include `` // ... MsgPack::registerType(QMetaType::QPoint, 3); QByteArray ba; MsgPackStream out(&ba, QIODevice::WriteOnly); out << QPoint(1, 2) << QPoint(); qDebug() << MsgPack::unpack(ba); // output: // QVariant(QVariantList, (QVariant(QPoint, QPoint(1,2)), QVariant(QPoint, QPoint(0,0))))