Qt 4.8
Classes | Public Functions | Private Types | Properties | List of all members
QXmlAttributes Class Reference

The QXmlAttributes class provides XML attributes. More...

#include <qxml.h>

Classes

struct  Attribute
 

Public Functions

void append (const QString &qName, const QString &uri, const QString &localPart, const QString &value)
 Appends a new attribute entry to the list of attributes. More...
 
void clear ()
 Clears the list of attributes. More...
 
int count () const
 Returns the number of attributes in the list. More...
 
int index (const QString &qName) const
 Looks up the index of an attribute by the qualified name qName. More...
 
int index (const QLatin1String &qName) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
int index (const QString &uri, const QString &localPart) const
 Looks up the index of an attribute by a namespace name. More...
 
int length () const
 Returns the number of attributes in the list. More...
 
QString localName (int index) const
 Looks up an attribute's local name for the attribute at position index. More...
 
QString qName (int index) const
 Looks up an attribute's XML 1.0 qualified name for the attribute at position index. More...
 
 QXmlAttributes ()
 Constructs an empty attribute list. More...
 
QString type (int index) const
 Looks up an attribute's type for the attribute at position index. More...
 
QString type (const QString &qName) const
 Looks up an attribute's type for the qualified name qName. More...
 
QString type (const QString &uri, const QString &localName) const
 Looks up an attribute's type by namespace name. More...
 
QString uri (int index) const
 Looks up an attribute's namespace URI for the attribute at position index. More...
 
QString value (int index) const
 Returns an attribute's value for the attribute at position index. More...
 
QString value (const QString &qName) const
 Returns an attribute's value for the qualified name qName, or an empty string if no attribute exists for the name given. More...
 
QString value (const QLatin1String &qName) const
 Returns an attribute's value for the qualified name qName, or an empty string if no attribute exists for the name given. More...
 
QString value (const QString &uri, const QString &localName) const
 Returns an attribute's value by namespace name. More...
 
virtual ~QXmlAttributes ()
 Destroys the attributes object. More...
 

Private Types

typedef QList< AttributeAttributeList
 

Properties

AttributeList attList
 
QXmlAttributesPrivated
 

Detailed Description

The QXmlAttributes class provides XML attributes.

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

If attributes are reported by QXmlContentHandler::startElement() this class is used to pass the attribute values.

Use index() to locate the position of an attribute in the list, count() to retrieve the number of attributes, and clear() to remove the attributes. New attributes can be added with append(). Use type() to get an attribute's type and value() to get its value. The attribute's name is available from localName() or qName(), and its namespace URI from uri().

Definition at line 119 of file qxml.h.

Typedefs

◆ AttributeList

Definition at line 148 of file qxml.h.

Constructors and Destructors

◆ QXmlAttributes()

QXmlAttributes::QXmlAttributes ( )
inline

Constructs an empty attribute list.

Definition at line 122 of file qxml.h.

122 {}

◆ ~QXmlAttributes()

QXmlAttributes::~QXmlAttributes ( )
inlinevirtual

Destroys the attributes object.

Definition at line 123 of file qxml.h.

123 {}

Functions

◆ append()

void QXmlAttributes::append ( const QString qName,
const QString uri,
const QString localPart,
const QString value 
)

Appends a new attribute entry to the list of attributes.

The qualified name of the attribute is qName, the namespace URI is uri and the local name is localPart. The value of the attribute is value.

See also
qName() uri() localName() value()

Definition at line 1273 of file qxml.cpp.

Referenced by append(), and QXmlSimpleReaderPrivate::processElementAttribute().

1274 {
1275  Attribute att;
1276  att.qname = qName;
1277  att.uri = uri;
1278  att.localname = localPart;
1279  att.value = value;
1280 
1281  attList.append(att);
1282 }
QString value(int index) const
Returns an attribute&#39;s value for the attribute at position index.
Definition: qxml.cpp:1192
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
AttributeList attList
Definition: qxml.h:149
QString uri(int index) const
Looks up an attribute&#39;s namespace URI for the attribute at position index.
Definition: qxml.cpp:1137
QString qName(int index) const
Looks up an attribute&#39;s XML 1.0 qualified name for the attribute at position index.
Definition: qxml.cpp:1125

◆ clear()

void QXmlAttributes::clear ( void  )

Clears the list of attributes.

See also
append()

Definition at line 1260 of file qxml.cpp.

Referenced by clear(), and QXmlSimpleReaderPrivate::parseElement().

1261 {
1262  attList.clear();
1263 }
AttributeList attList
Definition: qxml.h:149
void clear()
Removes all items from the list.
Definition: qlist.h:764

◆ count()

int QXmlAttributes::count ( ) const
inline

Returns the number of attributes in the list.

This function is equivalent to length().

Definition at line 420 of file qxml.h.

Referenced by length().

421 { return length(); }
int length() const
Returns the number of attributes in the list.
Definition: qxml.cpp:1092

◆ index() [1/3]

int QXmlAttributes::index ( const QString qName) const

Looks up the index of an attribute by the qualified name qName.

Returns the index of the attribute or -1 if it wasn't found.

See also
{Namespace Support via Features}

Definition at line 1041 of file qxml.cpp.

1042 {
1043  for (int i = 0; i < attList.size(); ++i) {
1044  if (attList.at(i).qname == qName)
1045  return i;
1046  }
1047  return -1;
1048 }
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QString qName(int index) const
Looks up an attribute&#39;s XML 1.0 qualified name for the attribute at position index.
Definition: qxml.cpp:1125

◆ index() [2/3]

int QXmlAttributes::index ( const QLatin1String qName) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 1052 of file qxml.cpp.

1053 {
1054  for (int i = 0; i < attList.size(); ++i) {
1055  if (attList.at(i).qname == qName)
1056  return i;
1057  }
1058  return -1;
1059 }
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
QString qName(int index) const
Looks up an attribute&#39;s XML 1.0 qualified name for the attribute at position index.
Definition: qxml.cpp:1125

◆ index() [3/3]

int QXmlAttributes::index ( const QString uri,
const QString localPart 
) const

Looks up the index of an attribute by a namespace name.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

uri specifies the namespace URI, or an empty string if the name has no namespace URI. localPart specifies the attribute's local name.

Returns the index of the attribute, or -1 if it wasn't found.

See also
{Namespace Support via Features}

Definition at line 1077 of file qxml.cpp.

1078 {
1079  for (int i = 0; i < attList.size(); ++i) {
1080  const Attribute &att = attList.at(i);
1081  if (att.uri == uri && att.localname == localPart)
1082  return i;
1083  }
1084  return -1;
1085 }
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149
int size() const
Returns the number of items in the list.
Definition: qlist.h:137

◆ length()

int QXmlAttributes::length ( ) const

Returns the number of attributes in the list.

See also
count()

Definition at line 1092 of file qxml.cpp.

Referenced by QDomHandler::startElement().

1093 {
1094  return attList.count();
1095 }
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
AttributeList attList
Definition: qxml.h:149

◆ localName()

QString QXmlAttributes::localName ( int  index) const

Looks up an attribute's local name for the attribute at position index.

If no namespace processing is done, the local name is an empty string.

See also
{Namespace Support via Features}

Definition at line 1114 of file qxml.cpp.

1115 {
1116  return attList.at(index).localname;
1117 }
int index(const QString &qName) const
Looks up the index of an attribute by the qualified name qName.
Definition: qxml.cpp:1041
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149

◆ qName()

QString QXmlAttributes::qName ( int  index) const

Looks up an attribute's XML 1.0 qualified name for the attribute at position index.

See also
{Namespace Support via Features}

Definition at line 1125 of file qxml.cpp.

Referenced by QDomHandler::startElement().

1126 {
1127  return attList.at(index).qname;
1128 }
int index(const QString &qName) const
Looks up the index of an attribute by the qualified name qName.
Definition: qxml.cpp:1041
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149

◆ type() [1/3]

QString QXmlAttributes::type ( int  index) const

Looks up an attribute's type for the attribute at position index.

Currently only "CDATA" is returned.

Definition at line 1148 of file qxml.cpp.

1149 {
1150  return QLatin1String("CDATA");
1151 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ type() [2/3]

QString QXmlAttributes::type ( const QString qName) const

Looks up an attribute's type for the qualified name qName.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Currently only "CDATA" is returned.

Definition at line 1163 of file qxml.cpp.

1164 {
1165  return QLatin1String("CDATA");
1166 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ type() [3/3]

QString QXmlAttributes::type ( const QString uri,
const QString localName 
) const

Looks up an attribute's type by namespace name.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

uri specifies the namespace URI and localName specifies the local name. If the name has no namespace URI, use an empty string for uri.

Currently only "CDATA" is returned.

Definition at line 1182 of file qxml.cpp.

1183 {
1184  return QLatin1String("CDATA");
1185 }
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString

◆ uri()

QString QXmlAttributes::uri ( int  index) const

Looks up an attribute's namespace URI for the attribute at position index.

If no namespace processing is done or if the attribute has no namespace, the namespace URI is an empty string.

See also
{Namespace Support via Features}

Definition at line 1137 of file qxml.cpp.

Referenced by QDomHandler::startElement(), and uri().

1138 {
1139  return attList.at(index).uri;
1140 }
int index(const QString &qName) const
Looks up the index of an attribute by the qualified name qName.
Definition: qxml.cpp:1041
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149

◆ value() [1/4]

QString QXmlAttributes::value ( int  index) const

Returns an attribute's value for the attribute at position index.

The index must be a valid position (i.e., 0 <= index < count()).

Definition at line 1192 of file qxml.cpp.

Referenced by QDomHandler::startElement(), and value().

1193 {
1194  return attList.at(index).value;
1195 }
int index(const QString &qName) const
Looks up the index of an attribute by the qualified name qName.
Definition: qxml.cpp:1041
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149

◆ value() [2/4]

QString QXmlAttributes::value ( const QString qName) const

Returns an attribute's value for the qualified name qName, or an empty string if no attribute exists for the name given.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
{Namespace Support via Features}

Definition at line 1208 of file qxml.cpp.

1209 {
1210  int i = index(qName);
1211  if (i == -1)
1212  return QString();
1213  return attList.at(i).value;
1214 }
int index(const QString &qName) const
Looks up the index of an attribute by the qualified name qName.
Definition: qxml.cpp:1041
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149

◆ value() [3/4]

QString QXmlAttributes::value ( const QLatin1String qName) const

Returns an attribute's value for the qualified name qName, or an empty string if no attribute exists for the name given.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

See also
{Namespace Support via Features}

Definition at line 1227 of file qxml.cpp.

1228 {
1229  int i = index(qName);
1230  if (i == -1)
1231  return QString();
1232  return attList.at(i).value;
1233 }
int index(const QString &qName) const
Looks up the index of an attribute by the qualified name qName.
Definition: qxml.cpp:1041
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149

◆ value() [4/4]

QString QXmlAttributes::value ( const QString uri,
const QString localName 
) const

Returns an attribute's value by namespace name.

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

uri specifies the namespace URI, or an empty string if the name has no namespace URI. localName specifies the attribute's local name.

Definition at line 1247 of file qxml.cpp.

1248 {
1249  int i = index(uri, localName);
1250  if (i == -1)
1251  return QString();
1252  return attList.at(i).value;
1253 }
int index(const QString &qName) const
Looks up the index of an attribute by the qualified name qName.
Definition: qxml.cpp:1041
The QString class provides a Unicode character string.
Definition: qstring.h:83
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
AttributeList attList
Definition: qxml.h:149

Properties

◆ attList

AttributeList QXmlAttributes::attList
private

Definition at line 149 of file qxml.h.

◆ d

QXmlAttributesPrivate* QXmlAttributes::d
private

Definition at line 151 of file qxml.h.


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