dbertoni 2003/02/12 16:13:21
Modified: c/src/XPath XNodeSetBase.hpp XObject.hpp XObjectFactory.hpp
XObjectFactoryDefault.cpp XObjectFactoryDefault.hpp
XPathExecutionContext.hpp
XPathExecutionContextDefault.cpp
XPathExecutionContextDefault.hpp
Added: c/src/XPath XNodeSetNodeProxy.cpp XNodeSetNodeProxy.hpp
XNodeSetNodeProxyAllocator.cpp
XNodeSetNodeProxyAllocator.hpp
Log:
New implementation for singleton node in a node-set.
Revision Changes Path
1.7 +12 -12 xml-xalan/c/src/XPath/XNodeSetBase.hpp
Index: XNodeSetBase.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNodeSetBase.hpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- XNodeSetBase.hpp 21 Nov 2002 01:26:18 -0000 1.6
+++ XNodeSetBase.hpp 13 Feb 2003 00:13:21 -0000 1.7
@@ -86,18 +86,6 @@
typedef size_t size_type;
- /**
- * Create an XNodeSetBase
- */
- XNodeSetBase();
-
- /**
- * Create an XNodeSetBase from another.
- *
- * @param source object to copy
- */
- XNodeSetBase(const XNodeSetBase& source);
-
virtual
~XNodeSetBase();
@@ -152,6 +140,18 @@
getLength() const = 0;
protected:
+
+ /**
+ * Create an XNodeSetBase
+ */
+ XNodeSetBase();
+
+ /**
+ * Create an XNodeSetBase from another.
+ *
+ * @param source object to copy
+ */
+ XNodeSetBase(const XNodeSetBase& source);
void
clearCachedValues();
1.28 +1 -0 xml-xalan/c/src/XPath/XObject.hpp
Index: XObject.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObject.hpp,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- XObject.hpp 24 Jan 2003 02:32:21 -0000 1.27
+++ XObject.hpp 13 Feb 2003 00:13:21 -0000 1.28
@@ -123,6 +123,7 @@
eTypeStringCached = 10,
eTypeXTokenNumberAdapter = 11,
eTypeXTokenStringAdapter = 12,
+ eTypeNodeSetNodeProxy = 13,
eUnknown
};
1.21 +9 -0 xml-xalan/c/src/XPath/XObjectFactory.hpp
Index: XObjectFactory.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactory.hpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XObjectFactory.hpp 21 Nov 2002 01:30:09 -0000 1.20
+++ XObjectFactory.hpp 13 Feb 2003 00:13:21 -0000 1.21
@@ -143,6 +143,15 @@
createNodeSet(BorrowReturnMutableNodeRefList& theValue) = 0;
/**
+ * Create a node set XObject from a node.
+ *
+ * @param theNOde value used to create object.
+ * @return pointer to new object
+ */
+ virtual const XObjectPtr
+ createNodeSet(XalanNode* theValue) = 0;
+
+ /**
* Create a null XObject.
*
* @param theValue value used to create object
1.32 +33 -3 xml-xalan/c/src/XPath/XObjectFactoryDefault.cpp
Index: XObjectFactoryDefault.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactoryDefault.cpp,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- XObjectFactoryDefault.cpp 8 Jan 2003 20:09:02 -0000 1.31
+++ XObjectFactoryDefault.cpp 13 Feb 2003 00:13:21 -0000 1.32
@@ -81,9 +81,10 @@
XObjectFactoryDefault::XObjectFactoryDefault(
- unsigned int theXStringBlockSize,
- unsigned int theXNumberBlockSize,
- unsigned int theXNodeSetBlockSize) :
+ size_type theXStringBlockSize,
+ size_type theXNumberBlockSize,
+ size_type theXNodeSetBlockSize,
+ size_type theXNodeSetNodeProxyBlockSize) :
XObjectFactory(),
m_xstringAdapterAllocator(theXStringBlockSize),
m_xstringAllocator(theXStringBlockSize),
@@ -91,6 +92,7 @@
m_xstringReferenceAllocator(theXStringBlockSize),
m_xnumberAllocator(theXNumberBlockSize),
m_xnodesetAllocator(theXNodeSetBlockSize),
+ m_xnodesetNodeProxyAllocator(theXNodeSetNodeProxyBlockSize),
m_xtokenNumberAdapterAllocator(theXNumberBlockSize),
m_xtokenStringAdapterAllocator(theXStringBlockSize),
m_xobjects(),
@@ -264,6 +266,19 @@
}
break;
+ case XObject::eTypeNodeSetNodeProxy:
+ {
+ XNodeSetNodeProxy* const theXNodeSet =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (XNodeSetNodeProxy*)theXObject;
+#else
+ static_cast<XNodeSetNodeProxy*>(theXObject);
+#endif
+
+ bStatus =
m_xnodesetNodeProxyAllocator.destroy(theXNodeSet);
+ }
+ break;
+
default:
{
XALAN_USING_STD(find)
@@ -396,6 +411,19 @@
const XObjectPtr
+XObjectFactoryDefault::createNodeSet(XalanNode* theValue)
+{
+ XNodeSetNodeProxy* const theNodeSet =
+ m_xnodesetNodeProxyAllocator.create(theValue);
+
+ theNodeSet->setFactory(this);
+
+ return XObjectPtr(theNodeSet);
+}
+
+
+
+const XObjectPtr
XObjectFactoryDefault::createString(const XalanDOMString& theValue)
{
if (m_xstringCache.empty() == false)
@@ -510,6 +538,8 @@
m_xnumberAllocator.reset();
m_xnodesetAllocator.reset();
+
+ m_xnodesetNodeProxyAllocator.reset();
m_xtokenNumberAdapterAllocator.reset();
1.27 +14 -4 xml-xalan/c/src/XPath/XObjectFactoryDefault.hpp
Index: XObjectFactoryDefault.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XObjectFactoryDefault.hpp,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- XObjectFactoryDefault.hpp 21 Nov 2002 01:30:09 -0000 1.26
+++ XObjectFactoryDefault.hpp 13 Feb 2003 00:13:21 -0000 1.27
@@ -75,6 +75,7 @@
#include <XPath/XNodeSetAllocator.hpp>
+#include <XPath/XNodeSetNodeProxyAllocator.hpp>
#include <XPath/XNumberAllocator.hpp>
#include <XPath/XStringAllocator.hpp>
#include <XPath/XStringAdapterAllocator.hpp>
@@ -119,12 +120,15 @@
eDefaultXStringBlockSize = 10,
eDefaultXNumberBlockSize = 10,
eDefaultXNodeSetBlockSize = 10,
+ eDefaultXNodeSetNodeProxyBlockSize = 5,
eXNumberCacheMax = 40,
eXNodeSetCacheMax = 40,
eXStringCacheMax = 40,
eXResultTreeFragCacheMax = 40
};
-
+
+ typedef unsigned long size_type;
+
/**
* Construct a factory for creating XObjects.
*
@@ -134,9 +138,10 @@
*/
explicit
XObjectFactoryDefault(
- unsigned int theXStringBlockSize =
eDefaultXStringBlockSize,
- unsigned int theXNumberBlockSize =
eDefaultXNumberBlockSize,
- unsigned int theXNodeSetBlockSize =
eDefaultXNodeSetBlockSize);
+ size_type theXStringBlockSize =
eDefaultXStringBlockSize,
+ size_type theXNumberBlockSize =
eDefaultXNumberBlockSize,
+ size_type theXNodeSetBlockSize =
eDefaultXNodeSetBlockSize,
+ size_type theXNodeSetNodeProxyBlockSize =
eDefaultXNodeSetNodeProxyBlockSize);
virtual
~XObjectFactoryDefault();
@@ -153,6 +158,9 @@
createNodeSet(BorrowReturnMutableNodeRefList& theValue);
virtual const XObjectPtr
+ createNodeSet(XalanNode* theValue);
+
+ virtual const XObjectPtr
createNull();
virtual const XObjectPtr
@@ -234,6 +242,8 @@
XNumberAllocator m_xnumberAllocator;
XNodeSetAllocator m_xnodesetAllocator;
+
+ XNodeSetNodeProxyAllocator m_xnodesetNodeProxyAllocator;
XTokenNumberAdapterAllocator m_xtokenNumberAdapterAllocator;
1.56 +0 -10 xml-xalan/c/src/XPath/XPathExecutionContext.hpp
Index: XPathExecutionContext.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExecutionContext.hpp,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- XPathExecutionContext.hpp 8 Jan 2003 06:58:12 -0000 1.55
+++ XPathExecutionContext.hpp 13 Feb 2003 00:13:21 -0000 1.56
@@ -198,16 +198,6 @@
}
/**
- * Convenience function for creating a node set with
- * the supplied node as the only member.
- *
- * @param node The node queried
- * @return a pointer to the XObject instance.
- */
- virtual XObjectPtr
- createNodeSet(XalanNode& theNode) = 0;
-
- /**
* Determine if a node is after another node, in document order.
*
* @param node1 The first node
1.59 +0 -15 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.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- XPathExecutionContextDefault.cpp 21 Dec 2002 00:20:45 -0000 1.58
+++ XPathExecutionContextDefault.cpp 13 Feb 2003 00:13:21 -0000 1.59
@@ -193,21 +193,6 @@
-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);
-}
-
-
-
bool
XPathExecutionContextDefault::isNodeAfter(
const XalanNode& node1,
1.50 +0 -3 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.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- XPathExecutionContextDefault.hpp 22 Jan 2003 23:02:38 -0000 1.49
+++ XPathExecutionContextDefault.hpp 13 Feb 2003 00:13:21 -0000 1.50
@@ -219,9 +219,6 @@
virtual void
setCurrentNode(XalanNode* theCurrentNode);
- virtual XObjectPtr
- createNodeSet(XalanNode& theNode);
-
virtual bool
isNodeAfter(
const XalanNode& node1,
1.1 xml-xalan/c/src/XPath/XNodeSetNodeProxy.cpp
Index: XNodeSetNodeProxy.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Class header file.
#include "XNodeSetNodeProxy.hpp"
XALAN_CPP_NAMESPACE_BEGIN
XNodeSetNodeProxy::Proxy::Proxy(XalanNode* theNode) :
m_node(theNode)
{
}
XNodeSetNodeProxy::Proxy::~Proxy()
{
}
XalanNode*
XNodeSetNodeProxy::Proxy::item(size_type index) const
{
if (m_node == 0 || index > 0)
{
return 0;
}
else
{
return m_node;
}
}
XNodeSetNodeProxy::Proxy::size_type
XNodeSetNodeProxy::Proxy::getLength() const
{
return m_node == 0 ? 0 : 1;
}
XNodeSetNodeProxy::Proxy::size_type
XNodeSetNodeProxy::Proxy::indexOf(const XalanNode* theNode) const
{
if (m_node == 0 || theNode != m_node)
{
return npos;
}
else
{
return 0;
}
}
XNodeSetNodeProxy::XNodeSetNodeProxy(XalanNode* theNode) :
XNodeSetBase(),
m_proxy(theNode)
{
}
XNodeSetNodeProxy::XNodeSetNodeProxy(const XNodeSetNodeProxy& source) :
XNodeSetBase(source),
m_proxy(source.m_proxy)
{
}
XNodeSetNodeProxy::~XNodeSetNodeProxy()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XObject*
#else
XNodeSetNodeProxy*
#endif
XNodeSetNodeProxy::clone(void* theAddress) const
{
return theAddress == 0 ? new XNodeSetNodeProxy(*this) : new
(theAddress) XNodeSetNodeProxy(*this);
}
XNodeSetNodeProxy::eObjectType
XNodeSetNodeProxy::getRealType() const
{
return eTypeNodeSetNodeProxy;
}
const NodeRefListBase&
XNodeSetNodeProxy::nodeset() const
{
return m_proxy;
}
XalanNode*
XNodeSetNodeProxy::item(size_type index) const
{
return m_proxy.item(index);
}
XNodeSetNodeProxy::size_type
XNodeSetNodeProxy::getLength() const
{
return m_proxy.getLength();
}
XALAN_CPP_NAMESPACE_END
1.1 xml-xalan/c/src/XPath/XNodeSetNodeProxy.hpp
Index: XNodeSetNodeProxy.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2001-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XNODESETNODEPROXY_HEADER_GUARD_1357924680)
#define XNODESETNODEPROXY_HEADER_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file.
#include <XPath/XNodeSetBase.hpp>
#include <XPath/NodeRefListBase.hpp>
XALAN_CPP_NAMESPACE_BEGIN
/**
* Class to hold XPath return types.
*/
class XALAN_XPATH_EXPORT XNodeSetNodeProxy : public XNodeSetBase
{
public:
/**
* Create an XNodeSetNodeProxy
*/
XNodeSetNodeProxy(XalanNode* theNode);
/**
* Create an XNodeSetNodeProxy from another.
*
* @param source object to copy
*/
XNodeSetNodeProxy(const XNodeSetNodeProxy& source);
virtual
~XNodeSetNodeProxy();
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XNodeSetNodeProxy*
#endif
clone(void* theAddress = 0) const;
virtual const NodeRefListBase&
nodeset() const;
virtual XalanNode*
item(size_type index) const;
virtual size_type
getLength() const;
protected:
virtual eObjectType
getRealType() const;
private:
// A proxy class to implement NodeRefListBase...
class Proxy : public NodeRefListBase
{
public:
Proxy(XalanNode* theNode);
virtual
~Proxy();
virtual XalanNode*
item(size_type index) const;
virtual size_type
getLength() const;
virtual size_type
indexOf(const XalanNode* theNode) const;
XalanNode* m_node;
};
// Not implemented...
XNodeSetNodeProxy&
operator=(const XNodeSetNodeProxy&);
// Data members...
const Proxy m_proxy;
};
XALAN_CPP_NAMESPACE_END
#endif // XNODESETNODEPROXY_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XNodeSetNodeProxyAllocator.cpp
Index: XNodeSetNodeProxyAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
// Class header file.
#include "XNodeSetNodeProxyAllocator.hpp"
XALAN_CPP_NAMESPACE_BEGIN
XNodeSetNodeProxyAllocator::XNodeSetNodeProxyAllocator(size_type
theBlockCount) :
m_allocator(theBlockCount)
{
}
XNodeSetNodeProxyAllocator::~XNodeSetNodeProxyAllocator()
{
}
XNodeSetNodeProxyAllocator::nodeset_type*
XNodeSetNodeProxyAllocator::create(XalanNode* value)
{
nodeset_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
nodeset_type* const theResult = new(theBlock) nodeset_type(value);
m_allocator.commitAllocation(theBlock);
return theResult;
}
XNodeSetNodeProxyAllocator::nodeset_type*
XNodeSetNodeProxyAllocator::clone(const nodeset_type& value)
{
nodeset_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
value.clone(theBlock);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
bool
XNodeSetNodeProxyAllocator::destroy(nodeset_type* theNodeSet)
{
return m_allocator.destroyObject(theNodeSet);
}
void
XNodeSetNodeProxyAllocator::reset()
{
m_allocator.reset();
}
XALAN_CPP_NAMESPACE_END
1.1 xml-xalan/c/src/XPath/XNodeSetNodeProxyAllocator.hpp
Index: XNodeSetNodeProxyAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000-2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Xalan" and "Apache Software Foundation" must
* not be used to endorse or promote products derived from this
* software without prior written permission. For written
* permission, please contact [EMAIL PROTECTED]
*
* 5. Products derived from this software may not be called "Apache",
* nor may "Apache" appear in their name, without prior written
* permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation and was
* originally based on software copyright (c) 1999, International
* Business Machines, Inc., http://www.ibm.com. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*/
#if !defined(XNODESETNODEPROXYALLOCATOR_INCLUDE_GUARD_12455133)
#define XNODESETNODEPROXYALLOCATOR_INCLUDE_GUARD_12455133
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XNodeSetNodeProxy.hpp>
#include <PlatformSupport/ReusableArenaAllocator.hpp>
XALAN_CPP_NAMESPACE_BEGIN
class XALAN_XPATH_EXPORT XNodeSetNodeProxyAllocator
{
public:
typedef XNodeSetNodeProxy
nodeset_type;
typedef ReusableArenaAllocator<nodeset_type> ArenaAllocatorType;
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified
size.
*
* @param theBlockSize The block size.
*/
XNodeSetNodeProxyAllocator(size_type theBlockCount);
~XNodeSetNodeProxyAllocator();
/**
* Create an object using the allocator.
*
* @param value source node
*
* @return pointer to instance
*/
nodeset_type*
create(XalanNode* value);
/**
* Clone an XNodeSet object.
*
* @param value source instance
*
* @return pointer to a new instance
*/
nodeset_type*
clone(const XNodeSetNodeProxy& value);
/**
* Delete an XNodeSet object from allocator.
*/
bool
destroy(nodeset_type* theNodeSet);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const nodeset_type* theObject)
{
return m_allocator.ownsObject(theObject);
}
/**
* Delete all XNodeSet objects from allocator.
*/
void
reset();
/**
* Get size of an ArenaBlock, that is, the number
* of objects in each block.
*
* @return The size of the block
*/
size_type
getBlockCount() const
{
return m_allocator.getBlockCount();
}
/**
* Get the number of ArenaBlocks currently allocated.
*
* @return The number of blocks.
*/
size_type
getBlockSize() const
{
return m_allocator.getBlockSize();
}
private:
// Not implemented...
XNodeSetNodeProxyAllocator(const XNodeSetNodeProxyAllocator&);
XNodeSetNodeProxyAllocator&
operator=(const XNodeSetNodeProxyAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
XALAN_CPP_NAMESPACE_END
#endif // XNODESETNODEPROXYALLOCATOR_INCLUDE_GUARD_12455133
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]