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 2001/03/30 00:19:09 UTC

cvs commit: xml-xalan/c/src/XPath XPathExecutionContextDefault.cpp XPathExecutionContextDefault.hpp

dbertoni    01/03/29 14:19:09

  Modified:    c/src/XPath XPathExecutionContextDefault.cpp
                        XPathExecutionContextDefault.hpp
  Log:
  Allow support classe instances to be changed.
  
  Revision  Changes    Path
  1.34      +89 -40    xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp
  
  Index: XPathExecutionContextDefault.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.cpp,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- XPathExecutionContextDefault.cpp	2001/03/09 16:23:29	1.33
  +++ XPathExecutionContextDefault.cpp	2001/03/29 22:19:08	1.34
  @@ -91,9 +91,9 @@
   			const NodeRefListBase*	theContextNodeList,
   			const PrefixResolver*	thePrefixResolver) :
   	XPathExecutionContext(),
  -	m_xpathEnvSupport(theXPathEnvSupport),
  -	m_domSupport(theDOMSupport),
  -	m_xobjectFactory(theXObjectFactory),
  +	m_xpathEnvSupport(&theXPathEnvSupport),
  +	m_domSupport(&theDOMSupport),
  +	m_xobjectFactory(&theXObjectFactory),
   	m_currentNode(theCurrentNode),
   	m_contextNodeList(theContextNodeList == 0 ? &s_dummyList : theContextNodeList),
   	m_prefixResolver(thePrefixResolver),
  @@ -111,6 +111,32 @@
   
   
   
  +XPathExecutionContextDefault::XPathExecutionContextDefault(
  +			XalanNode*				theCurrentNode,
  +			const NodeRefListBase*	theContextNodeList,
  +			const PrefixResolver*	thePrefixResolver) :
  +	XPathExecutionContext(),
  +	m_xpathEnvSupport(0),
  +	m_domSupport(0),
  +	m_xobjectFactory(0),
  +	m_currentNode(theCurrentNode),
  +	m_contextNodeList(theContextNodeList == 0 ? &s_dummyList : theContextNodeList),
  +	m_prefixResolver(thePrefixResolver),
  +	m_throwFoundIndex(false),
  +	m_availableCachedNodeLists(),
  +	m_busyCachedNodeLists(),
  +	m_availableCachedResultTreeFrags(),
  +	m_busyCachedResultTreeFrags(),
  +	m_stringCache()
  +{
  +	m_availableCachedNodeLists.reserve(eMutableNodeRefListCacheMax);
  +
  +	m_busyCachedNodeLists.reserve(eMutableNodeRefListCacheMax);
  +}
  +
  +
  +
  +
   XPathExecutionContextDefault::~XPathExecutionContextDefault()
   {
   #if !defined(XALAN_NO_NAMESPACES)
  @@ -135,9 +161,20 @@
   void
   XPathExecutionContextDefault::reset()
   {
  -	m_xpathEnvSupport.reset();
  -	m_domSupport.reset();
  -	m_xobjectFactory.reset();
  +	if (m_xpathEnvSupport != 0)
  +	{
  +		m_xpathEnvSupport->reset();
  +	}
  +
  +	if (m_domSupport != 0)
  +	{
  +		m_domSupport->reset();
  +	}
  +
  +	if (m_xobjectFactory != 0)
  +	{
  +		m_xobjectFactory->reset();
  +	}
   
   	m_currentNode = 0;
   	m_contextNodeList = &s_dummyList;
  @@ -182,7 +219,9 @@
   XObjectFactory&
   XPathExecutionContextDefault::getXObjectFactory() const
   {
  -	return m_xobjectFactory;
  +	assert(m_xobjectFactory != 0);
  +
  +	return *m_xobjectFactory;
   }
   
   
  @@ -190,12 +229,14 @@
   XObjectPtr
   XPathExecutionContextDefault::createNodeSet(XalanNode&	theNode)
   {
  +	assert(m_xobjectFactory != 0);
  +
   	// This list will hold the node...
   	BorrowReturnMutableNodeRefList	theNodeList(*this);
   
   	theNodeList->addNode(&theNode);
   
  -	return m_xobjectFactory.createNodeSet(theNodeList);
  +	return m_xobjectFactory->createNodeSet(theNodeList);
   }
   
   
  @@ -205,7 +246,7 @@
   			const XalanNode&	node1,
   			const XalanNode&	node2) const
   {
  -	return m_domSupport.isNodeAfter(node1, node2);
  +	return m_domSupport->isNodeAfter(node1, node2);
   }
   
   
  @@ -261,7 +302,9 @@
   			const XalanDOMString&	theNamespace, 
   			const XalanDOMString&	elementName) const
   {
  -	return m_xpathEnvSupport.elementAvailable(theNamespace, elementName);
  +	assert(m_xpathEnvSupport != 0);
  +
  +	return m_xpathEnvSupport->elementAvailable(theNamespace, elementName);
   }
   
   
  @@ -271,7 +314,9 @@
   			const XalanDOMString&	theNamespace, 
   			const XalanDOMString&	functionName) const
   {
  -	return m_xpathEnvSupport.functionAvailable(theNamespace, functionName);
  +	assert(m_xpathEnvSupport != 0);
  +
  +	return m_xpathEnvSupport->functionAvailable(theNamespace, functionName);
   }
   
   
  @@ -283,35 +328,21 @@
   			XalanNode*						context,
   			const XObjectArgVectorType&		argVec)
   {
  -	return m_xpathEnvSupport.extFunction(*this, theNamespace, functionName, context, argVec);
  -}
  -
  +	assert(m_xpathEnvSupport != 0);
   
  -
  -XLocator*
  -XPathExecutionContextDefault::getXLocatorFromNode(const XalanNode*	node) const
  -{
  -	return m_xpathEnvSupport.getXLocatorFromNode(node);
  +	return m_xpathEnvSupport->extFunction(*this, theNamespace, functionName, context, argVec);
   }
   
   
   
  -void
  -XPathExecutionContextDefault::associateXLocatorToNode(
  -			const XalanNode*	node,
  -			XLocator*			xlocator)
  -{
  -	m_xpathEnvSupport.associateXLocatorToNode(node, xlocator);
  -}
  -
  -
  -
   XalanDocument*
   XPathExecutionContextDefault::parseXML(
   			const XalanDOMString&	urlString,
   			const XalanDOMString&	base) const
   {
  -	return m_xpathEnvSupport.parseXML(urlString, base);
  +	assert(m_xpathEnvSupport != 0);
  +
  +	return m_xpathEnvSupport->parseXML(urlString, base);
   }
   
   
  @@ -453,7 +484,9 @@
   const XObjectPtr
   XPathExecutionContextDefault::getVariable(const QName&	name)
   {
  -	return m_xobjectFactory.createUnknown(name.getLocalPart());
  +	assert(m_xobjectFactory != 0);
  +
  +	return m_xobjectFactory->createUnknown(name.getLocalPart());
   }
   
   
  @@ -487,7 +520,9 @@
   XalanDocument*
   XPathExecutionContextDefault::getDOMFactory() const
   {
  -	return m_xpathEnvSupport.getDOMFactory();
  +	assert(m_xpathEnvSupport != 0);
  +
  +	return m_xpathEnvSupport->getDOMFactory();
   }
   
   
  @@ -495,7 +530,9 @@
   XalanDOMString
   XPathExecutionContextDefault::findURIFromDoc(const XalanDocument*	owner) const
   {
  -	return m_xpathEnvSupport.findURIFromDoc(owner);
  +	assert(m_xpathEnvSupport != 0);
  +
  +	return m_xpathEnvSupport->findURIFromDoc(owner);
   }
   
   
  @@ -505,7 +542,7 @@
   			const XalanDOMString&	theName,
   			const XalanDocument&	theDocument) const
   {
  -	return m_domSupport.getUnparsedEntityURI(theName, theDocument);
  +	return m_domSupport->getUnparsedEntityURI(theName, theDocument);
   }
   
   
  @@ -513,7 +550,9 @@
   bool
   XPathExecutionContextDefault::shouldStripSourceNode(const XalanNode&	node)
   {
  -	return m_xpathEnvSupport.shouldStripSourceNode(*this, node);
  +	assert(m_xpathEnvSupport != 0);
  +
  +	return m_xpathEnvSupport->shouldStripSourceNode(*this, node);
   }
   
   
  @@ -524,7 +563,9 @@
   			const XalanNode*		sourceNode,
   			const XalanNode*		/* styleNode */) const
   {
  -	if (m_xpathEnvSupport.problem(XPathEnvSupport::eXPATHProcessor, 
  +	assert(m_xpathEnvSupport != 0);
  +
  +	if (m_xpathEnvSupport->problem(XPathEnvSupport::eXPATHProcessor, 
   								  XPathEnvSupport::eError,
   								  m_prefixResolver, 
   								  sourceNode,
  @@ -556,7 +597,9 @@
   			const XalanNode*		sourceNode,
   			const XalanNode*		/* styleNode */) const
   {
  -	if (m_xpathEnvSupport.problem(XPathEnvSupport::eXPATHProcessor, 
  +	assert(m_xpathEnvSupport != 0);
  +
  +	if (m_xpathEnvSupport->problem(XPathEnvSupport::eXPATHProcessor, 
   								  XPathEnvSupport::eWarning,
   								  m_prefixResolver, 
   								  sourceNode,
  @@ -588,7 +631,9 @@
   			const XalanNode*		sourceNode,
   			const XalanNode*		/* styleNode */) const
   {
  -	if (m_xpathEnvSupport.problem(XPathEnvSupport::eXPATHProcessor, 
  +	assert(m_xpathEnvSupport != 0);
  +
  +	if (m_xpathEnvSupport->problem(XPathEnvSupport::eXPATHProcessor, 
   								  XPathEnvSupport::eMessage,
   								  m_prefixResolver, 
   								  sourceNode,
  @@ -633,7 +678,9 @@
   XalanDocument*
   XPathExecutionContextDefault::getSourceDocument(const XalanDOMString&	theURI) const
   {
  -	return m_xpathEnvSupport.getSourceDocument(theURI);
  +	assert(m_xpathEnvSupport != 0);
  +
  +	return m_xpathEnvSupport->getSourceDocument(theURI);
   }
   
   
  @@ -643,7 +690,9 @@
   			const XalanDOMString&	theURI,
   			XalanDocument*			theDocument)
   {
  -	m_xpathEnvSupport.setSourceDocument(theURI, theDocument);
  +	assert(m_xpathEnvSupport != 0);
  +
  +	m_xpathEnvSupport->setSourceDocument(theURI, theDocument);
   }
   
   
  
  
  
  1.32      +52 -11    xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp
  
  Index: XPathExecutionContextDefault.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContextDefault.hpp,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- XPathExecutionContextDefault.hpp	2001/01/16 02:34:46	1.31
  +++ XPathExecutionContextDefault.hpp	2001/03/29 22:19:08	1.32
  @@ -120,10 +120,59 @@
   			const NodeRefListBase*	theContextNodeList = 0,
   			const PrefixResolver*	thePrefixResolver = 0);
   
  +	/**
  +	 * Construct an XPathExecutionContextDefault object
  +	 *
  +	 * @param theXPathEnvSupport XPathEnvSupport class instance
  +	 * @param theXObjectFactory  factory class instance for XObjects
  +	 * @param theCurrentNode     current node in the source tree
  +	 * @param theContextNodeList node list for current context
  +	 * @param thePrefixResolver  pointer to prefix resolver to use
  +	 */
  +	explicit
  +	XPathExecutionContextDefault(
  +			XalanNode*				theCurrentNode = 0,
  +			const NodeRefListBase*	theContextNodeList = 0,
  +			const PrefixResolver*	thePrefixResolver = 0);
  +
   	virtual
   	~XPathExecutionContextDefault();
   
   
  +	/**
  +	 * Set the XPathEnvSupport instance.
  +	 *
  +	 * @param theSupport a reference to the instance to use.
  +	 */
  +	void
  +	setXPathEnvSupport(XPathEnvSupport*		theSupport)
  +	{
  +		m_xpathEnvSupport = theSupport;
  +	}
  +
  +	/**
  +	 * Set the XObjectFactory instance.
  +	 *
  +	 * @param theFactory a reference to the instance to use.
  +	 */
  +	void
  +	setXObjectFactory(XObjectFactory*	theFactory)
  +	{
  +		m_xobjectFactory = theFactory;
  +	}
  +
  +	/**
  +	 * Set the DOMSupport instance.
  +	 *
  +	 * @param theDOMSupport a reference to the instance to use.
  +	 */
  +	void
  +	setDOMSupport(DOMSupport*	theDOMSupport)
  +	{
  +		m_domSupport = theDOMSupport;
  +	}
  +
  +
   	// These interfaces are inherited from XPathExecutionContext...
   
   	virtual void
  @@ -175,14 +224,6 @@
   			XalanNode*						context,
   			const XObjectArgVectorType&		argVec);
   
  -	virtual XLocator*
  -	getXLocatorFromNode(const XalanNode*	node) const;
  -
  -	virtual void
  -	associateXLocatorToNode(
  -			const XalanNode*	node,
  -			XLocator*			xlocator);
  -
   	virtual XalanDocument*
   	parseXML(
   			const XalanDOMString&	urlString,
  @@ -313,11 +354,11 @@
   		   eResultTreeFragListCacheMax = 50,
   		   eCachedArgVectorDefaultSize = 10 };
   
  -	XPathEnvSupport&			m_xpathEnvSupport;
  +	XPathEnvSupport*			m_xpathEnvSupport;
   
  -	DOMSupport&					m_domSupport;
  +	DOMSupport*					m_domSupport;
   
  -	XObjectFactory&				m_xobjectFactory;
  +	XObjectFactory*				m_xobjectFactory;
   
   	XalanNode*					m_currentNode;
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org