Qt 4.8
Public Functions | Public Variables | List of all members
QDomNamedNodeMapPrivate Class Reference

Public Functions

void clearMap ()
 
QDomNamedNodeMapPrivateclone (QDomNodePrivate *parent)
 
bool contains (const QString &name) const
 
bool containsNS (const QString &nsURI, const QString &localName) const
 
bool isAppendToParent ()
 
bool isReadOnly ()
 
QDomNodePrivateitem (int index) const
 
uint length () const
 
QDomNodePrivatenamedItem (const QString &name) const
 
QDomNodePrivatenamedItemNS (const QString &nsURI, const QString &localName) const
 
 QDomNamedNodeMapPrivate (QDomNodePrivate *)
 
QDomNodePrivateremoveNamedItem (const QString &name)
 
void setAppendToParent (bool b)
 
QDomNodePrivatesetNamedItem (QDomNodePrivate *arg)
 
QDomNodePrivatesetNamedItemNS (QDomNodePrivate *arg)
 
void setReadOnly (bool r)
 
 ~QDomNamedNodeMapPrivate ()
 

Public Variables

bool appendToParent
 
QHash< QString, QDomNodePrivate * > map
 
QDomNodePrivateparent
 
bool readonly
 
QAtomicInt ref
 

Detailed Description

Definition at line 235 of file qdom.cpp.

Constructors and Destructors

◆ QDomNamedNodeMapPrivate()

QDomNamedNodeMapPrivate::QDomNamedNodeMapPrivate ( QDomNodePrivate n)

Definition at line 3103 of file qdom.cpp.

3104 {
3105  ref = 1;
3106  readonly = false;
3107  parent = n;
3108  appendToParent = false;
3109 }
QDomNodePrivate * parent
Definition: qdom.cpp:278

◆ ~QDomNamedNodeMapPrivate()

QDomNamedNodeMapPrivate::~QDomNamedNodeMapPrivate ( )

Definition at line 3111 of file qdom.cpp.

3112 {
3113  clearMap();
3114 }

Functions

◆ clearMap()

void QDomNamedNodeMapPrivate::clearMap ( )

Remove all children from the map.

Definition at line 3134 of file qdom.cpp.

3135 {
3136  // Dereference all of our children if we took references
3137  if (!appendToParent) {
3139  for (; it != map.constEnd(); ++it)
3140  if (!(*it)->ref.deref())
3141  delete *it;
3142  }
3143  map.clear();
3144 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)

◆ clone()

QDomNamedNodeMapPrivate * QDomNamedNodeMapPrivate::clone ( QDomNodePrivate parent)

Creates a copy of the map. It is a deep copy that means that all children are cloned.

Definition at line 3116 of file qdom.cpp.

Referenced by QDomElementPrivate::QDomElementPrivate().

3117 {
3119  m->readonly = readonly;
3120  m->appendToParent = appendToParent;
3121 
3123  for (; it != map.constEnd(); ++it) {
3124  QDomNodePrivate *new_node = (*it)->cloneNode();
3125  new_node->setParent(p);
3126  m->setNamedItem(new_node);
3127  }
3128 
3129  // we are no longer interested in ownership
3130  m->ref.deref();
3131  return m.take();
3132 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
The QScopedPointer class stores a pointer to a dynamically allocated object, and deletes it upon dest...
virtual QDomNodePrivate * cloneNode(bool deep=true)
Definition: qdom.cpp:1905
void setParent(QDomNodePrivate *p)
Definition: qdom.cpp:162
QDomNamedNodeMapPrivate(QDomNodePrivate *)
Definition: qdom.cpp:3103

◆ contains()

bool QDomNamedNodeMapPrivate::contains ( const QString name) const

Definition at line 3233 of file qdom.cpp.

Referenced by QDomElementPrivate::hasAttribute().

3234 {
3235  return map.value(name) != 0;
3236 }

◆ containsNS()

bool QDomNamedNodeMapPrivate::containsNS ( const QString nsURI,
const QString localName 
) const

Definition at line 3238 of file qdom.cpp.

Referenced by QDomElementPrivate::hasAttributeNS().

3239 {
3240  return namedItemNS(nsURI, localName) != 0;
3241 }
QDomNodePrivate * namedItemNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3152

◆ isAppendToParent()

bool QDomNamedNodeMapPrivate::isAppendToParent ( )
inline

Definition at line 257 of file qdom.cpp.

257 { return appendToParent; }

◆ isReadOnly()

bool QDomNamedNodeMapPrivate::isReadOnly ( )
inline

Definition at line 255 of file qdom.cpp.

255 { return readonly; }

◆ item()

QDomNodePrivate * QDomNamedNodeMapPrivate::item ( int  index) const

Definition at line 3220 of file qdom.cpp.

3221 {
3222  if ((uint)index >= length())
3223  return 0;
3224  return *(map.constBegin() + index);
3225 }
unsigned int uint
Definition: qglobal.h:996
uint length() const
Definition: qdom.cpp:3228
quint16 index

◆ length()

uint QDomNamedNodeMapPrivate::length ( ) const

Definition at line 3228 of file qdom.cpp.

Referenced by QDomDocumentTypePrivate::save().

3229 {
3230  return map.count();
3231 }

◆ namedItem()

QDomNodePrivate * QDomNamedNodeMapPrivate::namedItem ( const QString name) const

◆ namedItemNS()

QDomNodePrivate * QDomNamedNodeMapPrivate::namedItemNS ( const QString nsURI,
const QString localName 
) const

Definition at line 3152 of file qdom.cpp.

Referenced by QDomElementPrivate::attributeNodeNS(), QDomElementPrivate::attributeNS(), QDomElementPrivate::setAttributeNodeNS(), and QDomElementPrivate::setAttributeNS().

3153 {
3155  QDomNodePrivate *n;
3156  for (; it != map.constEnd(); ++it) {
3157  n = *it;
3158  if (!n->prefix.isNull()) {
3159  // node has a namespace
3160  if (n->namespaceURI == nsURI && n->name == localName)
3161  return n;
3162  }
3163  }
3164  return 0;
3165 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
QString name
Definition: qdom.cpp:198
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QString namespaceURI
Definition: qdom.cpp:201
QString prefix
Definition: qdom.cpp:200

◆ removeNamedItem()

QDomNodePrivate * QDomNamedNodeMapPrivate::removeNamedItem ( const QString name)

Definition at line 3203 of file qdom.cpp.

Referenced by QDomElementPrivate::removeAttribute(), and QDomElementPrivate::removeAttributeNode().

3204 {
3205  if (readonly)
3206  return 0;
3207 
3208  QDomNodePrivate* p = namedItem(name);
3209  if (p == 0)
3210  return 0;
3211  if (appendToParent)
3212  return parent->removeChild(p);
3213 
3214  map.remove(p->nodeName());
3215  // We took a reference, so we have to free one here
3216  p->ref.deref();
3217  return p;
3218 }
QAtomicInt ref
Definition: qdom.cpp:191
QDomNodePrivate * parent
Definition: qdom.cpp:278
bool deref()
Atomically decrements the value of this QAtomicInt.
virtual QDomNodePrivate * removeChild(QDomNodePrivate *oldChild)
Definition: qdom.cpp:1851
QString nodeName() const
Definition: qdom.cpp:142
QDomNodePrivate * namedItem(const QString &name) const
Definition: qdom.cpp:3146

◆ setAppendToParent()

void QDomNamedNodeMapPrivate::setAppendToParent ( bool  b)
inline

If true, then the node will redirect insert/remove calls to its parent by calling QDomNodePrivate::appendChild or removeChild. In addition the map wont increase or decrease the reference count of the nodes it contains.

By default this value is false and the map will handle reference counting by itself.

Definition at line 267 of file qdom.cpp.

Referenced by QDomDocumentTypePrivate::init().

267 { appendToParent = b; }

◆ setNamedItem()

QDomNodePrivate * QDomNamedNodeMapPrivate::setNamedItem ( QDomNodePrivate arg)

Definition at line 3167 of file qdom.cpp.

Referenced by clone(), QDomElementPrivate::setAttribute(), QDomElementPrivate::setAttributeNode(), QDomElementPrivate::setAttributeNodeNS(), and QDomElementPrivate::setAttributeNS().

3168 {
3169  if (readonly || !arg)
3170  return 0;
3171 
3172  if (appendToParent)
3173  return parent->appendChild(arg);
3174 
3175  QDomNodePrivate *n = map.value(arg->nodeName());
3176  // We take a reference
3177  arg->ref.ref();
3178  map.insertMulti(arg->nodeName(), arg);
3179  return n;
3180 }
bool ref()
Atomically increments the value of this QAtomicInt.
virtual QDomNodePrivate * appendChild(QDomNodePrivate *newChild)
Definition: qdom.cpp:1887
QAtomicInt ref
Definition: qdom.cpp:191
QDomNodePrivate * parent
Definition: qdom.cpp:278
QString nodeName() const
Definition: qdom.cpp:142

◆ setNamedItemNS()

QDomNodePrivate * QDomNamedNodeMapPrivate::setNamedItemNS ( QDomNodePrivate arg)

Definition at line 3182 of file qdom.cpp.

3183 {
3184  if (readonly || !arg)
3185  return 0;
3186 
3187  if (appendToParent)
3188  return parent->appendChild(arg);
3189 
3190  if (!arg->prefix.isNull()) {
3191  // node has a namespace
3192  QDomNodePrivate *n = namedItemNS(arg->namespaceURI, arg->name);
3193  // We take a reference
3194  arg->ref.ref();
3195  map.insertMulti(arg->nodeName(), arg);
3196  return n;
3197  } else {
3198  // ### check the following code if it is ok
3199  return setNamedItem(arg);
3200  }
3201 }
QString name
Definition: qdom.cpp:198
bool ref()
Atomically increments the value of this QAtomicInt.
virtual QDomNodePrivate * appendChild(QDomNodePrivate *newChild)
Definition: qdom.cpp:1887
QAtomicInt ref
Definition: qdom.cpp:191
QDomNodePrivate * parent
Definition: qdom.cpp:278
QDomNodePrivate * setNamedItem(QDomNodePrivate *arg)
Definition: qdom.cpp:3167
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
QString namespaceURI
Definition: qdom.cpp:201
QDomNodePrivate * namedItemNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3152
QString nodeName() const
Definition: qdom.cpp:142
QString prefix
Definition: qdom.cpp:200

◆ setReadOnly()

void QDomNamedNodeMapPrivate::setReadOnly ( bool  r)
inline

Definition at line 256 of file qdom.cpp.

256 { readonly = r; }

Properties

◆ appendToParent

bool QDomNamedNodeMapPrivate::appendToParent

Definition at line 280 of file qdom.cpp.

Referenced by clone().

◆ map

QHash<QString, QDomNodePrivate *> QDomNamedNodeMapPrivate::map

◆ parent

QDomNodePrivate* QDomNamedNodeMapPrivate::parent

Definition at line 278 of file qdom.cpp.

◆ readonly

bool QDomNamedNodeMapPrivate::readonly

Definition at line 279 of file qdom.cpp.

Referenced by clone().

◆ ref

QAtomicInt QDomNamedNodeMapPrivate::ref

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