Qt Model Utilities  2.0.3
A set of utilities for the model/view framework of Qt
binarymodelserialiser.h
1 /****************************************************************************\
2  Copyright 2018 Luca Beldi
3  Licensed under the Apache License, Version 2.0 (the "License");
4  you may not use this file except in compliance with the License.
5  You may obtain a copy of the License at
6  http://www.apache.org/licenses/LICENSE-2.0
7  Unless required by applicable law or agreed to in writing, software
8  distributed under the License is distributed on an "AS IS" BASIS,
9  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10  See the License for the specific language governing permissions and
11  limitations under the License.
12 \****************************************************************************/
13 
14 #ifndef BINARYMODELSERIALISER_H
15 #define BINARYMODELSERIALISER_H
16 
17 #include "abstractmodelserialiser.h"
18 class BinaryModelSerialiserPrivate;
19 class MODELUTILITIES_EXPORT BinaryModelSerialiser : public AbstractModelSerialiser
20 {
21  Q_OBJECT
22 
23  Q_DECLARE_PRIVATE(BinaryModelSerialiser)
24  Q_DISABLE_COPY(BinaryModelSerialiser)
25 public:
26  explicit BinaryModelSerialiser(QObject *parent = Q_NULLPTR);
27  BinaryModelSerialiser(QAbstractItemModel *model, QObject *parent);
28  BinaryModelSerialiser(const QAbstractItemModel *model, QObject *parent);
30  virtual bool saveModel(QDataStream &stream) const;
31  Q_INVOKABLE bool saveModel(QIODevice *destination) const Q_DECL_OVERRIDE;
32  Q_INVOKABLE bool saveModel(QByteArray *destination) const Q_DECL_OVERRIDE;
33  Q_INVOKABLE bool loadModel(QIODevice *source) Q_DECL_OVERRIDE;
34  Q_INVOKABLE bool loadModel(const QByteArray &source) Q_DECL_OVERRIDE;
35  virtual bool loadModel(QDataStream &stream);
36 
37 protected:
38  BinaryModelSerialiser(BinaryModelSerialiserPrivate &d, QObject *parent = Q_NULLPTR);
39 
40 #ifdef MS_DECLARE_STREAM_OPERATORS
41  friend QDataStream &operator<<(QDataStream &stream, const QAbstractItemModel &model);
42  friend QDataStream &operator>>(QDataStream &stream, QAbstractItemModel &model);
43 #endif
44 };
45 #ifdef MS_DECLARE_STREAM_OPERATORS
46 QDataStream &operator<<(QDataStream &stream, const QAbstractItemModel &model);
47 QDataStream &operator>>(QDataStream &stream, QAbstractItemModel &model);
48 #endif
49 #endif // BINARYMODELSERIALISER_H
The interface for model serialisers.
Definition: abstractmodelserialiser.h:24
virtual Q_INVOKABLE bool saveModel(QIODevice *destination) const =0
virtual Q_INVOKABLE bool loadModel(QIODevice *source)=0
Serialiser to save and load models in binary format.
Definition: binarymodelserialiser.h:20