Qt 4.8
Public Functions | Properties | List of all members
QPatternist::OutputValidator Class Reference

Receives QAbstractXmlReceiver events and validates that they are correct, before sending them on to a second QAbstractXmlReceiver. More...

#include <qoutputvalidator_p.h>

Inheritance diagram for QPatternist::OutputValidator:
QPatternist::QAbstractXmlReceiver QPatternist::DelegatingSourceLocationReflection QSharedData QPatternist::SourceLocationReflection

Public Functions

virtual void atomicValue (const QVariant &value)
 
virtual void attribute (const QXmlName &name, const QStringRef &value)
 
virtual void characters (const QStringRef &value)
 
virtual void comment (const QString &value)
 
virtual void endDocument ()
 
virtual void endElement ()
 Signals the end of the current element. More...
 
virtual void endOfSequence ()
 
virtual void item (const Item &item)
 Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an AtomicValue. More...
 
virtual void namespaceBinding (const QXmlName &nb)
 Signals the presence of the namespace declaration nb. More...
 
 OutputValidator (QAbstractXmlReceiver *const receiver, const DynamicContext::Ptr &context, const SourceLocationReflection *const r, const bool isXSLT)
 
virtual void processingInstruction (const QXmlName &name, const QString &value)
 
virtual void startDocument ()
 
virtual void startElement (const QXmlName &name)
 
virtual void startOfSequence ()
 
- Public Functions inherited from QPatternist::QAbstractXmlReceiver
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 processingInstruction (const QXmlName name, const QString &value)=0
 
 QAbstractXmlReceiver ()
 
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...
 
- Public Functions inherited from QPatternist::DelegatingSourceLocationReflection
virtual const SourceLocationReflectionactualReflection () const
 
 DelegatingSourceLocationReflection (const SourceLocationReflection *const r)
 
virtual QString description () const
 
- Public Functions inherited from QPatternist::SourceLocationReflection
virtual QSourceLocation sourceLocation () const
 
 SourceLocationReflection ()
 
virtual ~SourceLocationReflection ()
 

Properties

QSet< QXmlNamem_attributes
 
const DynamicContext::Ptr m_context
 
bool m_hasReceivedChildren
 
const bool m_isXSLT
 
QAbstractXmlReceiver *const m_receiver
 

Additional Inherited Members

- Public Types inherited from QPatternist::QAbstractXmlReceiver
typedef QExplicitlySharedDataPointer< QAbstractXmlReceiverPtr
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Protected Functions inherited from QPatternist::QAbstractXmlReceiver
void sendAsNode (const Item &outputItem)
 

Detailed Description

Receives QAbstractXmlReceiver events and validates that they are correct, before sending them on to a second QAbstractXmlReceiver.

Currently, this is only checking that attributes appear before other nodes.

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

Definition at line 78 of file qoutputvalidator_p.h.

Constructors and Destructors

◆ OutputValidator()

OutputValidator::OutputValidator ( QAbstractXmlReceiver *const  receiver,
const DynamicContext::Ptr context,
const SourceLocationReflection *const  r,
const bool  isXSLT 
)

Definition at line 50 of file qoutputvalidator.cpp.

54  , m_hasReceivedChildren(false)
55  , m_receiver(receiver)
56  , m_context(context)
57  , m_isXSLT(isXSLT)
58 {
59  Q_ASSERT(receiver);
60  Q_ASSERT(context);
61 }
const DynamicContext::Ptr m_context
DelegatingSourceLocationReflection(const SourceLocationReflection *const r)
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QAbstractXmlReceiver *const m_receiver

Functions

◆ atomicValue()

void OutputValidator::atomicValue ( const QVariant value)
virtual

Definition at line 148 of file qoutputvalidator.cpp.

149 {
150  Q_UNUSED(value);
151  // TODO
152 }
#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

◆ attribute()

void OutputValidator::attribute ( const QXmlName name,
const QStringRef value 
)
virtual

Definition at line 81 of file qoutputvalidator.cpp.

83 {
85  {
86  m_context->error(QtXmlPatterns::tr("It's not possible to add attributes after any other kind of node."),
88  }
89  else
90  {
91  if(!m_isXSLT && m_attributes.contains(name))
92  {
93  m_context->error(QtXmlPatterns::tr("An attribute by name %1 has already been created.").arg(formatKeyword(m_context->namePool(), name)),
95  }
96  else
97  {
98  m_attributes.insert(name);
99  m_receiver->attribute(name, value);
100  }
101  }
102 }
const DynamicContext::Ptr m_context
virtual NamePool::Ptr namePool() const =0
QString formatKeyword(const QString &keyword)
void error(const QString &message, const ReportContext::ErrorCode errorCode, const QSourceLocation &sourceLocation)
bool contains(const T &value) const
Definition: qset.h:91
const char * name
QAbstractXmlReceiver *const m_receiver
const_iterator insert(const T &value)
Definition: qset.h:179
virtual void attribute(const QXmlName name, const QString &value)=0
Signals the presence of an attribute node.

◆ characters()

void OutputValidator::characters ( const QStringRef value)
virtual

Definition at line 110 of file qoutputvalidator.cpp.

111 {
112  m_hasReceivedChildren = true;
113  m_receiver->characters(value);
114 }
QAbstractXmlReceiver *const m_receiver
virtual void characters(const QString &value)=0

◆ comment()

void OutputValidator::comment ( const QString value)
virtual

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 104 of file qoutputvalidator.cpp.

105 {
106  m_hasReceivedChildren = true;
107  m_receiver->comment(value);
108 }
QAbstractXmlReceiver *const m_receiver
virtual void comment(const QString &value)=0

◆ endDocument()

void OutputValidator::endDocument ( )
virtual

End of a document node.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 143 of file qoutputvalidator.cpp.

144 {
146 }
QAbstractXmlReceiver *const m_receiver

◆ endElement()

void OutputValidator::endElement ( )
virtual

Signals the end of the current element.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 75 of file qoutputvalidator.cpp.

76 {
77  m_hasReceivedChildren = true;
79 }
virtual void endElement()=0
Signals the end of the current element.
QAbstractXmlReceiver *const m_receiver

◆ endOfSequence()

void OutputValidator::endOfSequence ( )
virtual

Definition at line 154 of file qoutputvalidator.cpp.

155 {
156 }

◆ item()

void OutputValidator::item ( const Item item)
virtual

Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an AtomicValue.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 123 of file qoutputvalidator.cpp.

124 {
125  /* We can't send outputItem directly to m_receiver since its item() function
126  * won't dispatch to this OutputValidator, but to itself. We're not sub-classing here,
127  * we're delegating. */
128 
129  if(outputItem.isNode())
130  sendAsNode(outputItem);
131  else
132  {
133  m_hasReceivedChildren = true;
134  m_receiver->item(outputItem);
135  }
136 }
void sendAsNode(const Item &outputItem)
QAbstractXmlReceiver *const m_receiver
virtual void item(const Item &item)=0
Sends an Item to this QAbstractXmlReceiver that may be a QXmlNodeModelIndex or an AtomicValue...

◆ namespaceBinding()

void OutputValidator::namespaceBinding ( const QXmlName nb)
virtual

Signals the presence of the namespace declaration nb.

This event is received after startElement(), as opposed to SAX, and before any attribute() events.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 63 of file qoutputvalidator.cpp.

64 {
66 }
virtual void namespaceBinding(const QXmlName &nb)=0
Signals the presence of the namespace declaration nb.
QAbstractXmlReceiver *const m_receiver

◆ processingInstruction()

void OutputValidator::processingInstruction ( const QXmlName name,
const QString value 
)
virtual

Definition at line 116 of file qoutputvalidator.cpp.

118 {
119  m_hasReceivedChildren = true;
120  m_receiver->processingInstruction(name, value);
121 }
QAbstractXmlReceiver *const m_receiver
virtual void processingInstruction(const QXmlName name, const QString &value)=0

◆ startDocument()

void OutputValidator::startDocument ( )
virtual

Start of a document node.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 138 of file qoutputvalidator.cpp.

139 {
141 }
QAbstractXmlReceiver *const m_receiver

◆ startElement()

void OutputValidator::startElement ( const QXmlName name)
virtual

Definition at line 68 of file qoutputvalidator.cpp.

69 {
70  m_hasReceivedChildren = false;
71  m_receiver->startElement(name);
73 }
virtual void startElement(const QXmlName name)=0
Signals the start of an element by name name.
QAbstractXmlReceiver *const m_receiver
void clear()
Definition: qset.h:87

◆ startOfSequence()

void OutputValidator::startOfSequence ( )
virtual

Definition at line 158 of file qoutputvalidator.cpp.

159 {
160 }

Properties

◆ m_attributes

QSet<QXmlName> QPatternist::OutputValidator::m_attributes
private

Keeps the current received attributes, in order to check uniqueness.

Definition at line 118 of file qoutputvalidator_p.h.

Referenced by attribute(), and startElement().

◆ m_context

const DynamicContext::Ptr QPatternist::OutputValidator::m_context
private

Definition at line 113 of file qoutputvalidator_p.h.

Referenced by attribute().

◆ m_hasReceivedChildren

bool QPatternist::OutputValidator::m_hasReceivedChildren
private

◆ m_isXSLT

const bool QPatternist::OutputValidator::m_isXSLT
private

Definition at line 119 of file qoutputvalidator_p.h.

Referenced by attribute().

◆ m_receiver

QAbstractXmlReceiver* const QPatternist::OutputValidator::m_receiver
private

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