Qt 4.8
Public Functions | Public Variables | List of all members
QPatternist::DocumentProjector Class Reference

#include <qdocumentprojector_p.h>

Inheritance diagram for QPatternist::DocumentProjector:
QPatternist::QAbstractXmlReceiver QSharedData

Public Functions

virtual void attribute (const QXmlName name, const QString &value)
 Signals the presence of an attribute node. More...
 
virtual void characters (const QString &value)
 
virtual void comment (const QString &value)
 
 DocumentProjector (const ProjectedExpression::Vector &paths, QAbstractXmlReceiver *const receiver)
 
virtual void endDocument ()
 
virtual void endElement ()
 Signals the end of the current element. More...
 
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)
 
virtual void processingInstruction (const QXmlName name, const QString &value)
 
virtual void startDocument ()
 
virtual void startElement (const QXmlName name)
 Signals the start of an element by name name. More...
 
- Public Functions inherited from QPatternist::QAbstractXmlReceiver
virtual void namespaceBinding (const QXmlName &nb)=0
 Signals the presence of the namespace declaration nb. More...
 
 QAbstractXmlReceiver ()
 
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 Variables

ProjectedExpression::Action m_action
 
int m_nodesInProcess
 
const int m_pathCount
 
ProjectedExpression::Vector m_paths
 
QAbstractXmlReceiver *const m_receiver
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 

Additional Inherited Members

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

Detailed Description

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

Definition at line 69 of file qdocumentprojector_p.h.

Constructors and Destructors

◆ DocumentProjector()

DocumentProjector::DocumentProjector ( const ProjectedExpression::Vector paths,
QAbstractXmlReceiver *const  receiver 
)

Definition at line 48 of file qdocumentprojector.cpp.

49  : m_paths(paths)
50  , m_pathCount(paths.count())
52  , m_nodesInProcess(0)
53  , m_receiver(receiver)
54 {
55  Q_ASSERT_X(paths.count() > 0, Q_FUNC_INFO,
56  "Using DocumentProjector with no paths is an "
57  "overhead and has also undefined behavior.");
59 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QAbstractXmlReceiver *const m_receiver
ProjectedExpression::Vector m_paths
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
ProjectedExpression::Action m_action
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Functions

◆ attribute()

void DocumentProjector::attribute ( const QXmlName  name,
const QString value 
)
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.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 168 of file qdocumentprojector.cpp.

170 {
171  Q_UNUSED(name);
172  Q_UNUSED(value);
173 }
#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

◆ characters()

void DocumentProjector::characters ( const QString value)
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()

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 187 of file qdocumentprojector.cpp.

188 {
189  Q_UNUSED(value);
190 }
#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

◆ comment()

void DocumentProjector::comment ( const QString value)
virtual

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 180 of file qdocumentprojector.cpp.

181 {
183  "Invalid input; it's the caller's responsibility to ensure the input is correct.");
184  Q_UNUSED(value);
185 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#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
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ endDocument()

void DocumentProjector::endDocument ( )
virtual

End of a document node.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 210 of file qdocumentprojector.cpp.

211 {
212 }

◆ endElement()

void DocumentProjector::endElement ( )
virtual

Signals the end of the current element.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 125 of file qdocumentprojector.cpp.

126 {
128  {
130 
132 
133  /* We have now kept the single node, and now wants to skip
134  * all its children. */
136  m_nodesInProcess = 0;
137  }
139  {
142 
143  if(m_nodesInProcess == 0)
144  {
145  /* We have now skipped all the children, let's do
146  * a new path analysis. */
148  }
149  }
150  else
151  {
153  "We're not supposed to be in a Move action here.");
154  /* We skip calling m_receiver's endElement() here since we're
155  * skipping. */
158 
159  if(m_nodesInProcess == 0)
160  {
161  /* Ok, we've skipped them all, let's do something
162  * new -- let's Move on to the next path! */
164  }
165  }
166 }
virtual void endElement()=0
Signals the end of the current element.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QAbstractXmlReceiver *const m_receiver
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
ProjectedExpression::Action m_action
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ item()

void DocumentProjector::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 201 of file qdocumentprojector.cpp.

202 {
203  Q_UNUSED(outputItem);
204 }
#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

◆ namespaceBinding()

void DocumentProjector::namespaceBinding ( const QXmlName  nb)
virtual

Definition at line 175 of file qdocumentprojector.cpp.

176 {
177  Q_UNUSED(nb);
178 }
#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

◆ processingInstruction()

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

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 192 of file qdocumentprojector.cpp.

194 {
196  "Invalid input; it's the caller's responsibility to ensure the input is correct.");
197  Q_UNUSED(name);
198  Q_UNUSED(value);
199 }
QBool contains(QChar c, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Definition: qstring.h:904
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
Definition: qstring.h:654
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
#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
#define Q_FUNC_INFO
Definition: qglobal.h:1871

◆ startDocument()

void DocumentProjector::startDocument ( )
virtual

Start of a document node.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 206 of file qdocumentprojector.cpp.

207 {
208 }

◆ startElement()

void DocumentProjector::startElement ( const QXmlName  name)
virtual

Signals the start of an element by name name.

Implements QPatternist::QAbstractXmlReceiver.

Definition at line 61 of file qdocumentprojector.cpp.

62 {
63  Q_UNUSED(name);
64 
65  switch(m_action)
66  {
68  {
69  m_receiver->startElement(name);
70  /* Fallthrough. */
71  }
73  {
75  return;
76  }
77  default:
78  {
80  "We're not supposed to receive Keep here, because "
81  "endElement() should always end that state.");
82 
83  for(int i = 0; i < m_pathCount; ++i)
84  {
85  m_action = m_paths.at(i)->actionForElement(name, m_paths[i]);
86 
87  switch(m_action)
88  {
90  {
92  continue;
93  }
95  {
96  /* Ok, at least one path wanted this node. Pass it on,
97  * and exit. */
98  m_receiver->startElement(name);
100  return;
101  }
103  {
104  /* This particular path doesn't need it, but
105  * some other path might, so continue looping. */
106  continue;
107  }
109  Q_ASSERT_X(false, Q_FUNC_INFO, "The action functions can never return Move.");
110  }
111  }
112 
114 
116  m_receiver->startElement(name);
117  else
118  {
120  }
121  }
122  }
123 }
virtual void startElement(const QXmlName name)=0
Signals the start of an element by name name.
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
QAbstractXmlReceiver *const m_receiver
ProjectedExpression::Vector m_paths
virtual Action actionForElement(const QXmlName name, ProjectedExpression::Ptr &next) const
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
#define Q_ASSERT_X(cond, where, what)
Definition: qglobal.h:1837
ProjectedExpression::Action m_action
#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
#define Q_FUNC_INFO
Definition: qglobal.h:1871

Properties

◆ m_action

ProjectedExpression::Action QPatternist::DocumentProjector::m_action

Definition at line 97 of file qdocumentprojector_p.h.

Referenced by endElement(), and startElement().

◆ m_nodesInProcess

int QPatternist::DocumentProjector::m_nodesInProcess

Definition at line 98 of file qdocumentprojector_p.h.

Referenced by endElement(), and startElement().

◆ m_pathCount

const int QPatternist::DocumentProjector::m_pathCount

Definition at line 96 of file qdocumentprojector_p.h.

Referenced by startElement().

◆ m_paths

ProjectedExpression::Vector QPatternist::DocumentProjector::m_paths

Definition at line 95 of file qdocumentprojector_p.h.

Referenced by startElement().

◆ m_receiver

QAbstractXmlReceiver* const QPatternist::DocumentProjector::m_receiver

Definition at line 99 of file qdocumentprojector_p.h.

Referenced by DocumentProjector(), endElement(), and startElement().


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