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

The QXmlStreamAttribute class represents a single XML attribute. More...

#include <qxmlstream.h>

Public Functions

bool isDefault () const
 Returns true if the parser added this attribute with a default value following an ATTLIST declaration in the DTD; otherwise returns false. More...
 
QStringRef name () const
 Returns the attribute's local name. More...
 
QStringRef namespaceUri () const
 Returns the attribute's resolved namespaceUri, or an empty string reference if the attribute does not have a defined namespace. More...
 
bool operator!= (const QXmlStreamAttribute &other) const
 Compares this attribute with other and returns true if they are not equal; otherwise returns false. More...
 
QXmlStreamAttributeoperator= (const QXmlStreamAttribute &)
 Assigns other to this attribute. More...
 
bool operator== (const QXmlStreamAttribute &other) const
 Compares this attribute with other and returns true if they are equal; otherwise returns false. More...
 
QStringRef prefix () const
 Returns the attribute's namespace prefix. More...
 
QStringRef qualifiedName () const
 Returns the attribute's qualified name. More...
 
 QXmlStreamAttribute ()
 Creates an empty attribute. More...
 
 QXmlStreamAttribute (const QString &qualifiedName, const QString &value)
 Constructs an attribute with qualified name qualifiedName and value value. More...
 
 QXmlStreamAttribute (const QString &namespaceUri, const QString &name, const QString &value)
 Constructs an attribute in the namespace described with namespaceUri with name and value value. More...
 
 QXmlStreamAttribute (const QXmlStreamAttribute &)
 Creates a copy of other. More...
 
QStringRef value () const
 Returns the attribute's value. More...
 
 ~QXmlStreamAttribute ()
 Destructs an attribute. More...
 

Properties

uint m_isDefault: 1
 
QXmlStreamStringRef m_name
 
QXmlStreamStringRef m_namespaceUri
 
QXmlStreamStringRef m_qualifiedName
 
QXmlStreamStringRef m_value
 
void * reserved
 

Friends

class QXmlStreamAttributes
 
class QXmlStreamReaderPrivate
 

Detailed Description

The QXmlStreamAttribute class represents a single XML attribute.

Since
4.3
Note
This class or function is reentrant.

An attribute consists of an optionally empty namespaceUri(), a name(), a value(), and an isDefault() attribute.

The raw XML attribute name is returned as qualifiedName().

Definition at line 135 of file qxmlstream.h.

Constructors and Destructors

◆ QXmlStreamAttribute() [1/4]

QXmlStreamAttribute::QXmlStreamAttribute ( )

Creates an empty attribute.

Definition at line 2345 of file qxmlstream.cpp.

2346 {
2347  m_isDefault = false;
2348 }

◆ QXmlStreamAttribute() [2/4]

QXmlStreamAttribute::QXmlStreamAttribute ( const QString qualifiedName,
const QString value 
)

Constructs an attribute with qualified name qualifiedName and value value.

Definition at line 2371 of file qxmlstream.cpp.

2372 {
2373  int colon = qualifiedName.indexOf(QLatin1Char(':'));
2374  m_name = QXmlStreamStringRef(QStringRef(&qualifiedName,
2375  colon + 1,
2376  qualifiedName.size() - (colon + 1)));
2377  m_qualifiedName = QXmlStreamStringRef(QStringRef(&qualifiedName));
2379 }
QXmlStreamStringRef m_value
Definition: qxmlstream.h:136
QXmlStreamStringRef m_name
Definition: qxmlstream.h:136
int size() const
Returns the number of characters in this string.
Definition: qstring.h:102
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.cpp:2838
QXmlStreamStringRef m_qualifiedName
Definition: qxmlstream.h:136
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ QXmlStreamAttribute() [3/4]

QXmlStreamAttribute::QXmlStreamAttribute ( const QString namespaceUri,
const QString name,
const QString value 
)

Constructs an attribute in the namespace described with namespaceUri with name and value value.

Definition at line 2360 of file qxmlstream.cpp.

2361 {
2362  m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri));
2365  m_namespaceUri = QXmlStreamStringRef(QStringRef(&namespaceUri));
2366 }
QXmlStreamStringRef m_namespaceUri
Definition: qxmlstream.h:136
QXmlStreamStringRef m_value
Definition: qxmlstream.h:136
QXmlStreamStringRef m_name
Definition: qxmlstream.h:136
QXmlStreamStringRef m_qualifiedName
Definition: qxmlstream.h:136
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099

◆ QXmlStreamAttribute() [4/4]

QXmlStreamAttribute::QXmlStreamAttribute ( const QXmlStreamAttribute other)

Creates a copy of other.

Definition at line 2458 of file qxmlstream.cpp.

2459 {
2460  *this = other;
2461 }

◆ ~QXmlStreamAttribute()

QXmlStreamAttribute::~QXmlStreamAttribute ( )

Destructs an attribute.

Definition at line 2353 of file qxmlstream.cpp.

2354 {
2355 }

Functions

◆ isDefault()

bool QXmlStreamAttribute::isDefault ( ) const
inline

Returns true if the parser added this attribute with a default value following an ATTLIST declaration in the DTD; otherwise returns false.

Definition at line 157 of file qxmlstream.h.

157 { return m_isDefault; }

◆ name()

QStringRef QXmlStreamAttribute::name ( ) const
inline

◆ namespaceUri()

QStringRef QXmlStreamAttribute::namespaceUri ( ) const
inline

◆ operator!=()

bool QXmlStreamAttribute::operator!= ( const QXmlStreamAttribute other) const
inline

Compares this attribute with other and returns true if they are not equal; otherwise returns false.

Definition at line 163 of file qxmlstream.h.

164  { return !operator==(other); }
bool operator==(const QXmlStreamAttribute &other) const
Compares this attribute with other and returns true if they are equal; otherwise returns false...
Definition: qxmlstream.h:158

◆ operator=()

QXmlStreamAttribute & QXmlStreamAttribute::operator= ( const QXmlStreamAttribute other)

Assigns other to this attribute.

Definition at line 2466 of file qxmlstream.cpp.

2467 {
2468  m_name = other.m_name;
2471  m_value = other.m_value;
2472  m_isDefault = other.m_isDefault;
2473  return *this;
2474 }
QXmlStreamStringRef m_namespaceUri
Definition: qxmlstream.h:136
QXmlStreamStringRef m_value
Definition: qxmlstream.h:136
QXmlStreamStringRef m_name
Definition: qxmlstream.h:136
QXmlStreamStringRef m_qualifiedName
Definition: qxmlstream.h:136

◆ operator==()

bool QXmlStreamAttribute::operator== ( const QXmlStreamAttribute other) const
inline

Compares this attribute with other and returns true if they are equal; otherwise returns false.

Definition at line 158 of file qxmlstream.h.

158  {
159  return (value() == other.value()
160  && (namespaceUri().isNull() ? (qualifiedName() == other.qualifiedName())
161  : (namespaceUri() == other.namespaceUri() && name() == other.name())));
162  }
QStringRef value() const
Returns the attribute&#39;s value.
Definition: qxmlstream.h:156
QStringRef qualifiedName() const
Returns the attribute&#39;s qualified name.
Definition: qxmlstream.h:150
QStringRef name() const
Returns the attribute&#39;s local name.
Definition: qxmlstream.h:149
bool isNull() const
Returns true if string() returns a null pointer or a pointer to a null string; otherwise returns true...
Definition: qstring.h:1170
QStringRef namespaceUri() const
Returns the attribute&#39;s resolved namespaceUri, or an empty string reference if the attribute does not...
Definition: qxmlstream.h:148

◆ prefix()

QStringRef QXmlStreamAttribute::prefix ( ) const
inline

Returns the attribute's namespace prefix.

Since
4.4
See also
name(), qualifiedName()

Definition at line 151 of file qxmlstream.h.

Referenced by QPatternist::XSLTTokenizer::insideSequenceConstructor(), and QPatternist::AccelTreeResourceLoader::streamToReceiver().

151  {
154  qMax(0, m_qualifiedName.size() - m_name.size() - 1));
155  }
int position() const
Definition: qxmlstream.h:128
const QString * string() const
Definition: qxmlstream.h:127
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
QXmlStreamStringRef m_name
Definition: qxmlstream.h:136
QXmlStreamStringRef m_qualifiedName
Definition: qxmlstream.h:136
int size() const
Definition: qxmlstream.h:129
The QStringRef class provides a thin wrapper around QString substrings.
Definition: qstring.h:1099

◆ qualifiedName()

QStringRef QXmlStreamAttribute::qualifiedName ( ) const
inline

Returns the attribute's qualified name.

A qualified name is the raw name of an attribute in the XML data. It consists of the namespace prefix(), followed by colon, followed by the attribute's local name(). Since the namespace prefix is not unique (the same prefix can point to different namespaces and different prefixes can point to the same namespace), you shouldn't use qualifiedName(), but the resolved namespaceUri() and the attribute's local name().

Definition at line 150 of file qxmlstream.h.

Referenced by QPatternist::XSLTTokenizer::handleStandardAttributes(), QPatternist::XSLTTokenizer::insideSequenceConstructor(), operator==(), parseCoreNode(), QSvgAttributes::QSvgAttributes(), QXmlStreamReaderPrivate::resolveTag(), QXmlStreamAttributes::value(), and QXmlStreamWriter::writeAttribute().

150 { return m_qualifiedName; }
QXmlStreamStringRef m_qualifiedName
Definition: qxmlstream.h:136

◆ value()

QStringRef QXmlStreamAttribute::value ( ) const
inline

Friends and Related Functions

◆ QXmlStreamAttributes

friend class QXmlStreamAttributes
friend

Definition at line 140 of file qxmlstream.h.

◆ QXmlStreamReaderPrivate

Definition at line 139 of file qxmlstream.h.

Properties

◆ m_isDefault

uint QXmlStreamAttribute::m_isDefault
private

Definition at line 138 of file qxmlstream.h.

Referenced by operator=(), and QXmlStreamReaderPrivate::resolveTag().

◆ m_name

QXmlStreamStringRef QXmlStreamAttribute::m_name
private

Definition at line 136 of file qxmlstream.h.

Referenced by operator=(), and QXmlStreamReaderPrivate::resolveTag().

◆ m_namespaceUri

QXmlStreamStringRef QXmlStreamAttribute::m_namespaceUri
private

Definition at line 136 of file qxmlstream.h.

Referenced by operator=(), and QXmlStreamReaderPrivate::resolveTag().

◆ m_qualifiedName

QXmlStreamStringRef QXmlStreamAttribute::m_qualifiedName
private

Definition at line 136 of file qxmlstream.h.

Referenced by operator=(), and QXmlStreamReaderPrivate::resolveTag().

◆ m_value

QXmlStreamStringRef QXmlStreamAttribute::m_value
private

Definition at line 136 of file qxmlstream.h.

Referenced by operator=(), and QXmlStreamReaderPrivate::resolveTag().

◆ reserved

void* QXmlStreamAttribute::reserved
private

Definition at line 137 of file qxmlstream.h.


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