diff options
| author | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-08-03 14:39:21 +0200 |
|---|---|---|
| committer | Jeremy Lainé <jeremy.laine@m4x.org> | 2012-08-03 14:39:21 +0200 |
| commit | 96c449cd837fc141a0ee3fede727f58b7b4fb2d6 (patch) | |
| tree | 9d877445da80a3a37b12244139aafe6184c58c28 /src/base/QXmppIq.cpp | |
| parent | 02929ceb4d2c07606ed4fa81db66733d2ad8c872 (diff) | |
| download | qxmpp-96c449cd837fc141a0ee3fede727f58b7b4fb2d6.tar.gz | |
make QXmppIq use pimpl + implicit data sharing
Diffstat (limited to 'src/base/QXmppIq.cpp')
| -rw-r--r-- | src/base/QXmppIq.cpp | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/base/QXmppIq.cpp b/src/base/QXmppIq.cpp index 67f22274..351eeca7 100644 --- a/src/base/QXmppIq.cpp +++ b/src/base/QXmppIq.cpp @@ -35,22 +35,51 @@ static const char* iq_types[] = { "result" }; +class QXmppIqPrivate : public QSharedData +{ +public: + QXmppIq::Type type; +}; + /// Constructs a QXmppIq with the specified \a type. /// /// \param type QXmppIq::QXmppIq(QXmppIq::Type type) - : QXmppStanza(), m_type(type) + : QXmppStanza() + , d(new QXmppIqPrivate) { + d->type = type; generateAndSetNextId(); } +/// Constructs a copy of \a other. + +QXmppIq::QXmppIq(const QXmppIq &other) + : QXmppStanza(other) + , d(other.d) +{ +} + +QXmppIq::~QXmppIq() +{ +} + +/// Assigns \a other to this IQ. + +QXmppIq& QXmppIq::operator=(const QXmppIq &other) +{ + QXmppStanza::operator=(other); + d = other.d; + return *this; +} + /// Returns the IQ's type. /// QXmppIq::Type QXmppIq::type() const { - return m_type; + return d->type; } /// Sets the IQ's type. @@ -59,7 +88,7 @@ QXmppIq::Type QXmppIq::type() const void QXmppIq::setType(QXmppIq::Type type) { - m_type = type; + d->type = type; } /// \cond @@ -70,7 +99,7 @@ void QXmppIq::parse(const QDomElement &element) const QString type = element.attribute("type"); for (int i = Error; i <= Result; i++) { if (type == iq_types[i]) { - m_type = static_cast<Type>(i); + d->type = static_cast<Type>(i); break; } } @@ -97,7 +126,7 @@ void QXmppIq::toXml( QXmlStreamWriter *xmlWriter ) const helperToXmlAddAttribute(xmlWriter, "id", id()); helperToXmlAddAttribute(xmlWriter, "to", to()); helperToXmlAddAttribute(xmlWriter, "from", from()); - helperToXmlAddAttribute(xmlWriter, "type", iq_types[m_type]); + helperToXmlAddAttribute(xmlWriter, "type", iq_types[d->type]); toXmlElementFromChild(xmlWriter); error().toXml(xmlWriter); xmlWriter->writeEndElement(); |
