summaryrefslogtreecommitdiffstats
path: root/src/dom/xpathtoken.cpp
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2006-05-02 05:29:03 +0000
committergouldtj <gouldtj@users.sourceforge.net>2006-05-02 05:29:03 +0000
commitdc81b746cf1305802b07f367a44e518d9036a2d6 (patch)
tree079328ba4b24bee0c7dc90b022f5d7b3529c62d7 /src/dom/xpathtoken.cpp
parentr11569@tres: ted | 2006-04-29 08:55:02 -0700 (diff)
downloadinkscape-dc81b746cf1305802b07f367a44e518d9036a2d6.tar.gz
inkscape-dc81b746cf1305802b07f367a44e518d9036a2d6.zip
(bzr r690)
Diffstat (limited to 'src/dom/xpathtoken.cpp')
-rw-r--r--src/dom/xpathtoken.cpp120
1 files changed, 53 insertions, 67 deletions
diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp
index c9d4898d7..2d5dfc1d7 100644
--- a/src/dom/xpathtoken.cpp
+++ b/src/dom/xpathtoken.cpp
@@ -131,12 +131,12 @@ static TokenStringPair tokenStrings[] =
/**
- * Return the string TokenType of this token
+ * Return the enumerated TokenType of this token
* (in the .cpp file)
*/
DOMString Token::getTypeString()
{
- DOMString ret = "unknown";
+ DOMString ret;
for (TokenStringPair *pair = tokenStrings ; pair->sval ; pair++)
{
if (pair->ival == type)
@@ -148,8 +148,6 @@ DOMString Token::getTypeString()
return ret;
}
-
-
//########################################################################
//# X P A T H A X I S
//########################################################################
@@ -168,8 +166,7 @@ Axis::Axis()
*/
Axis::Axis(int tokPos)
{
- init();
- tokenPosition = tokPos;
+ assign(other);
}
@@ -186,15 +183,7 @@ Axis::Axis(const Axis &other)
/**
*
*/
-Axis::~Axis()
-{
-}
-
-
-/**
- *
- */
-Axis &Axis::operator=(const Axis &other)
+StackItem &StackItem::operator=(const StackItem &other)
{
assign(other);
return *this;
@@ -203,82 +192,72 @@ Axis &Axis::operator=(const Axis &other)
/**
*
*/
-void Axis::init()
+void StackItem::assign(const StackItem &other)
{
- tokenPosition = 0;
+ sval = other.sval;
+ ival = other.ival;
+ dval = other.dval;
}
-/**
- *
- */
-void Axis::assign(const Axis &other)
-{
- tokenPosition = other.tokenPosition;
-}
-/**
- *
- */
-void Axis::setPosition(unsigned int val)
-{
- tokenPosition = val;
-}
+//########################################################################
+//# X P A T H S T A C K I T E M
+//########################################################################
/**
*
*/
-unsigned int Axis::getPosition()
+StackItem::StackItem()
{
- return tokenPosition;
+ ival = 0L;
+ dval = 0.0;
}
-/**
- *
- */
-void Axis::setNode(const Node *val)
-{
- node = (Node *)val;
-}
/**
*
*/
-Node *Axis::getNode()
+StackItem::StackItem(const StackItem &other)
{
- return node;
+ assign(other);
}
-//########################################################################
-//# X P A T H S T A C K I T E M
-//########################################################################
/**
*
*/
-StackItem::StackItem()
+Stack::~Stack()
{
- ival = 0L;
- dval = 0.0;
}
/**
*
*/
-StackItem::StackItem(const StackItem &other)
+void Stack::assign(const Stack &other)
{
- assign(other);
+ root = other.root;
+ nodeList = other.nodeList;
+ size = other.size;
+ for (int i=0 ; i<size ; i++)
+ items[i] = other.items[i];
}
/**
*
*/
-StackItem::~StackItem()
+void Stack::reset()
{
+ root = NULL;
+ NodeList n; /*no "clear" in api*/
+ nodeList = n;
+ size = 0;
}
+
+
/**
*
*/
@@ -298,6 +277,22 @@ void StackItem::assign(const StackItem &other)
dval = other.dval;
}
+/**
+ * Set the root node
+ */
+void Stack::setRootNode(const Node *node)
+{
+ root = (Node *)node;
+}
+
+/**
+ * Get the current node list;
+ */
+NodeList &Stack::getNodeList()
+{
+ return nodeList;
+}
+
//########################################################################
//# T O K E N L I S T
@@ -375,31 +370,22 @@ unsigned int TokenList::size() const
}
-/**
- *
- */
-void TokenList::dump()
-{
+ Stack stack;
+ stack.setRootNode(root);
+
+ //### Execute the token list
std::vector<Token *>::iterator iter;
printf("############# TOKENS\n");
for (iter = tokens.begin() ; iter != tokens.end() ; iter++)
{
Token *tok = *iter;
- tok->dump();
+ tok->execute(stack);
}
}
+ list = stack.getNodeList();
-//########################################################################
-//# X P A T H E X E C U T O R
-//########################################################################
-
-/**
- *
- */
-TokenExecutor::TokenExecutor()
-{
- reset();
+ return list;
}