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

Delegates another Tokenizer, and while doing so prints the tokens it delivers to stderr. More...

#include <qtokenrevealer_p.h>

Inheritance diagram for QPatternist::TokenRevealer:
QPatternist::Tokenizer QPatternist::TokenSource QSharedData

Public Functions

virtual int commenceScanOnly ()
 
virtual Token nextToken (YYLTYPE *const sourceLocator)
 
virtual void resumeTokenizationFrom (const int position)
 
virtual void setParserContext (const ParserContext::Ptr &parseInfo)
 
 TokenRevealer (const QUrl &uri, const Tokenizer::Ptr &other)
 
virtual ~TokenRevealer ()
 
- Public Functions inherited from QPatternist::Tokenizer
const QUrlqueryURI () const
 
 Tokenizer (const QUrl &queryU)
 
- Public Functions inherited from QPatternist::TokenSource
 TokenSource ()
 
virtual ~TokenSource ()
 
- 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...
 

Properties

QString m_indentationString
 
QString m_result
 
const Tokenizer::Ptr m_tokenizer
 

Additional Inherited Members

- Public Types inherited from QPatternist::Tokenizer
typedef QExplicitlySharedDataPointer< TokenizerPtr
 
- Public Types inherited from QPatternist::TokenSource
typedef QExplicitlySharedDataPointer< TokenSourcePtr
 
typedef QQueue< PtrQueue
 
typedef yytokentype TokenType
 
- Public Variables inherited from QSharedData
QAtomicInt ref
 
- Static Protected Functions inherited from QPatternist::Tokenizer
static QString tokenToString (const Token &token)
 

Detailed Description

Delegates another Tokenizer, and while doing so prints the tokens it delivers to stderr.

Hence, this class is used solely for debugging.

Since
4.5

Definition at line 72 of file qtokenrevealer_p.h.

Constructors and Destructors

◆ TokenRevealer()

TokenRevealer::TokenRevealer ( const QUrl uri,
const Tokenizer::Ptr other 
)

Definition at line 48 of file qtokenrevealer.cpp.

49  : Tokenizer(uri)
50  , m_tokenizer(other)
51 {
52  Q_ASSERT(other);
53 }
Tokenizer(const QUrl &queryU)
Definition: qtokenizer_p.h:158
#define Q_ASSERT(cond)
Definition: qglobal.h:1823
const Tokenizer::Ptr m_tokenizer

◆ ~TokenRevealer()

TokenRevealer::~TokenRevealer ( )
virtual

Definition at line 55 of file qtokenrevealer.cpp.

56 {
57  qDebug() << "Tokens Revealed:" << m_result;
58 }
Q_CORE_EXPORT void qDebug(const char *,...)

Functions

◆ commenceScanOnly()

int TokenRevealer::commenceScanOnly ( )
virtual

Switches the Tokenizer to only do scanning, and returns complete strings for attribute value templates as opposed to the tokens for the contained expressions.

The current position in the stream is returned. It can be used to later resume regular tokenization.

Implements QPatternist::Tokenizer.

Definition at line 101 of file qtokenrevealer.cpp.

102 {
103  return m_tokenizer->commenceScanOnly();
104 }
const Tokenizer::Ptr m_tokenizer

◆ nextToken()

Tokenizer::Token TokenRevealer::nextToken ( YYLTYPE *const  sourceLocator)
virtual
Returns
the next token.

Implements QPatternist::TokenSource.

Definition at line 65 of file qtokenrevealer.cpp.

66 {
67  const Token token(m_tokenizer->nextToken(sourceLocator));
68  const QString asString(tokenToString(token));
69  const TokenType type = token.type;
70 
71  /* Indent. */
72  switch(type)
73  {
74  case CURLY_LBRACE:
75  {
76  m_result += QLatin1Char('\n') + m_indentationString + asString + QLatin1Char('\n');
79  break;
80  }
81  case CURLY_RBRACE:
82  {
84  m_result += QLatin1Char('\n') + m_indentationString + asString;
85  break;
86  }
87  case SEMI_COLON:
88  /* Fallthrough. */
89  case COMMA:
90  {
91  m_result += asString + QLatin1Char('\n') + m_indentationString;
92  break;
93  }
94  default:
95  m_result += asString + QLatin1Char(' ');
96  }
97 
98  return token;
99 }
int type
Definition: qmetatype.cpp:239
void chop(int n)
Removes n characters from the end of the string.
Definition: qstring.cpp:4623
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
The QString class provides a Unicode character string.
Definition: qstring.h:83
static QString tokenToString(const Token &token)
QString & append(QChar c)
Definition: qstring.cpp:1777
const Tokenizer::Ptr m_tokenizer
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

◆ resumeTokenizationFrom()

void TokenRevealer::resumeTokenizationFrom ( const int  position)
virtual

Resumes regular parsing from position. The tokenizer must be in the scan-only state, which the commenceScanOnly() call transists to.

The tokenizer will return the token POSITION_SET once after this function has been called.

Implements QPatternist::Tokenizer.

Definition at line 106 of file qtokenrevealer.cpp.

107 {
108  m_tokenizer->resumeTokenizationFrom(position);
109 }
static qreal position(QGraphicsObject *item, QDeclarativeAnchorLine::AnchorLine anchorLine)
const Tokenizer::Ptr m_tokenizer

◆ setParserContext()

void TokenRevealer::setParserContext ( const ParserContext::Ptr parseInfo)
virtual

Implements QPatternist::Tokenizer.

Definition at line 60 of file qtokenrevealer.cpp.

61 {
62  m_tokenizer->setParserContext(parseInfo);
63 }
const Tokenizer::Ptr m_tokenizer

Properties

◆ m_indentationString

QString QPatternist::TokenRevealer::m_indentationString
private

Definition at line 88 of file qtokenrevealer_p.h.

Referenced by nextToken().

◆ m_result

QString QPatternist::TokenRevealer::m_result
private

Definition at line 87 of file qtokenrevealer_p.h.

Referenced by nextToken(), and ~TokenRevealer().

◆ m_tokenizer

const Tokenizer::Ptr QPatternist::TokenRevealer::m_tokenizer
private

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