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

The QDomNamedNodeMap class contains a collection of nodes that can be accessed by name. More...

#include <qdom.h>

Public Functions

bool contains (const QString &name) const
 Returns true if the map contains a node called name; otherwise returns false. More...
 
int count () const
 This function is provided for Qt API consistency. More...
 
bool isEmpty () const
 Returns true if the map is empty; otherwise returns false. More...
 
QDomNode item (int index) const
 Retrieves the node at position index. More...
 
uint length () const
 Returns the number of nodes in the map. More...
 
QDomNode namedItem (const QString &name) const
 Returns the node called name. More...
 
QDomNode namedItemNS (const QString &nsURI, const QString &localName) const
 Returns the node associated with the local name localName and the namespace URI nsURI. More...
 
bool operator!= (const QDomNamedNodeMap &) const
 Returns true if n and this named node map are not equal; otherwise returns false. More...
 
QDomNamedNodeMapoperator= (const QDomNamedNodeMap &)
 Assigns n to this named node map. More...
 
bool operator== (const QDomNamedNodeMap &) const
 Returns true if n and this named node map are equal; otherwise returns false. More...
 
 QDomNamedNodeMap ()
 Constructs an empty named node map. More...
 
 QDomNamedNodeMap (const QDomNamedNodeMap &)
 Constructs a copy of n. More...
 
QDomNode removeNamedItem (const QString &name)
 Removes the node called name from the map. More...
 
QDomNode removeNamedItemNS (const QString &nsURI, const QString &localName)
 Removes the node with the local name localName and the namespace URI nsURI from the map. More...
 
QDomNode setNamedItem (const QDomNode &newNode)
 Inserts the node newNode into the named node map. More...
 
QDomNode setNamedItemNS (const QDomNode &newNode)
 Inserts the node newNode in the map. More...
 
int size () const
 This function is provided for Qt API consistency. More...
 
 ~QDomNamedNodeMap ()
 Destroys the object and frees its resources. More...
 

Private Functions

 QDomNamedNodeMap (QDomNamedNodeMapPrivate *)
 

Properties

QDomNamedNodeMapPrivateimpl
 

Friends

class QDomDocumentType
 
class QDomElement
 
class QDomNode
 

Detailed Description

The QDomNamedNodeMap class contains a collection of nodes that can be accessed by name.

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

Note that QDomNamedNodeMap does not inherit from QDomNodeList. QDomNamedNodeMaps do not provide any specific node ordering. Although nodes in a QDomNamedNodeMap may be accessed by an ordinal index, this is simply to allow a convenient enumeration of the contents of a QDomNamedNodeMap, and does not imply that the DOM specifies an ordering of the nodes.

The QDomNamedNodeMap is used in three places:

  1. QDomDocumentType::entities() returns a map of all entities described in the DTD.
  2. QDomDocumentType::notations() returns a map of all notations described in the DTD.
  3. QDomNode::attributes() returns a map of all attributes of an element.

Items in the map are identified by the name which QDomNode::name() returns. Nodes are retrieved using namedItem(), namedItemNS() or item(). New nodes are inserted with setNamedItem() or setNamedItemNS() and removed with removeNamedItem() or removeNamedItemNS(). Use contains() to see if an item with the given name is in the named node map. The number of items is returned by length().

Terminology: in this class we use "item" and "node" interchangeably.

Definition at line 362 of file qdom.h.

Constructors and Destructors

◆ QDomNamedNodeMap() [1/3]

QDomNamedNodeMap::QDomNamedNodeMap ( )

Constructs an empty named node map.

Definition at line 3295 of file qdom.cpp.

3296 {
3297  impl = 0;
3298 }
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ QDomNamedNodeMap() [2/3]

QDomNamedNodeMap::QDomNamedNodeMap ( const QDomNamedNodeMap n)

Constructs a copy of n.

Definition at line 3303 of file qdom.cpp.

3304 {
3305  impl = n.impl;
3306  if (impl)
3307  impl->ref.ref();
3308 }
bool ref()
Atomically increments the value of this QAtomicInt.
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ ~QDomNamedNodeMap()

QDomNamedNodeMap::~QDomNamedNodeMap ( )

Destroys the object and frees its resources.

Definition at line 3351 of file qdom.cpp.

3352 {
3353  if (impl && !impl->ref.deref())
3354  delete impl;
3355 }
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ QDomNamedNodeMap() [3/3]

QDomNamedNodeMap::QDomNamedNodeMap ( QDomNamedNodeMapPrivate n)
private

Definition at line 3310 of file qdom.cpp.

3311 {
3312  impl = n;
3313  if (impl)
3314  impl->ref.ref();
3315 }
bool ref()
Atomically increments the value of this QAtomicInt.
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

Functions

◆ contains()

bool QDomNamedNodeMap::contains ( const QString name) const

Returns true if the map contains a node called name; otherwise returns false.

Note: This function does not take the presence of namespaces into account. Use namedItemNS() to test whether the map contains a node with a specific namespace URI and name.

Definition at line 3521 of file qdom.cpp.

3522 {
3523  if (!impl)
3524  return false;
3525  return IMPL->contains(name);
3526 }
#define IMPL
Definition: qdom.cpp:6666
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ count()

int QDomNamedNodeMap::count ( ) const
inline

This function is provided for Qt API consistency.

It is equivalent to length().

Definition at line 383 of file qdom.h.

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

◆ isEmpty()

bool QDomNamedNodeMap::isEmpty ( ) const
inline

Returns true if the map is empty; otherwise returns false.

This function is provided for Qt API consistency.

Definition at line 385 of file qdom.h.

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

◆ item()

QDomNode QDomNamedNodeMap::item ( int  index) const

Retrieves the node at position index.

This can be used to iterate over the map. Note that the nodes in the map are ordered arbitrarily.

See also
length()

Definition at line 3414 of file qdom.cpp.

3415 {
3416  if (!impl)
3417  return QDomNode();
3418  return QDomNode(IMPL->item(index));
3419 }
#define IMPL
Definition: qdom.cpp:6666
quint16 index
friend class QDomNode
Definition: qdom.h:394
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ length()

uint QDomNamedNodeMap::length ( ) const

Returns the number of nodes in the map.

See also
item()

Definition at line 3478 of file qdom.cpp.

3479 {
3480  if (!impl)
3481  return 0;
3482  return IMPL->length();
3483 }
#define IMPL
Definition: qdom.cpp:6666
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ namedItem()

QDomNode QDomNamedNodeMap::namedItem ( const QString name) const

Returns the node called name.

If the named node map does not contain such a node, a null node is returned. A node's name is the name returned by QDomNode::nodeName().

See also
setNamedItem() namedItemNS()

Definition at line 3366 of file qdom.cpp.

3367 {
3368  if (!impl)
3369  return QDomNode();
3370  return QDomNode(IMPL->namedItem(name));
3371 }
#define IMPL
Definition: qdom.cpp:6666
friend class QDomNode
Definition: qdom.h:394
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ namedItemNS()

QDomNode QDomNamedNodeMap::namedItemNS ( const QString nsURI,
const QString localName 
) const

Returns the node associated with the local name localName and the namespace URI nsURI.

If the map does not contain such a node, a null node is returned.

See also
setNamedItemNS() namedItem()

Definition at line 3430 of file qdom.cpp.

3431 {
3432  if (!impl)
3433  return QDomNode();
3434  return QDomNode(IMPL->namedItemNS(nsURI, localName));
3435 }
#define IMPL
Definition: qdom.cpp:6666
friend class QDomNode
Definition: qdom.h:394
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ operator!=()

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

Returns true if n and this named node map are not equal; otherwise returns false.

Definition at line 3343 of file qdom.cpp.

3344 {
3345  return (impl != n.impl);
3346 }
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ operator=()

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

Assigns n to this named node map.

Definition at line 3320 of file qdom.cpp.

3321 {
3322  if (n.impl)
3323  n.impl->ref.ref();
3324  if (impl && !impl->ref.deref())
3325  delete impl;
3326  impl = n.impl;
3327  return *this;
3328 }
bool ref()
Atomically increments the value of this QAtomicInt.
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ operator==()

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

Returns true if n and this named node map are equal; otherwise returns false.

Definition at line 3334 of file qdom.cpp.

3335 {
3336  return (impl == n.impl);
3337 }
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ removeNamedItem()

QDomNode QDomNamedNodeMap::removeNamedItem ( const QString name)

Removes the node called name from the map.

The function returns the removed node or a null node if the map did not contain a node called name.

See also
setNamedItem() namedItem() removeNamedItemNS()

Definition at line 3399 of file qdom.cpp.

3400 {
3401  if (!impl)
3402  return QDomNode();
3403  return QDomNode(IMPL->removeNamedItem(name));
3404 }
#define IMPL
Definition: qdom.cpp:6666
friend class QDomNode
Definition: qdom.h:394
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ removeNamedItemNS()

QDomNode QDomNamedNodeMap::removeNamedItemNS ( const QString nsURI,
const QString localName 
)

Removes the node with the local name localName and the namespace URI nsURI from the map.

The function returns the removed node or a null node if the map did not contain a node with the local name localName and the namespace URI nsURI.

See also
setNamedItemNS() namedItemNS() removeNamedItem()

Definition at line 3463 of file qdom.cpp.

3464 {
3465  if (!impl)
3466  return QDomNode();
3467  QDomNodePrivate *n = IMPL->namedItemNS(nsURI, localName);
3468  if (!n)
3469  return QDomNode();
3470  return QDomNode(IMPL->removeNamedItem(n->name));
3471 }
QString name
Definition: qdom.cpp:198
#define IMPL
Definition: qdom.cpp:6666
friend class QDomNode
Definition: qdom.h:394
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ setNamedItem()

QDomNode QDomNamedNodeMap::setNamedItem ( const QDomNode newNode)

Inserts the node newNode into the named node map.

The name used by the map is the node name of newNode as returned by QDomNode::nodeName().

If the new node replaces an existing node, i.e. the map contains a node with the same name, the replaced node is returned.

See also
namedItem() removeNamedItem() setNamedItemNS()

Definition at line 3383 of file qdom.cpp.

3384 {
3385  if (!impl)
3386  return QDomNode();
3387  return QDomNode(IMPL->setNamedItem((QDomNodePrivate*)newNode.impl));
3388 }
QDomNodePrivate * impl
Definition: qdom.h:243
#define IMPL
Definition: qdom.cpp:6666
friend class QDomNode
Definition: qdom.h:394
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ setNamedItemNS()

QDomNode QDomNamedNodeMap::setNamedItemNS ( const QDomNode newNode)

Inserts the node newNode in the map.

If a node with the same namespace URI and the same local name already exists in the map, it is replaced by newNode. If the new node replaces an existing node, the replaced node is returned.

See also
namedItemNS() removeNamedItemNS() setNamedItem()

Definition at line 3445 of file qdom.cpp.

3446 {
3447  if (!impl)
3448  return QDomNode();
3449  return QDomNode(IMPL->setNamedItemNS((QDomNodePrivate*)newNode.impl));
3450 }
QDomNodePrivate * impl
Definition: qdom.h:243
#define IMPL
Definition: qdom.cpp:6666
friend class QDomNode
Definition: qdom.h:394
QDomNamedNodeMapPrivate * impl
Definition: qdom.h:391

◆ size()

int QDomNamedNodeMap::size ( ) const
inline

This function is provided for Qt API consistency.

It is equivalent to length().

Definition at line 384 of file qdom.h.

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

Friends and Related Functions

◆ QDomDocumentType

friend class QDomDocumentType
friend

Definition at line 395 of file qdom.h.

◆ QDomElement

friend class QDomElement
friend

Definition at line 396 of file qdom.h.

◆ QDomNode

friend class QDomNode
friend

Definition at line 394 of file qdom.h.

Properties

◆ impl

QDomNamedNodeMapPrivate* QDomNamedNodeMap::impl
private

Definition at line 391 of file qdom.h.

Referenced by operator!=(), operator=(), operator==(), and QDomNamedNodeMap().


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