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/12/21 05:23:08 UTC
cvs commit: xml-xalan/c/src/XPath XStringAdapter.cpp XStringAdapter.hpp XStringAdapterAllocator.cpp XStringAdapterAllocator.hpp XStringBase.cpp XStringBase.hpp XStringCached.cpp XStringCached.hpp XStringCachedAllocator.cpp XStringCachedAllocator.hpp XStringReference.cpp XStringReference.hpp XStringReferenceAllocator.cpp XStringReferenceAllocator.hpp
dbertoni 00/12/20 20:23:08
Added: c/src/XPath XStringAdapter.cpp XStringAdapter.hpp
XStringAdapterAllocator.cpp
XStringAdapterAllocator.hpp XStringBase.cpp
XStringBase.hpp XStringCached.cpp XStringCached.hpp
XStringCachedAllocator.cpp
XStringCachedAllocator.hpp XStringReference.cpp
XStringReference.hpp XStringReferenceAllocator.cpp
XStringReferenceAllocator.hpp
Log:
Initial revision.
Revision Changes Path
1.1 xml-xalan/c/src/XPath/XStringAdapter.cpp
Index: XStringAdapter.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2000 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 apache@apache.org.
*
* 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 "XStringAdapter.hpp"
XStringAdapter::XStringAdapter(const XObjectPtr& val) :
XStringBase(),
m_value(val)
{
}
XStringAdapter::XStringAdapter(const XStringAdapter& source) :
XStringBase(source),
m_value(source.m_value)
{
}
XStringAdapter::~XStringAdapter()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XObject*
#else
XStringAdapter*
#endif
XStringAdapter::clone(void* theAddress) const
{
return theAddress == 0 ? new XStringAdapter(*this) : new (theAddress) XStringAdapter(*this);
};
const XalanDOMString&
XStringAdapter::str() const
{
return m_value->str();
}
XStringAdapter::eObjectType
XStringAdapter::getRealType() const
{
return eTypeStringAdapter;
}
1.1 xml-xalan/c/src/XPath/XStringAdapter.hpp
Index: XStringAdapter.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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(XSTRINGADAPTER_HEADER_GUARD_1357924680)
#define XSTRINGADAPTER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file.
#include <XPath/XStringBase.hpp>
class XALAN_XPATH_EXPORT XStringAdapter : public XStringBase
{
public:
/**
* Create a string XObject that will adapt another XObject to
* behave like a string. The XObject holds a reference to the
* other XObject.
*
* @param theValue value used to create object
*/
XStringAdapter(const XObjectPtr& val);
XStringAdapter(const XStringAdapter& source);
virtual
~XStringAdapter();
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XStringAdapter*
#endif
clone(void* theAddress = 0) const;
virtual const XalanDOMString&
str() const;
protected:
virtual eObjectType
getRealType() const;
private:
const XObjectPtr m_value;
};
#endif // XSTRINGADAPTER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XStringAdapterAllocator.cpp
Index: XStringAdapterAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 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 apache@apache.org.
*
* 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 "XStringAdapterAllocator.hpp"
XStringAdapterAllocator::XStringAdapterAllocator(size_type theBlockCount) :
m_allocator(theBlockCount)
{
}
XStringAdapterAllocator::~XStringAdapterAllocator()
{
}
XStringAdapterAllocator::string_type*
XStringAdapterAllocator::createString(const XObjectPtr& theXObject)
{
string_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
string_type* const theResult = new(theBlock) string_type(theXObject);
m_allocator.commitAllocation(theBlock);
return theResult;
}
XStringAdapterAllocator::string_type*
XStringAdapterAllocator::clone(const string_type& value)
{
string_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
value.clone(theBlock);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
bool
XStringAdapterAllocator::destroy(string_type* theString)
{
return m_allocator.destroyObject(theString);
}
void
XStringAdapterAllocator::reset()
{
m_allocator.reset();
}
1.1 xml-xalan/c/src/XPath/XStringAdapterAllocator.hpp
Index: XStringAdapterAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 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 apache@apache.org.
*
* 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(XSTRINGADAPTERALLOCATOR_INCLUDE_GUARD_1357924680)
#define XSTRINGADAPTERALLOCATOR_INCLUDE_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XStringAdapter.hpp>
#include <PlatformSupport/ReusableArenaAllocator.hpp>
class XALAN_XPATH_EXPORT XStringAdapterAllocator
{
public:
typedef XStringAdapter string_type;
typedef ReusableArenaAllocator<string_type> ArenaAllocatorType;
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified size.
*
* @param theBlockSize The block size.
*/
XStringAdapterAllocator(size_type theBlockCount);
~XStringAdapterAllocator();
/**
* Create an XString object from a string.
*
* @param theXObject The source XObject
*
* @return a pointer to string
*/
string_type*
createString(const XObjectPtr& theXObject);
/**
* Clone an XStringAdapter object.
*
* @param value source XStringAdapter
*
* @return pointer to an XStringAdapter
*/
string_type*
clone(const string_type& value);
/**
* Delete an XStringAdapter object from allocator.
*/
bool
destroy(string_type* theString);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const string_type* theObject)
{
return m_allocator.ownsObject(theObject);
}
/**
* Delete all XStringAdapter 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...
XStringAdapterAllocator(const XStringAdapterAllocator&);
XStringAdapterAllocator&
operator=(const XStringAdapterAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XSTRINGADAPTERALLOCATOR_INCLUDE_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XStringBase.cpp
Index: XStringBase.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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 "XStringBase.hpp"
#include <XalanDOM/XalanText.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
#include <PlatformSupport/DoubleSupport.hpp>
#include "ResultTreeFrag.hpp"
#include "XObjectTypeCallback.hpp"
#include "XPathExecutionContext.hpp"
XStringBase::XStringBase() :
XObject(eTypeString),
m_cachedNumberValue(0.0),
m_resultTreeFrag(0)
{
}
XStringBase::XStringBase(const XStringBase& source) :
XObject(source),
m_cachedNumberValue(source.m_cachedNumberValue),
m_resultTreeFrag(source.m_resultTreeFrag.get() == 0 ?
0 :
source.m_resultTreeFrag->clone(true))
{
}
XStringBase::~XStringBase()
{
}
XalanDOMString
XStringBase::getTypeString() const
{
return XALAN_STATIC_UCODE_STRING("#STRING");
}
double
XStringBase::num() const
{
if (m_cachedNumberValue == 0.0)
{
#if defined(XALAN_NO_MUTABLE)
((XStringBase*)this)->m_cachedNumberValue = DoubleSupport::toDouble(str());
#else
m_cachedNumberValue = DoubleSupport::toDouble(str());
#endif
}
return m_cachedNumberValue;
}
bool
XStringBase::boolean() const
{
return length(str()) > 0 ? true : false;
}
const ResultTreeFragBase&
XStringBase::rtree(XPathExecutionContext& executionContext) const
{
if (m_resultTreeFrag.get() == 0)
{
XalanDocument* const theFactory = executionContext.getDOMFactory();
assert(theFactory != 0);
ResultTreeFrag* const theFrag =
new ResultTreeFrag(*theFactory);
XalanNode* const textNode =
theFactory->createTextNode(str());
assert(textNode != 0);
theFrag->appendChild(textNode);
#if defined(XALAN_NO_MUTABLE)
((XStringBase*)this)->m_resultTreeFrag.reset(theFrag);
#else
m_resultTreeFrag.reset(theFrag);
#endif
}
return *m_resultTreeFrag.get();
}
void
XStringBase::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
theCallbackObject.String(*this,
str());
}
void
XStringBase::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const
{
theCallbackObject.String(*this,
str());
}
1.1 xml-xalan/c/src/XPath/XStringBase.hpp
Index: XStringBase.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2000 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 apache@apache.org.
*
* 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(XSTRINGBASE_HEADER_GUARD_1357924680)
#define XSTRINGBASE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XalanDOM/XalanDOMString.hpp>
#if defined(XALAN_AUTO_PTR_REQUIRES_DEFINITION)
#include <XPath/ResultTreeFragBase.hpp>
#endif
#include <Include/XalanAutoPtr.hpp>
// Base class header file.
#include <XPath/XObject.hpp>
class ResultTreeFragBase;
class XPathEnvSupport;
class XALAN_XPATH_EXPORT XStringBase : public XObject
{
public:
/**
* Construct an XStringBase object from a string.
*
*/
XStringBase();
XStringBase(const XStringBase& source);
virtual
~XStringBase();
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XStringBase*
#endif
clone(void* theAddress = 0) const = 0;
virtual XalanDOMString
getTypeString() const;
virtual double
num() const;
virtual bool
boolean() const;
virtual const XalanDOMString&
str() const = 0;
virtual const ResultTreeFragBase&
rtree(XPathExecutionContext& executionContext) const;
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const;
private:
mutable double m_cachedNumberValue;
mutable XalanAutoPtr<ResultTreeFragBase> m_resultTreeFrag;
};
#endif // XSTRINGBASE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XStringCached.cpp
Index: XStringCached.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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 "XStringCached.hpp"
#include <PlatformSupport/DOMStringHelper.hpp>
XStringCached::XStringCached(GetAndReleaseCachedString& val) :
XStringBase(),
m_value(val)
{
}
XStringCached::XStringCached(const XStringCached& source) :
XStringBase(source),
m_value(source.m_value.getExecutionContext())
{
m_value.get() = source.m_value.get();
}
XStringCached::~XStringCached()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XObject*
#else
XStringCached*
#endif
XStringCached::clone(void* theAddress) const
{
return theAddress == 0 ? new XStringCached(*this) : new (theAddress) XStringCached(*this);
};
const XalanDOMString&
XStringCached::str() const
{
return m_value;
}
XStringCached::eObjectType
XStringCached::getRealType() const
{
return eTypeStringCached;
}
1.1 xml-xalan/c/src/XPath/XStringCached.hpp
Index: XStringCached.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2000 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 apache@apache.org.
*
* 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(XSTRINGCACHED_HEADER_GUARD_1357924680)
#define XSTRINGCACHED_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file.
#include <XPath/XStringBase.hpp>
#include <XPath/XPathExecutionContext.hpp>
class XALAN_XPATH_EXPORT XStringCached : public XStringBase
{
public:
typedef XPathExecutionContext::GetAndReleaseCachedString GetAndReleaseCachedString;
/**
* Create a string XObject from a cached string.
*
* @param theValue value used to create object
*/
XStringCached(GetAndReleaseCachedString& val);
XStringCached(const XStringCached& source);
virtual
~XStringCached();
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XStringCached*
#endif
clone(void* theAddress = 0) const;
virtual const XalanDOMString&
str() const;
protected:
virtual eObjectType
getRealType() const;
private:
const GetAndReleaseCachedString m_value;
};
#endif // XSTRINGCACHED_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XStringCachedAllocator.cpp
Index: XStringCachedAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 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 apache@apache.org.
*
* 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 "XStringCachedAllocator.hpp"
XStringCachedAllocator::XStringCachedAllocator(size_type theBlockCount) :
m_allocator(theBlockCount)
{
}
XStringCachedAllocator::~XStringCachedAllocator()
{
}
XStringCachedAllocator::string_type*
XStringCachedAllocator::createString(GetAndReleaseCachedString& theValue)
{
string_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
string_type* const theResult = new(theBlock) string_type(theValue);
m_allocator.commitAllocation(theBlock);
return theResult;
}
XStringCachedAllocator::string_type*
XStringCachedAllocator::clone(const string_type& value)
{
string_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
value.clone(theBlock);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
bool
XStringCachedAllocator::destroy(string_type* theString)
{
return m_allocator.destroyObject(theString);
}
void
XStringCachedAllocator::reset()
{
m_allocator.reset();
}
1.1 xml-xalan/c/src/XPath/XStringCachedAllocator.hpp
Index: XStringCachedAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 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 apache@apache.org.
*
* 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(XSTRINGCACHEDALLOCATOR_INCLUDE_GUARD_1357924680)
#define XSTRINGCACHEDALLOCATOR_INCLUDE_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XStringCached.hpp>
#include <PlatformSupport/ReusableArenaAllocator.hpp>
class XALAN_XPATH_EXPORT XStringCachedAllocator
{
public:
typedef XStringCached string_type;
typedef string_type::GetAndReleaseCachedString GetAndReleaseCachedString;
typedef ReusableArenaAllocator<string_type> ArenaAllocatorType;
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified size.
*
* @param theBlockSize The block size.
*/
XStringCachedAllocator(size_type theBlockCount);
~XStringCachedAllocator();
/**
* Create an XString object from a cached string.
*
* @param theXObject The source cached string
*
* @return a pointer to the new XStringCached instance.
*/
string_type*
createString(GetAndReleaseCachedString& theValue);
/**
* Clone an XStringCached object.
*
* @param value source XStringCached
*
* @return pointer to an XStringCached
*/
string_type*
clone(const string_type& value);
/**
* Delete an XStringCached object from allocator.
*/
bool
destroy(string_type* theString);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const string_type* theObject)
{
return m_allocator.ownsObject(theObject);
}
/**
* Delete all XStringCached 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...
XStringCachedAllocator(const XStringCachedAllocator&);
XStringCachedAllocator&
operator=(const XStringCachedAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XSTRINGCACHEDALLOCATOR_INCLUDE_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XStringReference.cpp
Index: XStringReference.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2000 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 apache@apache.org.
*
* 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 "XStringReference.hpp"
XStringReference::XStringReference(const XalanDOMString& val) :
XStringBase(),
m_value(val)
{
}
XStringReference::XStringReference(const XStringReference& source) :
XStringBase(source),
m_value(source.m_value)
{
}
XStringReference::~XStringReference()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XObject*
#else
XStringReference*
#endif
XStringReference::clone(void* theAddress) const
{
return theAddress == 0 ? new XStringReference(*this) : new (theAddress) XStringReference(*this);
};
const XalanDOMString&
XStringReference::str() const
{
return m_value;
}
XStringReference::eObjectType
XStringReference::getRealType() const
{
return eTypeStringReference;
}
1.1 xml-xalan/c/src/XPath/XStringReference.hpp
Index: XStringReference.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999 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 apache@apache.org.
*
* 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(XSTRINGREFERENCE_HEADER_GUARD_1357924680)
#define XSTRINGREFERENCE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class header file.
#include <XPath/XStringBase.hpp>
class XALAN_XPATH_EXPORT XStringReference : public XStringBase
{
public:
/**
* Construct an XStringReference object from a string.
* The XStringReference will hold a reference to the
* supplied string, so the string must be in scope for
* the lifetime of the instance
*
* @param value source string
*/
XStringReference(const XalanDOMString& val);
XStringReference(const XStringReference& source);
virtual
~XStringReference();
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XStringReference*
#endif
clone(void* theAddress = 0) const;
virtual const XalanDOMString&
str() const;
protected:
virtual eObjectType
getRealType() const;
private:
const XalanDOMString& m_value;
};
#endif // XSTRINGREFERENCE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XStringReferenceAllocator.cpp
Index: XStringReferenceAllocator.cpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 1999-2000 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 apache@apache.org.
*
* 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 "XStringReferenceAllocator.hpp"
XStringReferenceAllocator::XStringReferenceAllocator(size_type theBlockCount) :
m_allocator(theBlockCount)
{
}
XStringReferenceAllocator::~XStringReferenceAllocator()
{
}
XStringReferenceAllocator::string_type*
XStringReferenceAllocator::createString(const XalanDOMString& theString)
{
string_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
string_type* const theResult = new(theBlock) string_type(theString);
m_allocator.commitAllocation(theBlock);
return theResult;
}
XStringReferenceAllocator::string_type*
XStringReferenceAllocator::clone(const string_type& value)
{
string_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
value.clone(theBlock);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
bool
XStringReferenceAllocator::destroy(string_type* theString)
{
return m_allocator.destroyObject(theString);
}
void
XStringReferenceAllocator::reset()
{
m_allocator.reset();
}
1.1 xml-xalan/c/src/XPath/XStringReferenceAllocator.hpp
Index: XStringReferenceAllocator.hpp
===================================================================
/*
* The Apache Software License, Version 1.1
*
*
* Copyright (c) 2000 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 apache@apache.org.
*
* 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(XSTRINGREFERENCEALLOCATOR_INCLUDE_GUARD_1357924680)
#define XSTRINGREFERENCEALLOCATOR_INCLUDE_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XStringReference.hpp>
#include <PlatformSupport/ReusableArenaAllocator.hpp>
class XALAN_XPATH_EXPORT XStringReferenceAllocator
{
public:
typedef XStringReference string_type;
typedef ReusableArenaAllocator<string_type> ArenaAllocatorType;
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified size.
*
* @param theBlockSize The block size.
*/
XStringReferenceAllocator(size_type theBlockCount);
~XStringReferenceAllocator();
/**
* Create an XStringReference object from a string.
*
* @param theString source string
*
* @return a pointer to string
*/
string_type*
createString(const XalanDOMString& theString);
/**
* Clone an XStringReference object.
*
* @param value source XStringReference
*
* @return pointer to an XStringReference
*/
string_type*
clone(const string_type& value);
/**
* Delete an XStringReference object from allocator.
*/
bool
destroy(string_type* theString);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const string_type* theObject)
{
return m_allocator.ownsObject(theObject);
}
/**
* Delete all XStringReference 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...
XStringReferenceAllocator(const XStringReferenceAllocator&);
XStringReferenceAllocator&
operator=(const XStringReferenceAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XSTRINGREFERENCEALLOCATOR_INCLUDE_GUARD_1357924680