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...@locus.apache.org on 2000/05/01 17:38:35 UTC
cvs commit: xml-xalan/c/src/XPath FunctionID.hpp
dbertoni 00/05/01 08:38:35
Modified: c/src/XPath FunctionID.hpp
Log:
Made FunctionID re-entrant.
Revision Changes Path
1.6 +85 -67 xml-xalan/c/src/XPath/FunctionID.hpp
Index: FunctionID.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/FunctionID.hpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- FunctionID.hpp 2000/04/11 14:46:05 1.5
+++ FunctionID.hpp 2000/05/01 15:38:34 1.6
@@ -53,6 +53,8 @@
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
+ *
+ * @author <a href="mailto:david_n_bertoni@lotus.com">David N. Bertoni</a>
*/
#if !defined(FUNCTIONID_HEADER_GUARD_1357924680)
#define FUNCTIONID_HEADER_GUARD_1357924680
@@ -100,14 +102,12 @@
// These are all inline, even though
// there are virtual functions, because we expect that they will only be
// needed by the XPath class.
-class XALAN_XPATH_EXPORT FunctionID : public Function, public XObjectTypeCallback
+class XALAN_XPATH_EXPORT FunctionID : public Function
{
public:
FunctionID() :
- Function(),
- XObjectTypeCallback(),
- m_executionContext(0)
+ Function()
{
}
@@ -131,13 +131,13 @@
context);
}
- // OK, reset the data members...
- m_executionContext = &executionContext;
+ assert(args[0] != 0);
- clear(m_resultString);
-
// Do the callback to get the data.
- args[0]->ProcessXObjectTypeCallback(*this);
+ FunctionIDXObjectTypeCallback theCallback(executionContext);
+
+ const XalanDOMString theResultString =
+ theCallback.processCallback(*args[0]);
// Get the context document, so we can search for nodes.
const XalanDocument* const theDocContext = context->getNodeType() == XalanNode::DOCUMENT_NODE ?
@@ -154,7 +154,7 @@
executionContext.error("The context node does not have an owner document!",
context);
}
- else if (length(m_resultString) > 0)
+ else if (length(theResultString) > 0)
{
#if !defined(XALAN_NO_NAMESPACES)
using std::set;
@@ -166,7 +166,7 @@
// we can avoid looking more than once.
TokenSetType thePreviousTokens;
- StringTokenizer theTokenizer(m_resultString);
+ StringTokenizer theTokenizer(theResultString);
// Parse the result string...
while(theTokenizer.hasMoreTokens() == true)
@@ -209,84 +209,102 @@
}
- // These methods are inherited from XObjectTypeCallback ...
+private:
- virtual void
- Number(const XObject& theXObject,
- double /* theValue */)
+ class FunctionIDXObjectTypeCallback : public XObjectTypeCallback
{
- m_resultString = theXObject.str();
- }
+ public:
- virtual void
- Boolean(const XObject& theXObject,
- bool /* theValue */)
- {
- m_resultString = theXObject.str();
- }
+ FunctionIDXObjectTypeCallback(XPathExecutionContext& theExecutionContext) :
+ XObjectTypeCallback(),
+ m_executionContext(theExecutionContext),
+ m_resultString()
+ {
+ }
- virtual void
- String(const XObject& theXObject,
- const XalanDOMString& /* theValue */)
- {
- m_resultString = theXObject.str();
- }
+ const XalanDOMString&
+ processCallback(const XObject& theXObject)
+ {
+ theXObject.ProcessXObjectTypeCallback(*this);
- virtual void
- ResultTreeFragment(const XObject& theXObject,
- const ResultTreeFragBase& /* theValue */)
- {
- m_resultString = theXObject.str();
- }
+ return m_resultString;
+ }
- virtual void
- ResultTreeFragment(const XObject& theXObject,
- ResultTreeFragBase& /* theValue */)
- {
- m_resultString = theXObject.str();
- }
+ // These methods are inherited from XObjectTypeCallback ...
- virtual void
- NodeSet(const XObject& /* theXObject */,
- const NodeRefListBase& theValue)
- {
- assert(m_executionContext != 0);
+ virtual void
+ Number(const XObject& theXObject,
+ double /* theValue */)
+ {
+ m_resultString = theXObject.str();
+ }
- const unsigned int theNodeCount = theValue.getLength();
+ virtual void
+ Boolean(const XObject& theXObject,
+ bool /* theValue */)
+ {
+ m_resultString = theXObject.str();
+ }
- for (unsigned int i = 0 ; i < theNodeCount; i++)
+ virtual void
+ String(const XObject& theXObject,
+ const XalanDOMString& /* theValue */)
{
- m_resultString += m_executionContext->getNodeData(*theValue.item(i));
+ m_resultString = theXObject.str();
+ }
- m_resultString += " ";
+ virtual void
+ ResultTreeFragment(const XObject& theXObject,
+ const ResultTreeFragBase& /* theValue */)
+ {
+ m_resultString = theXObject.str();
}
- }
- virtual void
- Unknown(const XObject& /* theObject */,
- const XalanDOMString& /* theName */)
- {
- }
+ virtual void
+ ResultTreeFragment(const XObject& theXObject,
+ ResultTreeFragBase& /* theValue */)
+ {
+ m_resultString = theXObject.str();
+ }
- virtual void
- Null(const XObject& /* theObject */)
- {
- }
+ virtual void
+ NodeSet(const XObject& /* theXObject */,
+ const NodeRefListBase& theValue)
+ {
+ const unsigned int theNodeCount = theValue.getLength();
-private:
+ for (unsigned int i = 0 ; i < theNodeCount; i++)
+ {
+ m_resultString += m_executionContext.getNodeData(*theValue.item(i));
+
+ m_resultString += " ";
+ }
+ }
+ virtual void
+ Unknown(const XObject& /* theObject */,
+ const XalanDOMString& /* theName */)
+ {
+ }
+
+ virtual void
+ Null(const XObject& /* theObject */)
+ {
+ }
+
+ private:
+
+ XalanDOMString m_resultString;
+
+ XPathExecutionContext& m_executionContext;
+ };
+
// Not implemented...
FunctionID&
operator=(const FunctionID&);
bool
operator==(const FunctionID&) const;
-
-
- // Data members...
- XPathExecutionContext* m_executionContext;
-
- XalanDOMString m_resultString;
};