Qt 4.8
Public Functions | Public Variables | List of all members
QDomElementPrivate Class Reference
Inheritance diagram for QDomElementPrivate:
QDomNodePrivate

Public Functions

QString attribute (const QString &name, const QString &defValue) const
 
QDomAttrPrivateattributeNode (const QString &name)
 
QDomAttrPrivateattributeNodeNS (const QString &nsURI, const QString &localName)
 
QString attributeNS (const QString &nsURI, const QString &localName, const QString &defValue) const
 
QDomNamedNodeMapPrivateattributes ()
 
QDomNodePrivatecloneNode (bool deep=true)
 
bool hasAttribute (const QString &name)
 
bool hasAttributeNS (const QString &nsURI, const QString &localName)
 
bool hasAttributes ()
 
virtual bool isElement () const
 
QDomNode::NodeType nodeType () const
 
 QDomElementPrivate (QDomDocumentPrivate *, QDomNodePrivate *parent, const QString &name)
 
 QDomElementPrivate (QDomDocumentPrivate *, QDomNodePrivate *parent, const QString &nsURI, const QString &qName)
 
 QDomElementPrivate (QDomElementPrivate *n, bool deep)
 
void removeAttribute (const QString &name)
 
QDomAttrPrivateremoveAttributeNode (QDomAttrPrivate *oldAttr)
 
virtual void save (QTextStream &s, int, int) const
 
void setAttribute (const QString &name, const QString &value)
 
QDomAttrPrivatesetAttributeNode (QDomAttrPrivate *newAttr)
 
QDomAttrPrivatesetAttributeNodeNS (QDomAttrPrivate *newAttr)
 
void setAttributeNS (const QString &nsURI, const QString &qName, const QString &newValue)
 
QString text ()
 
 ~QDomElementPrivate ()
 
- Public Functions inherited from QDomNodePrivate
virtual QDomNodePrivateappendChild (QDomNodePrivate *newChild)
 
virtual void clear ()
 
virtual QDomNodePrivateinsertAfter (QDomNodePrivate *newChild, QDomNodePrivate *refChild)
 
virtual QDomNodePrivateinsertBefore (QDomNodePrivate *newChild, QDomNodePrivate *refChild)
 
virtual bool isAttr () const
 
virtual bool isCDATASection () const
 
virtual bool isCharacterData () const
 
virtual bool isComment () const
 
virtual bool isDocument () const
 
virtual bool isDocumentFragment () const
 
virtual bool isDocumentType () const
 
virtual bool isEntity () const
 
virtual bool isEntityReference () const
 
virtual bool isNotation () const
 
virtual bool isProcessingInstruction () const
 
virtual bool isText () const
 
QDomNodePrivatenamedItem (const QString &name)
 
QString nodeName () const
 
QString nodeValue () const
 
virtual void normalize ()
 
QDomDocumentPrivateownerDocument ()
 
QDomNodePrivateparent () const
 
 QDomNodePrivate (QDomDocumentPrivate *, QDomNodePrivate *parent=0)
 
 QDomNodePrivate (QDomNodePrivate *n, bool deep)
 
virtual QDomNodePrivateremoveChild (QDomNodePrivate *oldChild)
 
virtual QDomNodePrivatereplaceChild (QDomNodePrivate *newChild, QDomNodePrivate *oldChild)
 
void setLocation (int lineNumber, int columnNumber)
 
virtual void setNodeValue (const QString &v)
 
void setNoParent ()
 
void setOwnerDocument (QDomDocumentPrivate *doc)
 
void setParent (QDomNodePrivate *p)
 
virtual ~QDomNodePrivate ()
 

Public Variables

QDomNamedNodeMapPrivatem_attr
 
- Public Variables inherited from QDomNodePrivate
int columnNumber
 
bool createdWithDom1Interface: 1
 
QDomNodePrivatefirst
 
bool hasParent: 1
 
QDomNodePrivatelast
 
int lineNumber
 
QString name
 
QString namespaceURI
 
QDomNodePrivatenext
 
QDomNodePrivateownerNode
 
QString prefix
 
QDomNodePrivateprev
 
QAtomicInt ref
 
QString value
 

Detailed Description

Definition at line 378 of file qdom.cpp.

Constructors and Destructors

◆ QDomElementPrivate() [1/3]

QDomElementPrivate::QDomElementPrivate ( QDomDocumentPrivate d,
QDomNodePrivate parent,
const QString name 
)

Definition at line 4496 of file qdom.cpp.

Referenced by cloneNode().

4498  : QDomNodePrivate(d, p)
4499 {
4500  name = tagname;
4501  m_attr = new QDomNamedNodeMapPrivate(this);
4502 }
QDomNodePrivate(QDomDocumentPrivate *, QDomNodePrivate *parent=0)
Definition: qdom.cpp:1482
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410

◆ QDomElementPrivate() [2/3]

QDomElementPrivate::QDomElementPrivate ( QDomDocumentPrivate d,
QDomNodePrivate parent,
const QString nsURI,
const QString qName 
)

Definition at line 4504 of file qdom.cpp.

4506  : QDomNodePrivate(d, p)
4507 {
4508  qt_split_namespace(prefix, name, qName, !nsURI.isNull());
4509  namespaceURI = nsURI;
4510  createdWithDom1Interface = false;
4511  m_attr = new QDomNamedNodeMapPrivate(this);
4512 }
bool createdWithDom1Interface
Definition: qdom.cpp:202
QString name
Definition: qdom.cpp:198
static void qt_split_namespace(QString &prefix, QString &name, const QString &qName, bool hasURI)
Definition: qdom.cpp:104
QDomNodePrivate(QDomDocumentPrivate *, QDomNodePrivate *parent=0)
Definition: qdom.cpp:1482
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
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

◆ QDomElementPrivate() [3/3]

QDomElementPrivate::QDomElementPrivate ( QDomElementPrivate n,
bool  deep 
)

Definition at line 4514 of file qdom.cpp.

4514  :
4515  QDomNodePrivate(n, deep)
4516 {
4517  m_attr = n->m_attr->clone(this);
4518  // Reference is down to 0, so we set it to 1 here.
4519  m_attr->ref.ref();
4520 }
bool ref()
Atomically increments the value of this QAtomicInt.
QDomNamedNodeMapPrivate * clone(QDomNodePrivate *parent)
Definition: qdom.cpp:3116
QDomNodePrivate(QDomDocumentPrivate *, QDomNodePrivate *parent=0)
Definition: qdom.cpp:1482
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410

◆ ~QDomElementPrivate()

QDomElementPrivate::~QDomElementPrivate ( )

Definition at line 4522 of file qdom.cpp.

4523 {
4524  if (!m_attr->ref.deref())
4525  delete m_attr;
4526 }
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410

Functions

◆ attribute()

QString QDomElementPrivate::attribute ( const QString name,
const QString defValue 
) const

Definition at line 4536 of file qdom.cpp.

4537 {
4538  QDomNodePrivate* n = m_attr->namedItem(name_);
4539  if (!n)
4540  return defValue;
4541 
4542  return n->nodeValue();
4543 }
QString nodeValue() const
Definition: qdom.cpp:143
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
QDomNodePrivate * namedItem(const QString &name) const
Definition: qdom.cpp:3146

◆ attributeNode()

QDomAttrPrivate * QDomElementPrivate::attributeNode ( const QString name)

Definition at line 4596 of file qdom.cpp.

4597 {
4598  return (QDomAttrPrivate*)m_attr->namedItem(aname);
4599 }
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
QDomNodePrivate * namedItem(const QString &name) const
Definition: qdom.cpp:3146

◆ attributeNodeNS()

QDomAttrPrivate * QDomElementPrivate::attributeNodeNS ( const QString nsURI,
const QString localName 
)

Definition at line 4601 of file qdom.cpp.

4602 {
4603  return (QDomAttrPrivate*)m_attr->namedItemNS(nsURI, localName);
4604 }
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
QDomNodePrivate * namedItemNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3152

◆ attributeNS()

QString QDomElementPrivate::attributeNS ( const QString nsURI,
const QString localName,
const QString defValue 
) const

Definition at line 4545 of file qdom.cpp.

4546 {
4547  QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4548  if (!n)
4549  return defValue;
4550 
4551  return n->nodeValue();
4552 }
QString nodeValue() const
Definition: qdom.cpp:143
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
QDomNodePrivate * namedItemNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3152

◆ attributes()

QDomNamedNodeMapPrivate* QDomElementPrivate::attributes ( )
inline

Definition at line 402 of file qdom.cpp.

402 { return m_attr; }
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410

◆ cloneNode()

QDomNodePrivate * QDomElementPrivate::cloneNode ( bool  deep = true)
virtual

Reimplemented from QDomNodePrivate.

Definition at line 4528 of file qdom.cpp.

4529 {
4530  QDomNodePrivate* p = new QDomElementPrivate(this, deep);
4531  // We are not interested in this node
4532  p->ref.deref();
4533  return p;
4534 }
QAtomicInt ref
Definition: qdom.cpp:191
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomElementPrivate(QDomDocumentPrivate *, QDomNodePrivate *parent, const QString &name)
Definition: qdom.cpp:4496

◆ hasAttribute()

bool QDomElementPrivate::hasAttribute ( const QString name)

Definition at line 4635 of file qdom.cpp.

4636 {
4637  return m_attr->contains(aname);
4638 }
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
bool contains(const QString &name) const
Definition: qdom.cpp:3233

◆ hasAttributeNS()

bool QDomElementPrivate::hasAttributeNS ( const QString nsURI,
const QString localName 
)

Definition at line 4640 of file qdom.cpp.

4641 {
4642  return m_attr->containsNS(nsURI, localName);
4643 }
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
bool containsNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3238

◆ hasAttributes()

bool QDomElementPrivate::hasAttributes ( )
inline

Definition at line 403 of file qdom.cpp.

403 { return (m_attr->length() > 0); }
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
uint length() const
Definition: qdom.cpp:3228

◆ isElement()

virtual bool QDomElementPrivate::isElement ( ) const
inlinevirtual

Reimplemented from QDomNodePrivate.

Definition at line 404 of file qdom.cpp.

404 { return true; }

◆ nodeType()

QDomNode::NodeType QDomElementPrivate::nodeType ( ) const
inlinevirtual

Reimplemented from QDomNodePrivate.

Definition at line 405 of file qdom.cpp.

◆ removeAttribute()

void QDomElementPrivate::removeAttribute ( const QString name)

Definition at line 4589 of file qdom.cpp.

4590 {
4591  QDomNodePrivate* p = m_attr->removeNamedItem(aname);
4592  if (p && p->ref == 0)
4593  delete p;
4594 }
QDomNodePrivate * removeNamedItem(const QString &name)
Definition: qdom.cpp:3203
QAtomicInt ref
Definition: qdom.cpp:191
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410

◆ removeAttributeNode()

QDomAttrPrivate * QDomElementPrivate::removeAttributeNode ( QDomAttrPrivate oldAttr)

Definition at line 4630 of file qdom.cpp.

4631 {
4632  return (QDomAttrPrivate*)m_attr->removeNamedItem(oldAttr->nodeName());
4633 }
QDomNodePrivate * removeNamedItem(const QString &name)
Definition: qdom.cpp:3203
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
QString nodeName() const
Definition: qdom.cpp:142

◆ save()

void QDomElementPrivate::save ( QTextStream s,
int  depth,
int  indent 
) const
virtual
Warning
This function is not part of the public interface. depth is used for indentation, it seems.

Qt 5:

If we still have QDom, optimize this so that we only declare namespaces that are not yet declared. We loose default namespace mappings, so maybe we should rather store the information that we get from startPrefixMapping()/endPrefixMapping() and use them. Modifications becomes more complex then, however.

We cannot do this during the Qt 4 series because it would require too invasive changes, and hence possibly behavioral changes.

Reimplemented from QDomNodePrivate.

Definition at line 4661 of file qdom.cpp.

4662 {
4663  if (!(prev && prev->isText()))
4664  s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
4665 
4666  QString qName(name);
4667  QString nsDecl(QLatin1String(""));
4668  if (!namespaceURI.isNull()) {
4679  if (prefix.isEmpty()) {
4680  nsDecl = QLatin1String(" xmlns");
4681  } else {
4682  qName = prefix + QLatin1Char(':') + name;
4683  nsDecl = QLatin1String(" xmlns:") + prefix;
4684  }
4685  nsDecl += QLatin1String("=\"") + encodeText(namespaceURI, s) + QLatin1Char('\"');
4686  }
4687  s << '<' << qName << nsDecl;
4688 
4689  QSet<QString> outputtedPrefixes;
4690 
4691  /* Write out attributes. */
4692  if (!m_attr->map.isEmpty()) {
4694  for (; it != m_attr->map.constEnd(); ++it) {
4695  s << ' ';
4696  if (it.value()->namespaceURI.isNull()) {
4697  s << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
4698  } else {
4699  s << it.value()->prefix << ':' << it.value()->name << "=\"" << encodeText(it.value()->value, s, true, true) << '\"';
4700  /* This is a fix for 138243, as good as it gets.
4701  *
4702  * QDomElementPrivate::save() output a namespace declaration if
4703  * the element is in a namespace, no matter what. This function do as well, meaning
4704  * that we get two identical namespace declaration if we don't have the if-
4705  * statement below.
4706  *
4707  * This doesn't work when the parent element has the same prefix as us but
4708  * a different namespace. However, this can only occur by the user modifying the element,
4709  * and we don't do fixups by that anyway, and hence it's the user responsibility to not
4710  * arrive in those situations. */
4711  if((!it.value()->ownerNode ||
4712  it.value()->ownerNode->prefix != it.value()->prefix) &&
4713  !outputtedPrefixes.contains(it.value()->prefix)) {
4714  s << " xmlns:" << it.value()->prefix << "=\"" << encodeText(it.value()->namespaceURI, s, true, true) << '\"';
4715  outputtedPrefixes.insert(it.value()->prefix);
4716  }
4717  }
4718  }
4719  }
4720 
4721  if (last) {
4722  // has child nodes
4723  if (first->isText())
4724  s << '>';
4725  else {
4726  s << '>';
4727 
4728  /* -1 disables new lines. */
4729  if (indent != -1)
4730  s << endl;
4731  }
4732  QDomNodePrivate::save(s, depth + 1, indent); if (!last->isText())
4733  s << QString(indent < 1 ? 0 : depth * indent, QLatin1Char(' '));
4734 
4735  s << "</" << qName << '>';
4736  } else {
4737  s << "/>";
4738  }
4739  if (!(next && next->isText())) {
4740  /* -1 disables new lines. */
4741  if (indent != -1)
4742  s << endl;
4743  }
4744 }
The QHash::const_iterator class provides an STL-style const iterator for QHash and QMultiHash...
Definition: qhash.h:395
#define it(className, varName)
QDomNodePrivate * prev
Definition: qdom.cpp:192
QHash< QString, QDomNodePrivate * > map
Definition: qdom.cpp:277
virtual bool isText() const
Definition: qdom.cpp:177
QString name
Definition: qdom.cpp:198
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
bool contains(const T &value) const
Definition: qset.h:91
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
bool isEmpty() const
Returns true if the hash contains no items; otherwise returns false.
Definition: qhash.h:297
const T & value() const
Returns the current item&#39;s value.
Definition: qhash.h:420
const_iterator insert(const T &value)
Definition: qset.h:179
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
bool isNull() const
Returns true if this string is null; otherwise returns false.
Definition: qstring.h:505
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the hash.
Definition: qhash.h:466
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the hash...
Definition: qhash.h:469
QDomNodePrivate * last
Definition: qdom.cpp:196
QString namespaceURI
Definition: qdom.cpp:201
QDomNodePrivate * first
Definition: qdom.cpp:195
static QString encodeText(const QString &str, QTextStream &s, const bool encodeQuotes=true, const bool performAVN=false, const bool encodeEOLs=false)
Definition: qdom.cpp:4245
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55
QString prefix
Definition: qdom.cpp:200

◆ setAttribute()

void QDomElementPrivate::setAttribute ( const QString name,
const QString value 
)

Definition at line 4554 of file qdom.cpp.

4555 {
4556  QDomNodePrivate* n = m_attr->namedItem(aname);
4557  if (!n) {
4558  n = new QDomAttrPrivate(ownerDocument(), this, aname);
4559  n->setNodeValue(newValue);
4560 
4561  // Referencing is done by the map, so we set the reference counter back
4562  // to 0 here. This is ok since we created the QDomAttrPrivate.
4563  n->ref.deref();
4564  m_attr->setNamedItem(n);
4565  } else {
4566  n->setNodeValue(newValue);
4567  }
4568 }
QDomDocumentPrivate * ownerDocument()
Definition: qdom.cpp:1893
QAtomicInt ref
Definition: qdom.cpp:191
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomNodePrivate * setNamedItem(QDomNodePrivate *arg)
Definition: qdom.cpp:3167
virtual void setNodeValue(const QString &v)
Definition: qdom.cpp:144
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
QDomNodePrivate * namedItem(const QString &name) const
Definition: qdom.cpp:3146

◆ setAttributeNode()

QDomAttrPrivate * QDomElementPrivate::setAttributeNode ( QDomAttrPrivate newAttr)

Definition at line 4606 of file qdom.cpp.

4607 {
4608  QDomNodePrivate* n = m_attr->namedItem(newAttr->nodeName());
4609 
4610  // Referencing is done by the maps
4611  m_attr->setNamedItem(newAttr);
4612 
4613  newAttr->setParent(this);
4614 
4615  return (QDomAttrPrivate*)n;
4616 }
QDomNodePrivate * setNamedItem(QDomNodePrivate *arg)
Definition: qdom.cpp:3167
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
void setParent(QDomNodePrivate *p)
Definition: qdom.cpp:162
QString nodeName() const
Definition: qdom.cpp:142
QDomNodePrivate * namedItem(const QString &name) const
Definition: qdom.cpp:3146

◆ setAttributeNodeNS()

QDomAttrPrivate * QDomElementPrivate::setAttributeNodeNS ( QDomAttrPrivate newAttr)

Definition at line 4618 of file qdom.cpp.

4619 {
4620  QDomNodePrivate* n = 0;
4621  if (!newAttr->prefix.isNull())
4622  n = m_attr->namedItemNS(newAttr->namespaceURI, newAttr->name);
4623 
4624  // Referencing is done by the maps
4625  m_attr->setNamedItem(newAttr);
4626 
4627  return (QDomAttrPrivate*)n;
4628 }
QString name
Definition: qdom.cpp:198
QDomNodePrivate * setNamedItem(QDomNodePrivate *arg)
Definition: qdom.cpp:3167
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
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 prefix
Definition: qdom.cpp:200

◆ setAttributeNS()

void QDomElementPrivate::setAttributeNS ( const QString nsURI,
const QString qName,
const QString newValue 
)

Definition at line 4570 of file qdom.cpp.

4571 {
4572  QString prefix, localName;
4573  qt_split_namespace(prefix, localName, qName, true);
4574  QDomNodePrivate* n = m_attr->namedItemNS(nsURI, localName);
4575  if (!n) {
4576  n = new QDomAttrPrivate(ownerDocument(), this, nsURI, qName);
4577  n->setNodeValue(newValue);
4578 
4579  // Referencing is done by the map, so we set the reference counter back
4580  // to 0 here. This is ok since we created the QDomAttrPrivate.
4581  n->ref.deref();
4582  m_attr->setNamedItem(n);
4583  } else {
4584  n->setNodeValue(newValue);
4585  n->prefix = prefix;
4586  }
4587 }
QDomDocumentPrivate * ownerDocument()
Definition: qdom.cpp:1893
The QString class provides a Unicode character string.
Definition: qstring.h:83
QAtomicInt ref
Definition: qdom.cpp:191
static void qt_split_namespace(QString &prefix, QString &name, const QString &qName, bool hasURI)
Definition: qdom.cpp:104
bool deref()
Atomically decrements the value of this QAtomicInt.
QDomNodePrivate * setNamedItem(QDomNodePrivate *arg)
Definition: qdom.cpp:3167
virtual void setNodeValue(const QString &v)
Definition: qdom.cpp:144
QDomNamedNodeMapPrivate * m_attr
Definition: qdom.cpp:410
QDomNodePrivate * namedItemNS(const QString &nsURI, const QString &localName) const
Definition: qdom.cpp:3152
QString prefix
Definition: qdom.cpp:200

◆ text()

QString QDomElementPrivate::text ( )

Definition at line 4645 of file qdom.cpp.

4646 {
4647  QString t(QLatin1String(""));
4648 
4649  QDomNodePrivate* p = first;
4650  while (p) {
4651  if (p->isText() || p->isCDATASection())
4652  t += p->nodeValue();
4653  else if (p->isElement())
4654  t += ((QDomElementPrivate*)p)->text();
4655  p = p->next;
4656  }
4657 
4658  return t;
4659 }
QString text()
Definition: qdom.cpp:4645
virtual bool isText() const
Definition: qdom.cpp:177
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual bool isElement() const
Definition: qdom.cpp:175
QString nodeValue() const
Definition: qdom.cpp:143
virtual bool isCDATASection() const
Definition: qdom.cpp:171
QDomNodePrivate * next
Definition: qdom.cpp:193
QDomNodePrivate * first
Definition: qdom.cpp:195

Properties

◆ m_attr

QDomNamedNodeMapPrivate* QDomElementPrivate::m_attr

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