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/16 03:34:50 UTC
cvs commit: xml-xalan/c/src/XPath XNumberBase.cpp XNumberBase.hpp XToken.cpp XToken.hpp XTokenNumberAdapter.cpp XTokenNumberAdapter.hpp XTokenNumberAdapterAllocator.cpp XTokenNumberAdapterAllocator.hpp XTokenStringAdapter.cpp XTokenStringAdapter.hpp XTokenStringAdapterAllocator.cpp XTokenStringAdapterAllocator.hpp XNumber.cpp XNumber.hpp XObject.hpp XObjectFactory.hpp XObjectFactoryDefault.cpp XObjectFactoryDefault.hpp XPath.cpp XPathExecutionContext.hpp XPathExecutionContextDefault.cpp XPathExecutionContextDefault.hpp XPathExpression.cpp XPathExpression.hpp
dbertoni 01/01/15 18:34:49
Modified: c/src/XPath XNumber.cpp XNumber.hpp XObject.hpp
XObjectFactory.hpp XObjectFactoryDefault.cpp
XObjectFactoryDefault.hpp XPath.cpp
XPathExecutionContext.hpp
XPathExecutionContextDefault.cpp
XPathExecutionContextDefault.hpp
XPathExpression.cpp XPathExpression.hpp
Added: c/src/XPath XNumberBase.cpp XNumberBase.hpp XToken.cpp
XToken.hpp XTokenNumberAdapter.cpp
XTokenNumberAdapter.hpp
XTokenNumberAdapterAllocator.cpp
XTokenNumberAdapterAllocator.hpp
XTokenStringAdapter.cpp XTokenStringAdapter.hpp
XTokenStringAdapterAllocator.cpp
XTokenStringAdapterAllocator.hpp
Log:
Moved XToken to a separate file. Made changes to allow adapters for XTokens, which reduces creation of XStrings and XNumbers.
Revision Changes Path
1.12 +5 -34 xml-xalan/c/src/XPath/XNumber.cpp
Index: XNumber.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNumber.cpp,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- XNumber.cpp 2000/12/01 21:41:55 1.11
+++ XNumber.cpp 2001/01/16 02:34:45 1.12
@@ -60,16 +60,11 @@
#include <PlatformSupport/DOMStringHelper.hpp>
-#include <PlatformSupport/DoubleSupport.hpp>
-#include "XObjectTypeCallback.hpp"
-
-
-
XNumber::XNumber(double val) :
- XObject(eTypeNumber),
+ XNumberBase(),
m_value(val),
m_cachedStringValue()
{
@@ -78,7 +73,7 @@
XNumber::XNumber(const XNumber& source) :
- XObject(source),
+ XNumberBase(source),
m_value(source.m_value),
m_cachedStringValue(source.m_cachedStringValue)
{
@@ -104,14 +99,6 @@
-XalanDOMString
-XNumber::getTypeString() const
-{
- return XALAN_STATIC_UCODE_STRING("#NUMBER");
-}
-
-
-
double
XNumber::num() const
{
@@ -120,14 +107,6 @@
-bool
-XNumber::boolean() const
-{
- return DoubleSupport::isNaN(m_value) || DoubleSupport::equal(m_value, 0.0) ? false : true;
-}
-
-
-
const XalanDOMString&
XNumber::str() const
{
@@ -146,17 +125,9 @@
void
-XNumber::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
+XNumber::set(double theValue)
{
- theCallbackObject.Number(*this,
- num());
-}
+ m_value = theValue;
-
-
-void
-XNumber::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const
-{
- theCallbackObject.Number(*this,
- num());
+ clear(m_cachedStringValue);
}
1.11 +11 -13 xml-xalan/c/src/XPath/XNumber.hpp
Index: XNumber.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XNumber.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XNumber.hpp 2000/09/19 14:56:06 1.10
+++ XNumber.hpp 2001/01/16 02:34:45 1.11
@@ -69,18 +69,18 @@
// Base class header file.
-#include <XPath/XObject.hpp>
+#include <XPath/XNumberBase.hpp>
-class XALAN_XPATH_EXPORT XNumber : public XObject
+class XALAN_XPATH_EXPORT XNumber : public XNumberBase
{
public:
/**
* Create an XNumber from a number.
*
- * @param val numeric value to use
+ * @param val numeric value to use
*/
XNumber(double val);
@@ -98,23 +98,21 @@
#endif
clone(void* theAddress = 0) const;
- virtual XalanDOMString
- getTypeString() const;
-
virtual double
num() const;
- virtual bool
- boolean() const;
-
virtual const XalanDOMString&
str() const;
- virtual void
- ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
+ // These methods are new to XNumber...
- virtual void
- ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const;
+ /**
+ * Change the value of an XNumber
+ *
+ * @param theValue The new value.
+ */
+ void
+ set(double theValue);
private:
1.16 +2 -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.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- XObject.hpp 2001/01/03 19:32:39 1.15
+++ XObject.hpp 2001/01/16 02:34:45 1.16
@@ -110,6 +110,8 @@
eTypeStringReference = 8,
eTypeStringAdapter = 9,
eTypeStringCached = 10,
+ eTypeXTokenNumberAdapter = 11,
+ eTypeXTokenStringAdapter = 12,
eUnknown
};
1.17 +25 -1 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.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- XObjectFactory.hpp 2000/12/21 04:43:49 1.16
+++ XObjectFactory.hpp 2001/01/16 02:34:45 1.17
@@ -81,6 +81,7 @@
class ResultTreeFragBase;
class XObject;
class XObjectPtr;
+class XToken;
@@ -92,6 +93,7 @@
public:
typedef XPathExecutionContext::BorrowReturnMutableNodeRefList BorrowReturnMutableNodeRefList;
+ typedef XPathExecutionContext::BorrowReturnResultTreeFrag BorrowReturnResultTreeFrag;
typedef XPathExecutionContext::GetAndReleaseCachedString GetAndReleaseCachedString;
@@ -157,6 +159,17 @@
createNumber(double theValue) = 0;
/**
+ * Create a numeric XObject from an XToken. The XToken
+ * instance must be inexistence for the lifetime of the
+ * object.
+ *
+ * @param theValue value used to create object
+ * @return pointer to new object
+ */
+ virtual const XObjectPtr
+ createNumber(const XToken& theValue) = 0;
+
+ /**
* Create a string XObject from a string.
*
* @param theValue value used to create object
@@ -187,6 +200,17 @@
unsigned int theLength) = 0;
/**
+ * Create a string XObject from an XToken. The XToken
+ * instance must be inexistence for the lifetime of the
+ * object.
+ *
+ * @param theValue value used to create object
+ * @return pointer to new object
+ */
+ virtual const XObjectPtr
+ createString(const XToken& theValue) = 0;
+
+ /**
* Create a string XObject from a string. The XObject
* will hold a reference to the supplied string, so
* the string must be in scope for the lifetime of
@@ -234,7 +258,7 @@
* @return pointer to new object
*/
virtual const XObjectPtr
- createResultTreeFrag(ResultTreeFragBase* theValue) = 0;
+ createResultTreeFrag(BorrowReturnResultTreeFrag& theValue) = 0;
/**
* Create a span XObject from a node list.
1.19 +88 -9 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.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- XObjectFactoryDefault.cpp 2000/12/21 04:43:49 1.18
+++ XObjectFactoryDefault.cpp 2001/01/16 02:34:45 1.19
@@ -96,7 +96,10 @@
m_xnumberAllocator(theXNumberBlockSize),
m_xnodesetAllocator(theXNodeSetBlockSize),
m_xresultTreeFragAllocator(theXResultTreeFragBlockSize),
+ m_xtokenNumberAdapterAllocator(theXNumberBlockSize),
+ m_xtokenStringAdapterAllocator(theXStringBlockSize),
m_xobjects(),
+ m_xnumberCache(),
m_XNull(new XNull)
{
}
@@ -142,6 +145,32 @@
}
break;
+ case XObject::eTypeXTokenNumberAdapter:
+ {
+ XTokenNumberAdapter* const theAdapter =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (XTokenNumberAdapter*)theXObject;
+#else
+ static_cast<XTokenNumberAdapter*>(theXObject);
+#endif
+
+ bStatus = m_xtokenNumberAdapterAllocator.destroy(theAdapter);
+ }
+ break;
+
+ case XObject::eTypeXTokenStringAdapter:
+ {
+ XTokenStringAdapter* const theAdapter =
+#if defined(XALAN_OLD_STYLE_CASTS)
+ (XTokenStringAdapter*)theXObject;
+#else
+ static_cast<XTokenStringAdapter*>(theXObject);
+#endif
+
+ bStatus = m_xtokenStringAdapterAllocator.destroy(theAdapter);
+ }
+ break;
+
case XObject::eTypeString:
{
XString* const theXString =
@@ -189,8 +218,17 @@
#else
static_cast<XNumber*>(theXObject);
#endif
+
+ if (m_xnumberCache.size() < eXNumberCacheMax)
+ {
+ m_xnumberCache.push_back(theXNumber);
- bStatus = m_xnumberAllocator.destroy(theXNumber);
+ bStatus = true;
+ }
+ else
+ {
+ bStatus = m_xnumberAllocator.destroy(theXNumber);
+ }
}
break;
@@ -279,13 +317,13 @@
const XObjectPtr
XObjectFactoryDefault::createSpan(BorrowReturnMutableNodeRefList& theValue)
{
- XSpan* const theXSpan = new XSpan(theValue);
+ XSpan* const theXObject = new XSpan(theValue);
- m_xobjects.insert(theXSpan);
+ m_xobjects.insert(theXObject);
- theXSpan->setFactory(this);
+ theXObject->setFactory(this);
- return XObjectPtr(theXSpan);
+ return XObjectPtr(theXObject);
}
@@ -293,16 +331,43 @@
const XObjectPtr
XObjectFactoryDefault::createNumber(double theValue)
{
- XNumber* theXNumber = m_xnumberAllocator.createNumber(theValue);
+ if (m_xnumberCache.size() > 0)
+ {
+ XNumber* const theXNumber = m_xnumberCache.back();
+
+ m_xnumberCache.pop_back();
- theXNumber->setFactory(this);
+ theXNumber->set(theValue);
- return XObjectPtr(theXNumber);
+ return XObjectPtr(theXNumber);
+ }
+ else
+ {
+ m_xnumberCache.reserve(eXNumberCacheMax);
+
+ XObject* const theXObject = m_xnumberAllocator.createNumber(theValue);
+
+ theXObject->setFactory(this);
+
+ return XObjectPtr(theXObject);
+ }
}
const XObjectPtr
+XObjectFactoryDefault::createNumber(const XToken& theValue)
+{
+ XObject* theXObject = m_xtokenNumberAdapterAllocator.create(theValue);
+
+ theXObject->setFactory(this);
+
+ return XObjectPtr(theXObject);
+}
+
+
+
+const XObjectPtr
XObjectFactoryDefault::createNodeSet(BorrowReturnMutableNodeRefList& theValue)
{
XNodeSet* const theXNodeSet = m_xnodesetAllocator.createNodeSet(theValue);
@@ -353,6 +418,18 @@
const XObjectPtr
+XObjectFactoryDefault::createString(const XToken& theValue)
+{
+ XObject* theXObject = m_xtokenStringAdapterAllocator.create(theValue);
+
+ theXObject->setFactory(this);
+
+ return XObjectPtr(theXObject);
+}
+
+
+
+const XObjectPtr
XObjectFactoryDefault::createStringReference(const XalanDOMString& theValue)
{
XStringReference* const theXStringReference = m_xstringReferenceAllocator.createString(theValue);
@@ -389,7 +466,7 @@
const XObjectPtr
-XObjectFactoryDefault::createResultTreeFrag(ResultTreeFragBase* theValue)
+XObjectFactoryDefault::createResultTreeFrag(BorrowReturnResultTreeFrag& theValue)
{
XResultTreeFrag* const theResultTreeFrag = m_xresultTreeFragAllocator.create(theValue);
@@ -424,4 +501,6 @@
DeleteXObjectFunctor(*this, true));
m_xobjects.clear();
+
+ m_xnumberCache.clear();
}
1.18 +33 -13 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.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- XObjectFactoryDefault.hpp 2000/12/21 04:43:49 1.17
+++ XObjectFactoryDefault.hpp 2001/01/16 02:34:45 1.18
@@ -65,6 +65,7 @@
#include <set>
+#include <vector>
@@ -75,11 +76,13 @@
#include <XPath/XNodeSetAllocator.hpp>
#include <XPath/XNumberAllocator.hpp>
+#include <XPath/XResultTreeFragAllocator.hpp>
#include <XPath/XStringAllocator.hpp>
#include <XPath/XStringAdapterAllocator.hpp>
#include <XPath/XStringCachedAllocator.hpp>
#include <XPath/XStringReferenceAllocator.hpp>
-#include <XPath/XResultTreeFragAllocator.hpp>
+#include <XPath/XTokenNumberAdapterAllocator.hpp>
+#include <XPath/XTokenStringAdapterAllocator.hpp>
@@ -94,6 +97,7 @@
class XNull;
+class XNumber;
@@ -148,6 +152,9 @@
createNumber(double theValue);
virtual const XObjectPtr
+ createNumber(const XToken& theValue);
+
+ virtual const XObjectPtr
createString(const XalanDOMString& theValue);
virtual const XObjectPtr
@@ -159,6 +166,9 @@
unsigned int theLength);
virtual const XObjectPtr
+ createString(const XToken& theValue);
+
+ virtual const XObjectPtr
createStringReference(const XalanDOMString& theValue);
virtual const XObjectPtr
@@ -172,15 +182,17 @@
const XalanDOMString& theValue);
virtual const XObjectPtr
- createResultTreeFrag(ResultTreeFragBase* theValue);
+ createResultTreeFrag(BorrowReturnResultTreeFrag& theValue);
virtual const XObjectPtr
createSpan(BorrowReturnMutableNodeRefList& theValue);
#if defined(XALAN_NO_NAMESPACES)
- typedef set<XObject*, less<XObject*> > CollectionType;
+ typedef set<XObject*, less<XObject*> > CollectionType;
+ typedef vector<XNumber*>, less<XNumber*> > XNumberCacheType;
#else
- typedef std::set<XObject*> CollectionType;
+ typedef std::set<XObject*> CollectionType;
+ typedef std::vector<XNumber*> XNumberCacheType;
#endif
protected:
@@ -192,6 +204,8 @@
private:
+ enum { eXNumberCacheMax = 40 };
+
// Not implemented...
XObjectFactoryDefault(const XObjectFactoryDefault&);
@@ -206,23 +220,29 @@
// This one's first, since it may be be holding references
// to objects in other allocators.
- XStringAdapterAllocator m_xstringAdapterAllocator;
+ XStringAdapterAllocator m_xstringAdapterAllocator;
+
+ XStringAllocator m_xstringAllocator;
+
+ XStringCachedAllocator m_xstringCachedAllocator;
+
+ XStringReferenceAllocator m_xstringReferenceAllocator;
- XStringAllocator m_xstringAllocator;
+ XNumberAllocator m_xnumberAllocator;
- XStringCachedAllocator m_xstringCachedAllocator;
+ XNodeSetAllocator m_xnodesetAllocator;
- XStringReferenceAllocator m_xstringReferenceAllocator;
+ XResultTreeFragAllocator m_xresultTreeFragAllocator;
- XNumberAllocator m_xnumberAllocator;
+ XTokenNumberAdapterAllocator m_xtokenNumberAdapterAllocator;
- XNodeSetAllocator m_xnodesetAllocator;
+ XTokenStringAdapterAllocator m_xtokenStringAdapterAllocator;
- XResultTreeFragAllocator m_xresultTreeFragAllocator;
+ CollectionType m_xobjects;
- CollectionType m_xobjects;
+ XNumberCacheType m_xnumberCache;
- const XalanAutoPtr<XNull> m_XNull;
+ const XalanAutoPtr<XNull> m_XNull;
};
1.40 +9 -47 xml-xalan/c/src/XPath/XPath.cpp
Index: XPath.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPath.cpp,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- XPath.cpp 2001/01/08 18:28:24 1.39
+++ XPath.cpp 2001/01/16 02:34:46 1.40
@@ -992,7 +992,7 @@
}
else
{
- return executionContext.getXObjectFactory().createString(expr1->str());
+ return executionContext.getXObjectFactory().createStringAdapter(expr1);
}
}
@@ -1004,7 +1004,7 @@
int opPos,
XPathExecutionContext& executionContext) const
{
- XObjectPtr expr1(executeMore(context, opPos + 2, executionContext));
+ const XObjectPtr expr1(executeMore(context, opPos + 2, executionContext));
assert(expr1.get() != 0);
// Try to optimize when the result of the execution is
@@ -1027,7 +1027,7 @@
int opPos,
XPathExecutionContext& executionContext) const
{
- XObjectPtr expr1(executeMore(context, opPos + 2, executionContext));
+ const XObjectPtr expr1(executeMore(context, opPos + 2, executionContext));
assert(expr1.get() != 0);
// Try to optimize when the result of the execution is
@@ -1085,9 +1085,9 @@
assert(m_expression.m_opMap.size() > unsigned(opPos + 2));
assert(m_expression.m_tokenQueue.size() > unsigned(m_expression.m_opMap[opPos + 2]));
- const XObject& theLiteral = m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
+ const XToken& theLiteral = m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
- return executionContext.getXObjectFactory().createString(theLiteral.str());
+ return executionContext.getXObjectFactory().createString(theLiteral);
}
@@ -1146,13 +1146,13 @@
assert(m_expression.m_opMap.size() > unsigned(opPos + 2));
assert(m_expression.m_tokenQueue.size() > unsigned(m_expression.m_opMap[opPos + 2]));
- const XObject& theLiteral = m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
+ const XToken& theLiteral = m_expression.m_tokenQueue[m_expression.m_opMap[opPos + 2]];
- return executionContext.getXObjectFactory().createNumber(theLiteral.num());
+ return executionContext.getXObjectFactory().createNumber(theLiteral);
}
-
+
const XObjectPtr
XPath::arg(
XalanNode* context,
@@ -1172,33 +1172,6 @@
{
assert(context != 0);
-/*
- const int stepType = m_expression.m_opMap[opPos + 2];
-
- XLocator xlocator = null;
- if(OP_VARIABLE == stepType)
- {
- // Bit of a hack here...
- XObject obj = execute(context, opPos+2);
- NodeList nl = obj.nodeset();
- if(nl.getLength() > 0)
- {
- // Use the xlocator of the first node...
- // I guess we should really loop through the contexts, but things
- // will get very nasty quick, so just do this for now.
- xlocator = m_callbacks.getXLocatorFromNode(nl.item(0));
- }
- else
- {
- xlocator = m_callbacks.getXLocatorFromNode(context);
- }
- }
- else
- {
- xlocator = m_callbacks.getXLocatorFromNode(context);
- }
-*/
-
XLocator* xlocator = executionContext.getXLocatorFromNode(context);
if(0 == xlocator)
@@ -1217,18 +1190,7 @@
int opPos,
XPathExecutionContext& executionContext) const
{
- const XObjectPtr expr1 = executeMore(context, opPos + 2, executionContext);
-
- // $$$ ToDo: This appears to be just an optimization, but is it really?
-/*
- int objType = expr1.getType();
- if((XObject.CLASS_NUMBER != objType) && (XObject.CLASS_BOOLEAN != objType))
- {
- expr1 = expr1.bool() ? m_true : m_false;
- }
-*/
-
- return expr1;
+ return executeMore(context, opPos + 2, executionContext);
}
1.34 +102 -5 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.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- XPathExecutionContext.hpp 2001/01/08 18:28:24 1.33
+++ XPathExecutionContext.hpp 2001/01/16 02:34:46 1.34
@@ -80,8 +80,8 @@
-//#include <XPath/Function.hpp>
#include <XPath/MutableNodeRefList.hpp>
+#include <XPath/ResultTreeFragBase.hpp>
@@ -332,17 +332,17 @@
const XalanDOMString& base) const = 0;
/**
- * Borrow a cached MutableNodeRefList.
+ * Borrow a cached MutableNodeRefList instance.
*
- * @return A pointer the to node list.
+ * @return A pointer to the instance.
*/
virtual MutableNodeRefList*
borrowMutableNodeRefList() = 0;
/**
- * Return a previously borrowed MutableNodeRefList.
+ * Return a previously borrowed MutableNodeRefList instance.
*
- * @param theList A pointer the to previously borrowed node list.
+ * @param theList A pointer the to previously borrowed instance.
* @return true if the list was borrowed (at therefore, destroyed), false if not.
*/
virtual bool
@@ -477,6 +477,103 @@
XalanDOMString* m_string;
};
+
+ /**
+ * Borrow a cached ResultTreeFragBase instance.
+ *
+ * @return A pointer to the instance.
+ */
+ virtual ResultTreeFragBase*
+ borrowResultTreeFrag() = 0;
+
+ /**
+ * Return a previously borrowed ResultTreeFragBase instance.
+ *
+ * @param theList A pointer the to previously borrowed instance.
+ * @return true if the list was borrowed (at therefore, destroyed), false if not.
+ */
+ virtual bool
+ returnResultTreeFrag(ResultTreeFragBase* theResultTreeFragBase) = 0;
+
+
+ class BorrowReturnResultTreeFrag
+ {
+ public:
+
+ BorrowReturnResultTreeFrag(XPathExecutionContext& executionContext) :
+ m_xpathExecutionContext(executionContext),
+ m_resultTreeFrag(executionContext.borrowResultTreeFrag())
+ {
+ assert(m_resultTreeFrag != 0);
+ }
+
+ // N.B. Non-const copy constructor semantics (like std::auto_ptr)
+ BorrowReturnResultTreeFrag(const BorrowReturnResultTreeFrag& theSource) :
+ m_xpathExecutionContext(theSource.m_xpathExecutionContext),
+ m_resultTreeFrag(theSource.m_resultTreeFrag)
+ {
+ assert(m_resultTreeFrag != 0);
+
+ ((BorrowReturnResultTreeFrag&)theSource).m_resultTreeFrag = 0;
+ }
+
+ ~BorrowReturnResultTreeFrag()
+ {
+ if (m_resultTreeFrag != 0)
+ {
+ if (m_xpathExecutionContext.returnResultTreeFrag(m_resultTreeFrag) == false)
+ {
+ delete m_resultTreeFrag;
+ }
+ }
+ }
+
+ ResultTreeFragBase&
+ operator*() const
+ {
+ return *m_resultTreeFrag;
+ }
+
+ ResultTreeFragBase*
+ get() const
+ {
+ return m_resultTreeFrag;
+ }
+
+ ResultTreeFragBase*
+ operator->() const
+ {
+ return get();
+ }
+
+ BorrowReturnResultTreeFrag
+ clone(bool deep = false) const
+ {
+ BorrowReturnResultTreeFrag theResult(
+ m_xpathExecutionContext,
+ m_resultTreeFrag->clone(deep));
+
+ return theResult;
+ }
+
+ private:
+
+ BorrowReturnResultTreeFrag(
+ XPathExecutionContext& executionContext,
+ ResultTreeFragBase* resultTreeFrag) :
+ m_xpathExecutionContext(executionContext),
+ m_resultTreeFrag(resultTreeFrag)
+ {
+ assert(m_resultTreeFrag != 0);
+ }
+
+ // Data members...
+ XPathExecutionContext& m_xpathExecutionContext;
+
+ ResultTreeFragBase* m_resultTreeFrag;
+ };
+
+ friend class BorrowReturnResultTreeFrag;
/**
* Create a MutableNodeRefList with the appropriate context.
1.31 +69 -6 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.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- XPathExecutionContextDefault.cpp 2001/01/08 18:28:24 1.30
+++ XPathExecutionContextDefault.cpp 2001/01/16 02:34:46 1.31
@@ -73,6 +73,7 @@
#include "FoundIndex.hpp"
#include "XObjectFactory.hpp"
#include "PrefixResolver.hpp"
+#include "ResultTreeFrag.hpp"
#include "QName.hpp"
#include "XPathEnvSupport.hpp"
@@ -99,6 +100,8 @@
m_throwFoundIndex(false),
m_availableCachedNodeLists(),
m_busyCachedNodeLists(),
+ m_availableCachedResultTreeFrags(),
+ m_busyCachedResultTreeFrags(),
m_stringCache()
{
m_availableCachedNodeLists.reserve(eMutableNodeRefListCacheMax);
@@ -120,6 +123,11 @@
m_availableCachedNodeLists.begin(),
m_availableCachedNodeLists.end(),
DeleteFunctor<MutableNodeRefList>());
+
+ for_each(
+ m_availableCachedResultTreeFrags.begin(),
+ m_availableCachedResultTreeFrags.end(),
+ DeleteFunctor<ResultTreeFragBase>());
}
@@ -138,6 +146,13 @@
m_busyCachedNodeLists.pop_back();
}
+ while (m_busyCachedResultTreeFrags.size() != 0)
+ {
+ m_availableCachedResultTreeFrags.push_back(m_busyCachedResultTreeFrags.back());
+
+ m_busyCachedResultTreeFrags.pop_back();
+ }
+
m_stringCache.reset();
}
@@ -324,21 +339,69 @@
using std::find;
#endif
- // Search from the back to the front, since we push the latest borrowed on the back.
- NodeRefListCacheType::reverse_iterator i =
- find(m_busyCachedNodeLists.rbegin(), m_busyCachedNodeLists.rend(), theList);
+ const NodeRefListCacheType::iterator i =
+ find(m_busyCachedNodeLists.begin(), m_busyCachedNodeLists.end(), theList);
- if (i == m_busyCachedNodeLists.rend())
+ if (i == m_busyCachedNodeLists.end())
{
return false;
}
else
{
theList->clear();
+
+ m_availableCachedNodeLists.push_back(theList);
+
+ m_busyCachedNodeLists.erase(i);
+
+ return true;
+ }
+}
+
+
+
+ResultTreeFragBase*
+XPathExecutionContextDefault::borrowResultTreeFrag()
+{
+ // We'll always return the back of the free list, since
+ // that's the cheapest thing.
+ if (m_availableCachedResultTreeFrags.size() == 0)
+ {
+ m_busyCachedResultTreeFrags.push_back(new ResultTreeFrag);
+ }
+ else
+ {
+ m_busyCachedResultTreeFrags.push_back(m_availableCachedResultTreeFrags.back());
+
+ m_availableCachedResultTreeFrags.pop_back();
+ }
+
+ return m_busyCachedResultTreeFrags.back();
+}
+
+
+
+bool
+XPathExecutionContextDefault::returnResultTreeFrag(ResultTreeFragBase* theResultTreeFragBase)
+{
+#if !defined(XALAN_NO_NAMESPACES)
+ using std::find;
+#endif
+
+ const ResultTreeFragCacheType::iterator i =
+ find(m_busyCachedResultTreeFrags.begin(), m_busyCachedResultTreeFrags.end(), theResultTreeFragBase);
+
+ if (i == m_busyCachedResultTreeFrags.end())
+ {
+ return false;
+ }
+ else
+ {
+ theResultTreeFragBase->clear();
- m_availableCachedNodeLists.push_back(*i);
+ m_availableCachedResultTreeFrags.push_back(theResultTreeFragBase);
- m_busyCachedNodeLists.erase(&*i);
+ m_busyCachedResultTreeFrags.erase(i);
return true;
}
1.31 +14 -1 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.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- XPathExecutionContextDefault.hpp 2001/01/08 18:28:24 1.30
+++ XPathExecutionContextDefault.hpp 2001/01/16 02:34:46 1.31
@@ -90,8 +90,8 @@
-class XPathEnvSupport;
class DOMSupport;
+class XPathEnvSupport;
@@ -194,6 +194,12 @@
virtual bool
returnMutableNodeRefList(MutableNodeRefList* theList);
+ virtual ResultTreeFragBase*
+ borrowResultTreeFrag();
+
+ virtual bool
+ returnResultTreeFrag(ResultTreeFragBase* theResultTreeFragBase);
+
virtual MutableNodeRefList*
createMutableNodeRefList() const;
@@ -295,13 +301,16 @@
#if defined(XALAN_NO_NAMESPACES)
typedef vector<MutableNodeRefList*> NodeRefListCacheType;
+ typedef vector<ResultTreeFragBase*> ResultTreeFragCacheType;
#else
typedef std::vector<MutableNodeRefList*> NodeRefListCacheType;
+ typedef std::vector<ResultTreeFragBase*> ResultTreeFragCacheType;
#endif
protected:
enum { eMutableNodeRefListCacheMax = 50,
+ eResultTreeFragListCacheMax = 50,
eCachedArgVectorDefaultSize = 10 };
XPathEnvSupport& m_xpathEnvSupport;
@@ -323,6 +332,10 @@
NodeRefListCacheType m_availableCachedNodeLists;
NodeRefListCacheType m_busyCachedNodeLists;
+
+ ResultTreeFragCacheType m_availableCachedResultTreeFrags;
+
+ ResultTreeFragCacheType m_busyCachedResultTreeFrags;
XalanDOMStringCache m_stringCache;
1.21 +0 -132 xml-xalan/c/src/XPath/XPathExpression.cpp
Index: XPathExpression.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XPathExpression.cpp 2000/11/30 19:40:59 1.20
+++ XPathExpression.cpp 2001/01/16 02:34:46 1.21
@@ -256,138 +256,6 @@
-XPathExpression::XToken::XToken() :
- XObject(eTypeString),
- m_stringValue(),
- m_numberValue(DoubleSupport::getNaN())
-{
-}
-
-
-
-XPathExpression::XToken::XToken(const XalanDOMString& theString) :
- XObject(eTypeString),
- m_stringValue(theString),
- m_numberValue(DoubleSupport::toDouble(theString))
-{
-}
-
-
-
-XPathExpression::XToken::XToken(double theNumber) :
- XObject(eTypeString),
- m_stringValue(DoubleToDOMString(theNumber)),
- m_numberValue(theNumber)
-{
-}
-
-
-
-XPathExpression::XToken::XToken(const XToken& theSource) :
- XObject(theSource),
- m_stringValue(theSource.m_stringValue),
- m_numberValue(theSource.m_numberValue)
-{
-}
-
-
-
-XPathExpression::XToken::~XToken()
-{
-}
-
-
-
-#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
-XObject*
-#else
-XPathExpression::XToken*
-#endif
-XPathExpression::XToken::clone(void* theAddress) const
-{
- return theAddress == 0 ? new XToken(*this) : new (theAddress) XToken(*this);
-}
-
-
-
-XalanDOMString
-XPathExpression::XToken::getTypeString() const
-{
- return XALAN_STATIC_UCODE_STRING("#TOKEN");
-}
-
-
-
-double
-XPathExpression::XToken::num() const
-{
- return m_numberValue;
-}
-
-
-
-const XalanDOMString&
-XPathExpression::XToken::str() const
-{
- return m_stringValue;
-}
-
-
-
-void
-XPathExpression::XToken::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
-{
- theCallbackObject.String(*this, m_stringValue);
-}
-
-
-
-void
-XPathExpression::XToken::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const
-{
- theCallbackObject.String(*this, m_stringValue);
-}
-
-
-
-XPathExpression::XToken&
-XPathExpression::XToken::operator=(const XalanDOMString& theString)
-{
- m_stringValue = theString;
-
- m_numberValue = DoubleSupport::toDouble(theString);
-
- return *this;
-}
-
-
-
-XPathExpression::XToken&
-XPathExpression::XToken::operator=(double theNumber)
-{
- m_stringValue = DoubleToDOMString(theNumber);
-
- m_numberValue = theNumber;
-
- return *this;
-}
-
-
-
-void
-XPathExpression::XToken::referenced()
-{
-}
-
-
-
-void
-XPathExpression::XToken::dereferenced()
-{
-}
-
-
-
XPathExpression::XPathExpression() :
m_opMap(),
m_lastOpCodeIndex(0),
1.13 +1 -75 xml-xalan/c/src/XPath/XPathExpression.hpp
Index: XPathExpression.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XPath/XPathExpression.hpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XPathExpression.hpp 2000/11/21 21:08:38 1.12
+++ XPathExpression.hpp 2001/01/16 02:34:46 1.13
@@ -80,7 +80,7 @@
-#include <XPath/XObject.hpp>
+#include <XPath/XToken.hpp>
#include <XPath/XPathException.hpp>
@@ -728,80 +728,6 @@
static XalanDOMString
FormatErrorMessage(int theOffset);
- };
-
- class XToken : public XObject
- {
- public:
-
- explicit
- XToken();
-
- XToken(const XalanDOMString& theString);
-
- XToken(double theNumber);
-
- XToken(const XToken& theSource);
-
- virtual
- ~XToken();
-
-#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
- virtual XObject*
-#else
- virtual XToken*
-#endif
- clone(void* theAddress = 0) const;
-
- virtual XalanDOMString
- getTypeString() const;
-
- virtual double
- num() const;
-
- virtual const XalanDOMString&
- str() const;
-
- virtual void
- ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
-
- virtual void
- ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const;
-
- XToken&
- operator=(const XToken& theRHS)
- {
- m_stringValue = theRHS.m_stringValue;
-
- m_numberValue = theRHS.m_numberValue;
-
- return *this;
- }
-
- XToken&
- operator=(const XalanDOMString& theString);
-
- XToken&
- operator=(double theNumber);
-
- protected:
-
- virtual void
- referenced();
-
- virtual void
- dereferenced();
-
- private:
-
- // Not defined...
- bool
- operator==(const XToken&) const;
-
- // Data members...
- XalanDOMString m_stringValue;
-
- double m_numberValue;
};
1.1 xml-xalan/c/src/XPath/XNumberBase.cpp
Index: XNumberBase.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 "XNumberBase.hpp"
#include <PlatformSupport/DoubleSupport.hpp>
#include "XObjectTypeCallback.hpp"
XNumberBase::XNumberBase() :
XObject(eTypeNumber)
{
}
XNumberBase::XNumberBase(const XNumberBase& source) :
XObject(source)
{
}
XNumberBase::~XNumberBase()
{
}
XalanDOMString
XNumberBase::getTypeString() const
{
return XALAN_STATIC_UCODE_STRING("#NUMBER");
}
bool
XNumberBase::boolean() const
{
const double theValue = num();
return DoubleSupport::isNaN(theValue) || DoubleSupport::equal(theValue, 0.0) ? false : true;
}
void
XNumberBase::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
theCallbackObject.Number(*this,
num());
}
void
XNumberBase::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const
{
theCallbackObject.Number(*this,
num());
}
1.1 xml-xalan/c/src/XPath/XNumberBase.hpp
Index: XNumberBase.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(XNUMBERBASE_HEADER_GUARD_1357924680)
#define XNUMBERBASE_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XalanDOM/XalanDOMString.hpp>
// Base class header file.
#include <XPath/XObject.hpp>
class XALAN_XPATH_EXPORT XNumberBase : public XObject
{
public:
XNumberBase(const XNumberBase& source);
virtual
~XNumberBase();
// These methods are inherited from XObject ...
virtual XalanDOMString
getTypeString() const;
virtual double
num() const = 0;
virtual bool
boolean() const;
virtual const XalanDOMString&
str() const = 0;
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const;
protected:
/**
* Constructor for derived classes
*/
explicit
XNumberBase();
private:
};
#endif // XNUMBERBASE_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XToken.cpp
Index: XToken.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 "XToken.hpp"
#include <PlatformSupport/DoubleSupport.hpp>
#include "XObjectTypeCallback.hpp"
XToken::XToken() :
XObject(eTypeString),
m_stringValue(),
m_numberValue(DoubleSupport::getNaN())
{
}
XToken::XToken(const XalanDOMString& theString) :
XObject(eTypeString),
m_stringValue(theString),
m_numberValue(DoubleSupport::toDouble(theString))
{
}
XToken::XToken(double theNumber) :
XObject(eTypeString),
m_stringValue(DoubleToDOMString(theNumber)),
m_numberValue(theNumber)
{
}
XToken::XToken(const XToken& theSource) :
XObject(theSource),
m_stringValue(theSource.m_stringValue),
m_numberValue(theSource.m_numberValue)
{
}
XToken::~XToken()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XObject*
#else
XToken*
#endif
XToken::clone(void* theAddress) const
{
return theAddress == 0 ? new XToken(*this) : new (theAddress) XToken(*this);
}
XalanDOMString
XToken::getTypeString() const
{
return XALAN_STATIC_UCODE_STRING("#TOKEN");
}
double
XToken::num() const
{
return m_numberValue;
}
const XalanDOMString&
XToken::str() const
{
return m_stringValue;
}
void
XToken::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject)
{
theCallbackObject.String(*this, m_stringValue);
}
void
XToken::ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const
{
theCallbackObject.String(*this, m_stringValue);
}
XToken&
XToken::operator=(const XalanDOMString& theString)
{
m_stringValue = theString;
m_numberValue = DoubleSupport::toDouble(theString);
return *this;
}
XToken&
XToken::operator=(double theNumber)
{
m_stringValue = DoubleToDOMString(theNumber);
m_numberValue = theNumber;
return *this;
}
void
XToken::referenced()
{
}
void
XToken::dereferenced()
{
}
1.1 xml-xalan/c/src/XPath/XToken.hpp
Index: XToken.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(XTOKEN_HEADER_GUARD_1357924680)
#define XTOKEN_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
// Base class...
#include <XPath/XObject.hpp>
class XALAN_XPATH_EXPORT XToken : public XObject
{
public:
explicit
XToken();
XToken(const XalanDOMString& theString);
XToken(double theNumber);
XToken(const XToken& theSource);
virtual
~XToken();
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XToken*
#endif
clone(void* theAddress = 0) const;
virtual XalanDOMString
getTypeString() const;
virtual double
num() const;
virtual const XalanDOMString&
str() const;
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject);
virtual void
ProcessXObjectTypeCallback(XObjectTypeCallback& theCallbackObject) const;
XToken&
operator=(const XToken& theRHS)
{
m_stringValue = theRHS.m_stringValue;
m_numberValue = theRHS.m_numberValue;
return *this;
}
XToken&
operator=(const XalanDOMString& theString);
XToken&
operator=(double theNumber);
protected:
virtual void
referenced();
virtual void
dereferenced();
private:
// Not defined...
bool
operator==(const XToken&) const;
// Data members...
XalanDOMString m_stringValue;
double m_numberValue;
};
#endif // XTOKEN_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XTokenNumberAdapter.cpp
Index: XTokenNumberAdapter.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 "XTokenNumberAdapter.hpp"
#include "XToken.hpp"
XTokenNumberAdapter::XTokenNumberAdapter(const XToken& theToken) :
XNumberBase(),
m_value(theToken)
{
}
XTokenNumberAdapter::XTokenNumberAdapter(const XTokenNumberAdapter& source) :
XNumberBase(source),
m_value(source.m_value)
{
}
XTokenNumberAdapter::~XTokenNumberAdapter()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XObject*
#else
XTokenNumberAdapter*
#endif
XTokenNumberAdapter::clone(void* theAddress) const
{
return theAddress == 0 ? new XTokenNumberAdapter(*this) : new (theAddress) XTokenNumberAdapter(*this);
};
double
XTokenNumberAdapter::num() const
{
return m_value.num();
}
const XalanDOMString&
XTokenNumberAdapter::str() const
{
return m_value.str();
}
XTokenNumberAdapter::eObjectType
XTokenNumberAdapter::getRealType() const
{
return eTypeXTokenNumberAdapter;
}
1.1 xml-xalan/c/src/XPath/XTokenNumberAdapter.hpp
Index: XTokenNumberAdapter.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(XTOKENNUMBERADAPTER_HEADER_GUARD_1357924680)
#define XTOKENNUMBERADAPTER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XalanDOM/XalanDOMString.hpp>
// Base class header file.
#include <XPath/XNumberBase.hpp>
class XToken;
class XALAN_XPATH_EXPORT XTokenNumberAdapter : public XNumberBase
{
public:
/**
* Create an XTokenNumberAdapter from an XToken.
*
* @param theXToken The XToken instance to adapt
*/
XTokenNumberAdapter(const XToken& theToken);
XTokenNumberAdapter(const XTokenNumberAdapter& source);
virtual
~XTokenNumberAdapter();
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XTokenNumberAdapter*
#endif
clone(void* theAddress = 0) const;
virtual double
num() const;
virtual const XalanDOMString&
str() const;
protected:
virtual eObjectType
getRealType() const;
private:
// XToken instance that we're adapting...
const XToken& m_value;
};
#endif // XTOKENNUMBERADAPTER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XTokenNumberAdapterAllocator.cpp
Index: XTokenNumberAdapterAllocator.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 "XTokenNumberAdapterAllocator.hpp"
XTokenNumberAdapterAllocator::XTokenNumberAdapterAllocator(size_type theBlockCount) :
m_allocator(theBlockCount)
{
}
XTokenNumberAdapterAllocator::~XTokenNumberAdapterAllocator()
{
}
XTokenNumberAdapterAllocator::object_type*
XTokenNumberAdapterAllocator::create(const XToken& theXToken)
{
object_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
object_type* const theResult = new(theBlock) object_type(theXToken);
m_allocator.commitAllocation(theBlock);
return theResult;
}
XTokenNumberAdapterAllocator::object_type*
XTokenNumberAdapterAllocator::clone(const object_type& theObject)
{
object_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
theObject.clone(theBlock);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
bool
XTokenNumberAdapterAllocator::destroy(object_type* theObject)
{
return m_allocator.destroyObject(theObject);
}
void
XTokenNumberAdapterAllocator::reset()
{
m_allocator.reset();
}
1.1 xml-xalan/c/src/XPath/XTokenNumberAdapterAllocator.hpp
Index: XTokenNumberAdapterAllocator.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(XTOKENNUMBERADAPTERALLOCATOR_INCLUDE_GUARD_1357924680)
#define XTOKENNUMBERADAPTERALLOCATOR_INCLUDE_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XTokenNumberAdapter.hpp>
#include <PlatformSupport/ReusableArenaAllocator.hpp>
class XALAN_XPATH_EXPORT XTokenNumberAdapterAllocator
{
public:
typedef XTokenNumberAdapter object_type;
typedef ReusableArenaAllocator<object_type> ArenaAllocatorType;
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified size.
*
* @param theBlockSize The block size.
*/
XTokenNumberAdapterAllocator(size_type theBlockCount);
~XTokenNumberAdapterAllocator();
/**
* Create an instance from an XToken.
*
* @param theXToken The source XToken
*
* @return A pointer to the new object
*/
object_type*
create(const XToken& theXToken);
/**
* Clone an object.
*
* @param theObject The source object
*
* @return A pointer to the new object
*/
object_type*
clone(const object_type& theObject);
/**
* Delete an XStringAdapter object from allocator.
*/
bool
destroy(object_type* theObject);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const object_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...
XTokenNumberAdapterAllocator(const XTokenNumberAdapterAllocator&);
XTokenNumberAdapterAllocator&
operator=(const XTokenNumberAdapterAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XTOKENNUMBERADAPTERALLOCATOR_INCLUDE_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XTokenStringAdapter.cpp
Index: XTokenStringAdapter.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 "XTokenStringAdapter.hpp"
#include "XToken.hpp"
XTokenStringAdapter::XTokenStringAdapter(const XToken& theToken) :
XStringBase(),
m_value(theToken)
{
}
XTokenStringAdapter::XTokenStringAdapter(const XTokenStringAdapter& source) :
XStringBase(source),
m_value(source.m_value)
{
}
XTokenStringAdapter::~XTokenStringAdapter()
{
}
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
XObject*
#else
XTokenStringAdapter*
#endif
XTokenStringAdapter::clone(void* theAddress) const
{
return theAddress == 0 ? new XTokenStringAdapter(*this) : new (theAddress) XTokenStringAdapter(*this);
};
double
XTokenStringAdapter::num() const
{
return m_value.num();
}
const XalanDOMString&
XTokenStringAdapter::str() const
{
return m_value.str();
}
XTokenStringAdapter::eObjectType
XTokenStringAdapter::getRealType() const
{
return eTypeXTokenStringAdapter;
}
1.1 xml-xalan/c/src/XPath/XTokenStringAdapter.hpp
Index: XTokenStringAdapter.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(XTOKENSTRINGADAPTER_HEADER_GUARD_1357924680)
#define XTOKENSTRINGADAPTER_HEADER_GUARD_1357924680
// Base header file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XalanDOM/XalanDOMString.hpp>
// Base class header file.
#include <XPath/XStringBase.hpp>
class XToken;
class XALAN_XPATH_EXPORT XTokenStringAdapter : public XStringBase
{
public:
/**
* Create an XTokenStringAdapter from an XToken.
*
* @param theXToken The XToken instance to adapt
*/
XTokenStringAdapter(const XToken& theToken);
XTokenStringAdapter(const XTokenStringAdapter& source);
virtual
~XTokenStringAdapter();
// These methods are inherited from XObject ...
#if defined(XALAN_NO_COVARIANT_RETURN_TYPE)
virtual XObject*
#else
virtual XTokenStringAdapter*
#endif
clone(void* theAddress = 0) const;
virtual double
num() const;
virtual const XalanDOMString&
str() const;
protected:
virtual eObjectType
getRealType() const;
private:
// XToken instance that we're adapting...
const XToken& m_value;
};
#endif // XTOKENSTRINGADAPTER_HEADER_GUARD_1357924680
1.1 xml-xalan/c/src/XPath/XTokenStringAdapterAllocator.cpp
Index: XTokenStringAdapterAllocator.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 "XTokenStringAdapterAllocator.hpp"
XTokenStringAdapterAllocator::XTokenStringAdapterAllocator(size_type theBlockCount) :
m_allocator(theBlockCount)
{
}
XTokenStringAdapterAllocator::~XTokenStringAdapterAllocator()
{
}
XTokenStringAdapterAllocator::object_type*
XTokenStringAdapterAllocator::create(const XToken& theXToken)
{
object_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
object_type* const theResult = new(theBlock) object_type(theXToken);
m_allocator.commitAllocation(theBlock);
return theResult;
}
XTokenStringAdapterAllocator::object_type*
XTokenStringAdapterAllocator::clone(const object_type& value)
{
object_type* const theBlock = m_allocator.allocateBlock();
assert(theBlock != 0);
value.clone(theBlock);
m_allocator.commitAllocation(theBlock);
return theBlock;
}
bool
XTokenStringAdapterAllocator::destroy(object_type* theString)
{
return m_allocator.destroyObject(theString);
}
void
XTokenStringAdapterAllocator::reset()
{
m_allocator.reset();
}
1.1 xml-xalan/c/src/XPath/XTokenStringAdapterAllocator.hpp
Index: XTokenStringAdapterAllocator.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(XTOKENSTRINGADAPTERALLOCATOR_INCLUDE_GUARD_1357924680)
#define XTOKENSTRINGADAPTERALLOCATOR_INCLUDE_GUARD_1357924680
// Base include file. Must be first.
#include <XPath/XPathDefinitions.hpp>
#include <XPath/XTokenStringAdapter.hpp>
#include <PlatformSupport/ReusableArenaAllocator.hpp>
class XALAN_XPATH_EXPORT XTokenStringAdapterAllocator
{
public:
typedef XTokenStringAdapter object_type;
typedef ReusableArenaAllocator<object_type> ArenaAllocatorType;
typedef ArenaAllocatorType::size_type size_type;
/**
* Construct an instance that will allocate blocks of the specified size.
*
* @param theBlockSize The block size.
*/
XTokenStringAdapterAllocator(size_type theBlockCount);
~XTokenStringAdapterAllocator();
/**
* Create an XTokenStringAdapter object from an XToken.
*
* @param theXToken The source XToken
*
* @return a pointer to string
*/
object_type*
create(const XToken& theXToken);
/**
* Clone an XTokenStringAdapter object.
*
* @param value source XTokenStringAdapter
*
* @return pointer to an XTokenStringAdapter
*/
object_type*
clone(const object_type& value);
/**
* Delete an XStringAdapter object from allocator.
*/
bool
destroy(object_type* theString);
/**
* Determine if an object is owned by the allocator...
*/
bool
ownsObject(const object_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...
XTokenStringAdapterAllocator(const XTokenStringAdapterAllocator&);
XTokenStringAdapterAllocator&
operator=(const XTokenStringAdapterAllocator&);
// Data members...
ArenaAllocatorType m_allocator;
};
#endif // XTOKENSTRINGADAPTERALLOCATOR_INCLUDE_GUARD_1357924680