diff options
Diffstat (limited to 'src/base')
| -rw-r--r-- | src/base/QXmppBitsOfBinaryDataList.cpp | 58 | ||||
| -rw-r--r-- | src/base/QXmppBitsOfBinaryDataList.h | 51 |
2 files changed, 109 insertions, 0 deletions
diff --git a/src/base/QXmppBitsOfBinaryDataList.cpp b/src/base/QXmppBitsOfBinaryDataList.cpp new file mode 100644 index 00000000..a9de33e1 --- /dev/null +++ b/src/base/QXmppBitsOfBinaryDataList.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2008-2019 The QXmpp developers + * + * Author: + * Linus Jahn + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#include "QXmppBitsOfBinaryDataList.h" + +#include <QDomElement> + +#include "QXmppBitsOfBinaryData.h" +#include "QXmppConstants_p.h" + +QXmppBitsOfBinaryDataList::QXmppBitsOfBinaryDataList() = default; + +QXmppBitsOfBinaryDataList::~QXmppBitsOfBinaryDataList() = default; + +/// \cond +void QXmppBitsOfBinaryDataList::parse(const QDomElement &element) +{ + // clear previous data elements + clear(); + + // parse all <data/> elements + QDomElement child = element.firstChildElement(); + while (!child.isNull()) { + if (QXmppBitsOfBinaryData::isBitsOfBinaryData(child)) { + QXmppBitsOfBinaryData data; + data.parseElementFromChild(child); + append(data); + } + child = child.nextSiblingElement(); + } +} + +void QXmppBitsOfBinaryDataList::toXml(QXmlStreamWriter *writer) const +{ + for (const auto &bitsOfBinaryData : *this) + bitsOfBinaryData.toXmlElementFromChild(writer); +} +/// \endcond diff --git a/src/base/QXmppBitsOfBinaryDataList.h b/src/base/QXmppBitsOfBinaryDataList.h new file mode 100644 index 00000000..2a6f5311 --- /dev/null +++ b/src/base/QXmppBitsOfBinaryDataList.h @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2008-2019 The QXmpp developers + * + * Author: + * Linus Jahn + * + * Source: + * https://github.com/qxmpp-project/qxmpp + * + * This file is a part of QXmpp library. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + */ + +#ifndef QXMPPBITSOFBINARYDATACONTAINER_H +#define QXMPPBITSOFBINARYDATACONTAINER_H + +#include <QVector> + +#include "QXmppBitsOfBinaryData.h" + +class QDomElement; +class QXmlStreamWriter; + +/// \class QXmppBitsOfBinaryDataList represents a list of data elements from +/// XEP-0231: Bits of Binary. +/// +/// \since QXmpp 1.2 + +class QXMPP_EXPORT QXmppBitsOfBinaryDataList : public QVector<QXmppBitsOfBinaryData> +{ +public: + QXmppBitsOfBinaryDataList(); + ~QXmppBitsOfBinaryDataList(); + + /// \cond + void parse(const QDomElement &element); + void toXml(QXmlStreamWriter *writer) const; + /// \endcond +}; + +#endif // QXMPPBITSOFBINARYDATACONTAINER_H |
