add swap and move support for QAMQP::Message
- declared typeinfo as Q_MOVABLE_TYPE - declared message as shared
This commit is contained in:
parent
7e151dfc7b
commit
d7dbcb892c
|
|
@ -109,6 +109,13 @@ QVariant Message::header(const QString &header, const QVariant &defaultValue) co
|
|||
return d->headers.value(header, defaultValue);
|
||||
}
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
bool Message::isDetached() const
|
||||
{
|
||||
return d && d->ref == 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
uint qHash(const QAMQP::Message &message, uint seed)
|
||||
{
|
||||
Q_UNUSED(seed);
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@ public:
|
|||
Message &operator=(const Message &other);
|
||||
~Message();
|
||||
|
||||
#if QT_VERSION >= 0x050000
|
||||
inline void swap(Message &other) { qSwap(d, other.d); }
|
||||
#endif
|
||||
|
||||
bool operator==(const Message &message) const;
|
||||
inline bool operator!=(const Message &message) const { return !(operator==(message)); }
|
||||
|
||||
|
|
@ -62,12 +66,25 @@ private:
|
|||
friend class QueuePrivate;
|
||||
friend class Queue;
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
public:
|
||||
typedef QSharedDataPointer<MessagePrivate> DataPtr;
|
||||
inline DataPtr &data_ptr() { return d; }
|
||||
|
||||
// internal
|
||||
bool isDetached() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace QAMQP
|
||||
|
||||
Q_DECLARE_METATYPE(QAMQP::Message::PropertyHash)
|
||||
|
||||
#if QT_VERSION < 0x050000
|
||||
Q_DECLARE_TYPEINFO(QAMQP::Message, Q_MOVABLE_TYPE);
|
||||
#endif
|
||||
Q_DECLARE_SHARED(QAMQP::Message)
|
||||
|
||||
// NOTE: needed only for MSVC support, don't depend on this hash
|
||||
QAMQP_EXPORT uint qHash(const QAMQP::Message &key, uint seed = 0);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue