tdesktop/Telegram/SourceFiles/storage/serialize_common.cpp

61 lines
1.4 KiB
C++
Raw Normal View History

/*
This file is part of Telegram Desktop,
the official desktop application for the Telegram messaging service.
For license and copyright information please follow this link:
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
*/
2017-03-04 10:23:56 +00:00
#include "storage/serialize_common.h"
namespace Serialize {
2018-07-13 16:49:46 +00:00
void writeStorageImageLocation(
QDataStream &stream,
const StorageImageLocation &location) {
stream
<< qint32(location.width())
<< qint32(location.height())
<< qint32(location.dc())
<< quint64(location.volume())
<< qint32(location.local())
<< quint64(location.secret());
stream << location.fileReference();
}
2018-07-13 16:49:46 +00:00
StorageImageLocation readStorageImageLocation(
int streamAppVersion,
QDataStream &stream) {
qint32 width, height, dc, local;
quint64 volume, secret;
2018-07-13 16:49:46 +00:00
QByteArray fileReference;
stream >> width >> height >> dc >> volume >> local >> secret;
2018-07-13 21:25:47 +00:00
#ifdef _DEBUG
if (streamAppVersion >= 1003013 || true) { // #TODO testing
#else
#error "test"
#endif
2018-07-13 16:49:46 +00:00
stream >> fileReference;
}
return StorageImageLocation(
width,
height,
dc,
volume,
local,
secret,
fileReference);
}
2018-07-13 16:49:46 +00:00
int storageImageLocationSize(const StorageImageLocation &location) {
// width + height + dc + volume + local + secret + fileReference
return sizeof(qint32)
+ sizeof(qint32)
+ sizeof(qint32)
+ sizeof(quint64)
+ sizeof(qint32)
+ sizeof(quint64)
+ bytearraySize(location.fileReference());
}
} // namespace Serialize