Qt 4.8
Public Functions | Private Functions | Properties | Friends | List of all members
QDomNodeList Class Reference

The QDomNodeList class is a list of QDomNode objects. More...

#include <qdom.h>

Public Functions

QDomNode at (int index) const
 This function is provided for Qt API consistency. More...
 
int count () const
 This function is provided for Qt API consistency. More...
 
bool isEmpty () const
 Returns true if the list contains no items; otherwise returns false. More...
 
QDomNode item (int index) const
 Returns the node at position index. More...
 
uint length () const
 Returns the number of nodes in the list. More...
 
bool operator!= (const QDomNodeList &) const
 Returns true the node list n and this node list are not equal; otherwise returns false. More...
 
QDomNodeListoperator= (const QDomNodeList &)
 Assigns n to this node list. More...
 
bool operator== (const QDomNodeList &) const
 Returns true if the node list n and this node list are equal; otherwise returns false. More...
 
 QDomNodeList ()
 Creates an empty node list. More...
 
 QDomNodeList (const QDomNodeList &)
 Constructs a copy of n. More...
 
int size () const
 This function is provided for Qt API consistency. More...
 
 ~QDomNodeList ()
 Destroys the object and frees its resources. More...
 

Private Functions

 QDomNodeList (QDomNodeListPrivate *)
 

Properties

QDomNodeListPrivateimpl
 

Friends

class QDomDocument
 
class QDomElement
 
class QDomNode
 

Detailed Description

The QDomNodeList class is a list of QDomNode objects.

Note
This class or function is reentrant.
Attention
Module: QtXml

Lists can be obtained by QDomDocument::elementsByTagName() and QDomNode::childNodes(). The Document Object Model (DOM) requires these lists to be "live": whenever you change the underlying document, the contents of the list will get updated.

You can get a particular node from the list with item(). The number of items in the list is returned by length().

For further information about the Document Object Model see Level 1 and Level 2 Core. For a more general introduction of the DOM implementation see the QDomDocument documentation.

See also
QDomNode::childNodes() QDomDocument::elementsByTagName()

Definition at line 253 of file qdom.h.

Constructors and Destructors

◆ QDomNodeList() [1/3]

QDomNodeList::QDomNodeList ( )

Creates an empty node list.

Definition at line 1337 of file qdom.cpp.

1338 {
1339  impl = 0;
1340 }
QDomNodeListPrivate * impl
Definition: qdom.h:274

◆ QDomNodeList() [2/3]

QDomNodeList::QDomNodeList ( const QDomNodeList n)

Constructs a copy of n.

Definition at line 1350 of file qdom.cpp.

1351 {
1352  impl = n.impl;
1353  if (impl)
1354  impl->ref.ref();
1355 }
QAtomicInt ref
Definition: qdom.cpp:224
bool ref()
Atomically increments the value of this QAtomicInt.
QDomNodeListPrivate * impl
Definition: qdom.h:274

◆ ~QDomNodeList()

QDomNodeList::~QDomNodeList ( )

Destroys the object and frees its resources.

Definition at line 1395 of file qdom.cpp.

1396 {
1397  if (impl && !impl->ref.deref())
1398  delete impl;
1399 }
QAtomicInt ref
Definition: qdom.cpp:224
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomNodeListPrivate * impl
Definition: qdom.h:274

◆ QDomNodeList() [3/3]

QDomNodeList::QDomNodeList ( QDomNodeListPrivate p)
private

Definition at line 1342 of file qdom.cpp.

1343 {
1344  impl = p;
1345 }
QDomNodeListPrivate * impl
Definition: qdom.h:274

Functions

◆ at()

QDomNode QDomNodeList::at ( int  index) const
inline

This function is provided for Qt API consistency.

It is equivalent to item().

If index is negative or if index >= length() then a null node is returned (i.e. a node for which QDomNode::isNull() returns true).

Definition at line 265 of file qdom.h.

265 { return item(index); } // Qt API consistency
quint16 index
QDomNode item(int index) const
Returns the node at position index.
Definition: qdom.cpp:1410

◆ count()

int QDomNodeList::count ( ) const
inline

This function is provided for Qt API consistency.

It is equivalent to length().

Definition at line 269 of file qdom.h.

Referenced by QDBusXmlParser::interfaces(), QDBusXmlParser::object(), QDBusXmlParser::objectTree(), parseAnnotations(), and parseArgs().

269 { return length(); } // Qt API consitancy
uint length() const
Returns the number of nodes in the list.
Definition: qdom.cpp:1421

◆ isEmpty()

bool QDomNodeList::isEmpty ( ) const
inline

Returns true if the list contains no items; otherwise returns false.

This function is provided for Qt API consistency.

Definition at line 271 of file qdom.h.

271 { return length() == 0; } // Qt API consistency
uint length() const
Returns the number of nodes in the list.
Definition: qdom.cpp:1421

◆ item()

QDomNode QDomNodeList::item ( int  index) const

Returns the node at position index.

If index is negative or if index >= length() then a null node is returned (i.e. a node for which QDomNode::isNull() returns true).

See also
length()

Definition at line 1410 of file qdom.cpp.

Referenced by QDBusXmlParser::interfaces(), QDBusXmlParser::object(), QDBusXmlParser::objectTree(), parseAnnotations(), and parseArgs().

1411 {
1412  if (!impl)
1413  return QDomNode();
1414 
1415  return QDomNode(impl->item(index));
1416 }
QDomNodePrivate * item(int index)
Definition: qdom.cpp:1271
friend class QDomNode
Definition: qdom.h:277
QDomNodeListPrivate * impl
Definition: qdom.h:274
quint16 index

◆ length()

uint QDomNodeList::length ( ) const

Returns the number of nodes in the list.

Definition at line 1421 of file qdom.cpp.

1422 {
1423  if (!impl)
1424  return 0;
1425  return impl->length();
1426 }
uint length() const
Definition: qdom.cpp:1286
QDomNodeListPrivate * impl
Definition: qdom.h:274

◆ operator!=()

bool QDomNodeList::operator!= ( const QDomNodeList n) const

Returns true the node list n and this node list are not equal; otherwise returns false.

Definition at line 1387 of file qdom.cpp.

1388 {
1389  return !operator==(n);
1390 }
bool operator==(const QDomNodeList &) const
Returns true if the node list n and this node list are equal; otherwise returns false.
Definition: qdom.cpp:1374

◆ operator=()

QDomNodeList & QDomNodeList::operator= ( const QDomNodeList n)

Assigns n to this node list.

Definition at line 1360 of file qdom.cpp.

1361 {
1362  if (n.impl)
1363  n.impl->ref.ref();
1364  if (impl && !impl->ref.deref())
1365  delete impl;
1366  impl = n.impl;
1367  return *this;
1368 }
QAtomicInt ref
Definition: qdom.cpp:224
bool ref()
Atomically increments the value of this QAtomicInt.
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomNodeListPrivate * impl
Definition: qdom.h:274

◆ operator==()

bool QDomNodeList::operator== ( const QDomNodeList n) const

Returns true if the node list n and this node list are equal; otherwise returns false.

Definition at line 1374 of file qdom.cpp.

1375 {
1376  if (impl == n.impl)
1377  return true;
1378  if (!impl || !n.impl)
1379  return false;
1380  return (*impl == *n.impl);
1381 }
QDomNodeListPrivate * impl
Definition: qdom.h:274

◆ size()

int QDomNodeList::size ( ) const
inline

This function is provided for Qt API consistency.

It is equivalent to length().

Definition at line 270 of file qdom.h.

270 { return length(); } // Qt API consistency
uint length() const
Returns the number of nodes in the list.
Definition: qdom.cpp:1421

Friends and Related Functions

◆ QDomDocument

friend class QDomDocument
friend

Definition at line 279 of file qdom.h.

◆ QDomElement

friend class QDomElement
friend

Definition at line 278 of file qdom.h.

◆ QDomNode

friend class QDomNode
friend

Definition at line 277 of file qdom.h.

Properties

◆ impl

QDomNodeListPrivate* QDomNodeList::impl
private

Definition at line 274 of file qdom.h.

Referenced by operator=(), operator==(), and QDomNodeList().


The documentation for this class was generated from the following files: