diff options
Diffstat (limited to 'src/base/QXmppElement.cpp')
| -rw-r--r-- | src/base/QXmppElement.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/src/base/QXmppElement.cpp b/src/base/QXmppElement.cpp index 129b68c1..0aadfb2d 100644 --- a/src/base/QXmppElement.cpp +++ b/src/base/QXmppElement.cpp @@ -91,11 +91,23 @@ QXmppElementPrivate::~QXmppElementPrivate() delete child; } +/// +/// \class QXmppElement +/// +/// QXmppElement represents a raw XML element with possible children. +/// + +/// +/// Default constructor +/// QXmppElement::QXmppElement() { d = new QXmppElementPrivate(); } +/// +/// Copy constructor +/// QXmppElement::QXmppElement(const QXmppElement &other) { other.d->counter.ref(); @@ -108,6 +120,9 @@ QXmppElement::QXmppElement(QXmppElementPrivate *other) d = other; } +/// +/// Copy-construct DOM element contents +/// QXmppElement::QXmppElement(const QDomElement &element) { d = new QXmppElementPrivate(element); @@ -119,6 +134,9 @@ QXmppElement::~QXmppElement() delete d; } +/// +/// Assignment operator +/// QXmppElement &QXmppElement::operator=(const QXmppElement &other) { if (this != &other) // self-assignment check @@ -131,6 +149,12 @@ QXmppElement &QXmppElement::operator=(const QXmppElement &other) return *this; } +/// +/// Creates a DOM element from the source element +/// +/// The source DOM element is saved as XML and needs to be parsed again in this +/// step. +/// QDomElement QXmppElement::sourceDomElement() const { if (d->serializedSource.isEmpty()) @@ -145,21 +169,33 @@ QDomElement QXmppElement::sourceDomElement() const return doc.documentElement(); } +/// +/// Returns the list of attributes +/// QStringList QXmppElement::attributeNames() const { return d->attributes.keys(); } +/// +/// Returns an attribute by name +/// QString QXmppElement::attribute(const QString &name) const { return d->attributes.value(name); } +/// +/// Sets an attribute +/// void QXmppElement::setAttribute(const QString &name, const QString &value) { d->attributes.insert(name, value); } +/// +/// Adds a child element +/// void QXmppElement::appendChild(const QXmppElement &child) { if (child.d->parent == d) @@ -173,6 +209,10 @@ void QXmppElement::appendChild(const QXmppElement &child) d->children.append(child.d); } +/// +/// Returns the first child element with the given name or the first child +/// element if the given name is empty. +/// QXmppElement QXmppElement::firstChildElement(const QString &name) const { for (auto *child_d : d->children) @@ -181,6 +221,10 @@ QXmppElement QXmppElement::firstChildElement(const QString &name) const return QXmppElement(); } +/// +/// Returns the next sibling element with the given name or the next sibling +/// element if the given name is empty. +/// QXmppElement QXmppElement::nextSiblingElement(const QString &name) const { if (!d->parent) @@ -192,11 +236,17 @@ QXmppElement QXmppElement::nextSiblingElement(const QString &name) const return QXmppElement(); } +/// +/// Returns true if the element is null +/// bool QXmppElement::isNull() const { return d->name.isEmpty(); } +/// +/// Removes a child element +/// void QXmppElement::removeChild(const QXmppElement &child) { if (child.d->parent != d) @@ -207,26 +257,41 @@ void QXmppElement::removeChild(const QXmppElement &child) child.d->parent = nullptr; } +/// +/// Returns the tag name of the element +/// QString QXmppElement::tagName() const { return d->name; } +/// +/// Sets the tag name of the element +/// void QXmppElement::setTagName(const QString &tagName) { d->name = tagName; } +/// +/// Returns the text content of the element +/// QString QXmppElement::value() const { return d->value; } +/// +/// Sets the text content of the element +/// void QXmppElement::setValue(const QString &value) { d->value = value; } +/// +/// Serializes the element to XML +/// void QXmppElement::toXml(QXmlStreamWriter *writer) const { if (isNull()) |
