You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by db...@apache.org on 2002/09/05 03:38:04 UTC
cvs commit: xml-xalan/c/src/XPath XPath.cpp XPath.hpp XPathInit.cpp XPathProcessorImpl.cpp XPathProcessorImpl.hpp
dbertoni 2002/09/04 18:38:03
Modified: c/src/XPath XPath.cpp XPath.hpp XPathInit.cpp
XPathProcessorImpl.cpp XPathProcessorImpl.hpp
Log:
Reduce start-up dynamic memory utilization.
Revision Changes Path
1.73 +83 -50 xml-xalan/c/src/XPath/XPath.cpp
Index: XPath.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
retrieving revision 1.72
retrieving revision 1.73
diff -u -r1.72 -r1.73
--- XPath.cpp 11 Jul 2002 00:29:11 -0000 1.72
+++ XPath.cpp 5 Sep 2002 01:38:03 -0000 1.73
@@ -430,7 +430,7 @@
{
eMatchScore score = eMatchScoreNone;
- const XalanDOMString* targetLocalName = 0;
+ const XalanDOMChar* targetLocalName = 0;
TargetData::eTargetType targetType = TargetData::eOther;
@@ -443,13 +443,13 @@
switch(stepType)
{
case XPathExpression::eOP_FUNCTION:
- targetLocalName = &PSEUDONAME_ANY;
+ targetLocalName = PSEUDONAME_ANY;
score = eMatchScoreOther;
targetType = TargetData::eAny;
break;
case XPathExpression::eFROM_ROOT:
- targetLocalName = &PSEUDONAME_ROOT;
+ targetLocalName = PSEUDONAME_ROOT;
score = eMatchScoreOther;
break;
@@ -465,27 +465,27 @@
switch(tok)
{
case XPathExpression::eNODETYPE_COMMENT:
- targetLocalName = &PSEUDONAME_COMMENT;
+ targetLocalName = PSEUDONAME_COMMENT;
score = eMatchScoreNodeTest;
break;
case XPathExpression::eNODETYPE_TEXT:
- targetLocalName = &PSEUDONAME_TEXT;
+ targetLocalName = PSEUDONAME_TEXT;
score = eMatchScoreNodeTest;
break;
case XPathExpression::eNODETYPE_NODE:
- targetLocalName = &PSEUDONAME_NODE;
+ targetLocalName = PSEUDONAME_NODE;
score = eMatchScoreNodeTest;
break;
case XPathExpression::eNODETYPE_ROOT:
- targetLocalName = &PSEUDONAME_ROOT;
+ targetLocalName = PSEUDONAME_ROOT;
score = eMatchScoreNodeTest;
break;
case XPathExpression::eNODETYPE_ANYELEMENT:
- targetLocalName = &PSEUDONAME_ANY;
+ targetLocalName = PSEUDONAME_ANY;
score = eMatchScoreNodeTest;
targetType = TargetData::eElement;
break;
@@ -495,7 +495,7 @@
const int argLen =
m_expression.getOpCodeMapValue(opPos - 3 + XPathExpression::s_opCodeMapLengthIndex + 1) - 3;
- targetLocalName = &PSEUDONAME_PI;
+ targetLocalName = PSEUDONAME_PI;
if (argLen == 1)
{
@@ -513,8 +513,17 @@
const XalanDOMString* const targetNamespace =
getStringFromTokenQueue(m_expression, opPos + 1);
- targetLocalName =
- getStringFromTokenQueue(m_expression, opPos + 2);
+ const XalanDOMString* const targetLocal =
+ getStringFromTokenQueue(m_expression, opPos + 2);
+
+ if (targetLocal == 0)
+ {
+ targetLocalName = 0;
+ }
+ else
+ {
+ targetLocalName = targetLocal->c_str();
+ }
targetType = fIsAttribute ?
TargetData::eAttribute :
@@ -522,9 +531,9 @@
if(targetLocalName != 0)
{
- if(::equals(*targetLocalName, PSEUDONAME_ANY) == true)
+ if(::equals(targetLocalName, PSEUDONAME_ANY) == true)
{
- targetLocalName = &PSEUDONAME_ANY;
+ targetLocalName = PSEUDONAME_ANY;
if (targetNamespace == 0 ||
::equals(*targetNamespace, PSEUDONAME_ANY) == true)
@@ -543,7 +552,7 @@
}
else
{
- targetLocalName = &PSEUDONAME_ANY;
+ targetLocalName = PSEUDONAME_ANY;
if (targetNamespace == 0 ||
::equals(*targetNamespace, PSEUDONAME_ANY) == true)
@@ -560,7 +569,7 @@
break;
default:
- targetLocalName = &PSEUDONAME_ANY;
+ targetLocalName = PSEUDONAME_ANY;
score = eMatchScoreNodeTest;
break;
}
@@ -578,8 +587,7 @@
score = eMatchScoreOther;
}
- targetData.push_back(
- TargetData(*targetLocalName, score, targetType));
+ targetData.push_back(TargetData(targetLocalName, score, targetType));
}
opPos = nextStepPos;
@@ -3668,23 +3676,64 @@
-static XalanDOMString PSEUDONAME_ANY;
-static XalanDOMString PSEUDONAME_ROOT;
-static XalanDOMString PSEUDONAME_TEXT;
-static XalanDOMString PSEUDONAME_COMMENT;
-static XalanDOMString PSEUDONAME_PI;
-static XalanDOMString PSEUDONAME_OTHER;
-static XalanDOMString PSEUDONAME_NODE;
-
-
-
-const XalanDOMString& XPath::PSEUDONAME_ANY = ::PSEUDONAME_ANY;
-const XalanDOMString& XPath::PSEUDONAME_ROOT = ::PSEUDONAME_ROOT;
-const XalanDOMString& XPath::PSEUDONAME_TEXT = ::PSEUDONAME_TEXT;
-const XalanDOMString& XPath::PSEUDONAME_COMMENT = ::PSEUDONAME_COMMENT;
-const XalanDOMString& XPath::PSEUDONAME_PI = ::PSEUDONAME_PI;
-const XalanDOMString& XPath::PSEUDONAME_OTHER = ::PSEUDONAME_OTHER;
-const XalanDOMString& XPath::PSEUDONAME_NODE = ::PSEUDONAME_NODE;
+const XalanDOMChar XPath::PSEUDONAME_ANY[] =
+{
+ XalanUnicode::charAsterisk,
+ 0
+};
+
+const XalanDOMChar XPath::PSEUDONAME_ROOT[] =
+{
+ XalanUnicode::charSolidus,
+ 0
+};
+
+const XalanDOMChar XPath::PSEUDONAME_TEXT[] =
+{
+ XalanUnicode::charNumberSign,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_x,
+ XalanUnicode::charLetter_t,
+ 0
+};
+
+const XalanDOMChar XPath::PSEUDONAME_COMMENT[] =
+{
+ XalanUnicode::charNumberSign,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_m,
+ XalanUnicode::charLetter_m,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_t,
+ 0
+};
+
+const XalanDOMChar XPath::PSEUDONAME_PI[] =
+{
+ XalanUnicode::charNumberSign,
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charLetter_i,
+ 0
+};
+
+const XalanDOMChar XPath::PSEUDONAME_OTHER[] =
+{
+ XalanUnicode::charAsterisk,
+ 0
+};
+
+const XalanDOMChar XPath::PSEUDONAME_NODE[] =
+{
+ XalanUnicode::charNumberSign,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_e,
+ 0
+};
@@ -3697,14 +3746,6 @@
XPath::initialize()
{
s_functions.CreateTable();
-
- ::PSEUDONAME_ANY = XALAN_STATIC_UCODE_STRING("*");
- ::PSEUDONAME_ROOT = XALAN_STATIC_UCODE_STRING("/");
- ::PSEUDONAME_TEXT = XALAN_STATIC_UCODE_STRING("#text");
- ::PSEUDONAME_COMMENT = XALAN_STATIC_UCODE_STRING("#comment");
- ::PSEUDONAME_PI = XALAN_STATIC_UCODE_STRING("#pi");
- ::PSEUDONAME_OTHER = XALAN_STATIC_UCODE_STRING("*");
- ::PSEUDONAME_NODE = XALAN_STATIC_UCODE_STRING("#node");
}
@@ -3712,13 +3753,5 @@
void
XPath::terminate()
{
- releaseMemory(::PSEUDONAME_ANY);
- releaseMemory(::PSEUDONAME_ROOT);
- releaseMemory(::PSEUDONAME_TEXT);
- releaseMemory(::PSEUDONAME_COMMENT);
- releaseMemory(::PSEUDONAME_PI);
- releaseMemory(::PSEUDONAME_OTHER);
- releaseMemory(::PSEUDONAME_NODE);
-
s_functions.DestroyTable();
}
1.33 +13 -13 xml-xalan/c/src/XPath/XPath.hpp
Index: XPath.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.hpp,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- XPath.hpp 11 Jul 2002 00:29:11 -0000 1.32
+++ XPath.hpp 5 Sep 2002 01:38:03 -0000 1.33
@@ -94,13 +94,13 @@
{
public:
- static const XalanDOMString& PSEUDONAME_ANY;
- static const XalanDOMString& PSEUDONAME_ROOT;
- static const XalanDOMString& PSEUDONAME_TEXT;
- static const XalanDOMString& PSEUDONAME_COMMENT;
- static const XalanDOMString& PSEUDONAME_PI;
- static const XalanDOMString& PSEUDONAME_OTHER;
- static const XalanDOMString& PSEUDONAME_NODE;
+ static const XalanDOMChar PSEUDONAME_ANY[];
+ static const XalanDOMChar PSEUDONAME_ROOT[];
+ static const XalanDOMChar PSEUDONAME_TEXT[];
+ static const XalanDOMChar PSEUDONAME_COMMENT[];
+ static const XalanDOMChar PSEUDONAME_PI[];
+ static const XalanDOMChar PSEUDONAME_OTHER[];
+ static const XalanDOMChar PSEUDONAME_NODE[];
enum eMatchScore
{
@@ -118,14 +118,14 @@
enum eTargetType { eAttribute, eElement, eAny, eOther };
TargetData() :
- m_string(),
+ m_string(0),
m_priority(eMatchScoreNone),
m_targetType(eOther)
{
}
TargetData(
- const XalanDOMString& theString,
+ const XalanDOMChar* theString,
eMatchScore thePriority,
eTargetType theTargetType) :
m_string(theString),
@@ -134,7 +134,7 @@
{
}
- const XalanDOMString&
+ const XalanDOMChar*
getString() const
{
return m_string;
@@ -154,11 +154,11 @@
private:
- XalanDOMString m_string;
+ const XalanDOMChar* m_string;
- eMatchScore m_priority;
+ eMatchScore m_priority;
- eTargetType m_targetType;
+ eTargetType m_targetType;
};
#if defined(XALAN_NO_NAMESPACES)
1.4 +0 -4 xml-xalan/c/src/XPath/XPathInit.cpp
Index: XPathInit.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathInit.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XPathInit.cpp 9 Nov 2000 19:39:30 -0000 1.3
+++ XPathInit.cpp 5 Sep 2002 01:38:03 -0000 1.4
@@ -106,8 +106,6 @@
XPath::initialize();
- XPathProcessorImpl::initialize();
-
XPathEnvSupportDefault::initialize();
}
@@ -117,8 +115,6 @@
XPathInit::terminate()
{
XPathEnvSupportDefault::terminate();
-
- XPathProcessorImpl::terminate();
XPath::terminate();
1.59 +485 -286 xml-xalan/c/src/XPath/XPathProcessorImpl.cpp
Index: XPathProcessorImpl.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.cpp,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- XPathProcessorImpl.cpp 16 Aug 2002 19:30:38 -0000 1.58
+++ XPathProcessorImpl.cpp 5 Sep 2002 01:38:03 -0000 1.59
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -70,6 +70,7 @@
#include <PlatformSupport/DOMStringPrintWriter.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
#include <PlatformSupport/PrefixResolver.hpp>
+#include <PlatformSupport/XalanUnicode.hpp>
#include <PlatformSupport/XalanXMLChar.hpp>
@@ -196,9 +197,7 @@
void
-XPathProcessorImpl::tokenize(
- const XalanDOMString& pat,
- DOMStringVectorType* targetStrings)
+XPathProcessorImpl::tokenize(const XalanDOMString& pat)
{
m_expression->setCurrentPattern(pat);
@@ -390,11 +389,6 @@
{
if(XalanUnicode::charVerticalLine == c)
{
- if(0 != targetStrings)
- {
- recordTokenString(*targetStrings);
- }
-
isStartOfPat = true;
}
}
@@ -513,10 +507,6 @@
{
error("Empty expression!");
}
- else if (0 != targetStrings)
- {
- recordTokenString(*targetStrings);
- }
m_expression->setTokenPosition(0);
}
@@ -551,72 +541,6 @@
void
-XPathProcessorImpl::recordTokenString(DOMStringVectorType& targetStrings)
-{
- assert(m_expression != 0);
-
- int tokPos = getTokenQueuePosFromMap(m_expression->patternMapSize() - 1);
-
- resetTokenMark(tokPos + 1);
-
- if(lookahead(XalanUnicode::charLeftParenthesis, 1) == true)
- {
- const int tok = getKeywordToken(m_token);
-
- switch(tok)
- {
- case XPathExpression::eNODETYPE_COMMENT:
- targetStrings.push_back(XPath::PSEUDONAME_COMMENT);
- break;
-
- case XPathExpression::eNODETYPE_TEXT:
- targetStrings.push_back(XPath::PSEUDONAME_TEXT);
- break;
-
- case XPathExpression::eNODETYPE_NODE:
- targetStrings.push_back(XPath::PSEUDONAME_ANY);
- break;
-
- case XPathExpression::eNODETYPE_ROOT:
- targetStrings.push_back(XPath::PSEUDONAME_ROOT);
- break;
-
- case XPathExpression::eNODETYPE_ANYELEMENT:
- targetStrings.push_back(XPath::PSEUDONAME_ANY);
- break;
-
- case XPathExpression::eNODETYPE_PI:
- targetStrings.push_back(XPath::PSEUDONAME_ANY);
- break;
-
- default:
- targetStrings.push_back(XPath::PSEUDONAME_ANY);
- break;
- }
- }
- else
- {
- if(tokenIs(XalanUnicode::charCommercialAt) == true)
- {
- tokPos++;
-
- resetTokenMark(tokPos + 1);
- }
-
- if(lookahead(XalanUnicode::charColon, 1) == true)
- {
- tokPos += 2;
- }
-
- assert(m_expression->getToken(tokPos) != 0);
-
- targetStrings.push_back(m_expression->getToken(tokPos)->str());
- }
-}
-
-
-
-void
XPathProcessorImpl::addToTokenQueue(const XalanDOMString& s) const
{
assert(m_xpath != 0);
@@ -1086,40 +1010,63 @@
}
-
+#if 0
int
-XPathProcessorImpl::getKeywordToken(const XalanDOMString& key) const
+XPathProcessorImpl::getFunctionToken(const XalanDOMString& key) const
{
- KeywordsMapType::const_iterator i =
- s_keywords.find(key);
-
- if (i == s_keywords.end())
+ if (equals(key, s_commentString) == true)
{
- return 0;
+ return XPathExpression::eNODETYPE_COMMENT;
+ }
+ else if (equals(key, s_piString) == true)
+ {
+ return XPathExpression::eNODETYPE_PI;
+ }
+ else if (equals(key, s_nodeString) == true)
+ {
+ return XPathExpression::eNODETYPE_NODE;
+ }
+ else if (equals(key, s_textString) == true)
+ {
+ return XPathExpression::eNODETYPE_TEXT;
}
else
{
- return (*i).second;
+ return -1;
}
}
-int
-XPathProcessorImpl::getFunctionToken(const XalanDOMString& key) const
+XPathExpression::eOpCodes
+XPathProcessorImpl::getNodeTypeToken(const XalanDOMString& key) const
{
- FunctionNameMapType::const_iterator i = s_functions.find(key);
-
- if (i != s_functions.end())
+ if (equals(key, s_asteriskString) == true)
{
- return (*i).second;
+ return XPathExpression::eNODETYPE_ANYELEMENT;
+ }
+ else if (equals(key, s_commentString) == true)
+ {
+ return XPathExpression::eNODETYPE_COMMENT;
+ }
+ else if (equals(key, s_piString) == true)
+ {
+ return XPathExpression::eNODETYPE_PI;
+ }
+ else if (equals(key, s_nodeString) == true)
+ {
+ return XPathExpression::eNODETYPE_NODE;
+ }
+ else if (equals(key, s_textString) == true)
+ {
+ return XPathExpression::eNODETYPE_TEXT;
}
else
{
- return 0;
+ return XPathExpression::eENDOP;
}
}
-
+#endif
void
@@ -1784,7 +1731,7 @@
TranscodeFromLocalCodePage("()"));
}
- const int funcTok = getFunctionToken(m_token);
+ const XPathExpression::eOpCodes funcTok = getFunctionToken(m_token);
switch(funcTok)
{
@@ -1806,23 +1753,20 @@
int theFunctionID =
XPath::getFunctionTable().nameToID(m_token);
- // This code is disabled for the time being, as
- // it needs more testing.
-#if 1
if (equals(m_token, s_positionString) == true &&
m_positionPredicateStack.empty() == false)
{
m_positionPredicateStack.back() = true;
}
-#endif
XPathExpression::OpCodeMapValueVectorType theArgs(2, 0);
theArgs[0] = theFunctionID;
theArgs[1] = 0;
- m_expression->appendOpCode(XPathExpression::eOP_FUNCTION,
- theArgs);
+ m_expression->appendOpCode(
+ XPathExpression::eOP_FUNCTION,
+ theArgs);
}
}
@@ -1970,7 +1914,7 @@
const int opPos = m_expression->opCodeMapLength();
- int axisType = 0;
+ XPathExpression::eOpCodes axisType = XPathExpression::eENDOP;
// The next blocks guarantee that a FROM_XXX will be added.
if(lookahead(s_axisString, 1) == true)
@@ -2032,32 +1976,31 @@
-int
+XPathExpression::eOpCodes
XPathProcessorImpl::AxisName()
{
assert(m_xpath != 0);
assert(m_expression != 0);
- const AxisNamesMapType::const_iterator i =
- s_axisNames.find(m_token);
+ const XPathExpression::eOpCodes theOpCode =
+ getAxisToken(m_token);
- if (i == s_axisNames.end())
+ if (theOpCode == XPathExpression::eENDOP)
{
- error(TranscodeFromLocalCodePage("illegal axis name: ") +
- m_token);
+ error(TranscodeFromLocalCodePage("Illegal axis name: ") + m_token);
}
else
{
- m_expression->appendOpCode((*i).second);
+ m_expression->appendOpCode(theOpCode);
}
- return (*i).second;
+ return theOpCode;
}
int
-XPathProcessorImpl::NodeTest(int axisType)
+XPathProcessorImpl::NodeTest(XPathExpression::eOpCodes axisType)
{
assert(m_xpath != 0);
assert(m_expression != 0);
@@ -2066,10 +2009,9 @@
if(lookahead(XalanUnicode::charLeftParenthesis, 1) == true)
{
- NodeTypesMapType::const_iterator i =
- s_nodeTypes.find(m_token);
+ const XPathExpression::eOpCodes theOpCode = getNodeTypeToken(m_token);
- if (i == s_nodeTypes.end())
+ if (theOpCode == XPathExpression::eENDOP)
{
error(TranscodeFromLocalCodePage("Unknown nodetype: ") +
m_token);
@@ -2078,11 +2020,11 @@
{
nextToken();
- nodeTestPos = m_expression->appendOpCode((*i).second);
+ nodeTestPos = m_expression->appendOpCode(theOpCode);
consumeExpected(XalanUnicode::charLeftParenthesis);
- if(XPathExpression::eNODETYPE_PI == (*i).second)
+ if(XPathExpression::eNODETYPE_PI == theOpCode)
{
if(tokenIs(XalanUnicode::charRightParenthesis) == false)
{
@@ -2556,13 +2498,13 @@
bool
-XPathProcessorImpl::isValidFunction(const XalanDOMString& key) const
+XPathProcessorImpl::isValidFunction(const XalanDOMString& key)
{
bool fResult = true;
if(XPath::isInstalledFunction(key) == false)
{
- if (getFunctionToken(key) == 0)
+ if (searchTable(s_functionTable, s_functionTableSize, key).m_opCode == XPathExpression::eENDOP)
{
fResult = false;
}
@@ -2619,10 +2561,10 @@
}
else
{
- const AxisNamesMapType::const_iterator i =
- s_axisNames.find(theToken);
+ const XPathExpression::eOpCodes theOpCode =
+ getAxisToken(theToken);
- if (i != s_axisNames.end())
+ if (theOpCode != XPathExpression::eENDOP)
{
return true;
}
@@ -2662,185 +2604,442 @@
-void
-XPathProcessorImpl::initializeKeywordsTable(KeywordsMapType& /* theKeywords */)
-{
- // $$$ ToDo: This is very confusing. This table is only used
- // by getKeywordToken(). But if you look at the switch
- // statement there, none of these values are considered in the
- // case statement. So what's the point?
-
- // theKeywords[FROM_SELF_ABBREVIATED_STRING] = XPathExpression::eFROM_SELF;
- // theKeywords[FROM_ATTRIBUTE_STRING] = XPathExpression::eFROM_ATTRIBUTE;
- // theKeywords[FROM_DOC_STRING] = XPathExpression::eFROM_DOC;
- // theKeywords[FROM_DOCREF_STRING] = XPathExpression::eFROM_DOCREF;
- // theKeywords[FROM_ID_STRING] = XPathExpression::eFROM_ID;
- // theKeywords[FROM_IDREF_STRING] = XPathExpression::eFROM_IDREF;
- // theKeywords[FUNC_ID_STRING] = XPathExpression::eFUNC_ID;
- // theKeywords[FUNC_KEY_STRING] = XPathExpression::eFUNC_KEY;
- // theKeywords[FUNC_DOCUMENT_STRING] = XPathExpression::eFUNC_DOC;
-}
-
-
-
-void
-XPathProcessorImpl::initializeFunctionTable(FunctionNameMapType& theFunctions)
+const XPathProcessorImpl::TableEntry&
+XPathProcessorImpl::searchTable(
+ const TableEntry theTable[],
+ size_type theTableSize,
+ const XalanDOMString& theString)
{
- theFunctions[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("processing-instruction"))] = XPathExpression::eNODETYPE_PI;
- theFunctions[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("comment"))] = XPathExpression::eNODETYPE_COMMENT;
- theFunctions[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("text"))] = XPathExpression::eNODETYPE_TEXT;
- theFunctions[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("node"))] = XPathExpression::eNODETYPE_NODE;
-}
-
+ const TableEntry* theFirst = theTable;
+ const TableEntry* theLast = &theTable[theTableSize - 1];
+ while(theFirst <= theLast)
+ {
+ const TableEntry* theCurrent = theFirst + (theLast - theFirst) / 2;
+ assert(theCurrent->m_string[0] != 0);
-void
-XPathProcessorImpl::initializeAxisNamesTable(AxisNamesMapType& theAxisNames)
-{
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("ancestor"))] = XPathExpression::eFROM_ANCESTORS;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("ancestor-or-self"))] = XPathExpression::eFROM_ANCESTORS_OR_SELF;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("attribute"))] = XPathExpression::eFROM_ATTRIBUTES;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("child"))] = XPathExpression::eFROM_CHILDREN;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("descendant"))] = XPathExpression::eFROM_DESCENDANTS;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("descendant-or-self"))] = XPathExpression::eFROM_DESCENDANTS_OR_SELF;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("following"))] = XPathExpression::eFROM_FOLLOWING;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("following-sibling"))] = XPathExpression::eFROM_FOLLOWING_SIBLINGS;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("parent"))] = XPathExpression::eFROM_PARENT;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("preceding"))] = XPathExpression::eFROM_PRECEDING;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("preceding-sibling"))] = XPathExpression::eFROM_PRECEDING_SIBLINGS;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("self"))] = XPathExpression::eFROM_SELF;
- theAxisNames[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("namespace"))] = XPathExpression::eFROM_NAMESPACE;
-}
-
+ const int theResult = compare(c_wstr(theString), theCurrent->m_string);
+ if (theResult < 0)
+ {
+ theLast = theCurrent - 1;
+ }
+ else if (theResult > 0)
+ {
+ theFirst = theCurrent + 1;
+ }
+ else
+ {
+ return *theCurrent;
+ }
+ }
-void
-XPathProcessorImpl::initializeNodeTypesTable(NodeTypesMapType& theNodeTypes)
-{
- theNodeTypes[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("comment"))] = XPathExpression::eNODETYPE_COMMENT;
- theNodeTypes[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("text"))] = XPathExpression::eNODETYPE_TEXT;
- theNodeTypes[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("processing-instruction"))] = XPathExpression::eNODETYPE_PI;
- theNodeTypes[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("node"))] = XPathExpression::eNODETYPE_NODE;
- theNodeTypes[StaticStringToDOMString(XALAN_STATIC_UCODE_STRING("*"))] = XPathExpression::eNODETYPE_ANYELEMENT;
+ return s_dummyEntry;
}
-static XalanDOMString s_functionIDString;
-
-static XalanDOMString s_functionKeyString;
-
-static XalanDOMString s_orString;
-
-static XalanDOMString s_andString;
-
-static XalanDOMString s_divString;
-
-static XalanDOMString s_modString;
-
-static XalanDOMString s_dotString;
-
-static XalanDOMString s_dotDotString;
-
-static XalanDOMString s_axisString;
-
-static XalanDOMString s_attributeString;
-
-static XalanDOMString s_childString;
-
-static XalanDOMString s_positionString;
-
-
-
const XalanDOMString XPathProcessorImpl::s_emptyString;
-const XalanDOMString& XPathProcessorImpl::s_functionIDString = ::s_functionIDString;
-
-
- // This shouldn't really be here, since it's not part of the XPath standard,
- // but rather a part ofthe XSLT standard.
-const XalanDOMString& XPathProcessorImpl::s_functionKeyString = ::s_functionKeyString;
-
-const XalanDOMString& XPathProcessorImpl::s_orString = ::s_orString;
-
-const XalanDOMString& XPathProcessorImpl::s_andString = ::s_andString;
-
-const XalanDOMString& XPathProcessorImpl::s_divString = ::s_divString;
-
-const XalanDOMString& XPathProcessorImpl::s_modString = ::s_modString;
-
-const XalanDOMString& XPathProcessorImpl::s_dotString = ::s_dotString;
-
-const XalanDOMString& XPathProcessorImpl::s_dotDotString = ::s_dotDotString;
-
-const XalanDOMString& XPathProcessorImpl::s_axisString = ::s_axisString;
-
-const XalanDOMString& XPathProcessorImpl::s_attributeString = ::s_attributeString;
-
-const XalanDOMString& XPathProcessorImpl::s_childString = ::s_childString;
-
-const XalanDOMString& XPathProcessorImpl::s_positionString = ::s_positionString;
-
-
-
-static XPathProcessorImpl::KeywordsMapType s_keywords;
-static XPathProcessorImpl::FunctionNameMapType s_functions;
-static XPathProcessorImpl::AxisNamesMapType s_axisNames;
-static XPathProcessorImpl::NodeTypesMapType s_nodeTypes;
-
-
-
-const XPathProcessorImpl::KeywordsMapType& XPathProcessorImpl::s_keywords = ::s_keywords;
-const XPathProcessorImpl::FunctionNameMapType& XPathProcessorImpl::s_functions = ::s_functions;
-const XPathProcessorImpl::AxisNamesMapType& XPathProcessorImpl::s_axisNames = ::s_axisNames;
-const XPathProcessorImpl::NodeTypesMapType& XPathProcessorImpl::s_nodeTypes = ::s_nodeTypes;
-
-
-
-void
-XPathProcessorImpl::initialize()
+const XalanDOMChar XPathProcessorImpl::s_functionIDString[] =
{
- initializeKeywordsTable(::s_keywords);
- initializeFunctionTable(::s_functions);
- initializeAxisNamesTable(::s_axisNames);
- initializeNodeTypesTable(::s_nodeTypes);
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_d,
+ 0
+};
+
+// This shouldn't really be here, since it's not part of the XPath standard,
+// but rather a part ofthe XSLT standard.
+const XalanDOMChar XPathProcessorImpl::s_functionKeyString[] =
+{
+ XalanUnicode::charLetter_k,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_y,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_orString[] =
+{
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_r,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_andString[] =
+{
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_d,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_divString[] =
+{
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_v,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_modString[] =
+{
+ XalanUnicode::charLetter_m,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_d,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_dotString[] =
+{
+ XalanUnicode::charFullStop,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_dotDotString[] =
+{
+ XalanUnicode::charFullStop,
+ XalanUnicode::charFullStop,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_axisString[] =
+{
+ XalanUnicode::charColon,
+ XalanUnicode::charColon,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_attributeString[] =
+{
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_b,
+ XalanUnicode::charLetter_u,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_e,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_childString[] =
+{
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_h,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_d,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_positionString[] =
+{
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_n,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_asteriskString[] =
+{
+ XalanUnicode::charAsterisk,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_commentString[] =
+{
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_m,
+ XalanUnicode::charLetter_m,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_t,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_piString[] =
+{
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_g,
+ XalanUnicode::charHyphenMinus,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_u,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_n,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_nodeString[] =
+{
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_e,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_textString[] =
+{
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_x,
+ XalanUnicode::charLetter_t,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_ancestorString[] =
+{
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_r,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_ancestorOrSelfString[] =
+{
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charHyphenMinus,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charHyphenMinus,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_f,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_descendantString[] =
+{
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_t,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_descendantOrSelfString[] =
+{
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_t,
+ XalanUnicode::charHyphenMinus,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charHyphenMinus,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_f,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_followingString[] =
+{
+ XalanUnicode::charLetter_f,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_w,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_g,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_followingSiblingString[] =
+{
+ XalanUnicode::charLetter_f,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_o,
+ XalanUnicode::charLetter_w,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_g,
+ XalanUnicode::charHyphenMinus,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_b,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_g,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_parentString[] =
+{
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_t,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_precedingString[] =
+{
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_g,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_precedingSiblingString[] =
+{
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charLetter_r,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_d,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_g,
+ XalanUnicode::charHyphenMinus,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_b,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_i,
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_g,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_selfString[] =
+{
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_l,
+ XalanUnicode::charLetter_f,
+ 0
+};
+
+const XalanDOMChar XPathProcessorImpl::s_namespaceString[] =
+{
+ XalanUnicode::charLetter_n,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_m,
+ XalanUnicode::charLetter_e,
+ XalanUnicode::charLetter_s,
+ XalanUnicode::charLetter_p,
+ XalanUnicode::charLetter_a,
+ XalanUnicode::charLetter_c,
+ XalanUnicode::charLetter_e,
+ 0
+};
+
+
+
+const XPathProcessorImpl::TableEntry XPathProcessorImpl::s_functionTable[] =
+{
+ { XPathProcessorImpl::s_nodeString, XPathExpression::eNODETYPE_NODE },
+ { XPathProcessorImpl::s_textString, XPathExpression::eNODETYPE_TEXT },
+ { XPathProcessorImpl::s_commentString, XPathExpression::eNODETYPE_COMMENT },
+ { XPathProcessorImpl::s_piString, XPathExpression::eNODETYPE_PI },
+};
+
+const XPathProcessorImpl::size_type XPathProcessorImpl::s_functionTableSize =
+ sizeof(s_functionTable) / sizeof(s_functionTable[0]);
+
+
+
+const XPathProcessorImpl::TableEntry XPathProcessorImpl::s_nodeTypeTable[] =
+{
+ { XPathProcessorImpl::s_asteriskString, XPathExpression::eNODETYPE_ANYELEMENT },
+ { XPathProcessorImpl::s_nodeString, XPathExpression::eNODETYPE_NODE },
+ { XPathProcessorImpl::s_textString, XPathExpression::eNODETYPE_TEXT },
+ { XPathProcessorImpl::s_commentString, XPathExpression::eNODETYPE_COMMENT },
+ { XPathProcessorImpl::s_piString, XPathExpression::eNODETYPE_PI },
+};
+
+const XPathProcessorImpl::size_type XPathProcessorImpl::s_nodeTypeTableSize =
+ sizeof(s_nodeTypeTable) / sizeof(s_nodeTypeTable[0]);
+
+
+
+const XPathProcessorImpl::TableEntry XPathProcessorImpl::s_axisTable[] =
+{
+ { XPathProcessorImpl::s_selfString, XPathExpression::eFROM_SELF },
+ { XPathProcessorImpl::s_childString, XPathExpression::eFROM_CHILDREN },
+ { XPathProcessorImpl::s_parentString, XPathExpression::eFROM_PARENT },
+ { XPathProcessorImpl::s_ancestorString, XPathExpression::eFROM_ANCESTORS },
+ { XPathProcessorImpl::s_attributeString, XPathExpression::eFROM_ATTRIBUTES },
+ { XPathProcessorImpl::s_followingString, XPathExpression::eFROM_FOLLOWING },
+ { XPathProcessorImpl::s_namespaceString, XPathExpression::eFROM_NAMESPACE },
+ { XPathProcessorImpl::s_precedingString, XPathExpression::eFROM_PRECEDING },
+ { XPathProcessorImpl::s_descendantString, XPathExpression::eFROM_DESCENDANTS },
+ { XPathProcessorImpl::s_ancestorOrSelfString, XPathExpression::eFROM_ANCESTORS_OR_SELF },
+ { XPathProcessorImpl::s_followingSiblingString, XPathExpression::eFROM_FOLLOWING_SIBLINGS },
+ { XPathProcessorImpl::s_precedingSiblingString, XPathExpression::eFROM_PRECEDING_SIBLINGS },
+ { XPathProcessorImpl::s_descendantOrSelfString, XPathExpression::eFROM_DESCENDANTS_OR_SELF },
+};
- ::s_functionIDString = XALAN_STATIC_UCODE_STRING("id");
- ::s_functionKeyString = XALAN_STATIC_UCODE_STRING("key");
- ::s_orString = XALAN_STATIC_UCODE_STRING("or");
- ::s_andString = XALAN_STATIC_UCODE_STRING("and");
- ::s_divString = XALAN_STATIC_UCODE_STRING("div");
- ::s_modString = XALAN_STATIC_UCODE_STRING("mod");
- ::s_dotString = XALAN_STATIC_UCODE_STRING(".");
- ::s_dotDotString = XALAN_STATIC_UCODE_STRING("..");
- ::s_axisString = XALAN_STATIC_UCODE_STRING("::");
- ::s_attributeString = XALAN_STATIC_UCODE_STRING("attribute");
- ::s_childString = XALAN_STATIC_UCODE_STRING("child");
- ::s_positionString = XALAN_STATIC_UCODE_STRING("position");
-}
+const XPathProcessorImpl::size_type XPathProcessorImpl::s_axisTableSize =
+ sizeof(s_axisTable) / sizeof(s_axisTable[0]);
-
-void
-XPathProcessorImpl::terminate()
+const XPathProcessorImpl::TableEntry XPathProcessorImpl::s_dummyEntry =
{
- KeywordsMapType().swap(::s_keywords);
- FunctionNameMapType().swap(::s_functions);
- AxisNamesMapType().swap(::s_axisNames);
- NodeTypesMapType().swap(::s_nodeTypes);
-
- releaseMemory(::s_functionIDString);
- releaseMemory(::s_functionKeyString);
- releaseMemory(::s_orString);
- releaseMemory(::s_andString);
- releaseMemory(::s_divString);
- releaseMemory(::s_modString);
- releaseMemory(::s_dotString);
- releaseMemory(::s_dotDotString);
- releaseMemory(::s_axisString);
- releaseMemory(::s_attributeString);
- releaseMemory(::s_childString);
- releaseMemory(::s_positionString);
-}
+ 0, XPathExpression::eENDOP
+};
1.23 +99 -91 xml-xalan/c/src/XPath/XPathProcessorImpl.hpp
Index: XPathProcessorImpl.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathProcessorImpl.hpp,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- XPathProcessorImpl.hpp 16 Aug 2002 19:30:38 -0000 1.22
+++ XPathProcessorImpl.hpp 5 Sep 2002 01:38:03 -0000 1.23
@@ -64,7 +64,8 @@
-#include <set>
+#include <cstdlib>
+#include <map>
#include <vector>
@@ -96,54 +97,17 @@
#if defined(XALAN_NO_NAMESPACES)
typedef map<XalanDOMString,
- int,
- less<XalanDOMString> > KeywordsMapType;
- typedef map<XalanDOMString,
- XPathExpression::eOpCodes,
- less<XalanDOMString> > FunctionNameMapType;
- typedef map<XalanDOMString,
- XPathExpression::eOpCodes,
- less<XalanDOMString> > AxisNamesMapType;
- typedef map<XalanDOMString,
- XPathExpression::eOpCodes,
- less<XalanDOMString> > NodeTypesMapType;
- typedef map<XalanDOMString,
XalanDOMString,
- less<XalanDOMString> > StringToStringMapType;
+ less<XalanDOMString> > StringToStringMapType;
- typedef vector<XalanDOMString> DOMStringVectorType;
-
- typedef vector<bool> BoolVectorType;
+ typedef vector<bool> BoolVectorType;
#else
typedef std::map<XalanDOMString,
- int> KeywordsMapType;
- typedef std::map<XalanDOMString,
- XPathExpression::eOpCodes> FunctionNameMapType;
- typedef std::map<XalanDOMString,
- XPathExpression::eOpCodes> AxisNamesMapType;
- typedef std::map<XalanDOMString,
- XPathExpression::eOpCodes> NodeTypesMapType;
- typedef std::map<XalanDOMString,
- XalanDOMString> StringToStringMapType;
-
- typedef std::vector<XalanDOMString> DOMStringVectorType;
+ XalanDOMString> StringToStringMapType;
- typedef std::vector<bool> BoolVectorType;
+ typedef std::vector<bool> BoolVectorType;
#endif
- /**
- * Perform static initialization. See class XPathInit.
- */
- static void
- initialize();
-
- /**
- * Perform static shut down. See class XPathInit.
- */
- static void
- terminate();
-
- explicit
XPathProcessorImpl();
virtual
@@ -173,12 +137,9 @@
* top-level elements.
*
* @param pat XSLT Expression.
- * @param targetStrings Vector to hold Strings, may be null.
*/
void
- tokenize(
- const XalanDOMString& pat,
- DOMStringVectorType* targetStrings = 0);
+ tokenize(const XalanDOMString& pat);
/**
* Record the current position on the token queue as long as this is a
@@ -191,12 +152,6 @@
bool isStart,
bool isAttrName) const;
- /**
- * Record the correct token string in the passed vector.
- */
- void
- recordTokenString(DOMStringVectorType& targetStrings);
-
void
addToTokenQueue(const XalanDOMString& s) const;
@@ -438,14 +393,29 @@
/**
* Given a string, return the corresponding token.
*/
- int
- getKeywordToken(const XalanDOMString& key) const;
+ static XPathExpression::eOpCodes
+ getFunctionToken(const XalanDOMString& key)
+ {
+ return searchTable(s_functionTable, s_functionTableSize, key).m_opCode;
+ }
/**
* Given a string, return the corresponding token.
*/
- int
- getFunctionToken(const XalanDOMString& key) const;
+ static XPathExpression::eOpCodes
+ getNodeTypeToken(const XalanDOMString& key)
+ {
+ return searchTable(s_nodeTypeTable, s_nodeTypeTableSize, key).m_opCode;
+ }
+
+ /**
+ * Given a string, return the corresponding token.
+ */
+ static XPathExpression::eOpCodes
+ getAxisToken(const XalanDOMString& key)
+ {
+ return searchTable(s_axisTable, s_axisTableSize, key).m_opCode;
+ }
/**
*
@@ -662,7 +632,7 @@
Basis ::= AxisName '::' NodeTest
| AbbreviatedBasis
*/
- int
+ XPathExpression::eOpCodes
AxisName();
/**
@@ -672,7 +642,7 @@
| 'processing-instruction' '(' Literal ')'
*/
int
- NodeTest(int axisType);
+ NodeTest(XPathExpression::eOpCodes axisType);
/**
* --------------------------------------------------------------------------------
@@ -780,25 +750,32 @@
void
AbbreviatedNodeTestStep();
- bool
- isValidFunction(const XalanDOMString& key) const;
+ static bool
+ isValidFunction(const XalanDOMString& key);
private:
int
FunctionCallArguments();
- static void
- initializeKeywordsTable(KeywordsMapType& theKeywords);
+ struct TableEntry
+ {
+ const XalanDOMChar* m_string;
- static void
- initializeFunctionTable(FunctionNameMapType& theFunctions);
+ XPathExpression::eOpCodes m_opCode;
+ };
- static void
- initializeAxisNamesTable(AxisNamesMapType& theAxisNames);
+#if defined(XALAN_SIZE_T_IN_NAMESPACE_STD)
+ typedef std::size_t size_type;
+#else
+ typedef size_t size_type;
+#endif
- static void
- initializeNodeTypesTable(NodeTypesMapType& theNodeTypes);
+ static const TableEntry&
+ searchTable(
+ const TableEntry theTable[],
+ size_type theTableSize,
+ const XalanDOMString& theString);
/**
* The current input token.
@@ -844,46 +821,77 @@
static const XalanDOMString s_emptyString;
- // This shouldn't really be here, since it duplicates a string that is part
- // of the information that is maintained by the class XPathFunctionTable,
- // but this is a reasonable optimization.
- static const XalanDOMString& s_functionIDString;
-
+ static const XalanDOMChar s_functionIDString[];
// This shouldn't really be here, since it's not part of the XPath standard,
// but rather a part ofthe XSLT standard.
- static const XalanDOMString& s_functionKeyString;
+ static const XalanDOMChar s_functionKeyString[];
- static const XalanDOMString& s_orString;
+ static const XalanDOMChar s_orString[];
- static const XalanDOMString& s_andString;
+ static const XalanDOMChar s_andString[];
- static const XalanDOMString& s_divString;
+ static const XalanDOMChar s_divString[];
- static const XalanDOMString& s_modString;
+ static const XalanDOMChar s_modString[];
- static const XalanDOMString& s_dotString;
+ static const XalanDOMChar s_dotString[];
- static const XalanDOMString& s_dotDotString;
+ static const XalanDOMChar s_dotDotString[];
- static const XalanDOMString& s_axisString;
+ static const XalanDOMChar s_axisString[];
- static const XalanDOMString& s_attributeString;
+ static const XalanDOMChar s_attributeString[];
- static const XalanDOMString& s_childString;
+ static const XalanDOMChar s_childString[];
- static const XalanDOMString& s_positionString;
+ static const XalanDOMChar s_positionString[];
- /**
- * Map of keyword names to token values.
- */
- static const KeywordsMapType& s_keywords;
+ static const XalanDOMChar s_asteriskString[];
+
+ static const XalanDOMChar s_commentString[];
+
+ static const XalanDOMChar s_piString[];
+
+ static const XalanDOMChar s_nodeString[];
+
+ static const XalanDOMChar s_textString[];
+
+ static const XalanDOMChar s_ancestorString[];
+
+ static const XalanDOMChar s_ancestorOrSelfString[];
+
+ static const XalanDOMChar s_descendantString[];
+
+ static const XalanDOMChar s_descendantOrSelfString[];
+
+ static const XalanDOMChar s_followingString[];
+
+ static const XalanDOMChar s_followingSiblingString[];
+
+ static const XalanDOMChar s_parentString[];
+
+ static const XalanDOMChar s_precedingString[];
+
+ static const XalanDOMChar s_precedingSiblingString[];
+
+ static const XalanDOMChar s_selfString[];
+
+ static const XalanDOMChar s_namespaceString[];
+
+ static const TableEntry s_functionTable[];
+
+ static const size_type s_functionTableSize;
+
+ static const TableEntry s_nodeTypeTable[];
+
+ static const size_type s_nodeTypeTableSize;
- static const FunctionNameMapType& s_functions;
+ static const TableEntry s_axisTable[];
- static const AxisNamesMapType& s_axisNames;
+ static const size_type s_axisTableSize;
- static const NodeTypesMapType& s_nodeTypes;
+ static const TableEntry s_dummyEntry;
};
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org