summaryrefslogtreecommitdiffstats
path: root/src/dom/xpathtoken.h
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2006-07-07 01:26:05 +0000
committerishmal <ishmal@users.sourceforge.net>2006-07-07 01:26:05 +0000
commit4096e01820ce6b46d2eb56b7a395faf4d3980354 (patch)
tree7b4e83be5be2f1214da9ab3103b501d252e2a4ef /src/dom/xpathtoken.h
parentAdjust to account for removal of svglsimpl (diff)
downloadinkscape-4096e01820ce6b46d2eb56b7a395faf4d3980354.tar.gz
inkscape-4096e01820ce6b46d2eb56b7a395faf4d3980354.zip
rearrange axis/context structure. make tokens more robust
(bzr r1370)
Diffstat (limited to 'src/dom/xpathtoken.h')
-rw-r--r--src/dom/xpathtoken.h1322
1 files changed, 280 insertions, 1042 deletions
diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h
index 6c44e639d..26aee60f8 100644
--- a/src/dom/xpathtoken.h
+++ b/src/dom/xpathtoken.h
@@ -48,70 +48,13 @@ namespace xpath
typedef org::w3c::dom::DOMString DOMString;
-class Axis
-{
-public:
- /**
- * Constructor
- */
- Axis();
-
- /**
- * Constructor
- */
- Axis(int tokPos);
-
- /**
- * Copy constructor
- */
- Axis(const Axis &other);
- /**
- * Destructor
- */
- virtual ~Axis();
+class TokenExecutor;
- /**
- *
- */
- Axis &operator=(const Axis &other);
- /**
- *
- */
- void init();
-
- /**
- *
- */
- void assign(const Axis &other);
-
- /**
- *
- */
- void setPosition(unsigned int val);
-
- /**
- *
- */
- unsigned int getPosition();
-
- /**
- *
- */
- void setNode(const Node *node);
-
- /**
- *
- */
- Node *getNode();
-
-private:
-
- int tokenPosition;
-
- Node *node;
-};
+//########################################################################
+//# S T A C K I T E M
+//########################################################################
/**
@@ -124,28 +67,26 @@ public:
/**
* Constructor
*/
- StackItem();
+ StackItem()
+ { init(); }
/**
* Copy constructor
*/
- StackItem(const StackItem &other);
+ StackItem(const StackItem &other)
+ { assign(other); }
/**
* Destructor
*/
- virtual ~StackItem();
-
- /**
- *
- */
- StackItem &operator=(const StackItem &other);
+ virtual ~StackItem()
+ {}
/**
*
*/
- void assign(const StackItem &other);
-
+ StackItem &operator=(const StackItem &other)
+ { assign(other); return *this; }
//treat the stack item like an union of string, integer, and double
@@ -164,99 +105,41 @@ public:
*/
double dval;
-};
-
-class TokenList;
-
-//########################################################################
-//# T O K E N E X E C U T O R
-//########################################################################
-
-#define STACK_SIZE 1024
-
-/**
- * A token evaluator, with stack and axis context
- */
-class TokenExecutor
-{
-public:
-
- /**
- * Constructor
- */
- TokenExecutor();
-
- /**
- * Copy constructor
- */
- TokenExecutor(const TokenExecutor &other);
-
- /**
- * Destructor
- */
- virtual ~TokenExecutor();
-
- /**
- * Assign our values to those of the other
- */
- virtual void assign(const TokenExecutor &other);
-
- /**
- * Reset the stack to its original settings
- */
- virtual void reset();
-
- /**
- * Push a stack item onto the stack
- */
- virtual void push(StackItem &item);
-
- /**
- * Pop a stack item from the stack
- */
- virtual StackItem pop();
-
- /**
- * Execute a token list on the stack
- */
- NodeList execute(const TokenList &list, const Node *node);
-
- /**
- *
- */
- Axis axis;
-
- /**
- *
- */
- std::vector<Axis> axisStack;
private:
- /**
- * Contains the StackItem stack;
- */
- StackItem stack[STACK_SIZE];
+ void init()
+ {
+ sval = "";
+ ival = 0;
+ dval = 0.0;
+ }
- /**
- * Marks the head of the stack, for push() and pop()
- */
- int stackSize;
+ void assign(const StackItem &other)
+ {
+ sval = other.sval;
+ ival = other.ival;
+ dval = other.dval;
+ }
- /**
- * Current list of nodes found by the expression
- */
- NodeList nodeList;
+};
-};
+/**
+ * Contains the StackItem stack;
+ */
+typedef std::vector<StackItem> Stack;
//########################################################################
//# X P A T H T O K E N
//########################################################################
+class Token;
+class TokenExecutor;
+
+typedef bool (*TokenFunc)(Token &tok, TokenExecutor &exec);
/**
@@ -287,7 +170,7 @@ public:
TOK_OR,
TOK_MOD,
TOK_DIV,
- TOK_MULTIPLY,
+ TOK_MUL,
TOK_DOUBLE_SLASH,
TOK_SLASH,
TOK_PIPE,
@@ -358,22 +241,38 @@ public:
* Constructor with a NOP default type
*/
Token()
- {
- type = TOK_NOP;
- ival = 0L;
- dval = 0.0;
+ { init(); }
+
+ /**
+ * Constructor with a NOP default type
+ */
+ Token(int typeArg)
+ { init(); type = typeArg; }
+
+ /**
+ * Constructor with a NOP default type
+ */
+ Token(int typeArg,
+ long ivalArg, double dvalArg, const DOMString &svalArg)
+ {
+ init();
+ type = typeArg,
+ ival = ivalArg;
+ dval = dvalArg;
+ sval = svalArg;
}
/**
* Copy constructor
*/
Token(const Token &other)
- {
- type = other.type;
- sval = other.sval;
- ival = other.ival;
- dval = other.dval;
- }
+ { assign(other); }
+
+ /**
+ * Assignment
+ */
+ Token &operator=(const Token &other)
+ { assign(other); return *this; }
/**
* Destructor
@@ -395,8 +294,12 @@ public:
* Let this token execute itself on the given stack,
* possibly adding Nodes to the node list.
*/
- virtual bool execute(TokenExecutor &stack)
- { return true; }
+ virtual bool execute(TokenExecutor &exec)
+ {
+ if (tokenFunc)
+ return tokenFunc(*this, exec);
+ return false;
+ }
/**
* Print the contents of this token
@@ -424,1007 +327,345 @@ public:
*/
double dval;
-protected:
-
/**
- * The enmerated token type
+ *
*/
- int type;
-
-
-private:
-
-
-};
-
-
-//########################################################################
-//# X P A T H T O K E N T Y P E S
-//########################################################################
-
-
-
-//###########################
-//# V A L U E S
-//###########################
-
-class TokStr : public Token
-{
-public:
- TokStr(const DOMString &val)
- {
- type = TOK_STR;
- sval = val;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item;
- item.sval = sval;
- exec.push(item);
- return true;
- }
-};
-
-class TokFloat : public Token
-{
-public:
- TokFloat(double val)
- {
- type = TOK_FLOAT;
- dval = val;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item;
- item.dval = dval;
- exec.push(item);
- return true;
- }
-};
-
-class TokInt : public Token
-{
-public:
- TokInt(long val)
- {
- type = TOK_INT;
- ival = val;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item;
- item.ival = ival;
- exec.push(item);
- return true;
- }
-};
-
-class TokAnd : public Token
-{
-public:
- TokAnd()
- {
- type = TOK_AND;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = item1.ival && item2.ival;
- exec.push(item1);
- return true;
- }
-};
-
-class TokOr : public Token
-{
-public:
- TokOr()
- {
- type = TOK_OR;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = item1.ival || item2.ival;
- exec.push(item1);
- return true;
- }
-};
+ static Token create(int type, long ival,
+ double dval, const DOMString &sval);
-class TokMod : public Token
-{
-public:
- TokMod()
- {
- type = TOK_MOD;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.dval = fmod(item1.dval, item2.dval);
- exec.push(item1);
- return true;
- }
-};
-
-class TokDiv : public Token
-{
-public:
- TokDiv()
- {
- type = TOK_DIV;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.dval /= item2.dval;
- exec.push(item1);
- return true;
- }
-};
-
-class TokMul : public Token
-{
-public:
- TokMul()
- {
- type = TOK_MULTIPLY;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.dval *= item2.dval;
- exec.push(item1);
- return true;
- }
-};
-
-class TokPlus : public Token
-{
-public:
- TokPlus()
- {
- type = TOK_PLUS;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.dval += item2.dval;
- exec.push(item1);
- return true;
- }
-};
-
-class TokMinus : public Token
-{
-public:
- TokMinus()
- {
- type = TOK_MINUS;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.dval -= item2.dval;
- exec.push(item1);
- return true;
- }
-};
-
-class TokNeg : public Token
-{
-public:
- TokNeg()
- {
- type = TOK_NEG;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item = exec.pop();
- item.dval = -item.dval;
- item.ival = -item.ival;
- exec.push(item);
- return true;
- }
-};
-
-class TokEquals : public Token
-{
-public:
- TokEquals()
- {
- type = TOK_EQUALS;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = (item1.dval == item2.dval);
- exec.push(item1);
- return true;
- }
-};
-
-class TokNotEquals : public Token
-{
-public:
- TokNotEquals()
- {
- type = TOK_NOT_EQUALS;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = (item1.dval != item2.dval);
- exec.push(item1);
- return true;
- }
-};
-
-class TokLessThanEquals : public Token
-{
-public:
- TokLessThanEquals()
- {
- type = TOK_LESS_THAN_EQUALS;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = (item1.dval <= item2.dval);
- exec.push(item1);
- return true;
- }
-};
-
-class TokLessThan : public Token
-{
-public:
- TokLessThan()
- {
- type = TOK_LESS_THAN;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = (item1.dval < item2.dval);
- exec.push(item1);
- return true;
- }
-};
-
-class TokGreaterThanEquals : public Token
-{
-public:
- TokGreaterThanEquals()
- {
- type = TOK_GREATER_THAN_EQUALS;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = (item1.dval >= item2.dval);
- exec.push(item1);
- return true;
- }
-};
-
-class TokGreaterThan : public Token
-{
-public:
- TokGreaterThan()
- {
- type = TOK_GREATER_THAN;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.ival = (item1.dval > item2.dval);
- exec.push(item1);
- return true;
- }
-};
-
-
-//###########################
-//# X P A T H I T E M S
-//###########################
-
-class TokAbsolute : public Token
-{
-public:
- TokAbsolute()
- {
- type = TOK_ABSOLUTE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- Node *n = exec.axis.getNode();
- while (n->getParentNode())
- n = n->getParentNode();
- exec.axis.setNode(n);
- return true;
- }
-};
+ /**
+ *
+ */
+ static Token create(int type)
+ { return create(type, 0, 0.0, ""); }
-class TokRelative : public Token
-{
-public:
- TokRelative()
- {
- type = TOK_RELATIVE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- ///exec.axis.currentNode = stack.rootNode;
- return true;
- }
-};
+ /**
+ *
+ */
+ static Token create(int type, long val)
+ { return create(type, val, 0.0, ""); }
-class TokStep : public Token
-{
-public:
- TokStep()
- {
- type = TOK_STEP;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ static Token create(int type, double val)
+ { return create(type, 0, val, ""); }
-class TokNameTest : public Token
-{
-public:
- TokNameTest(const DOMString &name)
- {
- type = TOK_NAME_TEST;
- sval = name;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ static Token create(int type, const DOMString &val)
+ { return create(type, 0, 0.0, val); }
-class TokExpr : public Token
-{
-public:
- TokExpr()
- {
- type = TOK_EXPR;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokUnion : public Token
-{
-public:
- TokUnion()
- {
- type = TOK_UNION;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+protected:
+ /**
+ * The enmerated token type
+ */
+ int type;
+ /**
+ * The function that defines the behaviour of this token
+ */
+ TokenFunc tokenFunc;
-//###########################
-//# A X I S
-//###########################
+private:
-class TokAxisAncestorOrSelf : public Token
-{
-public:
- TokAxisAncestorOrSelf()
- {
- type = TOK_AXIS_ANCESTOR_OR_SELF;
- }
- virtual bool execute(TokenExecutor &exec)
+ void init()
{
- return true;
+ tokenFunc = NULL;
+ type = TOK_NOP;
+ ival = 0L;
+ dval = 0.0;
}
-};
-class TokAxisAncestor : public Token
-{
-public:
- TokAxisAncestor()
- {
- type = TOK_AXIS_ANCESTOR;
- }
- virtual bool execute(TokenExecutor &exec)
+ void assign(const Token &other)
{
- return true;
+ tokenFunc = other.tokenFunc;
+ type = other.type;
+ sval = other.sval;
+ ival = other.ival;
+ dval = other.dval;
}
-};
-class TokAxisAttribute : public Token
-{
-public:
- TokAxisAttribute()
- {
- type = TOK_AXIS_ATTRIBUTE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokAxisChild : public Token
-{
-public:
- TokAxisChild()
- {
- type = TOK_AXIS_CHILD;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
};
-class TokAxisDescendantOrSelf : public Token
-{
-public:
- TokAxisDescendantOrSelf()
- {
- type = TOK_AXIS_DESCENDANT_OR_SELF;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokAxisDescendant : public Token
-{
-public:
- TokAxisDescendant()
- {
- type = TOK_AXIS_DESCENDANT;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+//########################################################################
+//# C O N T E X T
+//########################################################################
-class TokAxisFollowingSibling : public Token
+/**
+ *
+ */
+class Context
{
public:
- TokAxisFollowingSibling()
- {
- type = TOK_AXIS_FOLLOWING_SIBLING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokAxisFollowing : public Token
-{
-public:
- TokAxisFollowing()
- {
- type = TOK_AXIS_FOLLOWING;
- }
- virtual bool execute(TokenExecutor &exec)
+ //# From 2.3, principal type of child axes
+ typedef enum
{
- return true;
- }
-};
+ AXIS_ATTRIBUTE,
+ AXIS_NAMESPACE,
+ AXIS_ELEMENT
+ } PrincipalNodeType;
-class TokAxisNamespace : public Token
-{
-public:
- TokAxisNamespace()
- {
- type = TOK_AXIS_NAMESPACE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ * Constructor
+ */
+ Context()
+ { init(); }
-class TokAxisParent : public Token
-{
-public:
- TokAxisParent()
- {
- type = TOK_AXIS_PARENT;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ * Constructor
+ */
+ Context(int principalNodeTypeArg)
+ { init(); principalNodeType = principalNodeTypeArg; }
-class TokAxisPrecedingSibling : public Token
-{
-public:
- TokAxisPrecedingSibling()
- {
- type = TOK_AXIS_PRECEDING_SIBLING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ * Copy constructor
+ */
+ Context(const Context &other)
+ { assign(other); }
-class TokAxisPreceding : public Token
-{
-public:
- TokAxisPreceding()
- {
- type = TOK_AXIS_PRECEDING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ * Destructor
+ */
+ virtual ~Context()
+ {}
-class TokAxisSelf : public Token
-{
-public:
- TokAxisSelf()
- {
- type = TOK_AXIS_SELF;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ Context &operator=(const Context &other)
+ { assign(other); return *this; }
+ /**
+ *
+ */
+ std::vector<Token> &getTokens()
+ { return tokens; }
+ /**
+ *
+ */
+ void setTokens(const std::vector<Token> &tokensArg)
+ { tokens = tokensArg; }
-//###########################
-//# F U N C T I O N S
-//###########################
+ /**
+ *
+ */
+ void add(const Token &token)
+ { tokens.push_back(token); }
-class TokFuncLast : public Token
-{
-public:
- TokFuncLast()
- {
- type = TOK_FUNC_LAST;
- }
- virtual bool execute(TokenExecutor &exec)
+ /**
+ *
+ */
+ virtual void dump()
{
- return true;
+ for (unsigned int i=0 ; i<tokens.size() ; i++)
+ {
+ Token token = tokens[i];
+ token.dump();
+ }
}
-};
-class TokFuncPosition : public Token
-{
-public:
- TokFuncPosition()
- {
- type = TOK_FUNC_POSITION;
- }
- virtual bool execute(TokenExecutor &exec)
+ /**
+ *
+ */
+ virtual void clear()
{
- return true;
+ tokens.clear();
}
-};
-class TokFuncCount : public Token
-{
-public:
- TokFuncCount()
- {
- type = TOK_FUNC_COUNT;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+private:
-class TokFuncId : public Token
-{
-public:
- TokFuncId()
- {
- type = TOK_FUNC_ID;
- }
- virtual bool execute(TokenExecutor &exec)
+ void init()
{
- return true;
+ principalNodeType = AXIS_ELEMENT;
}
-};
-class TokFuncLocalName : public Token
-{
-public:
- TokFuncLocalName()
+ void assign(const Context &other)
{
- type = TOK_FUNC_LOCAL_NAME;
+ principalNodeType = other.principalNodeType;
+ tokens = other.tokens;
}
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncNamespaceUri : public Token
-{
-public:
- TokFuncNamespaceUri()
- {
- type = TOK_FUNC_NAMESPACE_URI;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ int principalNodeType;
-class TokFuncName : public Token
-{
-public:
- TokFuncName()
- {
- type = TOK_FUNC_NAME;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ std::vector<Token> tokens;
-class TokFuncString : public Token
-{
-public:
- TokFuncString()
- {
- type = TOK_FUNC_STRING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
};
-class TokFuncConcat : public Token
-{
-public:
- TokFuncConcat()
- {
- type = TOK_FUNC_CONCAT;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncStartsWith : public Token
-{
-public:
- TokFuncStartsWith()
- {
- type = TOK_FUNC_STARTS_WITH;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+//########################################################################
+//# T O K E N L I S T
+//########################################################################
-class TokFuncContains : public Token
+/**
+ *
+ */
+class TokenList
{
public:
- TokFuncContains()
- {
- type = TOK_FUNC_CONTAINS;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncSubstringBefore : public Token
-{
-public:
- TokFuncSubstringBefore()
- {
- type = TOK_FUNC_SUBSTRING_BEFORE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ TokenList()
+ { init(); }
-class TokFuncSubstringAfter : public Token
-{
-public:
- TokFuncSubstringAfter()
- {
- type = TOK_FUNC_SUBSTRING_AFTER;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ TokenList(const TokenList &other)
+ { assign(other); }
-class TokFuncSubstring : public Token
-{
-public:
- TokFuncSubstring()
- {
- type = TOK_FUNC_SUBSTRING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ TokenList &operator=(const TokenList &other)
+ { assign(other); return *this; }
-class TokFuncStringLength : public Token
-{
-public:
- TokFuncStringLength()
- {
- type = TOK_FUNC_STRING_LENGTH;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ virtual ~TokenList()
+ { }
-class TokFuncNormalizeSpace : public Token
-{
-public:
- TokFuncNormalizeSpace()
- {
- type = TOK_FUNC_NORMALIZE_SPACE;
- }
- virtual bool execute(TokenExecutor &exec)
+ /**
+ *
+ */
+ virtual void add(const Context &contextArg)
{
- return true;
+ contexts.push_back(currentContext);
+ currentContext=contextArg;
}
-};
-class TokFuncTranslate : public Token
-{
-public:
- TokFuncTranslate()
- {
- type = TOK_FUNC_TRANSLATE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ virtual void add(const Token &token)
+ { currentContext.add(token); }
-class TokFuncBoolean : public Token
-{
-public:
- TokFuncBoolean()
- {
- type = TOK_FUNC_BOOLEAN;
- }
- virtual bool execute(TokenExecutor &exec)
+ /**
+ *
+ */
+ virtual void dump()
{
- return true;
+ for (unsigned int i=0 ; i<contexts.size() ; i++)
+ {
+ Context context = contexts[i];
+ context.dump();
+ }
}
-};
-class TokFuncNot : public Token
-{
-public:
- TokFuncNot()
- {
- type = TOK_FUNC_NOT;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ virtual void clear()
+ {
+ currentContext.clear();
+ contexts.clear();
+ }
-class TokFuncTrue : public Token
-{
-public:
- TokFuncTrue()
- {
- type = TOK_FUNC_TRUE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+private:
-class TokFuncFalse : public Token
-{
-public:
- TokFuncFalse()
- {
- type = TOK_FUNC_FALSE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncLang : public Token
-{
-public:
- TokFuncLang()
+ void init()
{
- type = TOK_FUNC_LANG;
+ clear();
}
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncNumber : public Token
-{
-public:
- TokFuncNumber()
- {
- type = TOK_FUNC_NUMBER;
- }
- virtual bool execute(TokenExecutor &exec)
+ void assign(const TokenList &other)
{
- return true;
+ currentContext = other.currentContext;
+ contexts = other.contexts;
}
-};
-class TokFuncSum : public Token
-{
-public:
- TokFuncSum()
- {
- type = TOK_FUNC_SUM;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ Context currentContext;
-class TokFuncFloor : public Token
-{
-public:
- TokFuncFloor()
- {
- type = TOK_FUNC_FLOOR;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ std::vector<Context> contexts;
-class TokFuncCeiling : public Token
-{
-public:
- TokFuncCeiling()
- {
- type = TOK_FUNC_CEILING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncRound : public Token
-{
-public:
- TokFuncRound()
- {
- type = TOK_FUNC_ROUND;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
};
-
-
//########################################################################
-//# T O K E N L I S T
+//# T O K E N E X E C U T O R
//########################################################################
+
/**
- *
+ * A token evaluator, with stack and axis context
*/
-class TokenList
+class TokenExecutor
{
public:
/**
- *
+ * Constructor
*/
- TokenList();
+ TokenExecutor();
/**
- *
+ * Copy constructor
*/
- TokenList(const TokenList &other);
+ TokenExecutor(const TokenExecutor &other);
/**
- *
+ * Destructor
*/
- TokenList &operator=(const TokenList &other);
+ virtual ~TokenExecutor();
/**
- *
+ * Assign our values to those of the other
*/
- void assign(const TokenList &other);
+ virtual void assign(const TokenExecutor &other);
/**
- *
+ * Reset the stack to its original settings
*/
- virtual ~TokenList();
+ virtual void reset();
/**
- *
+ * Push a stack item onto the stack
*/
- virtual void clear();
+ virtual void push(StackItem &item);
/**
- *
+ * Pop a stack item from the stack
*/
- virtual void add(Token *tok);
+ virtual StackItem pop();
/**
- *
+ * Execute a token list on the stack
*/
- virtual unsigned int size() const;
+ NodeList execute(const TokenList &list, const Node *node);
+
+private:
/**
- *
+ * Contains the StackItem stack;
*/
- virtual void dump();
+ Stack stack;
-private:
+ /**
+ *
+ */
+ TokenList tokenList;
- std::vector<Token *> tokens;
+ /**
+ *
+ */
+ NodeList nodeList;
};
@@ -1432,9 +673,6 @@ private:
-
-
-
} // namespace xpath
} // namespace dom
} // namespace w3c