summaryrefslogtreecommitdiffstats
path: root/src/dom/xpathtoken.cpp
diff options
context:
space:
mode:
authorBob Jamison <ishmalius@gmail.com>2006-04-28 21:26:40 +0000
committerishmal <ishmal@users.sourceforge.net>2006-04-28 21:26:40 +0000
commit4d8c0393fa42b90ecedc16b3b2ea15ada05aa15b (patch)
treeb64f4bae030fbdaceec334930b0ae4f64e74077b /src/dom/xpathtoken.cpp
parentBug 1478136 fix - "foo2" was shown instead of guideline id in Guideline dialog (diff)
downloadinkscape-4d8c0393fa42b90ecedc16b3b2ea15ada05aa15b.tar.gz
inkscape-4d8c0393fa42b90ecedc16b3b2ea15ada05aa15b.zip
Clean up type strings
(bzr r608)
Diffstat (limited to 'src/dom/xpathtoken.cpp')
-rw-r--r--src/dom/xpathtoken.cpp105
1 files changed, 105 insertions, 0 deletions
diff --git a/src/dom/xpathtoken.cpp b/src/dom/xpathtoken.cpp
index bed022943..5de011959 100644
--- a/src/dom/xpathtoken.cpp
+++ b/src/dom/xpathtoken.cpp
@@ -42,6 +42,111 @@ namespace dom
namespace xpath
{
+//########################################################################
+//# X P A T H T O K E N
+//########################################################################
+
+typedef struct
+{
+ int ival;
+ char *sval;
+} TokenStringPair;
+
+static TokenStringPair tokenStrings[] =
+{
+ //primitives
+ { Token::TOK_NOP, "nop" },
+ { Token::TOK_STR, "str" },
+ { Token::TOK_INT, "int" },
+ { Token::TOK_FLOAT, "float" },
+ //operators
+ { Token::TOK_AND, "and" },
+ { Token::TOK_OR, "or" },
+ { Token::TOK_MOD, "mod" },
+ { Token::TOK_DIV, "div" },
+ { Token::TOK_MULTIPLY, "multiply" },
+ { Token::TOK_DOUBLE_SLASH, "double-slash" },
+ { Token::TOK_SLASH, "slash" },
+ { Token::TOK_PIPE, "pipe" },
+ { Token::TOK_PLUS, "plus" },
+ { Token::TOK_MINUS, "minus" },
+ { Token::TOK_NEG, "neg" },
+ { Token::TOK_EQUALS, "equals" },
+ { Token::TOK_NOT_EQUALS, "not-equals" },
+ { Token::TOK_LESS_THAN_EQUALS, "less-than-equals" },
+ { Token::TOK_LESS_THAN, "less-than" },
+ { Token::TOK_GREATER_THAN_EQUALS, "greater-than-equals" },
+ { Token::TOK_GREATER_THAN, "greater-than" },
+ //path types
+ { Token::TOK_ABSOLUTE, "absolute" },
+ { Token::TOK_RELATIVE, "relative" },
+ { Token::TOK_STEP, "step" },
+ { Token::TOK_NAME_TEST, "name-test" },
+ { Token::TOK_EXPR, "expr" },
+ { Token::TOK_UNION, "union" },
+ //axis types
+ { Token::TOK_AXIS_ANCESTOR_OR_SELF, "axis-ancestor-or-self" },
+ { Token::TOK_AXIS_ANCESTOR, "axis-ancestor" },
+ { Token::TOK_AXIS_ATTRIBUTE, "axis-attribute" },
+ { Token::TOK_AXIS_CHILD, "axis-child" },
+ { Token::TOK_AXIS_DESCENDANT_OR_SELF, "axis-descendant-or-self" },
+ { Token::TOK_AXIS_DESCENDANT, "axis-descendant" },
+ { Token::TOK_AXIS_FOLLOWING_SIBLING, "axis-following-sibling" },
+ { Token::TOK_AXIS_FOLLOWING, "axis-following" },
+ { Token::TOK_AXIS_NAMESPACE, "axis-namespace" },
+ { Token::TOK_AXIS_PARENT, "axis-parent" },
+ { Token::TOK_AXIS_PRECEDING_SIBLING, "axis-preceding-sibling" },
+ { Token::TOK_AXIS_PRECEDING, "axis-preceding" },
+ { Token::TOK_AXIS_SELF, "axis-self" },
+ //function types
+ { Token::TOK_FUNC_LAST, "func-last" },
+ { Token::TOK_FUNC_POSITION, "func-position" },
+ { Token::TOK_FUNC_COUNT, "func-count" },
+ { Token::TOK_FUNC_ID, "func-id" },
+ { Token::TOK_FUNC_LOCAL_NAME, "func-local-name" },
+ { Token::TOK_FUNC_NAMESPACE_URI, "func-namespace-uri" },
+ { Token::TOK_FUNC_NAME, "func-name" },
+ { Token::TOK_FUNC_STRING, "func-string" },
+ { Token::TOK_FUNC_CONCAT, "func-concat" },
+ { Token::TOK_FUNC_STARTS_WITH, "func-starts-with" },
+ { Token::TOK_FUNC_CONTAINS, "func-contains" },
+ { Token::TOK_FUNC_SUBSTRING_BEFORE, "func-substring-before" },
+ { Token::TOK_FUNC_SUBSTRING_AFTER, "func-substring-after" },
+ { Token::TOK_FUNC_SUBSTRING, "func-substring" },
+ { Token::TOK_FUNC_STRING_LENGTH, "func-string-length" },
+ { Token::TOK_FUNC_NORMALIZE_SPACE, "func-normalize-space" },
+ { Token::TOK_FUNC_TRANSLATE, "func-translate" },
+ { Token::TOK_FUNC_BOOLEAN, "func-boolean" },
+ { Token::TOK_FUNC_NOT, "func-not" },
+ { Token::TOK_FUNC_TRUE, "func-true" },
+ { Token::TOK_FUNC_FALSE, "func-false" },
+ { Token::TOK_FUNC_LANG, "func-lang" },
+ { Token::TOK_FUNC_NUMBER, "func-number" },
+ { Token::TOK_FUNC_SUM, "func-sum" },
+ { Token::TOK_FUNC_FLOOR, "func-floor" },
+ { Token::TOK_FUNC_CEILING, "func-ceiling" },
+ { Token::TOK_FUNC_ROUND, "func-round" },
+ { -1, (char *)0 }
+};
+
+
+/**
+ * Return the enumerated TokenType of this token
+ * (in the .cpp file)
+ */
+DOMString Token::getTypeString()
+{
+ DOMString ret;
+ for (TokenStringPair *pair = tokenStrings ; pair->sval ; pair++)
+ {
+ if (pair->ival == type)
+ {
+ ret = pair->sval;
+ break;
+ }
+ }
+ return ret;
+}
//########################################################################
//# X P A T H S T A C K I T E M