Heart 1.4.984.b4712811
Heart is base back end library for your c++ Qt projects.
Loading...
Searching...
No Matches
QH::StreamMultiversion Class Reference

The StreamMultiversion class this parser works with simple multiversion packages. More...

#include <streammultiversion.h>

Inheritance diagram for QH::StreamMultiversion:
Inheritance graph
Collaboration diagram for QH::StreamMultiversion:
Collaboration graph

Public Member Functions

 StreamMultiversion ()
 ~StreamMultiversion ()
Public Member Functions inherited from QH::StreamBase
 StreamBase ()
virtual ~StreamBase ()
bool fromBytes (const QByteArray &dataz)
 fromBytes This method provide initialization of object from byte array.
QByteArray toBytes () const
 toBytes This method convert a current object to bytes array.
bool fromBase64 (const QString &data)
 fromBase64 This method provide initialization of object from the base64 string.
bool fromBase64 (const QByteArray &data)
 fromBase64 This method provide initialization of object from the base64 string.
QByteArray toBase64 () const
 toBase64 This method convert a current object to the base64 string.
template<class T>
T & copy (const StreamBase &right)
 copy This is base copy method for all StreamBase structures. Default implementation it is copy from byteArray.
template<class T>
bool compare (const T &right)
 compare This method compare array signatures of this and right objects.

Protected Member Functions

void saveVersion (char version, QDataStream &stream) const
 saveVersion save version of the object to the stream.
char readVersion (QDataStream &stream)
 readVersion read version of the object from the stream.
char versionHeader (char version, QDataStream &stream)
 versionHeader this is new function that automaticaly choose what shuld be to-do (read/wirte).
char versionHeader (char version, QDataStream &stream) const
 versionHeader this is new function that automaticaly choose what shuld be to-do (read/wirte).
template<class T>
void readWrite (QDataStream &stream, const T &data) const
 readWrite this method automaticaly choose what we need to-do read or write.
template<class T>
void readWrite (QDataStream &stream, T &data)
 readWrite this method automaticaly choose what we need to-do read or write.
template<typename... Args>
void readWritePack (QDataStream &stream, Args &&... args) const
 readWritePack - this is a pack write or read from the srting
template<typename... Args>
void readWritePack (QDataStream &stream, Args &&... args)
 readWritePack - this is a pack write or read from the srting
Protected Member Functions inherited from QH::StreamBase
virtual int parsingVersion () const
 parsingVersion this method return parsing version of Qt. By Default is 0 (last available parsing). see https://doc.qt.io/qt-6/qdatastream.html#Version-enum
virtual QDataStream & fromStream (QDataStream &stream)=0
 fromStream This method should be read all bytes from the stream object and full the current object.
virtual QDataStream & toStream (QDataStream &stream) const =0
 fromStream This method should be write all members of the current object to the stream object.
virtual unsigned int typeId () const
 typeId This method return id of type.

Detailed Description

The StreamMultiversion class this parser works with simple multiversion packages.

This class used to save and read version of the object in file.

See also
StreamBase
class myClass: public StreamMultiversion {
protected:
QDataStream &fromStream(QDataStream &stream) override {
char version = versionHeader(0, stream);
readWrite(stream, data);
return stream;
}
QDataStream &toStream(QDataStream &stream) const override {
char version = versionHeader(0, stream);
readWrite(stream, data);
return stream;
}
private:
int data;
}
virtual QDataStream & fromStream(QDataStream &stream)=0
fromStream This method should be read all bytes from the stream object and full the current object.
virtual QDataStream & toStream(QDataStream &stream) const =0
fromStream This method should be write all members of the current object to the stream object.
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.

More example of use:

QDataStream &ClassName::fromStream(QDataStream &stream)
{
versionHeader(0, stream);
fild1)
}
QDataStream &ClassName::toStream(QDataStream &stream) const
{
versionHeader(0, stream);
fild1)
}
#define READ_WRITE_IMPL(...)

Definition at line 63 of file streammultiversion.h.

Constructor & Destructor Documentation

◆ StreamMultiversion()

QH::StreamMultiversion::StreamMultiversion ( )

Definition at line 6 of file streammultiversion.cpp.

◆ ~StreamMultiversion()

QH::StreamMultiversion::~StreamMultiversion ( )

Definition at line 10 of file streammultiversion.cpp.

Member Function Documentation

◆ readVersion()

char QH::StreamMultiversion::readVersion ( QDataStream & stream)
protected

readVersion read version of the object from the stream.

Parameters
stream- stream to read.
Returns
version of the object.
See also
fromStream

Definition at line 18 of file streammultiversion.cpp.

Here is the caller graph for this function:

◆ readWrite() [1/2]

template<class T>
void QH::StreamMultiversion::readWrite ( QDataStream & stream,
const T & data ) const
inlineprotected

readWrite this method automaticaly choose what we need to-do read or write.

Parameters
stream
data

Definition at line 117 of file streammultiversion.h.

Here is the caller graph for this function:

◆ readWrite() [2/2]

template<class T>
void QH::StreamMultiversion::readWrite ( QDataStream & stream,
T & data )
inlineprotected

readWrite this method automaticaly choose what we need to-do read or write.

Parameters
stream
data

Definition at line 127 of file streammultiversion.h.

◆ readWritePack() [1/2]

template<typename... Args>
void QH::StreamMultiversion::readWritePack ( QDataStream & stream,
Args &&... args )
inlineprotected

readWritePack - this is a pack write or read from the srting

Parameters
stream- stream cheenel to save or read.
args- list of arguments

Definition at line 148 of file streammultiversion.h.

Here is the call graph for this function:

◆ readWritePack() [2/2]

template<typename... Args>
void QH::StreamMultiversion::readWritePack ( QDataStream & stream,
Args &&... args ) const
inlineprotected

readWritePack - this is a pack write or read from the srting

Parameters
stream- stream cheenel to save or read.
args- list of arguments

Definition at line 138 of file streammultiversion.h.

Here is the call graph for this function:

◆ saveVersion()

void QH::StreamMultiversion::saveVersion ( char version,
QDataStream & stream ) const
protected

saveVersion save version of the object to the stream.

Parameters
version- version of the object.
stream- stream to save.

This method used to save version of the object in file.

See also
toStream

Definition at line 14 of file streammultiversion.cpp.

Here is the caller graph for this function:

◆ versionHeader() [1/2]

char QH::StreamMultiversion::versionHeader ( char version,
QDataStream & stream )
protected

versionHeader this is new function that automaticaly choose what shuld be to-do (read/wirte).

Parameters
versionthis is a version of object.
streamthis is stream cheenel to save or read.
Returns
version of object.

Definition at line 26 of file streammultiversion.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ versionHeader() [2/2]

char QH::StreamMultiversion::versionHeader ( char version,
QDataStream & stream ) const
protected

versionHeader this is new function that automaticaly choose what shuld be to-do (read/wirte).

Parameters
versionthis is a version of object.
streamthis is stream cheenel to save or read.
Note
The version returned by versionHeader() should be handled manually.
For backward compatibility, toStream() always writes version 0.
Consider implementing version switching logic for multiversion support.
Returns
version of object.

Definition at line 30 of file streammultiversion.cpp.

Here is the call graph for this function:

The documentation for this class was generated from the following files: