Heart 1.4.984.b4712811
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
streammultiversion.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024-2027 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#ifndef STREAMMULTIVERSION_H
9#define STREAMMULTIVERSION_H
10
11#include "streambase.h"
12
13namespace QH {
14
63class HEARTSHARED_EXPORT StreamMultiversion: public StreamBase
64{
65public:
66
69 // StreamBase interface
70
71protected:
72
81 void saveVersion(char version, QDataStream &stream) const;
82
90 char readVersion(QDataStream &stream);
91
98 char versionHeader(char version, QDataStream &stream);
99
109 char versionHeader(char version, QDataStream &stream) const;
110
116 template <class T>
117 void readWrite(QDataStream &stream, const T& data) const {
118 stream << data;
119 }
120
126 template <class T>
127 void readWrite(QDataStream &stream, T& data) {
128 stream >> data;
129
130 }
131
137 template <typename... Args>
138 void readWritePack(QDataStream &stream, Args&&... args) const {
139 (readWrite(stream, std::forward<Args>(args)), ...);
140 }
141
147 template <typename... Args>
148 void readWritePack(QDataStream &stream, Args&&... args) {
149 (readWrite(stream, std::forward<Args>(args)), ...);
150 }
151
152};
153
154}
155
156
157#define READ_WRITE_IMPL(...) \
158 readWritePack(stream, __VA_ARGS__); \
159 return stream; \
160
161
162
163#endif // STREAMMULTIVERSION_H
void readWritePack(QDataStream &stream, Args &&... args)
readWritePack - this is a pack write or read from the srting
char versionHeader(char version, QDataStream &stream)
versionHeader this is new function that automaticaly choose what shuld be to-do (read/wirte).
void readWrite(QDataStream &stream, const T &data) const
readWrite this method automaticaly choose what we need to-do read or write.
void saveVersion(char version, QDataStream &stream) const
saveVersion save version of the object to the stream.
void readWrite(QDataStream &stream, T &data)
readWrite this method automaticaly choose what we need to-do read or write.
void readWritePack(QDataStream &stream, Args &&... args) const
readWritePack - this is a pack write or read from the srting
char readVersion(QDataStream &stream)
readVersion read version of the object from the stream.
The QH namespace - QuasarApp Heart namespace. This namespace contains all classes of the Heart librar...
Definition heart.cpp:13