Qt 4.8
Public Types | Public Functions | Static Protected Functions | Properties | List of all members
QPatternist::Tokenizer Class Referenceabstract

Base class for all tokenizers. More...

#include <qtokenizer_p.h>

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

Public Types

typedef QExplicitlySharedDataPointer< TokenizerPtr
 
- Public Types inherited from QPatternist::TokenSource
typedef QExplicitlySharedDataPointer< TokenSourcePtr
 
typedef QQueue< PtrQueue
 
typedef yytokentype TokenType
 

Public Functions

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

Static Protected Functions

static QString tokenToString (const Token &token)
 

Properties

const QUrl m_queryURI
 

Additional Inherited Members

- Public Variables inherited from QSharedData
QAtomicInt ref
 

Detailed Description

Base class for all tokenizers.

The main entry point is nextToken(), which ones calls to retrieve the stream of tokens this Tokenizer delivers.

See also
Building a Tokenizer for XPath or XQuery
Author
Frans Englich frans.nosp@m..eng.nosp@m.lich@.nosp@m.noki.nosp@m.a.com

Definition at line 155 of file qtokenizer_p.h.

Typedefs

◆ Ptr

Definition at line 163 of file qtokenizer_p.h.

Constructors and Destructors

◆ Tokenizer()

QPatternist::Tokenizer::Tokenizer ( const QUrl queryU)
inline

Definition at line 158 of file qtokenizer_p.h.

158  : m_queryURI(queryU)
159  {
160  Q_ASSERT(queryU.isValid());
161  }
bool isValid() const
Returns true if the URL is valid; otherwise returns false.
Definition: qurl.cpp:4303
#define Q_ASSERT(cond)
Definition: qglobal.h:1823

Functions

◆ commenceScanOnly()

virtual int QPatternist::Tokenizer::commenceScanOnly ( )
pure 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.

Implemented in QPatternist::XSLTTokenizer, QPatternist::XQueryTokenizer, and QPatternist::TokenRevealer.

◆ queryURI()

const QUrl& QPatternist::Tokenizer::queryURI ( ) const
inline
Returns
the URI of the resource being tokenized.

Definition at line 187 of file qtokenizer_p.h.

Referenced by QPatternist::fromYYLTYPE(), QPatternist::XSLTTokenizer::queueAVT(), QPatternist::XSLTTokenizer::queueExpression(), and QPatternist::XSLTTokenizer::queueSequenceType().

188  {
189  return m_queryURI;
190  }

◆ resumeTokenizationFrom()

virtual void QPatternist::Tokenizer::resumeTokenizationFrom ( const int  position)
pure 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.

Implemented in QPatternist::XSLTTokenizer, QPatternist::XQueryTokenizer, and QPatternist::TokenRevealer.

◆ setParserContext()

virtual void QPatternist::Tokenizer::setParserContext ( const ParserContext::Ptr parseInfo)
pure virtual

◆ tokenToString()

QString QPatternist::Tokenizer::tokenToString ( const Token token)
staticprotected

Returns a string representation of token.

This function is used for debugging purposes. The implementation of this function is in querytransformparser.ypp.

Definition at line 8003 of file qquerytransformparser.cpp.

Referenced by QPatternist::TokenRevealer::nextToken().

8004 {
8005  switch(token.type)
8006  {
8007  case NCNAME:
8008  /* Fallthrough. */
8009  case QNAME:
8010  /* Fallthrough. */
8011  case NUMBER:
8012  /* Fallthrough. */
8013  case XPATH2_NUMBER:
8014  return token.value;
8015  case STRING_LITERAL:
8016  return QLatin1Char('"') + token.value + QLatin1Char('"');
8017  default:
8018  {
8019  const QString raw(QString::fromLatin1(yytname[YYTRANSLATE(token.type)]));
8020 
8021  /* Remove the quotes. */
8022  if(raw.at(0) == QLatin1Char('"') && raw.length() > 1)
8023  return raw.mid(1, raw.length() - 2);
8024  else
8025  return raw;
8026  }
8027  }
8028 }
The QString class provides a Unicode character string.
Definition: qstring.h:83
static const char *const yytname[]
static QString fromLatin1(const char *, int size=-1)
Returns a QString initialized with the first size characters of the Latin-1 string str...
Definition: qstring.cpp:4188
#define YYTRANSLATE(YYX)
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
Definition: qchar.h:55

Properties

◆ m_queryURI

const QUrl QPatternist::Tokenizer::m_queryURI
private

Definition at line 205 of file qtokenizer_p.h.


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