added StreamMultiversion class
All checks were successful
buildbot/AndroidBuilder_v8Qt6 Build finished.
buildbot/DocsGenerator Build finished.
buildbot/LinuxCMakeBuilderQt6 Build finished.
buildbot/WindowsCMakeBuilder Build finished.

This commit is contained in:
Andrei Yankovich 2024-03-19 21:10:31 +01:00
parent da67aa78c7
commit 8289dcaf7f
3 changed files with 71 additions and 1 deletions

View File

@ -61,7 +61,7 @@ int StreamBase::parsingVersion() const {
}
unsigned int StreamBase::typeId() const {
return typeid (*this).hash_code();
return typeid (this).hash_code();
}
QDataStream &operator<<(QDataStream &stream, const StreamBase &obj) {

View File

@ -0,0 +1,24 @@
#include "streammultiversion.h"
#include <QDataStream>
namespace QH {
StreamMultiversion::StreamMultiversion() {
}
QDataStream &StreamMultiversion::fromStream(QDataStream &stream) {
stream >> _realVersion ;
return stream;
}
QDataStream &StreamMultiversion::toStream(QDataStream &stream) const {
stream << _realVersion;
return stream;
}
int StreamMultiversion::realVersion() const {
return _realVersion;
}
}

View File

@ -0,0 +1,46 @@
/*
* Copyright (C) 2024-2024 QuasarApp.
* Distributed under the lgplv3 software license, see the accompanying
* Everyone is permitted to copy and distribute verbatim copies
* of this license document, but changing it is not allowed.
*/
#ifndef STREAMMULTIVERSION_H
#define STREAMMULTIVERSION_H
#include "streambase.h"
namespace QH {
/**
* @brief The StreamMultiversion class this parser works with simple multiversion packages.
*/
class HEARTSHARED_EXPORT StreamMultiversion: public StreamBase
{
public:
StreamMultiversion();
// StreamBase interface
protected:
QDataStream &fromStream(QDataStream &stream) override;
QDataStream &toStream(QDataStream &stream) const override;
/**
* @brief version override this method to sets version of package.
* @return
*/
virtual int version() const = 0;
/**
* @brief realVersion This method return value of the version that was be saved in the bytes array.
* @return
* @note use this method to check version of read package in the fromStream method..
*/
virtual int realVersion() const;
private:
int _realVersion = 0;
};
}
#endif // STREAMMULTIVERSION_H