1/****************************************************************************
2**
3** Copyright (C) 2015 The Qt Company Ltd.
4** Contact: http://www.qt.io/licensing/
5**
6** This file is part of the QtContacts module of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL21$
9** Commercial License Usage
10** Licensees holding valid commercial Qt licenses may use this file in
11** accordance with the commercial license agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and The Qt Company. For licensing terms
14** and conditions see http://www.qt.io/terms-conditions. For further
15** information use the contact form at http://www.qt.io/contact-us.
16**
17** GNU Lesser General Public License Usage
18** Alternatively, this file may be used under the terms of the GNU Lesser
19** General Public License version 2.1 or version 3 as published by the Free
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the
22** following information to ensure the GNU Lesser General Public License
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
25**
26** As a special exception, The Qt Company gives you certain additional
27** rights. These rights are described in The Qt Company LGPL Exception
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
29**
30** $QT_END_LICENSE$
31**
32****************************************************************************/
33
34#ifndef QCONTACTFILTER_P_H
35#define QCONTACTFILTER_P_H
36
37//
38// W A R N I N G
39// -------------
40//
41// This file is not part of the Qt API. It exists purely as an
42// implementation detail. This header file may change from version to
43// version without notice, or even be removed.
44//
45// We mean it.
46//
47
48#ifndef QT_NO_DATASTREAM
49#include <QtCore/qdatastream.h>
50#endif
51#ifndef QT_NO_DEBUG_STREAM
52#include <QtCore/qdebug.h>
53#endif
54#include <QtCore/qlist.h>
55#include <QtCore/qshareddata.h>
56
57#include <QtContacts/qcontactfilter.h>
58
59/* Boiler plate code */
60#define Q_IMPLEMENT_CONTACTFILTER_PRIVATE(Class) \
61 Class##Private* Class::d_func() { return reinterpret_cast<Class##Private *>(d_ptr.data()); } \
62 const Class##Private* Class::d_func() const { return reinterpret_cast<const Class##Private *>(d_ptr.constData()); } \
63 Class::Class(const QContactFilter& other) : QContactFilter() { Class##Private::copyIfPossible(d_ptr, other); }
64
65#define Q_IMPLEMENT_CONTACTFILTER_VIRTUALCTORS(Class, Type) \
66 QContactFilterPrivate* clone() const { return new Class##Private(*this); } \
67 virtual QContactFilter::FilterType type() const {return Type;} \
68 static void copyIfPossible(QSharedDataPointer<QContactFilterPrivate>& d_ptr, const QContactFilter& other) \
69 { \
70 if (other.type() == Type) \
71 d_ptr = extract_d(other); \
72 else \
73 d_ptr = new Class##Private; \
74 }
75
76QT_BEGIN_NAMESPACE_CONTACTS
77class QContactFilterPrivate : public QSharedData
78{
79public:
80 QContactFilterPrivate()
81 {
82 }
83
84 virtual ~QContactFilterPrivate()
85 {
86 }
87
88 virtual bool compare(const QContactFilterPrivate* other) const = 0;
89 virtual QDataStream& outputToStream(QDataStream& stream, quint8 formatVersion) const = 0;
90 virtual QDataStream& inputFromStream(QDataStream& stream, quint8 formatVersion) = 0;
91#ifndef QT_NO_DEBUG_STREAM
92 // NOTE: on platforms where Qt is built without debug streams enabled, vtable will differ!
93 virtual QDebug& debugStreamOut(QDebug& dbg) const = 0;
94#endif
95 virtual QContactFilterPrivate* clone() const = 0;
96 virtual QContactFilter::FilterType type() const = 0;
97
98 /* Helper functions for C++ protection rules */
99 static const QSharedDataPointer<QContactFilterPrivate>& extract_d(const QContactFilter& other) {return other.d_ptr;}
100};
101QT_END_NAMESPACE_CONTACTS
102
103QT_BEGIN_NAMESPACE
104#if defined(Q_CC_MWERKS)
105// This results in multiple symbol definition errors on all other compilers
106// but not having a definition here results in an attempt to use the unspecialized
107// clone (which fails because of the pure virtuals above)
108template<> QTCONTACTS_PREPEND_NAMESPACE(QContactFilterPrivate) *QSharedDataPointer<QTCONTACTS_PREPEND_NAMESPACE(QContactFilterPrivate)>::clone()
109{
110 return d->clone();
111}
112#else
113template<> QTCONTACTS_PREPEND_NAMESPACE(QContactFilterPrivate) *QSharedDataPointer<QTCONTACTS_PREPEND_NAMESPACE(QContactFilterPrivate)>::clone();
114#endif
115QT_END_NAMESPACE
116
117#endif // QCONTACTFILTER_P_H
118

source code of qtpim/src/contacts/qcontactfilter_p.h