summaryrefslogtreecommitdiffstats
path: root/kommander/widget/parsenode.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /kommander/widget/parsenode.h
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kommander/widget/parsenode.h')
-rw-r--r--kommander/widget/parsenode.h129
1 files changed, 129 insertions, 0 deletions
diff --git a/kommander/widget/parsenode.h b/kommander/widget/parsenode.h
new file mode 100644
index 00000000..305b0998
--- /dev/null
+++ b/kommander/widget/parsenode.h
@@ -0,0 +1,129 @@
+/***************************************************************************
+ parsenode.cpp - Single parsed item
+ -------------------
+ copyright : (C) 2004 Michal Rudolf <mrudolf@kdewebdwev.org>
+
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ ***************************************************************************/
+
+#ifndef _HAVE_PARSENODE_H_
+#define _HAVE_PARSENODE_H_
+
+#include <qstring.h>
+
+namespace Parse
+{
+ enum Keyword {For, To, Step, End, While, Do, Foreach, In, If, Then, Else, Elseif, Endif, Switch, Case,
+ Break, Continue, Exit, Dot, Semicolon, Comma, Assign, Less, LessEqual, Greater, GreaterEqual, Equal, NotEqual,
+ Not, And, Or, False, True, LeftParenthesis, RightParenthesis, LeftBracket, DoubleBracket, RightBracket, LeftCurlyBrace, RightCurlyBrace, PlusEqual, MinusEqual, Increment, Decrement,
+ Plus, Minus, Multiply, Divide, Mod, LastRealKeyword = Mod, Variable, Invalid, Array, Matrix, ArrKeyVal};
+
+ enum KeywordGroup {GroupComparison, GroupAdd, GroupMultiply, GroupMisc};
+ enum ValueType {ValueString, ValueInt, ValueDouble, ValueValue = ValueDouble, ValueKeyword,
+ ValueNone, ValueError};
+
+ enum Mode{Execute, CheckOnly};
+
+ enum Flow{FlowStandard, FlowContinue, FlowBreak, FlowExit};
+}
+
+class ParseNode {
+public:
+ /* Default constructor */
+ ParseNode();
+ /* Create node from string */
+ ParseNode(const QString& s);
+ /* Create node from integer */
+ ParseNode(int i);
+ /* Create node from integer */
+ ParseNode(uint i);
+ /* Create node from double */
+ ParseNode(double d);
+ /* Create node from keyword */
+ ParseNode(Parse::Keyword k);
+ /* Create node from keyword and variable name */
+ ParseNode(Parse::Keyword k, const QString& s);
+ /* Create error node with optional error message */
+ static ParseNode error(const QString& s);
+
+ /* Return current type */
+ Parse::ValueType type() const;
+ /* Return current keyword if appropriate */
+ Parse::Keyword keyword() const;
+ /* Cast value to string */
+ QString toString() const;
+ /* Cast value to integer */
+ int toInt() const;
+ /* Cast value to double */
+ double toDouble() const;
+ /* Cast value to bool */
+ bool toBool() const;
+ /* Check if a value is valid */
+ bool isValid() const;
+ /* Check if current value is a keyword */
+ bool isKeyword() const;
+ /* Check if current value is a given keyword */
+ bool isKeyword(Parse::Keyword k) const;
+ /* Check if current value is a variable */
+ bool isVariable() const;
+ /* Check if current value is an Array */
+ bool isArray() const;
+ /* Return the name of variable */
+ QString variableName() const;
+ /* Return the name of array */
+ QString arrayName() const;
+ /* Return error message if applicable */
+ QString errorMessage() const;
+ /* Calculate common type for two nodes */
+ Parse::ValueType commonType(const ParseNode& p) const;
+ /* Find common type and compare values */
+ int compare(const ParseNode& p) const;
+ /* Various comparing functions */
+ bool operator==(int i) const;
+ bool operator==(bool b) const;
+ bool operator==(const QString& s) const;
+ bool operator==(const ParseNode& p) const;
+ bool operator!=(const ParseNode& p) const;
+ bool operator>=(const ParseNode& p) const;
+ bool operator<=(const ParseNode& p) const;
+ bool operator>(const ParseNode& p) const;
+ bool operator<(const ParseNode& p) const;
+ /* set value as integer */
+ void setValue(int i);
+ /* set value as double */
+ void setValue(double d);
+ /* set value as string */
+ void setValue(const QString& s);
+ /* set value as variable */
+ void setVariable(const QString& name);
+ /* set value as array */
+ void setArray(const QString& name);
+ /* check if it is correct value */
+ bool isValue() const;
+ /* for setting some context information, f. e. for bug reporting */
+ void setContext(int c);
+ /* get current context */
+ int context() const;
+
+private:
+ Parse::ValueType m_type;
+ union {
+ int m_int;
+ double m_double;
+ Parse::Keyword m_keyword;
+ };
+ QString m_string;
+ int m_context;
+};
+
+
+#endif
+