Serialization
This section documents utility functions used for serializing and deserializing raw data and Qt variant types, including support for disk-backed storage of large data payloads.
Functions
-
void mv::util::saveRawDataToBinaryFile(const char *bytes, const std::uint64_t &numberOfBytes, const QString &filePath)
Save raw data to binary file on disk.
- Parameters:
bytes – Pointer to input buffer
numberOfBytes – Number of input bytes
filePath – Path of the file on disk
-
void mv::util::loadRawDataFromBinaryFile(char *bytes, const std::uint64_t &numberOfBytes, const QString &filePath)
Load raw data from binary file on disk.
- Parameters:
bytes – Pointer to input buffer
numberOfBytes – Number of input bytes
filePath – Path of the file on disk
-
QVariantMap mv::util::rawDataToVariantMap(const char *bytes, const std::uint64_t &numberOfBytes, bool saveToDisk = false, std::uint64_t maxBlockSize = DEFAULT_MAX_BLOCK_SIZE)
Convert raw data buffer to variant map (divide up in blocks when the total number of bytes exceeds maxBlockSize)
- Parameters:
bytes – Pointer to input buffer
numberOfBytes – Number of input bytes
saveToDisk – Whether to save the raw data to disk or inline in the variant
maxBlockSize – Maximum size per block (defaults to DEFAULT_MAX_BLOCK_SIZE)
-
void mv::util::populateDataBufferFromVariantMap(const QVariantMap &variantMap, char *bytes)
Convert variant map to raw data.
- Parameters:
variantMap – Variant map containing the data blocks
bytes – Output buffer to which the data is copied
-
void mv::util::variantMapMustContain(const QVariantMap &variantMap, const QString &key)
Raises an exception if an item with key is not found in a variant map.
- Parameters:
variantMap – Variant map that should contain the key
key – Item name
-
QVariant mv::util::storeQVariant(const QVariant &variant)
Store QVariant on disk if it is too large (divide up in blocks when the total number of bytes exceeds maxBlockSize) and return a QVariantMap with the file information, otherwise return the QVariant parameter.
- Parameters:
variant – QVariant to store
-
QVariant mv::util::loadQVariant(const QVariant &variant)
Load QVariant from disk if it was large, othewise return QVariant.
- Parameters:
variant – QVariant to load
-
QVariantMap mv::util::storeOnDisk(const QStringList &list)
Convenience function to store QStringList on disk.
-
QVariantMap mv::util::storeOnDisk(const QVector<uint32_t> &vec)
Convenience function to store QVector of uints on disk.
-
void mv::util::loadFromDisk(const QVariantMap &variantMap, QStringList &list)
Convenience function to load QStringList from disk.
-
void mv::util::loadFromDisk(const QVariantMap &variantMap, QVector<uint32_t> &vec)
Convenience function to store QVector of uints on disk.