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/01/03 20:27:09 UTC

cvs commit: xml-xalan/c/src/DOMSupport DOMServices.cpp DOMServices.hpp

dbertoni    01/01/03 11:27:09

  Modified:    c/src/DOMSupport DOMServices.cpp DOMServices.hpp
  Log:
  Made some functions inline.
  
  Revision  Changes    Path
  1.21      +0 -198    xml-xalan/c/src/DOMSupport/DOMServices.cpp
  
  Index: DOMServices.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMServices.cpp,v
  retrieving revision 1.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- DOMServices.cpp	2000/12/21 03:59:34	1.20
  +++ DOMServices.cpp	2001/01/03 19:27:05	1.21
  @@ -320,42 +320,6 @@
   
   
   XalanDOMString
  -DOMServices::getNodeData(const XalanAttr&	attribute)
  -{
  -	return attribute.getNodeValue();
  -}
  -
  -
  -
  -void
  -DOMServices::getNodeData(
  -			const XalanAttr&	attribute,
  -			XalanDOMString&		data)
  -{
  -	append(data, attribute.getNodeValue());
  -}
  -
  -
  -
  -XalanDOMString
  -DOMServices::getNodeData(const XalanComment&	comment)
  -{
  -	return comment.getData();
  -}
  -
  -
  -
  -void
  -DOMServices::getNodeData(
  -			const XalanComment&		comment,
  -			XalanDOMString&			data)
  -{
  -	append(data, comment.getData());
  -}
  -
  -
  -
  -XalanDOMString
   DOMServices::getNodeData(const XalanDocument&	document)
   {
   	XalanDOMString	data;
  @@ -467,42 +431,6 @@
   
   
   
  -XalanDOMString
  -DOMServices::getNodeData(const XalanProcessingInstruction&	pi)
  -{
  -	return pi.getData();
  -}
  -
  -
  -
  -void
  -DOMServices::getNodeData(
  -			const XalanProcessingInstruction&	pi,
  -			XalanDOMString&						data)
  -{
  -	append(data, pi.getData());
  -}
  -
  -
  -
  -XalanDOMString
  -DOMServices::getNodeData(const XalanText&	text)
  -{
  -	return text.getData();
  -}
  -
  -
  -
  -void
  -DOMServices::getNodeData(
  -			const XalanText&	text,
  -			XalanDOMString&		data)
  -{
  -	append(data, text.getData());
  -}
  -
  -
  -
   const XalanDOMString&
   DOMServices::getNameOfNode(const XalanNode&		n)
   {
  @@ -534,132 +462,6 @@
   	}
   }
   
  -
  -
  -// Note: This may be inefficient in a Level 2 DOM, where localname
  -// and prefix may (or may not) have been stored in separate fields
  -const XalanDOMString&
  -DOMServices::getLocalNameOfNode(const XalanNode&	n)
  -{
  -	const XalanDOMString&	theLocalName = n.getLocalName();
  -
  -	if (length(theLocalName) != 0)
  -	{
  -		return theLocalName;
  -	}
  -	else
  -	{
  -		assert(length(n.getNodeName()) != 0);
  -
  -		return n.getNodeName();
  -	}
  -}
  -
  -
  -
  -/**
  - * Support for getParentOfNode.
  - */
  -static XalanNode*
  -locateAttrParent(
  -			const XalanElement&		elem,
  -			const XalanNode&		attr)
  -{
  -
  -    XalanNode*	parent = 0;
  -
  -	const XalanNamedNodeMap* const	attrs = elem.getAttributes();
  -	assert(attrs != 0);
  -
  -    if(attrs != 0)
  -	{
  -		const unsigned int	nAttrs = attrs->getLength();
  -
  -		for(unsigned int i = 0; i < nAttrs; i++)
  -		{
  -			if(attrs->item(i) == &attr)
  -			{
  -#if defined(XALAN_OLD_STYLE_CASTS)
  -				parent = (XalanElement*)&elem;
  -#else
  -				parent = const_cast<XalanElement*>(&elem);
  -#endif
  -				
  -				break;
  -			}
  -		}
  -    }
  -
  -	if(parent == 0)
  -    {
  -		bool				fFound = false;
  -
  -		const XalanNode*	child = elem.getFirstChild();
  -
  -		while(child != 0 && fFound == false)
  -		{
  -			if(child->getNodeType() == XalanNode::ELEMENT_NODE)
  -			{
  -#if defined(XALAN_OLD_STYLE_CASTS)
  -				parent = locateAttrParent((const XalanElement&)*child, attr);
  -#else
  -				parent = locateAttrParent(static_cast<const XalanElement&>(*child), attr);
  -#endif
  -
  -				if(parent != 0)
  -				{
  -					fFound = true;
  -				}
  -			}
  -
  -			if (fFound == false)
  -			{
  -				child = child->getNextSibling();
  -			}
  -		}
  -    }
  -
  -	return parent;
  -}
  -
  -
  -
  -
  -XalanNode*
  -DOMServices::getParentOfNode(const XalanNode&	node)
  -{
  -	XalanNode*					parent = 0;
  -
  -	const XalanNode::NodeType	nodeType = node.getNodeType();
  -
  -	if(XalanNode::ATTRIBUTE_NODE == nodeType)
  -	{
  -		XalanDocument* const	doc = node.getOwnerDocument();
  -
  -		if(doc == 0)
  -		{
  -			throw DOMSupportException(TranscodeFromLocalCodePage("Attribute child does not have an owner document!"));
  -		}
  -		else
  -		{
  -			XalanElement*	const	rootElem = doc->getDocumentElement();
  -			assert(rootElem != 0);
  -
  -			parent = locateAttrParent(*rootElem, node);
  -		}
  -	}
  -	else
  -	{
  -		parent = node.getParentNode();
  -
  -		if(nodeType != XalanNode::DOCUMENT_NODE && parent == 0)
  -		{
  -			throw DOMSupportException(TranscodeFromLocalCodePage("Child does not have parent!"));
  -		}
  -	}
  -
  -	return parent;
  -}
   
   
   // Note functional overlap with NamespaceResolver's 
  
  
  
  1.16      +67 -18    xml-xalan/c/src/DOMSupport/DOMServices.hpp
  
  Index: DOMServices.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xalan/c/src/DOMSupport/DOMServices.hpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- DOMServices.hpp	2000/11/02 01:45:28	1.15
  +++ DOMServices.hpp	2001/01/03 19:27:06	1.16
  @@ -65,23 +65,20 @@
   
   
   #include <XalanDOM/XalanDOMString.hpp>
  +#include <XalanDOM/XalanAttr.hpp>
  +#include <XalanDOM/XalanComment.hpp>
  +#include <XalanDOM/XalanElement.hpp>
  +#include <XalanDOM/XalanProcessingInstruction.hpp>
  +#include <XalanDOM/XalanText.hpp>
   
   
   
  -#if defined(XALAN_INLINE_INITIALIZATION)
   #include <PlatformSupport/DOMStringHelper.hpp>
  -#endif
   
   
   
  -class XalanAttr;
  -class XalanComment;
   class XalanDocument;
   class XalanDocumentFragment;
  -class XalanElement;
  -class XalanNode;
  -class XalanProcessingInstruction;
  -class XalanText;
   
   
   
  @@ -187,7 +184,10 @@
   	 * @return a string representation of the node's data
   	 */
   	static XalanDOMString
  -	getNodeData(const XalanAttr&	attribute);
  +	getNodeData(const XalanAttr&	attribute)
  +	{
  +		return attribute.getNodeValue();
  +	}
   
   	/**
   	 * Retrieves data for node
  @@ -198,7 +198,10 @@
   	static void
   	getNodeData(
   			const XalanAttr&	attribute,
  -			XalanDOMString&		data);
  +			XalanDOMString&		data)
  +	{
  +		append(data, attribute.getNodeValue());
  +	}
   
   	/**
   	 * Retrieves data for node
  @@ -207,7 +210,10 @@
   	 * @return a string representation of the node's data
   	 */
   	static XalanDOMString
  -	getNodeData(const XalanComment&		comment);
  +	getNodeData(const XalanComment&		comment)
  +	{
  +		return comment.getData();
  +	}
   
   	/**
   	 * Retrieves data for node
  @@ -218,7 +224,10 @@
   	static void
   	getNodeData(
   			const XalanComment&		comment,
  -			XalanDOMString&			data);
  +			XalanDOMString&			data)
  +	{
  +		append(data, comment.getData());
  +	}
   
   	/**
   	 * Retrieves data for node
  @@ -287,7 +296,10 @@
   	 * @return a string representation of the node's data
   	 */
   	static XalanDOMString
  -	getNodeData(const XalanProcessingInstruction&	pi);
  +	getNodeData(const XalanProcessingInstruction&	pi)
  +	{
  +		return pi.getData();
  +	}
   
   	/**
   	 * Retrieves data for node
  @@ -298,7 +310,10 @@
   	static void
   	getNodeData(
   			const XalanProcessingInstruction&	pi,
  -			XalanDOMString&						data);
  +			XalanDOMString&						data)
  +	{
  +		append(data, pi.getData());
  +	}
   
   	/**
   	 * Retrieves data for node
  @@ -307,7 +322,10 @@
   	 * @return a string representation of the node's data
   	 */
   	static XalanDOMString
  -	getNodeData(const XalanText&	text);
  +	getNodeData(const XalanText&	text)
  +	{
  +		return text.getData();
  +	}
   
   	/**
   	 * Retrieves data for node
  @@ -318,7 +336,10 @@
   	static void
   	getNodeData(
   			const XalanText&	text,
  -			XalanDOMString&		data);
  +			XalanDOMString&		data)
  +	{
  +		append(data, text.getData());
  +	}
   
   	/**
   	 * Retrieve the name of the node, taking into
  @@ -340,7 +361,21 @@
   	 * @return name of node without namespace
   	 */
   	static const XalanDOMString&
  -	getLocalNameOfNode(const XalanNode&		n);
  +	getLocalNameOfNode(const XalanNode&		n)
  +	{
  +		const XalanDOMString&	theLocalName = n.getLocalName();
  +
  +		if (length(theLocalName) != 0)
  +		{
  +			return theLocalName;
  +		}
  +		else
  +		{
  +			assert(length(n.getNodeName()) != 0);
  +
  +			return n.getNodeName();
  +		}
  +	}
   
   	/**
   	 * Retrieve the parent of a node. This function has to be implemented,
  @@ -350,7 +385,21 @@
   	 * @return parent node
   	 */
   	static XalanNode*
  -	getParentOfNode(const XalanNode&	node);
  +	getParentOfNode(const XalanNode&	node)
  +	{
  +		if(node.getNodeType() == XalanNode::ATTRIBUTE_NODE)
  +		{
  +	#if defined(XALAN_OLD_STYLE_CASTS)
  +			return ((const XalanAttr&)node).getOwnerElement();
  +	#else
  +			return static_cast<const XalanAttr&>(node).getOwnerElement();
  +	#endif
  +		}
  +		else
  +		{
  +			return node.getParentNode();
  +		}
  +	}
   
   	/**
   	 * Retrieve the URI corresponding to a namespace prefix