diff --git a/src/dom/xpathtoken.h b/src/dom/xpathtoken.h
index 6c44e639d7f8f155db97402c82ecd80456bf2ea6..9039006278981536bb9302f0627bb10a091cef8d 100644 (file)
--- a/src/dom/xpathtoken.h
+++ b/src/dom/xpathtoken.h
typedef org::w3c::dom::DOMString DOMString;
-class Axis
-{
-public:
- /**
- * Constructor
- */
- Axis();
-
- /**
- * Constructor
- */
- Axis(int tokPos);
-
- /**
- * Copy constructor
- */
- Axis(const Axis &other);
-
- /**
- * Destructor
- */
- virtual ~Axis();
-
- /**
- *
- */
- 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:
+class TokenExecutor;
- int tokenPosition;
- Node *node;
-};
+//########################################################################
+//# S T A C K I T E M
+//########################################################################
/**
/**
* 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
*/
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];
-
- /**
- * Marks the head of the stack, for push() and pop()
- */
- int stackSize;
-
- /**
- * Current list of nodes found by the expression
- */
- NodeList nodeList;
+ void init()
+ {
+ sval = "";
+ ival = 0;
+ dval = 0.0;
+ }
+ void assign(const StackItem &other)
+ {
+ sval = other.sval;
+ ival = other.ival;
+ dval = other.dval;
+ }
};
//# X P A T H T O K E N
//########################################################################
+class Token;
+class Stack;
+
+typedef bool (*TokenFunc)(Token &tok, Stack &stack);
/**
TOK_OR,
TOK_MOD,
TOK_DIV,
- TOK_MULTIPLY,
+ TOK_MUL,
TOK_DOUBLE_SLASH,
TOK_SLASH,
TOK_PIPE,
* 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
*/
virtual int getType()
{ return type; }
+
+ /**
+ * Return true if the type is one of the Axis types
+ * above;
+ */
+ virtual bool isAxis()
+ {
+ return type>=TOK_AXIS_ANCESTOR_OR_SELF &&
+ type <= TOK_AXIS_SELF;
+ }
/**
* Return the string TokenType of this token
*/
* 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(Stack &stack)
+ {
+ if (tokenFunc)
+ return tokenFunc(*this, stack);
+ return false;
+ }
/**
* Print the contents of this token
*/
double dval;
-protected:
+ /**
+ *
+ */
+ static Token create(int type, long ival,
+ double dval, const DOMString &sval);
/**
- * The enmerated token type
+ *
*/
- int type;
+ static Token create(int type)
+ { return create(type, 0, 0.0, ""); }
+ /**
+ *
+ */
+ static Token create(int type, long val)
+ { return create(type, val, 0.0, ""); }
-private:
+ /**
+ *
+ */
+ static Token create(int type, double val)
+ { return create(type, 0, val, ""); }
+ /**
+ *
+ */
+ static Token create(int type, const DOMString &val)
+ { return create(type, 0, 0.0, val); }
-};
-//########################################################################
-//# X P A T H T O K E N T Y P E S
-//########################################################################
+protected:
+ /**
+ * The enmerated token type
+ */
+ int type;
+ /**
+ * The function that defines the behaviour of this token
+ */
+ TokenFunc tokenFunc;
-//###########################
-//# 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;
- }
-};
+private:
-class TokFloat : public Token
-{
-public:
- TokFloat(double val)
+ void init()
{
- type = TOK_FLOAT;
- dval = val;
+ tokenFunc = NULL;
+ type = TOK_NOP;
+ ival = 0L;
+ dval = 0.0;
+ //sval = ""; //not necessary
}
- 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)
+ void assign(const Token &other)
{
- StackItem item;
- item.ival = ival;
- exec.push(item);
- return true;
+ tokenFunc = other.tokenFunc;
+ type = other.type;
+ sval = other.sval;
+ ival = other.ival;
+ dval = other.dval;
}
-};
-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;
- }
};
-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
+//########################################################################
+//# S T A C K
+//########################################################################
+
+/**
+ *
+ */
+class Stack
{
public:
- TokDiv()
+
+ //# From 2.3, principal type of child axes
+ typedef enum
{
- type = TOK_DIV;
- }
- virtual bool execute(TokenExecutor &exec)
+ AXIS_ATTRIBUTE,
+ AXIS_NAMESPACE,
+ AXIS_ELEMENT
+ } PrincipalNodeType;
+
+ /**
+ * Constructor
+ */
+ Stack(TokenExecutor &par) : parent(par)
+ { clear(); }
+
+ /**
+ * Copy constructor
+ */
+ Stack(const Stack &other) : parent(other.parent)
+ { assign(other); }
+
+ /**
+ * Destructor
+ */
+ virtual ~Stack()
+ {}
+
+ /**
+ *
+ */
+ Stack &operator=(const Stack &other)
+ { assign(other); return *this; }
+
+ /**
+ *
+ */
+ void push(StackItem &item)
+ { return stackItems.push_back(item); }
+
+ /**
+ *
+ */
+ StackItem pop()
{
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.dval /= item2.dval;
- exec.push(item1);
- return true;
+ if (stackItems.size() < 1)
+ {
+ //TODO: error here
+ StackItem item;
+ return item;
+ }
+ std::vector<StackItem>::iterator iter =
+ stackItems.end() - 1;
+ StackItem item = *iter;
+ stackItems.erase(iter);
+ return item;
}
-};
-class TokMul : public Token
-{
-public:
- TokMul()
+ /**
+ *
+ */
+ virtual void clear()
{
- type = TOK_MULTIPLY;
+ stackItems.clear();
+ principalNodeType = AXIS_ELEMENT;
}
- virtual bool execute(TokenExecutor &exec)
+
+private:
+
+ void assign(const Stack &other)
{
- StackItem item1 = exec.pop();
- StackItem item2 = exec.pop();
- item1.dval *= item2.dval;
- exec.push(item1);
- return true;
+ principalNodeType = other.principalNodeType;
+ stackItems = other.stackItems;
}
-};
-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;
- }
-};
+ int principalNodeType;
+ std::vector<StackItem> stackItems;
-//###########################
-//# X P A T H I T E M S
-//###########################
+ TokenExecutor &parent;
-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;
- }
};
-class TokRelative : public Token
-{
-public:
- TokRelative()
- {
- type = TOK_RELATIVE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- ///exec.axis.currentNode = stack.rootNode;
- return true;
- }
-};
-class TokStep : public Token
-{
-public:
- TokStep()
- {
- type = TOK_STEP;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokNameTest : public Token
-{
-public:
- TokNameTest(const DOMString &name)
- {
- type = TOK_NAME_TEST;
- sval = name;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-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;
- }
-};
+//########################################################################
+//# T O K E N L I S T
+//########################################################################
-
-//###########################
-//# A X I S
-//###########################
-
-
-class TokAxisAncestorOrSelf : public Token
-{
-public:
- TokAxisAncestorOrSelf()
- {
- type = TOK_AXIS_ANCESTOR_OR_SELF;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokAxisAncestor : public Token
-{
-public:
- TokAxisAncestor()
- {
- type = TOK_AXIS_ANCESTOR;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-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;
- }
-};
-
-class TokAxisFollowingSibling : public Token
-{
-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)
- {
- return true;
- }
-};
-
-class TokAxisNamespace : public Token
-{
-public:
- TokAxisNamespace()
- {
- type = TOK_AXIS_NAMESPACE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokAxisParent : public Token
-{
-public:
- TokAxisParent()
- {
- type = TOK_AXIS_PARENT;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokAxisPrecedingSibling : public Token
-{
-public:
- TokAxisPrecedingSibling()
- {
- type = TOK_AXIS_PRECEDING_SIBLING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokAxisPreceding : public Token
-{
-public:
- TokAxisPreceding()
- {
- type = TOK_AXIS_PRECEDING;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokAxisSelf : public Token
-{
-public:
- TokAxisSelf()
- {
- type = TOK_AXIS_SELF;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-
-
-//###########################
-//# F U N C T I O N S
-//###########################
-
-class TokFuncLast : public Token
-{
-public:
- TokFuncLast()
- {
- type = TOK_FUNC_LAST;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokFuncPosition : public Token
-{
-public:
- TokFuncPosition()
- {
- type = TOK_FUNC_POSITION;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokFuncCount : public Token
-{
-public:
- TokFuncCount()
- {
- type = TOK_FUNC_COUNT;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokFuncId : public Token
-{
-public:
- TokFuncId()
- {
- type = TOK_FUNC_ID;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-class TokFuncLocalName : public Token
-{
-public:
- TokFuncLocalName()
- {
- type = TOK_FUNC_LOCAL_NAME;
- }
- 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;
- }
-};
-
-class TokFuncName : public Token
-{
-public:
- TokFuncName()
- {
- type = TOK_FUNC_NAME;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-
-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;
- }
-};
-
-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)
- {
- return true;
- }
-};
-class TokFuncTranslate : public Token
-{
-public:
- TokFuncTranslate()
- {
- type = TOK_FUNC_TRANSLATE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ virtual void add(const Token &token)
+ { tokens.push_back(token); }
-class TokFuncBoolean : public Token
-{
-public:
- TokFuncBoolean()
- {
- type = TOK_FUNC_BOOLEAN;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ virtual std::vector<Token> &getTokens()
+ { return tokens; }
-class TokFuncNot : public Token
-{
-public:
- TokFuncNot()
- {
- type = TOK_FUNC_NOT;
- }
- 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 TokFuncTrue : public Token
-{
-public:
- TokFuncTrue()
- {
- type = TOK_FUNC_TRUE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ /**
+ *
+ */
+ virtual void clear()
+ {
+ tokens.clear();
+ }
-class TokFuncFalse : public Token
-{
-public:
- TokFuncFalse()
- {
- type = TOK_FUNC_FALSE;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+private:
-class TokFuncLang : public Token
-{
-public:
- TokFuncLang()
- {
- type = TOK_FUNC_LANG;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncNumber : public Token
-{
-public:
- TokFuncNumber()
- {
- type = TOK_FUNC_NUMBER;
- }
- virtual bool execute(TokenExecutor &exec)
+ void init()
{
- return true;
+ clear();
}
-};
-class TokFuncSum : public Token
-{
-public:
- TokFuncSum()
+ void assign(const TokenList &other)
{
- type = TOK_FUNC_SUM;
+ tokens = other.tokens;
}
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
-class TokFuncFloor : public Token
-{
-public:
- TokFuncFloor()
- {
- type = TOK_FUNC_FLOOR;
- }
- virtual bool execute(TokenExecutor &exec)
- {
- return true;
- }
-};
+ std::vector<Token> tokens;
-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();
/**
- *
+ * Execute a list upon a given node. For each Axis encountered,
+ * get the nodes encountered so far, and execute the rest of the
+ * list of tokens upon each of the nodes.
*/
- virtual void clear();
+ int execute(std::vector<Token> &tokens,
+ int position,
+ const NodePtr node,
+ NodeList &nodeList);
/**
- *
+ * Execute a token list on the stack
*/
- virtual void add(Token *tok);
+ bool execute(TokenList &list,
+ const NodePtr node,
+ NodeList &result);
+
+private:
/**
*
*/
- virtual unsigned int size() const;
+ TokenList tokenList;
/**
*
*/
- virtual void dump();
-
-private:
-
-
- std::vector<Token *> tokens;
+ NodeList nodeList;
};
-
-
-
} // namespace xpath
} // namespace dom
} // namespace w3c