2016-03-31 20:47:19 +08:00
|
|
|
#ifndef ADS_SERIALIZATION_H
|
|
|
|
#define ADS_SERIALIZATION_H
|
|
|
|
|
|
|
|
#include <QtGlobal>
|
|
|
|
#include <QList>
|
|
|
|
#include <QString>
|
|
|
|
#include <QDataStream>
|
2016-04-01 15:52:59 +08:00
|
|
|
#include <QBuffer>
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
#include "ads/API.h"
|
|
|
|
|
|
|
|
ADS_NAMESPACE_SER_BEGIN
|
|
|
|
|
2016-04-01 18:11:52 +08:00
|
|
|
enum EntryType
|
|
|
|
{
|
|
|
|
ET_Unknown = 0x00000000,
|
|
|
|
ET_Hierarchy = 0x00000001,
|
|
|
|
ET_SectionIndex = 0x00000002,
|
|
|
|
|
|
|
|
// Begin of custom entry types (e.g. CustomType + 42)
|
|
|
|
ET_Custom = 0x0000ffff
|
|
|
|
};
|
|
|
|
|
2016-04-01 18:35:33 +08:00
|
|
|
class ADS_EXPORT_API HeaderEntity
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-04-01 15:52:59 +08:00
|
|
|
static qint32 MAGIC;
|
|
|
|
static qint32 MAJOR_VERSION;
|
|
|
|
static qint32 MINOR_VERSION;
|
|
|
|
|
2016-04-01 18:35:33 +08:00
|
|
|
HeaderEntity();
|
2016-03-31 20:47:19 +08:00
|
|
|
qint32 magic;
|
2016-04-01 15:52:59 +08:00
|
|
|
qint32 majorVersion;
|
|
|
|
qint32 minorVersion;
|
2016-03-31 20:47:19 +08:00
|
|
|
};
|
2016-04-01 18:35:33 +08:00
|
|
|
QDataStream& operator<<(QDataStream& out, const HeaderEntity& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, HeaderEntity& data);
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
|
2016-04-01 18:35:33 +08:00
|
|
|
class ADS_EXPORT_API OffsetsHeaderEntity
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-04-01 18:35:33 +08:00
|
|
|
OffsetsHeaderEntity();
|
2016-04-01 15:52:59 +08:00
|
|
|
|
|
|
|
qint64 entriesCount;
|
2016-04-01 18:35:33 +08:00
|
|
|
QList<class OffsetsHeaderEntryEntity> entries;
|
2016-03-31 20:47:19 +08:00
|
|
|
};
|
2016-04-01 18:35:33 +08:00
|
|
|
QDataStream& operator<<(QDataStream& out, const OffsetsHeaderEntity& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, OffsetsHeaderEntity& data);
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
|
2016-04-01 18:35:33 +08:00
|
|
|
class ADS_EXPORT_API OffsetsHeaderEntryEntity
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-04-01 18:35:33 +08:00
|
|
|
OffsetsHeaderEntryEntity();
|
2016-03-31 20:47:19 +08:00
|
|
|
qint32 type;
|
|
|
|
qint64 offset;
|
2016-04-01 15:52:59 +08:00
|
|
|
qint64 contentSize;
|
2016-03-31 20:47:19 +08:00
|
|
|
};
|
2016-04-01 18:35:33 +08:00
|
|
|
QDataStream& operator<<(QDataStream& out, const OffsetsHeaderEntryEntity& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, OffsetsHeaderEntryEntity& data);
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
|
2016-04-01 18:35:33 +08:00
|
|
|
class ADS_EXPORT_API SectionEntity
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-04-01 18:35:33 +08:00
|
|
|
SectionEntity();
|
2016-04-04 14:51:38 +08:00
|
|
|
qint32 x;
|
|
|
|
qint32 y;
|
2016-03-31 20:47:19 +08:00
|
|
|
qint32 width;
|
|
|
|
qint32 height;
|
|
|
|
qint32 currentIndex;
|
|
|
|
qint32 sectionContentsCount;
|
2016-04-01 18:35:33 +08:00
|
|
|
QList<class SectionContentEntity> sectionContents;
|
2016-03-31 20:47:19 +08:00
|
|
|
};
|
2016-04-01 18:35:33 +08:00
|
|
|
QDataStream& operator<<(QDataStream& out, const SectionEntity& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, SectionEntity& data);
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
|
2016-04-01 18:35:33 +08:00
|
|
|
class ADS_EXPORT_API SectionContentEntity
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-04-01 18:35:33 +08:00
|
|
|
SectionContentEntity();
|
2016-03-31 20:47:19 +08:00
|
|
|
QString uniqueName;
|
|
|
|
bool visible;
|
|
|
|
qint32 preferredIndex;
|
|
|
|
};
|
2016-04-01 18:35:33 +08:00
|
|
|
QDataStream& operator<<(QDataStream& out, const SectionContentEntity& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, SectionContentEntity& data);
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
|
2016-04-01 18:35:33 +08:00
|
|
|
class ADS_EXPORT_API FloatingContentEntity
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
2016-04-01 18:35:33 +08:00
|
|
|
FloatingContentEntity();
|
2016-03-31 20:47:19 +08:00
|
|
|
QString uniqueName;
|
|
|
|
qint32 xpos;
|
|
|
|
qint32 ypos;
|
|
|
|
qint32 width;
|
|
|
|
qint32 height;
|
|
|
|
bool visible;
|
|
|
|
};
|
2016-04-01 18:35:33 +08:00
|
|
|
QDataStream& operator<<(QDataStream& out, const FloatingContentEntity& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, FloatingContentEntity& data);
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
|
|
|
|
// Type: OffsetHeaderEntry::Hierarchy
|
2016-04-01 18:11:52 +08:00
|
|
|
class ADS_EXPORT_API HierarchyData
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
HierarchyData();
|
|
|
|
QByteArray data;
|
|
|
|
};
|
|
|
|
QDataStream& operator<<(QDataStream& out, const HierarchyData& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, HierarchyData& data);
|
|
|
|
|
|
|
|
|
|
|
|
// Type: OffsetHeaderEntry::SectionIndex
|
2016-04-01 18:11:52 +08:00
|
|
|
class ADS_EXPORT_API SectionIndexData
|
2016-03-31 20:47:19 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
SectionIndexData();
|
|
|
|
qint32 sectionsCount;
|
2016-04-01 18:35:33 +08:00
|
|
|
QList<SectionEntity> sections;
|
2016-03-31 20:47:19 +08:00
|
|
|
};
|
2016-04-01 15:52:59 +08:00
|
|
|
QDataStream& operator<<(QDataStream& out, const SectionIndexData& data);
|
|
|
|
QDataStream& operator>>(QDataStream& in, SectionIndexData& data);
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The InMemoryWriter class writes into a QByteArray.
|
|
|
|
*/
|
2016-04-01 18:11:52 +08:00
|
|
|
class ADS_EXPORT_API InMemoryWriter
|
2016-04-01 15:52:59 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
InMemoryWriter();
|
2016-04-01 17:49:16 +08:00
|
|
|
bool write(qint32 entryType, const QByteArray& data);
|
2016-04-01 15:52:59 +08:00
|
|
|
bool write(const SectionIndexData& data);
|
|
|
|
QByteArray toByteArray() const;
|
2016-04-01 17:49:16 +08:00
|
|
|
qint32 offsetsCount() const { return _offsetsHeader.entriesCount; }
|
2016-04-01 15:52:59 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QBuffer _contentBuffer;
|
2016-04-01 18:35:33 +08:00
|
|
|
OffsetsHeaderEntity _offsetsHeader;
|
2016-04-01 15:52:59 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief The InMemoryReader class
|
|
|
|
*/
|
2016-04-01 18:11:52 +08:00
|
|
|
class ADS_EXPORT_API InMemoryReader
|
2016-04-01 15:52:59 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
InMemoryReader(const QByteArray& data);
|
|
|
|
bool initReadHeader();
|
2016-04-01 17:49:16 +08:00
|
|
|
bool read(qint32 entryType, QByteArray &data);
|
|
|
|
qint32 offsetsCount() const { return _offsetsHeader.entriesCount; }
|
2016-04-01 15:52:59 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
QByteArray _data;
|
2016-04-01 18:35:33 +08:00
|
|
|
OffsetsHeaderEntity _offsetsHeader;
|
2016-04-01 15:52:59 +08:00
|
|
|
};
|
2016-03-31 20:47:19 +08:00
|
|
|
|
|
|
|
ADS_NAMESPACE_SER_END
|
|
|
|
#endif
|