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

kalzium/libscience

  • sources
  • kde-4.14
  • kdeedu
  • kalzium
  • libscience
parser.h
Go to the documentation of this file.
1 /***************************************************************************
2  copyright : (C) 2005 by Inge Wallin
3  email : inge@lysator.liu.se
4  ***************************************************************************/
5 /***************************************************************************
6  * *
7  * This program is free software; you can redistribute it and/or modify *
8  * it under the terms of the GNU General Public License as published by *
9  * the Free Software Foundation; either version 2 of the License, or *
10  * (at your option) any later version. *
11  * *
12  ***************************************************************************/
13 
14 #ifndef PARSER_H
15 #define PARSER_H
16 
17 #include "libkdeedu_science_export.h"
18 
19 #include <QtCore/QString>
20 
21 
30 class SCIENCE_EXPORT Parser {
31 public:
35  Parser();
36 
42  explicit Parser(const QString& _str);
43 
47  virtual ~Parser();
48 
52  void start(const QString& _str);
53 
57  int nextChar() const { return m_nextChar; }
58 
62  int nextToken() const { return m_nextToken; }
63 
67  int intVal() const { return m_intVal; }
68  float floatVal() const { return m_floatVal; }
69 
70 private:
71 
72  // Try to parse some special datatypes.
73  bool parseInt(int *_result);
74  bool parseSimpleFloat(double *_result);
75 
76 protected:
81  static const int INT_TOKEN = 257;
82 
87  static const int FLOAT_TOKEN = 258;
88 
92  int getNextChar();
93 
97  int skipWhitespace();
98 
102  virtual int getNextToken();
103 
104 private:
105  QString m_str;
106  int m_index;
107  int m_nextChar;
108 
109  protected:
110 
111  // Lexical analysis and token handling. These members need to be
112  // protected instead of private since we want to be able to
113  // reimplement getNextToken().
114 
118  int m_nextToken;
119 
120  // Values for the respective token. These could be made into a
121  // union, but I don't think it is necessary to bother, since they
122  // are so few and we don't instantiate a lot of copies of the
123  // parser.
124 
128  int m_intVal; // Valid if m_nextToken == INT_TOKEN
129 
133  double m_floatVal; // Valid if m_nextToken == FLOAT_TOKEN
134 };
135 
136 #endif
libkdeedu_science_export.h
Parser::floatVal
float floatVal() const
Definition: parser.h:68
Parser::nextChar
int nextChar() const
Peek at the next character;.
Definition: parser.h:57
Parser::m_floatVal
double m_floatVal
Valid if m_nextToken == FLOAT_TOKEN.
Definition: parser.h:133
QString
Parser::nextToken
int nextToken() const
Peek at the next token.
Definition: parser.h:62
Parser::m_intVal
int m_intVal
Valid if m_nextToken == INT_TOKEN.
Definition: parser.h:128
Parser::m_nextToken
int m_nextToken
The next token to be used in the parser.
Definition: parser.h:118
SCIENCE_EXPORT
#define SCIENCE_EXPORT
Definition: libkdeedu_science_export.h:32
Parser::intVal
int intVal() const
Get the value stored for different types of tokens.
Definition: parser.h:67
Parser
This is a general purpose parser originally written by Inge Wallin.
Definition: parser.h:30
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:11:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kalzium/libscience

Skip menu "kalzium/libscience"
  • Main Page
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdeedu API Reference

Skip menu "kdeedu API Reference"
  • Analitza
  •     lib
  • kalgebra
  • kalzium
  •   libscience
  • kanagram
  • kig
  •   lib
  • klettres
  • marble
  • parley
  • rocs
  •   App
  •   RocsCore
  •   VisualEditor
  •   stepcore

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