• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KHTML

  • sources
  • kde-4.14
  • kdelibs
  • khtml
  • xpath
tokenizer.h
Go to the documentation of this file.
1 /*
2  * tokenizer.h - Copyright 2005 Maksim Orlovich <maksim@kde.org>
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  * notice, this list of conditions and the following disclaimer in the
12  * documentation and/or other materials provided with the distribution.
13  *
14  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  */
25 #ifndef TOKENIZER_H
26 #define TOKENIZER_H
27 
28 #include <QSet>
29 #include <QString>
30 #include <QHash>
31 
32 #include "step.h"
33 #include "path.h"
34 #include "predicate.h"
35 #include "expression.h"
36 #include "util.h"
37 #include "parser.h"
38 
39 namespace khtml {
40 namespace XPath {
41 
42 
43 struct Token
44 {
45  int type;
46  QString value;
47  int intValue; //0 if not set
48  bool hasString;
49 
50  Token(int _type): type(_type), intValue(0), hasString(false) {}
51  Token(QString _value): type(ERROR+1), value(_value), intValue(0), hasString(true) {}
52  Token(int _type, QString _value): type(_type), value(_value), intValue(0), hasString(true) {}
53  Token(int _type, int _value): type(_type), intValue(_value), hasString(false) {}
54 };
55 
56 class Tokenizer
57 {
58 private:
59  int m_nextPos;
60  QString m_data;
61  int m_lastTokenType;
62 
63  static QHash<QString, Step::AxisType>* s_axisNamesDict;
64  static QSet<QString>* s_nodeTypeNamesDict;
65 
66  enum XMLCat {
67  NameStart,
68  NameCont,
69  NotPartOfName
70  };
71 
72  XMLCat charCat(QChar aChar);
73 
74  bool isAxisName(QString name, Step::AxisType *type = 0);
75  bool isNodeTypeName(QString name);
76  bool isOperatorContext();
77 
78  void skipWS();
79  Token makeTokenAndAdvance(int code, int advance = 1);
80  Token makeIntTokenAndAdvance(int code, int val, int advance = 1);
81  char peekAheadHelper();
82  char peekCurHelper();
83 
84  Token lexString();
85  Token lexNumber();
86  Token lexNCName();
87  Token lexQName();
88 
89  Token nextTokenInternal();
90  Tokenizer();
91  Tokenizer(const Tokenizer &rhs); // disabled
92  Tokenizer &operator=(const Tokenizer &rhs); // disabled
93  ~Tokenizer();
94 public:
95  static Tokenizer &self();
96 
97  void reset(QString);
98  Token nextToken();
99 };
100 
101 // Interface to the parser
102 int khtmlxpathyylex();
103 void khtmlxpathyyerror(const char *str);
104 void initTokenizer(const DOM::DOMString& string);
105 
106 } // namespace XPath
107 
108 } // namespace khtml
109 
110 
111 #endif
112 // kate: indent-width 4; replace-tabs off; tab-width 4; indent-spaces: off;
step.h
khtml::XPath::initTokenizer
void initTokenizer(const DOM::DOMString &string)
Definition: tokenizer.cpp:447
khtml::XPath::khtmlxpathyyerror
void khtmlxpathyyerror(const char *str)
Definition: parser.cpp:2183
ERROR
Definition: parser.cpp:161
QChar
khtml::XPath::Tokenizer::reset
void reset(QString)
Definition: tokenizer.cpp:429
khtml::XPath::Token::value
QString value
Definition: tokenizer.h:46
name
const char * name(StandardAction id)
khtml::XPath::Token
Definition: tokenizer.h:43
khtml::XPath::Token::intValue
int intValue
Definition: tokenizer.h:47
khtml::XPath::Token::Token
Token(int _type)
Definition: tokenizer.h:50
parser.h
QHash
khtml::XPath::Token::hasString
bool hasString
Definition: tokenizer.h:48
expression.h
DOM::DOMString
This class implements the basic string we use in the DOM.
Definition: dom_string.h:43
QSet< QString >
khtml::XPath::Token::Token
Token(int _type, QString _value)
Definition: tokenizer.h:52
QString
util.h
khtml::XPath::khtmlxpathyylex
int khtmlxpathyylex()
Definition: tokenizer.cpp:436
path.h
khtml::XPath::Tokenizer::nextToken
Token nextToken()
Definition: tokenizer.cpp:411
khtml::XPath::Token::Token
Token(int _type, int _value)
Definition: tokenizer.h:53
predicate.h
khtml::XPath::Token::Token
Token(QString _value)
Definition: tokenizer.h:51
khtml::XPath::Tokenizer
Definition: tokenizer.h:56
khtml::XPath::Step::AxisType
AxisType
Definition: step.h:45
khtml::XPath::Token::type
int type
Definition: tokenizer.h:45
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:26:19 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHTML

Skip menu "KHTML"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal