Qt 4.8
Public Types | Public Functions | Protected Functions | Private Functions | List of all members
QPatternist::QAbstractXmlReceiver Class Referenceabstract

A push interface for the XPath Data Model. Similar to SAX's ContentHandler. More...

#include <qsequencereceiver_p.h>

Inheritance diagram for QPatternist::QAbstractXmlReceiver:
QSharedData QPatternist::DocumentContentValidator QPatternist::DocumentProjector QPatternist::NodeBuilder QPatternist::OutputValidator QPatternist::AccelTreeBuilder< true > QPatternist::AccelTreeBuilder< FromDocument >

Public Types

typedef QExplicitlySharedDataPointer< QAbstractXmlReceiverPtr
 

Public Functions

virtual void attribute (const QXmlName name, const QString &value)=0
 Signals the presence of an attribute node. More...
 
virtual void characters (const QString &value)=0
 
virtual void comment (const QString &value)=0
 
virtual void endDocument ()=0
 
virtual void endElement ()=0
 Signals the end of the current element. More...
 
virtual void item (const Item &item)=0
 Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an AtomicValue. More...
 
virtual void namespaceBinding (const QXmlName &nb)=0
 Signals the presence of the namespace declaration nb. More...
 
virtual void processingInstruction (const QXmlName name, const QString &value)=0
 
 QAbstractXmlReceiver ()
 
virtual void startDocument ()=0
 
virtual void startElement (const QXmlName name)=0
 Signals the start of an element by name name. More...
 
virtual void whitespaceOnly (const QStringRef &value)
 
virtual ~QAbstractXmlReceiver ()
 
- 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...
 

Protected Functions

void sendAsNode (const Item &outputItem)
 

Private Functions

template<const QXmlNodeModelIndex::Axis axis>
void sendFromAxis (const QXmlNodeModelIndex &node)
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

A push interface for the XPath Data Model. Similar to SAX's ContentHandler.

Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 72 of file qsequencereceiver_p.h.

Typedefs

◆ Ptr

Definition at line 75 of file qsequencereceiver_p.h.

Constructors and Destructors

◆ QAbstractXmlReceiver()

QPatternist::QAbstractXmlReceiver::QAbstractXmlReceiver ( )
inline

Definition at line 77 of file qsequencereceiver_p.h.

78  {
79  }

◆ ~QAbstractXmlReceiver()

QAbstractXmlReceiver::~QAbstractXmlReceiver ( )
virtual

Definition at line 50 of file qsequencereceiver.cpp.

Referenced by QAbstractXmlReceiver().

51 {
52 }

Functions

◆ attribute()

virtual void QPatternist::QAbstractXmlReceiver::attribute ( const QXmlName  name,
const QString value 
)
pure virtual

Signals the presence of an attribute node.

This function is guaranteed by the caller to always be called after a call to startElement() or attribute().

Parameters
namethe name of the attribute. Guaranteed to always be non-null.
valuethe value of the attribute. Guaranteed to always be non-null.

Implemented in QPatternist::DocumentProjector.

Referenced by QPatternist::DocumentContentValidator::attribute(), QPatternist::OutputValidator::attribute(), QPatternist::AccelTree::copyNodeTo(), QPatternist::AttributeConstructor::evaluateSingleton(), QPatternist::AttributeConstructor::evaluateToSequenceReceiver(), QAbstractXmlReceiver(), and sendAsNode().

◆ characters()

virtual void QPatternist::QAbstractXmlReceiver::characters ( const QString value)
pure virtual

Sends a text node with value value. Adjascent text nodes may be sent. There's no restrictions on value, beyond that it must be valid XML characters. For instance, value may contain only whitespace.

See also
whitespaceOnly()

Implemented in QPatternist::DocumentProjector.

Referenced by QPatternist::DocumentContentValidator::characters(), QPatternist::OutputValidator::characters(), QAbstractXmlReceiver(), sendAsNode(), and whitespaceOnly().

◆ comment()

virtual void QPatternist::QAbstractXmlReceiver::comment ( const QString value)
pure virtual

◆ endDocument()

virtual void QPatternist::QAbstractXmlReceiver::endDocument ( )
pure virtual

◆ endElement()

virtual void QPatternist::QAbstractXmlReceiver::endElement ( )
pure virtual

◆ item()

virtual void QPatternist::QAbstractXmlReceiver::item ( const Item item)
pure virtual

◆ namespaceBinding()

virtual void QPatternist::QAbstractXmlReceiver::namespaceBinding ( const QXmlName nb)
pure virtual

◆ processingInstruction()

virtual void QPatternist::QAbstractXmlReceiver::processingInstruction ( const QXmlName  name,
const QString value 
)
pure virtual

◆ sendAsNode()

void QAbstractXmlReceiver::sendAsNode ( const Item outputItem)
protected

Treats outputItem as an node and calls the appropriate function, such as attribute() or comment(), depending on its QXmlNodeModelIndex::NodeKind.

This a helper function sub-classes can use to multi-plex Nodes received via item().

Parameters
outputItemmust be a QXmlNodeModelIndex.

Definition at line 68 of file qsequencereceiver.cpp.

Referenced by QPatternist::DocumentContentValidator::item(), QPatternist::OutputValidator::item(), QAbstractXmlReceiver(), and sendFromAxis().

69 {
70  Q_ASSERT(outputItem);
71  Q_ASSERT(outputItem.isNode());
72  const QXmlNodeModelIndex asNode = outputItem.asNode();
73 
74  switch(asNode.kind())
75  {
77  {
78  attribute(asNode.name(), outputItem.stringValue());
79  break;
80  }
82  {
83  startElement(asNode.name());
84 
85  /* First the namespaces, then attributes, then the children. */
86  asNode.sendNamespaces(Ptr(const_cast<QAbstractXmlReceiver *>(this)));
87  sendFromAxis<QXmlNodeModelIndex::AxisAttribute>(asNode);
88  sendFromAxis<QXmlNodeModelIndex::AxisChild>(asNode);
89 
90  endElement();
91 
92  break;
93  }
95  {
96  characters(outputItem.stringValue());
97  break;
98  }
100  {
101  processingInstruction(asNode.name(), outputItem.stringValue());
102  break;
103  }
105  {
106  comment(outputItem.stringValue());
107  break;
108  }
110  {
111  sendFromAxis<QXmlNodeModelIndex::AxisChild>(asNode);
112  break;
113  }
115  Q_ASSERT_X(false, Q_FUNC_INFO, "Not implemented");
116  }
117 }
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
virtual void startElement(const QXmlName name)=0
Signals the start of an element by name name.
bool isNode() const
Determines whether this item is an atomic value, or a node.
Definition: qitem_p.h:349
virtual void endElement()=0
Signals the end of the current element.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QString stringValue() const
Returns the string value of this Item.
Definition: qitem_p.h:302
virtual void comment(const QString &value)=0
virtual void processingInstruction(const QXmlName name, const QString &value)=0
virtual void characters(const QString &value)=0
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
const QXmlNodeModelIndex & asNode() const
Definition: qitem_p.h:379
QExplicitlySharedDataPointer< QAbstractXmlReceiver > Ptr
virtual void attribute(const QXmlName name, const QString &value)=0
Signals the presence of an attribute node.
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ sendFromAxis()

template<const QXmlNodeModelIndex::Axis axis>
void QAbstractXmlReceiver::sendFromAxis ( const QXmlNodeModelIndex node)
inlineprivate

Call sendAsNode() for each child of node. As consistent with the XPath Data Model, this does not include attribute nodes.

Definition at line 55 of file qsequencereceiver.cpp.

Referenced by QAbstractXmlReceiver().

56 {
57  Q_ASSERT(!node.isNull());
59  QXmlNodeModelIndex next(it->next());
60 
61  while(!next.isNull())
62  {
63  sendAsNode(next);
64  next = it->next();
65  }
66 }
The QXmlNodeModelIndex class identifies a node in an XML node model subclassed from QAbstractXmlNodeM...
bool isNull() const
Returns true if this QXmlNodeModelIndex is a default constructed value, otherwise false...
#define it(className, varName)
The QExplicitlySharedDataPointer class represents a pointer to an explicitly shared object...
Definition: qshareddata.h:136
void sendAsNode(const Item &outputItem)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QExplicitlySharedDataPointer< QAbstractXmlForwardIterator< QXmlNodeModelIndex > > iterate(const Axis axis) const
Definition: qitem_p.h:456

◆ startDocument()

virtual void QPatternist::QAbstractXmlReceiver::startDocument ( )
pure virtual

◆ startElement()

virtual void QPatternist::QAbstractXmlReceiver::startElement ( const QXmlName  name)
pure virtual

◆ whitespaceOnly()

void QAbstractXmlReceiver::whitespaceOnly ( const QStringRef value)
virtual

This function may be called instead of characters() if, and only if, value consists only of whitespace.

The caller gurantees that value, is not empty.

By whitespace is meant a sequence of characters that are either spaces, tabs, or the two new line characters, in any order. In other words, the whole of Unicode's whitespace category is not considered whitespace.

However, there's no guarantee or requirement that whitespaceOnly() is called for text nodes containing whitespace only, characters() may be called just as well. This is why the default implementation for whitespaceOnly() calls characters().

See also
characters()

Reimplemented in QPatternist::AccelTreeBuilder< FromDocument >, and QPatternist::AccelTreeBuilder< true >.

Definition at line 119 of file qsequencereceiver.cpp.

Referenced by QAbstractXmlReceiver().

120 {
122  "The caller must guarantee only whitespace is passed. Use characters() in other cases.");
123  characters(value.toString());
124 }
QString toString() const
Returns a copy of the string reference as a QString object.
Definition: qstring.cpp:8653
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
Definition: qstring.cpp:4506
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
virtual void characters(const QString &value)=0
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#define Q_FUNC_INFO
Definition: qglobal.h:1871

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