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 2006/12/07 17:53:05 UTC
svn commit: r483545 [5/5] - in /xalan/c/trunk: Projects/Win32/VC6/AllInOne/
Projects/Win32/VC7.1/ Projects/Win32/VC7.1/AllInOne/
Projects/Win32/VC7/AllInOne/ Projects/Win32/VC8/AllInOne/
src/xalanc/Include/ src/xalanc/PlatformSupport/ src/xalanc/XPath/...
Modified: xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.hpp?view=diff&rev=483545&r1=483544&r2=483545
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.hpp (original)
+++ xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.hpp Thu Dec 7 08:53:03 2006
@@ -28,6 +28,7 @@
+#include <xalanc/Include/STLHelper.hpp>
#include <xalanc/Include/XalanMemoryManagement.hpp>
#include <xalanc/Include/XalanVector.hpp>
@@ -44,618 +45,618 @@
class XALAN_DOM_EXPORT XalanDOMString
{
public:
- typedef XalanVector<XalanDOMChar> XalanDOMCharVectorType;
- typedef XalanVector<char> CharVectorType;
- typedef XalanVector<wchar_t> WideCharVectorType;
-
- typedef XalanDOMChar value_type;
- typedef XalanDOMChar& reference;
- typedef const XalanDOMChar& const_reference;
+ typedef XalanVector<XalanDOMChar> XalanDOMCharVectorType;
+ typedef XalanVector<char> CharVectorType;
+ typedef XalanVector<wchar_t> WideCharVectorType;
+
+ typedef XalanDOMChar value_type;
+ typedef XalanDOMChar& reference;
+ typedef const XalanDOMChar& const_reference;
typedef unsigned int size_type;
- typedef XalanDOMCharVectorType::iterator iterator;
- typedef XalanDOMCharVectorType::const_iterator const_iterator;
- typedef XalanDOMCharVectorType::reverse_iterator reverse_iterator;
- typedef XalanDOMCharVectorType::const_reverse_iterator const_reverse_iterator;
+ typedef XalanDOMCharVectorType::iterator iterator;
+ typedef XalanDOMCharVectorType::const_iterator const_iterator;
+ typedef XalanDOMCharVectorType::reverse_iterator reverse_iterator;
+ typedef XalanDOMCharVectorType::const_reverse_iterator const_reverse_iterator;
#if defined(XALAN_INLINE_INITIALIZATION)
- static const size_type npos = ~0u;
+ static const size_type npos = ~0u;
#else
- enum { npos = -1 };
+ enum { npos = -1 };
#endif
- XalanDOMString(MemoryManagerType& theManager XALAN_DEFAULT_CONSTRACTOR_MEMORY_MGR );
+ XalanDOMString(MemoryManagerType& theManager XALAN_DEFAULT_CONSTRACTOR_MEMORY_MGR );
- explicit
- XalanDOMString(
- const char* theString,
+ explicit
+ XalanDOMString(
+ const char* theString,
MemoryManagerType& theManager XALAN_DEFAULT_MEMMGR,
- size_type theCount = size_type(npos));
+ size_type theCount = size_type(npos));
- XalanDOMString(
- const XalanDOMString& theSource,
+ XalanDOMString(
+ const XalanDOMString& theSource,
MemoryManagerType& theManager XALAN_DEFAULT_CONSTRACTOR_MEMORY_MGR,
- size_type theStartPosition = 0,
- size_type theCount = size_type(npos));
+ size_type theStartPosition = 0,
+ size_type theCount = size_type(npos));
- explicit
- XalanDOMString(
- const XalanDOMChar* theString,
+ explicit
+ XalanDOMString(
+ const XalanDOMChar* theString,
MemoryManagerType& theManager XALAN_DEFAULT_MEMMGR,
- size_type theCount = size_type(npos));
+ size_type theCount = size_type(npos));
- XalanDOMString(
- size_type theCount,
- XalanDOMChar theChar,
+ XalanDOMString(
+ size_type theCount,
+ XalanDOMChar theChar,
MemoryManagerType& theManager XALAN_DEFAULT_MEMMGR);
XalanDOMString*
clone(MemoryManagerType& theManager);
- ~XalanDOMString()
- {
- }
-
- XalanDOMString&
- operator=(const XalanDOMString& theRHS)
- {
- return assign(theRHS);
- }
-
- XalanDOMString&
- operator=(const XalanDOMChar* theRHS)
- {
- return assign(theRHS);
- }
-
- XalanDOMString&
- operator=(const char* theRHS)
- {
- return assign(theRHS);
- }
-
- XalanDOMString&
- operator=(XalanDOMChar theRHS)
- {
- return assign(1, theRHS);
- }
-
- iterator
- begin()
- {
- invariants();
-
- return m_data.begin();
- }
-
- const_iterator
- begin() const
- {
- invariants();
-
- return m_data.begin();
- }
-
- iterator
- end()
- {
- invariants();
-
- return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
- }
-
- const_iterator
- end() const
- {
- invariants();
-
- return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
- }
-
- reverse_iterator
- rbegin()
- {
- invariants();
-
- reverse_iterator i = m_data.rbegin();
-
- if (m_data.empty() == false)
- {
- ++i;
- }
-
- return i;
- }
-
- const_reverse_iterator
- rbegin() const
- {
- invariants();
-
- const_reverse_iterator i = m_data.rbegin();
-
- if (m_data.empty() == false)
- {
- ++i;
- }
-
- return i;
- }
-
- reverse_iterator
- rend()
- {
- invariants();
-
- return m_data.rend();
- }
-
- const_reverse_iterator
- rend() const
- {
- invariants();
-
- return m_data.rend();
- }
-
- size_type
- size() const
- {
- invariants();
-
- return m_size;
- }
-
- size_type
- length() const
- {
- invariants();
-
- return size();
- }
-
- size_type
- max_size() const
- {
- invariants();
-
- return ~size_type(0);
- }
-
- void
- resize(
- size_type theCount,
- XalanDOMChar theChar);
-
- void
- resize(size_type theCount)
- {
- invariants();
-
- resize(theCount, XalanDOMChar(0));
- }
-
- size_type
- capacity() const
- {
- invariants();
+ ~XalanDOMString()
+ {
+ }
+
+ XalanDOMString&
+ operator=(const XalanDOMString& theRHS)
+ {
+ return assign(theRHS);
+ }
+
+ XalanDOMString&
+ operator=(const XalanDOMChar* theRHS)
+ {
+ return assign(theRHS);
+ }
+
+ XalanDOMString&
+ operator=(const char* theRHS)
+ {
+ return assign(theRHS);
+ }
+
+ XalanDOMString&
+ operator=(XalanDOMChar theRHS)
+ {
+ return assign(1, theRHS);
+ }
+
+ iterator
+ begin()
+ {
+ invariants();
+
+ return m_data.begin();
+ }
+
+ const_iterator
+ begin() const
+ {
+ invariants();
+
+ return m_data.begin();
+ }
+
+ iterator
+ end()
+ {
+ invariants();
+
+ return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
+ }
+
+ const_iterator
+ end() const
+ {
+ invariants();
+
+ return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
+ }
+
+ reverse_iterator
+ rbegin()
+ {
+ invariants();
+
+ reverse_iterator i = m_data.rbegin();
+
+ if (m_data.empty() == false)
+ {
+ ++i;
+ }
+
+ return i;
+ }
+
+ const_reverse_iterator
+ rbegin() const
+ {
+ invariants();
+
+ const_reverse_iterator i = m_data.rbegin();
+
+ if (m_data.empty() == false)
+ {
+ ++i;
+ }
+
+ return i;
+ }
+
+ reverse_iterator
+ rend()
+ {
+ invariants();
+
+ return m_data.rend();
+ }
+
+ const_reverse_iterator
+ rend() const
+ {
+ invariants();
+
+ return m_data.rend();
+ }
+
+ size_type
+ size() const
+ {
+ invariants();
+
+ return m_size;
+ }
+
+ size_type
+ length() const
+ {
+ invariants();
+
+ return size();
+ }
+
+ size_type
+ max_size() const
+ {
+ invariants();
+
+ return ~size_type(0);
+ }
+
+ void
+ resize(
+ size_type theCount,
+ XalanDOMChar theChar);
+
+ void
+ resize(size_type theCount)
+ {
+ invariants();
+
+ resize(theCount, XalanDOMChar(0));
+ }
+
+ size_type
+ capacity() const
+ {
+ invariants();
const XalanDOMCharVectorType::size_type theCapacity =
m_data.capacity();
return theCapacity == 0 ? 0 : size_type(theCapacity - 1);
- }
+ }
- void
- reserve(size_type theCount = 0)
- {
- invariants();
+ void
+ reserve(size_type theCount = 0)
+ {
+ invariants();
- m_data.reserve(theCount + 1);
- }
+ m_data.reserve(theCount + 1);
+ }
- void
- clear()
- {
- invariants();
+ void
+ clear()
+ {
+ invariants();
- m_data.erase(m_data.begin(), m_data.end());
+ m_data.erase(m_data.begin(), m_data.end());
- m_size = 0;
+ m_size = 0;
- invariants();
- }
+ invariants();
+ }
- void
- erase(
- size_type theStartPosition = 0,
- size_type theCount = size_type(npos));
+ void
+ erase(
+ size_type theStartPosition = 0,
+ size_type theCount = size_type(npos));
- bool
- empty() const
- {
- invariants();
+ bool
+ empty() const
+ {
+ invariants();
- return m_size == 0 ? true : false;
- }
+ return m_size == 0 ? true : false;
+ }
- const_reference
- operator[](size_type theIndex) const
- {
- invariants();
+ const_reference
+ operator[](size_type theIndex) const
+ {
+ invariants();
- return m_data[theIndex];
- }
+ return m_data[theIndex];
+ }
- reference
- operator[](size_type theIndex)
- {
- invariants();
+ reference
+ operator[](size_type theIndex)
+ {
+ invariants();
- return m_data[theIndex];
- }
+ return m_data[theIndex];
+ }
- const_reference
- at(size_type theIndex) const
- {
- invariants();
+ const_reference
+ at(size_type theIndex) const
+ {
+ invariants();
- return m_data.at(theIndex);
- }
+ return m_data.at(theIndex);
+ }
- reference
- at(size_type theIndex)
- {
- invariants();
+ reference
+ at(size_type theIndex)
+ {
+ invariants();
- return m_data.at(theIndex);
- }
+ return m_data.at(theIndex);
+ }
- const XalanDOMChar*
- c_str() const
- {
- invariants();
+ const XalanDOMChar*
+ c_str() const
+ {
+ invariants();
- return m_data.empty() == true ? &s_empty : &m_data[0];
- }
+ return m_data.empty() == true ? &s_empty : &m_data[0];
+ }
- const XalanDOMChar*
- data() const
- {
- invariants();
+ const XalanDOMChar*
+ data() const
+ {
+ invariants();
- return c_str();
- }
+ return c_str();
+ }
- void
- swap(XalanDOMString& theOther)
- {
- invariants();
+ void
+ swap(XalanDOMString& theOther)
+ {
+ invariants();
- m_data.swap(theOther.m_data);
+ m_data.swap(theOther.m_data);
#if defined(XALAN_NO_STD_NAMESPACE)
- ::swap(m_size, theOther.m_size);
+ ::swap(m_size, theOther.m_size);
#else
- std::swap(m_size, theOther.m_size);
+ std::swap(m_size, theOther.m_size);
#endif
- }
+ }
+
+ XalanDOMString&
+ operator+=(const XalanDOMString& theSource)
+ {
+ return append(theSource);
+ }
+
+ XalanDOMString&
+ operator+=(const XalanDOMChar* theString)
+ {
+ return append(theString);
+ }
+
+ XalanDOMString&
+ operator+=(XalanDOMChar theChar)
+ {
+ append(1, theChar);
+
+ return *this;
+ }
+
+ XalanDOMString&
+ assign(const XalanDOMChar* theSource)
+ {
+ invariants();
+
+ erase();
+
+ invariants();
+
+ return append(theSource);
+ }
+
+ XalanDOMString&
+ assign(
+ const XalanDOMChar* theSource,
+ size_type theCount)
+ {
+ invariants();
+
+ erase();
+
+ invariants();
+
+ return append(theSource, theCount);
+ }
+
+ XalanDOMString&
+ assign(const char* theSource)
+ {
+ invariants();
+
+ erase();
+
+ invariants();
+
+ return append(theSource);
+ }
+
+ XalanDOMString&
+ assign(
+ const char* theSource,
+ size_type theCount)
+ {
+ invariants();
+
+ erase();
+
+ invariants();
+
+ return append(theSource, theCount);
+ }
+
+ XalanDOMString&
+ assign(
+ const XalanDOMString& theSource,
+ size_type thePosition,
+ size_type theCount);
+
+ XalanDOMString&
+ assign(const XalanDOMString& theSource)
+ {
+ invariants();
+
+ if (&theSource != this)
+ {
+ m_data = theSource.m_data;
+
+ m_size = theSource.m_size;
+ }
+
+ invariants();
+
+ return *this;
+ }
+
+ XalanDOMString&
+ assign(
+ size_type theCount,
+ XalanDOMChar theChar)
+ {
+ invariants();
+
+ erase();
+
+ invariants();
+
+ return append(theCount, theChar);
+ }
+
+ XalanDOMString&
+ assign(
+ iterator theFirstPosition,
+ iterator theLastPosition);
+
+ XalanDOMString&
+ append(const XalanDOMString& theSource)
+ {
+ return append(theSource.c_str(), theSource.length());
+ }
+
+ XalanDOMString&
+ append(
+ const XalanDOMString& theSource,
+ size_type thePosition,
+ size_type theCount)
+ {
+ assert(thePosition < theSource.length() &&
+ (theCount == size_type(npos) || thePosition + theCount <= theSource.length()));
+
+ return append(theSource.c_str() + thePosition, theCount);
+ }
+
+ XalanDOMString&
+ append(
+ const XalanDOMChar* theString,
+ size_type theCount);
+
+ XalanDOMString&
+ append(const XalanDOMChar* theString)
+ {
+ return append(theString, length(theString));
+ }
+
+ XalanDOMString&
+ append(
+ const char* theString,
+ size_type theCount);
+
+ XalanDOMString&
+ append(const char* theString)
+ {
+ return append(theString, length(theString));
+ }
+
+ XalanDOMString&
+ append(
+ size_type theCount,
+ XalanDOMChar theChar);
+
+ void
+ push_back(XalanDOMChar theChar)
+ {
+ invariants();
+
+ append(1, theChar);
+
+ invariants();
+ }
+
+ XalanDOMString&
+ insert(
+ size_type thePosition,
+ const XalanDOMString& theString)
+ {
+ return insert(thePosition, theString.c_str(), theString.length());
+ }
- XalanDOMString&
- operator+=(const XalanDOMString& theSource)
- {
- return append(theSource);
- }
-
- XalanDOMString&
- operator+=(const XalanDOMChar* theString)
- {
- return append(theString);
- }
-
- XalanDOMString&
- operator+=(XalanDOMChar theChar)
- {
- append(1, theChar);
-
- return *this;
- }
-
- XalanDOMString&
- assign(const XalanDOMChar* theSource)
- {
- invariants();
-
- erase();
-
- invariants();
-
- return append(theSource);
- }
-
- XalanDOMString&
- assign(
- const XalanDOMChar* theSource,
- size_type theCount)
- {
- invariants();
-
- erase();
-
- invariants();
-
- return append(theSource, theCount);
- }
-
- XalanDOMString&
- assign(const char* theSource)
- {
- invariants();
-
- erase();
-
- invariants();
-
- return append(theSource);
- }
-
- XalanDOMString&
- assign(
- const char* theSource,
- size_type theCount)
- {
- invariants();
-
- erase();
-
- invariants();
-
- return append(theSource, theCount);
- }
-
- XalanDOMString&
- assign(
- const XalanDOMString& theSource,
- size_type thePosition,
- size_type theCount);
-
- XalanDOMString&
- assign(const XalanDOMString& theSource)
- {
- invariants();
-
- if (&theSource != this)
- {
- m_data = theSource.m_data;
-
- m_size = theSource.m_size;
- }
-
- invariants();
-
- return *this;
- }
-
- XalanDOMString&
- assign(
- size_type theCount,
- XalanDOMChar theChar)
- {
- invariants();
-
- erase();
-
- invariants();
-
- return append(theCount, theChar);
- }
-
- XalanDOMString&
- assign(
- iterator theFirstPosition,
- iterator theLastPosition);
-
- XalanDOMString&
- append(const XalanDOMString& theSource)
- {
- return append(theSource.c_str(), theSource.length());
- }
-
- XalanDOMString&
- append(
- const XalanDOMString& theSource,
- size_type thePosition,
- size_type theCount)
- {
- assert(thePosition < theSource.length() &&
- (theCount == size_type(npos) || thePosition + theCount <= theSource.length()));
-
- return append(theSource.c_str() + thePosition, theCount);
- }
-
- XalanDOMString&
- append(
- const XalanDOMChar* theString,
- size_type theCount);
-
- XalanDOMString&
- append(const XalanDOMChar* theString)
- {
- return append(theString, length(theString));
- }
-
- XalanDOMString&
- append(
- const char* theString,
- size_type theCount);
-
- XalanDOMString&
- append(const char* theString)
- {
- return append(theString, length(theString));
- }
-
- XalanDOMString&
- append(
- size_type theCount,
- XalanDOMChar theChar);
-
- void
- push_back(XalanDOMChar theChar)
- {
- invariants();
-
- append(1, theChar);
-
- invariants();
- }
-
- XalanDOMString&
- insert(
- size_type thePosition,
- const XalanDOMString& theString)
- {
- return insert(thePosition, theString.c_str(), theString.length());
- }
-
- XalanDOMString&
- insert(
- size_type thePosition1,
- const XalanDOMString& theString,
- size_type thePosition2,
- size_type theCount)
- {
- return insert(thePosition1, theString.c_str() + thePosition2, theCount);
- }
-
- XalanDOMString&
- insert(
- size_type thePosition,
- const XalanDOMChar* theString,
- size_type theCount);
-
- XalanDOMString&
- insert(
- size_type thePosition,
- const XalanDOMChar* theString)
- {
- return insert(thePosition, theString, length(theString));
- }
-
- XalanDOMString&
- insert(
- size_type thePosition,
- size_type theCount,
- XalanDOMChar theChar);
-
- iterator
- insert(
- iterator thePosition,
- XalanDOMChar theChar);
-
- void
- insert(
- iterator thePosition,
- size_type theCount,
- XalanDOMChar theChar);
-
- void
- insert(
- iterator theInsertPosition,
- iterator theFirstPosition,
- iterator theLastPosition);
-
-
- XalanDOMString&
- substr(
- XalanDOMString& theSubstring,
- size_type thePosition = 0,
- size_type theCount = size_type(npos)) const
- {
- assert(theCount == size_type(npos) && thePosition < length() ||
- thePosition + theCount <= length());
-
- invariants();
-
- return theSubstring.assign(*this, thePosition, theCount);
- }
-
- int
- compare(const XalanDOMString& theString) const
- {
- invariants();
-
- return compare(theString.c_str());
- }
-
- int
- compare(
- size_type thePosition1,
- size_type theCount1,
- const XalanDOMString& theString) const
- {
- invariants();
-
- return compare(thePosition1, theCount1, theString.c_str(), theString.length());
- }
-
- int
- compare(
- size_type thePosition1,
- size_type theCount1,
- const XalanDOMString& theString,
- size_type thePosition2,
- size_type theCount2) const
- {
- invariants();
-
- return compare(thePosition1, theCount1, theString.c_str() + thePosition2, theCount2);
- }
-
- int
- compare(const XalanDOMChar* theString) const;
-
- int
- compare(
- size_type thePosition1,
- size_type theCount1,
- const XalanDOMChar* theString,
- size_type theCount2 = size_type(npos)) const;
+ XalanDOMString&
+ insert(
+ size_type thePosition1,
+ const XalanDOMString& theString,
+ size_type thePosition2,
+ size_type theCount)
+ {
+ return insert(thePosition1, theString.c_str() + thePosition2, theCount);
+ }
+
+ XalanDOMString&
+ insert(
+ size_type thePosition,
+ const XalanDOMChar* theString,
+ size_type theCount);
+
+ XalanDOMString&
+ insert(
+ size_type thePosition,
+ const XalanDOMChar* theString)
+ {
+ return insert(thePosition, theString, length(theString));
+ }
+
+ XalanDOMString&
+ insert(
+ size_type thePosition,
+ size_type theCount,
+ XalanDOMChar theChar);
+
+ iterator
+ insert(
+ iterator thePosition,
+ XalanDOMChar theChar);
+
+ void
+ insert(
+ iterator thePosition,
+ size_type theCount,
+ XalanDOMChar theChar);
+
+ void
+ insert(
+ iterator theInsertPosition,
+ iterator theFirstPosition,
+ iterator theLastPosition);
+
+
+ XalanDOMString&
+ substr(
+ XalanDOMString& theSubstring,
+ size_type thePosition = 0,
+ size_type theCount = size_type(npos)) const
+ {
+ assert(theCount == size_type(npos) && thePosition < length() ||
+ thePosition + theCount <= length());
+
+ invariants();
+
+ return theSubstring.assign(*this, thePosition, theCount);
+ }
+
+ int
+ compare(const XalanDOMString& theString) const
+ {
+ invariants();
+
+ return compare(theString.c_str());
+ }
+
+ int
+ compare(
+ size_type thePosition1,
+ size_type theCount1,
+ const XalanDOMString& theString) const
+ {
+ invariants();
+
+ return compare(thePosition1, theCount1, theString.c_str(), theString.length());
+ }
+
+ int
+ compare(
+ size_type thePosition1,
+ size_type theCount1,
+ const XalanDOMString& theString,
+ size_type thePosition2,
+ size_type theCount2) const
+ {
+ invariants();
+
+ return compare(thePosition1, theCount1, theString.c_str() + thePosition2, theCount2);
+ }
+
+ int
+ compare(const XalanDOMChar* theString) const;
+
+ int
+ compare(
+ size_type thePosition1,
+ size_type theCount1,
+ const XalanDOMChar* theString,
+ size_type theCount2 = size_type(npos)) const;
void
- reset(MemoryManagerType& theManager, const char* theString);
+ reset(MemoryManagerType& theManager, const char* theString);
void
reset(MemoryManagerType& theManager, const XalanDOMChar* theString);
- class TranscodingError : public XalanDOMException
- {
- public:
-
- TranscodingError() :
- XalanDOMException(TRANSCODING_ERR)
- {
- }
-
- virtual
- ~TranscodingError()
- {
- }
- };
+ class TranscodingError : public XalanDOMException
+ {
+ public:
+
+ TranscodingError() :
+ XalanDOMException(TRANSCODING_ERR)
+ {
+ }
+
+ virtual
+ ~TranscodingError()
+ {
+ }
+ };
- /**
- * Transcode the string to the local code page. If the string
- * cannot be properly transcoded, and the transcoder can detect
- * the error a TranscodingError exception is thrown.
- *
- * @param theResult A CharVectorType instance for the transcoded string. The string is null-terminated.
- */
- void
- transcode(CharVectorType& theResult) const;
+ /**
+ * Transcode the string to the local code page. If the string
+ * cannot be properly transcoded, and the transcoder can detect
+ * the error a TranscodingError exception is thrown.
+ *
+ * @param theResult A CharVectorType instance for the transcoded string. The string is null-terminated.
+ */
+ void
+ transcode(CharVectorType& theResult) const;
MemoryManagerType&
getMemoryManager()
@@ -663,125 +664,130 @@
return m_data.getMemoryManager();
}
- size_type
- hash() const
- {
- return hash(c_str(), size());
- }
-
- static bool
- equals(
- const XalanDOMChar* theLHS,
- size_type theLHSLength,
- const XalanDOMChar* theRHS,
- size_type theRHSLength);
-
- static bool
- equals(
- const XalanDOMChar* theLHS,
- const XalanDOMChar* theRHS)
- {
- return equals(theLHS, length(theLHS), theRHS, length(theRHS));
- }
-
- static bool
- equals(
- const XalanDOMString& theLHS,
- const XalanDOMString& theRHS);
-
- static bool
- equals(
- const XalanDOMString& theLHS,
- const XalanDOMChar* theRHS)
- {
- return equals(theLHS.c_str(), theRHS);
- }
-
- static bool
- equals(
- const XalanDOMChar* theLHS,
- const XalanDOMString& theRHS)
- {
- return equals(theLHS, theRHS.c_str());
- }
-
- /*
- * Helper function to determine the length of a null-
- * terminated string.
- *
- * @theString The string
- * @return the length
- */
- static size_type
- length(const XalanDOMChar* theString);
-
- /*
- * Helper function to determine the length of a null-
- * terminated string.
- *
- * @theString The string
- * @return the length
- */
- static size_type
- length(const char* theString);
-
- static size_type
- hash(
- const XalanDOMChar* theString,
- size_type theLength);
+ size_t
+ hash() const
+ {
+ return hash(c_str(), length());
+ }
+
+ static size_t
+ hash(
+ const XalanDOMChar* theString,
+ size_type theLength)
+ {
+ assert(theString != 0);
+
+ return hash_non_terminated_array<XalanDOMChar>()(theString, theLength);
+ }
+
+ static bool
+ equals(
+ const XalanDOMChar* theLHS,
+ size_type theLHSLength,
+ const XalanDOMChar* theRHS,
+ size_type theRHSLength);
+
+ static bool
+ equals(
+ const XalanDOMChar* theLHS,
+ const XalanDOMChar* theRHS)
+ {
+ return equals(theLHS, length(theLHS), theRHS, length(theRHS));
+ }
+
+ static bool
+ equals(
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS);
+
+ static bool
+ equals(
+ const XalanDOMString& theLHS,
+ const XalanDOMChar* theRHS)
+ {
+ return equals(theLHS.c_str(), theRHS);
+ }
+
+ static bool
+ equals(
+ const XalanDOMChar* theLHS,
+ const XalanDOMString& theRHS)
+ {
+ return equals(theLHS, theRHS.c_str());
+ }
+
+ /*
+ * Helper function to determine the length of a null-
+ * terminated string.
+ *
+ * @theString The string
+ * @return the length
+ */
+ static size_type
+ length(const XalanDOMChar* theString);
+
+ /*
+ * Helper function to determine the length of a null-
+ * terminated string.
+ *
+ * @theString The string
+ * @return the length
+ */
+ static size_type
+ length(const char* theString);
protected:
- /*
- * Function to assert invariant conditions for the class.
- *
- * @return the iterator
- */
- void
- invariants() const
- {
+ /*
+ * Function to assert invariant conditions for the class.
+ *
+ * @return the iterator
+ */
+ void
+ invariants() const
+ {
#if !defined(NDEBUG)
- assert((m_data.empty() == true && m_size == 0) || m_size == m_data.size() - 1);
- assert(m_data.empty() == true || m_data.back() == 0);
+ assert((m_data.empty() == true && m_size == 0) || m_size == m_data.size() - 1);
+ assert(m_data.empty() == true || m_data.back() == 0);
#endif
- }
+ }
+
+ /*
+ * Get an iterator to the position of the terminating null.
+ *
+ * @return the iterator
+ */
+ iterator
+ getBackInsertIterator()
+ {
+ invariants();
+
+ return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
+ }
+
+ const_iterator
+ getBackInsertIterator() const
+ {
+ invariants();
- /*
- * Get an iterator to the position of the terminating null.
- *
- * @return the iterator
- */
- iterator
- getBackInsertIterator()
- {
- invariants();
-
- return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
- }
-
- const_iterator
- getBackInsertIterator() const
- {
- invariants();
-
- return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
- }
-
- iterator
- getIteratorForPosition(size_type thePosition)
- {
- invariants();
-
- return m_data.begin() + thePosition;
- }
-
- const_iterator
- getIteratorForPosition(size_type thePosition) const
- {
- invariants();
+ return m_data.empty() == true ? m_data.end() : m_data.end() - 1;
+ }
+
+ iterator
+ getIteratorForPosition(size_type thePosition)
+ {
+ invariants();
+
+ return m_data.begin() + thePosition;
+ }
- return m_data.begin() + thePosition;
- }
+ const_iterator
+ getIteratorForPosition(size_type thePosition) const
+ {
+ invariants();
+
+ return m_data.begin() + thePosition;
+ }
#if defined (XALAN_DEVELOPMENT)
// not defined
@@ -792,149 +798,322 @@
private:
- XalanDOMCharVectorType m_data;
+ XalanDOMCharVectorType m_data;
+
+ size_type m_size;
+
+ static const XalanDOMChar s_empty;
+};
+
+
+
+/**
+ * Hash functor for DOMStrings
+ *
+ * @param theKey XalanDOMString to be hashed
+ * @return hash value for XalanDOMString
+ */
+struct DOMStringHashFunction : public XALAN_STD_QUALIFIER unary_function<const XalanDOMString&, size_t>
+{
+ result_type
+ operator() (argument_type theKey) const
+ {
+ return theKey.hash();
+ }
+};
+
+
+
+/**
+ * Hash functor for DOMStrings
+ *
+ * @param theKey XalanDOMString to be hashed
+ * @return hash value for XalanDOMString
+ */
+struct DOMStringPointerHashFunction : public XALAN_STD_QUALIFIER unary_function<const XalanDOMString*, size_t>
+{
+ result_type
+ operator() (argument_type theKey) const
+ {
+ assert (theKey != 0);
+
+ return theKey->hash();
+ }
+};
+
- size_type m_size;
- static const XalanDOMChar s_empty;
+template<>
+struct XalanMapKeyTraits<XalanDOMString*>
+{
+ typedef DOMStringPointerHashFunction Hasher;
+ typedef pointer_equal<XalanDOMString> Comparator;
+};
+
+template<>
+struct XalanMapKeyTraits<const XalanDOMString*>
+{
+ typedef DOMStringPointerHashFunction Hasher;
+ typedef pointer_equal<XalanDOMString> Comparator;
+};
+
+
+/**
+ * Equals functor for DOMStrings
+ *
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return true if the contents of both strings are identical
+ */
+#if defined(XALAN_NO_STD_NAMESPACE)
+struct DOMStringEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
+#else
+struct DOMStringEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
+#endif
+{
+ result_type
+ operator() (first_argument_type theLHS,
+ second_argument_type theRHS) const
+ {
+ return XalanDOMString::equals(theLHS, theRHS);
+ }
+};
+
+
+
+/**
+ * Not equals functor for DOMStrings
+ *
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return true if the contents of both strings are identical
+ */
+#if defined(XALAN_NO_STD_NAMESPACE)
+struct DOMStringNotEqualsFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
+#else
+struct DOMStringNotEqualsFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
+#endif
+{
+ result_type
+ operator() (first_argument_type theLHS,
+ second_argument_type theRHS) const
+ {
+ return !XalanDOMString::equals(theLHS, theRHS);
+ }
+};
+
+
+
+/**
+ * Less than functor for DOMStrings
+ *
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return true if the theLHS is less than theRHSl
+ */
+#if defined(XALAN_NO_STD_NAMESPACE)
+struct DOMStringLessThanFunction : public binary_function<const XalanDOMString&, const XalanDOMString&, bool>
+#else
+struct DOMStringLessThanFunction : public std::binary_function<const XalanDOMString&, const XalanDOMString&, bool>
+#endif
+{
+ result_type
+ operator() (first_argument_type theLHS,
+ second_argument_type theRHS) const
+ {
+ return theLHS.compare(theRHS) < 0 ? true : false;
+ }
+};
+
+
+/**
+ * Equal to functor for DOMStrings
+ *
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return true if the theLHS is equal to theRHS
+ */
+struct DOMStringPointerEqualToFunction : public XALAN_STD_QUALIFIER binary_function<const XalanDOMString*, const XalanDOMString*, bool>
+{
+ result_type
+ operator() (first_argument_type theLHS,
+ second_argument_type theRHS) const
+ {
+ assert(theLHS != 0 && theRHS != 0);
+
+ return XalanDOMString::equals(*theLHS, *theRHS);
+ }
+};
+
+
+/**
+ * Less than functor for DOMStrings
+ *
+ * @param theLHS first string to compare
+ * @param theRHS second string to compare
+ * @return true if the theLHS is less than theRHSl
+ */
+#if defined(XALAN_NO_STD_NAMESPACE)
+struct DOMStringPointerLessThanFunction : public binary_function<const XalanDOMString*, const XalanDOMString*, bool>
+#else
+struct DOMStringPointerLessThanFunction : public std::binary_function<const XalanDOMString*, const XalanDOMString*, bool>
+#endif
+{
+ result_type
+ operator() (first_argument_type theLHS,
+ second_argument_type theRHS) const
+ {
+ assert(theLHS != 0 && theRHS != 0);
+
+ return theLHS->compare(*theRHS) < 0 ? true : false;
+ }
+};
+
+
+
+template<>
+struct XalanMapKeyTraits<XalanDOMString>
+{
+ typedef DOMStringHashFunction Hasher;
+ typedef XALAN_STD_QUALIFIER equal_to<XalanDOMString> Comparator;
};
inline bool
operator==(
- const XalanDOMString& theLHS,
- const XalanDOMString& theRHS)
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS)
{
- return XalanDOMString::equals(theLHS, theRHS);
+ return XalanDOMString::equals(theLHS, theRHS);
}
inline bool
operator==(
- const XalanDOMString& theLHS,
- const XalanDOMChar* theRHS)
+ const XalanDOMString& theLHS,
+ const XalanDOMChar* theRHS)
{
- return XalanDOMString::equals(theLHS, theRHS);
+ return XalanDOMString::equals(theLHS, theRHS);
}
inline bool
operator==(
- const XalanDOMChar* theLHS,
- const XalanDOMString& theRHS)
+ const XalanDOMChar* theLHS,
+ const XalanDOMString& theRHS)
{
- // Note reversing of operands...
- return XalanDOMString::equals(theLHS, theRHS);
+ // Note reversing of operands...
+ return XalanDOMString::equals(theLHS, theRHS);
}
inline bool
operator!=(
- const XalanDOMString& theLHS,
- const XalanDOMString& theRHS)
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS)
{
- return !(theLHS == theRHS);
+ return !(theLHS == theRHS);
}
inline bool
operator!=(
- const XalanDOMChar* theLHS,
- const XalanDOMString& theRHS)
+ const XalanDOMChar* theLHS,
+ const XalanDOMString& theRHS)
{
- return !(theLHS == theRHS);
+ return !(theLHS == theRHS);
}
inline bool
operator!=(
- const XalanDOMString& theLHS,
- const XalanDOMChar* theRHS)
+ const XalanDOMString& theLHS,
+ const XalanDOMChar* theRHS)
{
- return !(theRHS == theLHS);
+ return !(theRHS == theLHS);
}
inline XalanDOMString&
add(
- const XalanDOMString& theLHS,
- const XalanDOMString& theRHS,
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS,
XalanDOMString& result)
{
result.assign(theLHS);
- return result += theRHS;
+ return result += theRHS;
}
inline XalanDOMString&
add(
- const XalanDOMString& theLHS,
- const XalanDOMChar* theRHS,
+ const XalanDOMString& theLHS,
+ const XalanDOMChar* theRHS,
XalanDOMString& result)
{
result.assign(theLHS);
- return result += theRHS;
+ return result += theRHS;
}
inline XalanDOMString&
add(
- const XalanDOMChar* theLHS,
- const XalanDOMString& theRHS,
+ const XalanDOMChar* theLHS,
+ const XalanDOMString& theRHS,
XalanDOMString& result)
{
result.assign(theLHS);
- return result += theRHS;
+ return result += theRHS;
}
inline const XalanDOMString&
add(
- const char* theLHS,
- const XalanDOMString& theRHS,
+ const char* theLHS,
+ const XalanDOMString& theRHS,
XalanDOMString& result)
{
result.assign(theLHS);
result.append(theRHS);
- return result;
+ return result;
}
inline const XalanDOMString&
add(
- const XalanDOMString& theLHS,
- const char* theRHS,
+ const XalanDOMString& theLHS,
+ const char* theRHS,
XalanDOMString& result)
{
result.assign(theLHS);
result.append(theRHS);
- return result;
+ return result;
}
// Standard vector of XalanDOMChars and chars
-typedef XalanVector<XalanDOMChar> XalanDOMCharVectorType;
+typedef XalanVector<XalanDOMChar> XalanDOMCharVectorType;
-typedef XalanVector<char> CharVectorType;
+typedef XalanVector<char> CharVectorType;
@@ -953,10 +1132,10 @@
*/
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- CharVectorType& targetVector,
- bool terminate = false);
+ const XalanDOMChar* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ CharVectorType& targetVector,
+ bool terminate = false);
/**
* Convert a XalanDOMChar string to C++ standard library
@@ -990,10 +1169,10 @@
#if !defined(XALAN_DEVELOPMENT)
inline const XalanDOMString
TranscodeFromLocalCodePage(
- const char* theSourceString,
- XalanDOMString::size_type theSourceStringLength = XalanDOMString::npos)
+ const char* theSourceString,
+ XalanDOMString::size_type theSourceStringLength = XalanDOMString::npos)
{
- return XalanDOMString(theSourceString,XalanMemMgrs::getDefaultXercesMemMgr(), theSourceStringLength);
+ return XalanDOMString(theSourceString,XalanMemMgrs::getDefaultXercesMemMgr(), theSourceStringLength);
}
#endif
@@ -1010,9 +1189,9 @@
*/
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- CharVectorType& targetVector,
- bool terminate = false);
+ const XalanDOMChar* theSourceString,
+ CharVectorType& targetVector,
+ bool terminate = false);
/**
* Convert a XalanDOMChar string to C++ standard library
@@ -1040,13 +1219,13 @@
*/
#if !defined(XALAN_DEVELOPMENT)
inline const CharVectorType
-TranscodeToLocalCodePage(const XalanDOMChar* theSourceString)
+TranscodeToLocalCodePage(const XalanDOMChar* theSourceString)
{
- CharVectorType theResult;
+ CharVectorType theResult;
- TranscodeToLocalCodePage(theSourceString, theResult, true, '?');
+ TranscodeToLocalCodePage(theSourceString, theResult, true, '?');
- return theResult;
+ return theResult;
}
#endif
@@ -1062,11 +1241,11 @@
*/
inline bool
TranscodeToLocalCodePage(
- const XalanDOMString& theSourceString,
- CharVectorType& targetVector,
- bool terminate = false)
+ const XalanDOMString& theSourceString,
+ CharVectorType& targetVector,
+ bool terminate = false)
{
- return TranscodeToLocalCodePage(theSourceString.c_str(), targetVector, terminate);
+ return TranscodeToLocalCodePage(theSourceString.c_str(), targetVector, terminate);
}
/**
@@ -1081,12 +1260,12 @@
*/
inline void
TranscodeToLocalCodePage(
- const XalanDOMString& theSourceString,
- CharVectorType& targetVector,
- bool terminate ,
+ const XalanDOMString& theSourceString,
+ CharVectorType& targetVector,
+ bool terminate ,
char theSubstitutionChar)
{
- TranscodeToLocalCodePage(theSourceString.c_str(), targetVector, terminate, theSubstitutionChar);
+ TranscodeToLocalCodePage(theSourceString.c_str(), targetVector, terminate, theSubstitutionChar);
}
/**
@@ -1099,13 +1278,13 @@
*/
#if !defined(XALAN_DEVELOPMENT)
inline const CharVectorType
-TranscodeToLocalCodePage(const XalanDOMString& theSourceString)
+TranscodeToLocalCodePage(const XalanDOMString& theSourceString)
{
- CharVectorType theResult;
+ CharVectorType theResult;
- TranscodeToLocalCodePage(theSourceString.c_str(), theResult, true, '?');
+ TranscodeToLocalCodePage(theSourceString.c_str(), theResult, true, '?');
- return theResult;
+ return theResult;
}
#endif
@@ -1120,13 +1299,13 @@
*/
inline const XalanDOMString&
TranscodeFromLocalCodePage(
- const char* theSourceString,
+ const char* theSourceString,
XalanDOMString& result,
- XalanDOMString::size_type theSourceStringLength = XalanDOMString::npos)
+ XalanDOMString::size_type theSourceStringLength = XalanDOMString::npos)
{
result.assign(theSourceString, theSourceStringLength);
- return result;
+ return result;
}
@@ -1144,10 +1323,10 @@
*/
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeFromLocalCodePage(
- const char* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- XalanDOMCharVectorType& theTargetVector,
- bool terminate = false);
+ const char* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ XalanDOMCharVectorType& theTargetVector,
+ bool terminate = false);
/**
* Convert a string to a C++ standard library
@@ -1161,9 +1340,9 @@
*/
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeFromLocalCodePage(
- const char* theSourceString,
- XalanDOMCharVectorType& theTargetVector,
- bool terminate = false);
+ const char* theSourceString,
+ XalanDOMCharVectorType& theTargetVector,
+ bool terminate = false);
/**
* Convert a vector of characters to a XalanDOMString,
@@ -1173,7 +1352,7 @@
* @return The transcoded string.
*/
XALAN_DOM_EXPORT_FUNCTION(const XalanDOMString&)
-TranscodeFromLocalCodePage(const CharVectorType& theSourceString,
+TranscodeFromLocalCodePage(const CharVectorType& theSourceString,
XalanDOMString& result);
@@ -1185,4 +1364,4 @@
-#endif // !defined(XALANDOMSTRING_HEADER_GUARD_1357924680)
+#endif // !defined(XALANDOMSTRING_HEADER_GUARD_1357924680)
Modified: xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.cpp?view=diff&rev=483545&r1=483544&r2=483545
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.cpp (original)
+++ xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.cpp Thu Dec 7 08:53:03 2006
@@ -109,8 +109,8 @@
m_memoryManager(theManager),
m_compiledStylesheets(m_memoryManager),
m_parsedSources(m_memoryManager),
- m_paramPairs(m_memoryManager),
- m_functionPairs(m_memoryManager),
+ m_params(m_memoryManager),
+ m_functions(m_memoryManager),
m_traceListeners(m_memoryManager),
m_errorMessage(1, '\0', m_memoryManager),
m_useValidation(false),
@@ -148,34 +148,23 @@
{
XALAN_USING_STD(for_each)
- // Clean up all entries in the compliledStylesheets vector.
- for_each(m_compiledStylesheets.begin(),
- m_compiledStylesheets.end(),
- DeleteFunctor<XalanCompiledStylesheet>(m_memoryManager));
-
- // Clean up all entries in the compliledStylesheets vector.
- for_each(m_parsedSources.begin(),
- m_parsedSources.end(),
- DeleteFunctor<XalanParsedSource>(m_memoryManager));
-
- for (FunctionParamPairVectorType::size_type i = 0; i < m_functionPairs.size(); ++i)
- {
- if(m_functionPairs[i].second!= 0)
- {
- destroyObjWithMemMgr(
- m_functionPairs[i].second,
- m_memoryManager);
- }
- }
-
- typedef ParamPairVectorType::iterator iterator;
-
- for (iterator j = m_paramPairs.begin(); j != m_paramPairs.end(); ++j)
- {
-
- destroyObjWithMemMgr((*j).first, m_memoryManager);
- destroyObjWithMemMgr((*j).second, m_memoryManager);
- }
+ // Clean up the XalanCompiledStylesheet vector.
+ for_each(
+ m_compiledStylesheets.begin(),
+ m_compiledStylesheets.end(),
+ DeleteFunctor<XalanCompiledStylesheet>(m_memoryManager));
+
+ // Clean up the XalanParsedSource vector.
+ for_each(
+ m_parsedSources.begin(),
+ m_parsedSources.end(),
+ DeleteFunctor<XalanParsedSource>(m_memoryManager));
+
+ // Clean up the Function map.
+ for_each(
+ m_functions.begin(),
+ m_functions.end(),
+ MapValueDeleteFunctor<FunctionMapType>(m_memoryManager));
#if defined(XALAN_USE_ICU)
// Uninstall the ICU collation compare functor, and destroy it...
@@ -216,7 +205,7 @@
assert( s_initMemoryManager!= 0 );
{
- EnsureFunctionsInstallation uninstalGuard(*s_initMemoryManager);
+ const EnsureFunctionsInstallation uninstallGuard(*s_initMemoryManager);
}
delete s_emptyInputSource;
@@ -226,10 +215,6 @@
s_emptyInputSource = 0;
s_xsltInit = 0;
s_initMemoryManager = 0;
-
-#if defined(XALAN_USE_ICU)
- ICUBridgeCleanup::cleanup();
-#endif
}
@@ -853,30 +838,12 @@
void
XalanTransformer::setStylesheetParam(
- const XalanDOMString& key,
- const XalanDOMString& expression)
-{
- m_paramPairs.push_back(
- ParamPairType(
- cloneObjWithMemMgr(
- key,
- m_memoryManager),
- cloneObjWithMemMgr(
- expression,
- m_memoryManager)));
-}
-
-
-
-void
-XalanTransformer::setStylesheetParam(
- const char* key,
+ const char* qname,
const char* expression)
{
-
setStylesheetParam(
XalanDOMString(
- key,
+ qname,
m_memoryManager),
XalanDOMString(
expression,
@@ -939,13 +906,19 @@
const XalanDOMString& functionName,
const Function& function)
{
- m_functionPairs.push_back(
- FunctionPairType(
- XalanQNameByValue::create(
- theNamespace,
- functionName,
- m_memoryManager),
- function.clone(m_memoryManager)));
+ const XalanQNameByValue theQName(theNamespace, functionName, m_memoryManager);
+
+ Function*& theFunction =
+ m_functions[theQName];
+
+ Function* const theOldFunction =
+ theFunction;
+
+ theFunction = function.clone(m_memoryManager);
+
+ XalanDestroy(
+ m_memoryManager,
+ theOldFunction);
}
@@ -969,18 +942,22 @@
const XalanDOMString& theNamespace,
const XalanDOMString& functionName)
{
- for (FunctionParamPairVectorType::size_type i = 0; i < m_functionPairs.size(); ++i)
+ const XalanQNameByValue theQName(theNamespace, functionName, m_memoryManager);
+
+ FunctionMapType::iterator i =
+ m_functions.find(theQName);
+
+ if (i != m_functions.end())
{
- if(m_functionPairs[i].first != 0 &&
- XalanQNameByReference(theNamespace, functionName).equals(* (m_functionPairs[i].first)))
- {
- destroyObjWithMemMgr( m_functionPairs[i].first, m_memoryManager);
+ Function* const theFunction = (*i).second;
+ assert(theFunction != 0);
- destroyObjWithMemMgr( m_functionPairs[i].second, m_memoryManager);
+ m_functions.erase(i);
- m_functionPairs.erase(m_functionPairs.begin() + i);
- }
- }
+ XalanDestroy(
+ m_memoryManager,
+ *theFunction);
+ }
}
@@ -1143,23 +1120,7 @@
m_stylesheetExecutionContext->reset();
- // Clear the ParamPairVectorType.
- XALAN_USING_STD(for_each)
-
-/* for_each(m_paramPairs.begin(),
- m_paramPairs.end(),
- DeleteParamPairFunctor<ParamPairType>(m_memoryManager));
-*/
- typedef ParamPairVectorType::iterator iterator;
-
- for (iterator j = m_paramPairs.begin(); j != m_paramPairs.end(); ++j)
- {
-
- destroyObjWithMemMgr((*j).first, m_memoryManager);
- destroyObjWithMemMgr((*j).second, m_memoryManager);
- }
-
- m_paramPairs.clear();
+ clearStylesheetParams();
}
catch(...)
{
@@ -1224,15 +1185,15 @@
// Set the functions if any.
{
- for (FunctionParamPairVectorType::size_type i = 0; i < m_functionPairs.size(); ++i)
+ for (FunctionMapType::const_iterator i = m_functions.begin();
+ i != m_functions.end(); ++i)
{
- assert( m_functionPairs[i].first != 0);
- assert( m_functionPairs[i].second != 0);
+ assert((*i).second != 0);
theXSLTProcessorEnvSupport.installExternalFunctionLocal(
- m_functionPairs[i].first->getNamespace(),
- m_functionPairs[i].first->getLocalPart(),
- *m_functionPairs[i].second);
+ (*i).first.getNamespace(),
+ (*i).first.getLocalPart(),
+ *(*i).second);
}
}
@@ -1278,15 +1239,18 @@
}
{
+ typedef ParamMapType::const_iterator const_iterator;
+
+ theProcessor.clearStylesheetParams();
+
// Set the parameters if any.
- for (ParamPairVectorType::size_type i = 0; i < m_paramPairs.size(); ++i)
+ for (const_iterator i = m_params.begin();
+ i != m_params.end();
+ ++i)
{
- assert ( m_paramPairs[i].first != 0);
- assert ( m_paramPairs[i].second != 0);
-
theProcessor.setStylesheetParam(
- * (m_paramPairs[i].first),
- * (m_paramPairs[i].second));
+ (*i).first,
+ (*i).second);
}
}
Modified: xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.hpp?view=diff&rev=483545&r1=483544&r2=483545
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.hpp (original)
+++ xalan/c/trunk/src/xalanc/XalanTransformer/XalanTransformer.hpp Thu Dec 7 08:53:03 2006
@@ -91,18 +91,18 @@
typedef std::ostream StreamType;
#endif
- XalanTransformer(MemoryManagerType& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
+ XalanTransformer(MemoryManager& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
virtual
~XalanTransformer();
- MemoryManagerType&
+ MemoryManager&
getMemoryManager()
{
return m_memoryManager;
}
- const MemoryManagerType&
+ const MemoryManager&
getMemoryManager() const
{
return m_memoryManager;
@@ -117,7 +117,7 @@
* initialization state, so you do not call it more than once.
*/
static void
- initialize(MemoryManagerType& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
+ initialize(MemoryManager& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
/**
* Terminate Xalan.
@@ -157,7 +157,7 @@
static void
- ICUStartUp(MemoryManagerType& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
+ ICUStartUp(MemoryManager& theManager = XalanMemMgrs::getDefaultXercesMemMgr());
/**
* Transform will apply the stylesheet source to the parsed xml source
@@ -476,30 +476,44 @@
const XalanDOMString& functionName);
/**
- * Set a top-level stylesheet parameter. This value can be evaluated via
- * xsl:param-variable. These values are cleared after a call to transform().
+ * Set a top-level parameter, which the stylesheet can access
+ * with a top-level xsl:param. Top-level params are "sticky,"
+ * and must be removed with a call to clearStylesheetParams().
*
* @param key name of the param
* @param expression expression that will be evaluated
*/
void
setStylesheetParam(
- const XalanDOMString& key,
- const XalanDOMString& expression);
+ const XalanDOMString& qname,
+ const XalanDOMString& expression)
+ {
+ m_params[qname] = expression;
+ }
/**
- * Set a top-level stylesheet parameter. This value can be evaluated via
- * xsl:param-variable. These values are cleared after a call to transform().
+ * Set a top-level parameter, which the stylesheet can access
+ * with a top-level xsl:param. Top-level params are "sticky,"
+ * and must be removed with a call to clearStylesheetParams().
*
* @param key name of the param
* @param expression expression that will be evaluated
*/
void
setStylesheetParam(
- const char* key,
+ const char* qname,
const char* expression);
/**
+ * Clear any stylesheet params.
+ */
+ void
+ clearStylesheetParams()
+ {
+ m_params.clear();
+ }
+
+ /**
* Add a TraceListener instance. TraceListeners instances are preserved
* between calls to transform(), so they will be called until they are
* removed.
@@ -846,19 +860,19 @@
typedef XalanVector<const XalanCompiledStylesheet*> CompiledStylesheetPtrVectorType;
typedef XalanVector<const XalanParsedSource*> ParsedSourcePtrVectorType;
- typedef XALAN_STD_QUALIFIER pair<XalanDOMString*, XalanDOMString*> ParamPairType;
- typedef XalanVector<ParamPairType> ParamPairVectorType;
- typedef XALAN_STD_QUALIFIER pair<XalanQNameByValue*, Function*> FunctionPairType;
- typedef XalanVector<FunctionPairType> FunctionParamPairVectorType;
- typedef XalanVector<TraceListener*> TraceListenerVectorType;
+
+ typedef XalanMap<XalanDOMString, XalanDOMString> ParamMapType;
+
+ typedef XalanMap<XalanQNameByValue, Function*> FunctionMapType;
+ typedef XalanVector<TraceListener*> TraceListenerVectorType;
class EnsureFunctionsInstallation
{
public:
-
- EnsureFunctionsInstallation(MemoryManagerType& theManager) :
- m_memoryManagement(theManager),
- m_release(false)
+
+ EnsureFunctionsInstallation(MemoryManager& theManager) :
+ m_memoryManagement(theManager),
+ m_release(false)
{
}
@@ -874,9 +888,10 @@
}
private:
- MemoryManagerType& m_memoryManagement;
- bool m_release;
+ MemoryManager& m_memoryManagement;
+
+ bool m_release;
};
class EnsureDestroyParsedSource
@@ -946,66 +961,7 @@
XalanDocumentBuilder* const m_documentBuilder;
};
- template <class T>
-#if defined(XALAN_NO_STD_NAMESPACE)
- struct DeleteParamPairFunctor : public unary_function<T&, void>
-#else
- struct DeleteParamPairFunctor : public std::unary_function<T&, void>
-#endif
- {
-#if defined(XALAN_NO_STD_NAMESPACE)
- typedef unary_function<T&, void> BaseClassType;
-#else
- typedef std::unary_function<T&, void> BaseClassType;
-#endif
- typedef typename BaseClassType::result_type result_type;
- typedef typename BaseClassType::argument_type argument_type;
-
- DeleteParamPairFunctor(MemoryManagerType& theManager) :
- m_memoryManager(theManager)
- {
- }
-
- template<class PtrT>
- void
- deletePtr(PtrT* ptr)const
- {
- ptr->~PtrT();
- }
-
- /**
- * Delete the object pointed to by argument.
- *
- * @param thePointer pointer to object to be deleted
- */
- result_type
- operator()(argument_type thePair) const
- {
- T& tmpPair = const_cast<T&>(thePair);
-
- if (tmpPair.first != 0)
- {
- deletePtr(tmpPair.first);
-
- m_memoryManager.deallocate((void*)tmpPair.first);
- }
-
- if (tmpPair.second != 0)
- {
- deletePtr(tmpPair.second);
-
- m_memoryManager.deallocate((void*)tmpPair.second);
- }
-
-
- }
-
- private:
-
- MemoryManagerType& m_memoryManager;
-
- };
protected:
private:
@@ -1040,15 +996,15 @@
// Data members...
- MemoryManagerType& m_memoryManager;
+ MemoryManager& m_memoryManager;
CompiledStylesheetPtrVectorType m_compiledStylesheets;
ParsedSourcePtrVectorType m_parsedSources;
- ParamPairVectorType m_paramPairs;
+ ParamMapType m_params;
- FunctionParamPairVectorType m_functionPairs;
+ FunctionMapType m_functions;
TraceListenerVectorType m_traceListeners;
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org