Qt 4.8
Public Functions | List of all members
QSimpleXmlNodeModel Class Reference

The QSimpleXmlNodeModel class is an implementation of QAbstractXmlNodeModel sufficient for many common cases. More...

#include <qsimplexmlnodemodel.h>

Inheritance diagram for QSimpleXmlNodeModel:
QAbstractXmlNodeModel QSharedData

Public Functions

virtual QUrl baseUri (const QXmlNodeModelIndex &node) const
 Returns the base URI for node. More...
 
virtual QXmlNodeModelIndex elementById (const QXmlName &id) const
 Always returns a default constructed QXmlNodeModelIndex instance, regardless of id. More...
 
QXmlNamePoolnamePool () const
 Returns the name pool associated with this model. More...
 
virtual QVector< QXmlNamenamespaceBindings (const QXmlNodeModelIndex &) const
 Always returns an empty QVector. More...
 
virtual QVector< QXmlNodeModelIndexnodesByIdref (const QXmlName &idref) const
 Always returns an empty vector, regardless of idref. More...
 
 QSimpleXmlNodeModel (const QXmlNamePool &namePool)
 Constructs a QSimpleXmlNodeModel for use with with the specified namePool. More...
 
virtual QString stringValue (const QXmlNodeModelIndex &node) const
 If node is an element or attribute, typedValue() is called, and the return value converted to a string, as per XQuery's rules. More...
 
virtual ~QSimpleXmlNodeModel ()
 Destructor. More...
 
- Public Functions inherited from QAbstractXmlNodeModel
virtual QXmlNodeModelIndex::DocumentOrder compareOrder (const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const =0
 This function returns the relative document order for the nodes indexed by ni1 and ni2. More...
 
virtual void copyNodeTo (const QXmlNodeModelIndex &node, QAbstractXmlReceiver *const receiver, const NodeCopySettings &) const
 
virtual QUrl documentUri (const QXmlNodeModelIndex &ni) const =0
 Returns the document URI of n. More...
 
virtual bool isDeepEqual (const QXmlNodeModelIndex &ni1, const QXmlNodeModelIndex &ni2) const
 Determines whether ni1 is deep equal to ni2. More...
 
virtual QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > iterate (const QXmlNodeModelIndex &ni, QXmlNodeModelIndex::Axis axis) const
 Performs navigation, starting from ni, by returning an QAbstractXmlForwardIterator that returns nodes the axis emanating from ni. More...
 
virtual QXmlNodeModelIndex::NodeKind kind (const QXmlNodeModelIndex &ni) const =0
 Returns a value indicating the kind of node identified by ni. More...
 
virtual QXmlName name (const QXmlNodeModelIndex &ni) const =0
 Returns the name of ni. More...
 
virtual QXmlName::NamespaceCode namespaceForPrefix (const QXmlNodeModelIndex &ni, const QXmlName::PrefixCode prefix) const
 Returns the namespace URI on ni that corresponds to prefix. More...
 
 QAbstractXmlNodeModel ()
 Default constructor. More...
 
virtual QXmlNodeModelIndex root (const QXmlNodeModelIndex &n) const =0
 Returns the root node of the tree that contains the node whose index is n. More...
 
virtual void sendNamespaces (const QXmlNodeModelIndex &n, QAbstractXmlReceiver *const receiver) const
 Sends the namespaces declared on n to receiver. More...
 
virtual QPatternist::ItemIteratorPtr sequencedTypedValue (const QXmlNodeModelIndex &ni) const
 
QSourceLocation sourceLocation (const QXmlNodeModelIndex &index) const
 Returns the source location for the object with the given index or a default constructed QSourceLocation in case no location information is available. More...
 
virtual QPatternist::ItemTypePtr type (const QXmlNodeModelIndex &ni) const
 
virtual QVariant typedValue (const QXmlNodeModelIndex &n) const =0
 Returns the typed value for node node. More...
 
virtual ~QAbstractXmlNodeModel ()
 Destructor. More...
 
- Public Functions inherited from QSharedData
 QSharedData ()
 Constructs a QSharedData object with a reference count of 0. More...
 
 QSharedData (const QSharedData &)
 Constructs a QSharedData object with reference count 0. More...
 

Additional Inherited Members

- Public Types inherited from QAbstractXmlNodeModel
typedef QList< PtrList
 A list of smart pointers to instances of QAbstractXmlNodeModel. More...
 
enum  NodeCopySetting { InheritNamespaces = 0x1, PreserveNamespaces = 0x2 }
 
typedef QFlags< NodeCopySettingNodeCopySettings
 
typedef QExplicitlySharedDataPointer< QAbstractXmlNodeModelPtr
 A QExplicitlySharedDataPointer {smart pointer} to an instance of QAbstractXmlNodeModel. More...
 
enum  SimpleAxis { Parent, FirstChild, PreviousSibling, NextSibling }
 Four axes that each contain one node only. More...
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QAbstractXmlNodeModel
virtual QVector< QXmlNodeModelIndexattributes (const QXmlNodeModelIndex &element) const =0
 Returns the attributes of element. More...
 
QXmlNodeModelIndex createIndex (qint64 data) const
 Creates a node index with data as its internal data. More...
 
QXmlNodeModelIndex createIndex (void *pointer, qint64 additionalData=0) const
 Creates a node index with pointer and additionalData as its internal data. More...
 
QXmlNodeModelIndex createIndex (qint64 data, qint64 additionalData) const
 Creates a QXmlNodeModelIndex containing data and additionalData. More...
 
virtual QXmlNodeModelIndex nextFromSimpleAxis (SimpleAxis axis, const QXmlNodeModelIndex &origin) const =0
 When QtXmlPatterns evaluate path expressions, it emulate them through a combination of calls with QSimpleXmlNodeModel::SimpleAxis values. More...
 
 QAbstractXmlNodeModel (QAbstractXmlNodeModelPrivate *d)
 
- Protected Variables inherited from QAbstractXmlNodeModel
QScopedPointer< QAbstractXmlNodeModelPrivated_ptr
 

Detailed Description

The QSimpleXmlNodeModel class is an implementation of QAbstractXmlNodeModel sufficient for many common cases.

Note
This class or function is reentrant.
Since
4.4

Subclassing QAbstractXmlNodeModel can be a significant task, because it requires implementing several, complex member functions. QSimpleXmlNodeModel provides default implementations of these member functions that are suitable for a wide range of node models.

Subclasses of QSimpleXmlNodeModel must be thread-safe.

Definition at line 56 of file qsimplexmlnodemodel.h.

Constructors and Destructors

◆ QSimpleXmlNodeModel()

QSimpleXmlNodeModel::QSimpleXmlNodeModel ( const QXmlNamePool namePool)

Constructs a QSimpleXmlNodeModel for use with with the specified namePool.

Definition at line 89 of file qsimplexmlnodemodel.cpp.

◆ ~QSimpleXmlNodeModel()

QSimpleXmlNodeModel::~QSimpleXmlNodeModel ( )
virtual

Destructor.

Definition at line 97 of file qsimplexmlnodemodel.cpp.

98 {
99 }

Functions

◆ baseUri()

QUrl QSimpleXmlNodeModel::baseUri ( const QXmlNodeModelIndex node) const
virtual

Returns the base URI for node.

This is always the document URI.

See also
documentUri()

Implements QAbstractXmlNodeModel.

Definition at line 134 of file qsimplexmlnodemodel.cpp.

135 {
136  return documentUri(node);
137 }
virtual QUrl documentUri(const QXmlNodeModelIndex &ni) const =0
Returns the document URI of n.

◆ elementById()

QXmlNodeModelIndex QSimpleXmlNodeModel::elementById ( const QXmlName id) const
virtual

Always returns a default constructed QXmlNodeModelIndex instance, regardless of id.

This effectively means the model has no elements that have an id.

Implements QAbstractXmlNodeModel.

Definition at line 167 of file qsimplexmlnodemodel.cpp.

168 {
169  Q_UNUSED(id);
170  return QXmlNodeModelIndex();
171 }
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ namePool()

QXmlNamePool & QSimpleXmlNodeModel::namePool ( ) const

Returns the name pool associated with this model.

The implementation of name() will use this name pool to create names.

Definition at line 144 of file qsimplexmlnodemodel.cpp.

145 {
146  Q_D(const QSimpleXmlNodeModel);
147 
148  return d->namePool;
149 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
The QSimpleXmlNodeModel class is an implementation of QAbstractXmlNodeModel sufficient for many commo...

◆ namespaceBindings()

QVector< QXmlName > QSimpleXmlNodeModel::namespaceBindings ( const QXmlNodeModelIndex node) const
virtual

Always returns an empty QVector.

This signals that no namespace bindings are in scope for node.

Implements QAbstractXmlNodeModel.

Definition at line 155 of file qsimplexmlnodemodel.cpp.

156 {
157  Q_UNUSED(node);
158  return QVector<QXmlName>();
159 }
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ nodesByIdref()

QVector< QXmlNodeModelIndex > QSimpleXmlNodeModel::nodesByIdref ( const QXmlName idref) const
virtual

Always returns an empty vector, regardless of idref.

This effectively means the model has no elements or attributes of type IDREF.

Implements QAbstractXmlNodeModel.

Definition at line 179 of file qsimplexmlnodemodel.cpp.

180 {
181  Q_UNUSED(idref);
183 }
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
Definition: qglobal.h:1729

◆ stringValue()

QString QSimpleXmlNodeModel::stringValue ( const QXmlNodeModelIndex node) const
virtual

If node is an element or attribute, typedValue() is called, and the return value converted to a string, as per XQuery's rules.

If node is another type of node, the empty string is returned.

If this function is overridden for comments or processing instructions, it is important to remember to call it (for elements and attributes having values not of type xs:string) to ensure that the values are formatted according to XQuery.

Implements QAbstractXmlNodeModel.

Definition at line 113 of file qsimplexmlnodemodel.cpp.

114 {
115  const QXmlNodeModelIndex::NodeKind k= kind(node);
117  {
118  const QVariant &candidate = typedValue(node);
119  if(candidate.isNull())
120  return QString();
121  else
122  return AtomicValue::toXDM(candidate).stringValue();
123  }
124  else
125  return QString();
126 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
bool isNull() const
Returns true if this is a NULL variant, false otherwise.
Definition: qvariant.cpp:3102
virtual QXmlNodeModelIndex::NodeKind kind(const QXmlNodeModelIndex &ni) const =0
Returns a value indicating the kind of node identified by ni.
The QString class provides a Unicode character string.
Definition: qstring.h:83
virtual QVariant typedValue(const QXmlNodeModelIndex &n) const =0
Returns the typed value for node node.
NodeKind
Identifies a kind of node.

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