Heart/src/public/streammultiversion.h

69 lines
1.6 KiB
C
Raw Normal View History

2024-03-19 21:10:31 +01:00
/*
2024-12-30 22:44:47 +01:00
* Copyright (C) 2024-2025 QuasarApp.
2024-03-19 21:10:31 +01:00
* 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.
2025-03-01 10:04:46 +01:00
*
* This class used to save and read version of the object in file.
*
* @see StreamBase
*
* @code{cpp}
* class myClass: public StreamMultiversion {
* protected:
* QDataStream &fromStream(QDataStream &stream) override {
* char version = readVersion();
* return stream;
* }
*
* QDataStream &toStream(QDataStream &stream) const override {
* saveVersion(1, stream);
* return stream;
* }
*
* }
*
2024-03-19 21:10:31 +01:00
*/
class HEARTSHARED_EXPORT StreamMultiversion: public StreamBase
{
public:
StreamMultiversion();
2025-03-02 15:15:30 +01:00
~StreamMultiversion();
2024-03-19 21:10:31 +01:00
// StreamBase interface
2025-03-01 10:04:46 +01:00
2024-03-19 21:10:31 +01:00
/**
2025-03-01 10:04:46 +01:00
* @brief saveVersion save version of the object to the stream.
* @param version - version of the object.
* @param stream - stream to save.
*
* This method used to save version of the object in file.
* @see toStream
2024-03-19 21:10:31 +01:00
*/
2025-03-01 10:04:46 +01:00
void saveVersion(char version, QDataStream &stream) const;
2024-03-19 21:10:31 +01:00
/**
2025-03-01 10:04:46 +01:00
* @brief readVersion read version of the object from the stream.
* @param stream - stream to read.
* @return version of the object.
* @see fromStream
2024-03-24 21:23:27 +01:00
2025-03-01 10:04:46 +01:00
*/
2025-03-04 21:48:00 +01:00
char readVersion(QDataStream &stream);
2024-03-24 21:23:27 +01:00
2024-03-19 21:10:31 +01:00
};
}
#endif // STREAMMULTIVERSION_H