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 [4/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/XSLT/XSLTProcessor.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XSLT/XSLTProcessor.hpp?view=diff&rev=483545&r1=483544&r2=483545
==============================================================================
--- xalan/c/trunk/src/xalanc/XSLT/XSLTProcessor.hpp (original)
+++ xalan/c/trunk/src/xalanc/XSLT/XSLTProcessor.hpp Thu Dec 7 08:53:03 2006
@@ -38,7 +38,7 @@
-typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType;
+typedef XERCES_CPP_NAMESPACE_QUALIFIER Locator LocatorType;
@@ -73,7 +73,7 @@
* of the implementation of the XSLTProcessor interface, collaborating with a
* XMLParserLiaison, the DOM, and the XPath engine, to transform a source tree
* of nodes into a result tree according to instructions and templates
- * specified by a stylesheet tree. The methods process(...) are
+ * specified by a stylesheet tree. The methods process(...) are
* the primary public entry points.
*
* If you reuse the processor instance, you should call reset() between calls.
@@ -82,353 +82,361 @@
{
public:
- typedef size_t size_type;
+ typedef size_t size_type;
- XSLTProcessor();
+ XSLTProcessor();
- virtual
- ~XSLTProcessor();
+ virtual
+ ~XSLTProcessor();
- /**
- * Transform the source tree to the output in the given result tree target.
- * The processor will process the input source, the stylesheet source,
- * and transform to the output target.
- *
- * @param inputSource input source
- * @param stylesheetSource stylesheet source
- * @param outputTarget output source tree
- * @param constructionContext context for construction of objects
- * @param executionContext current execution context
- * @exception XSLProcessorException
- */
- virtual void
- process(
- const XSLTInputSource& inputSource,
- const XSLTInputSource& stylesheetSource,
- XSLTResultTarget& outputTarget,
- StylesheetConstructionContext& constructionContext,
- StylesheetExecutionContext& executionContext) = 0;
-
- /**
- * Transform the source tree to the output in the given result tree target.
- * This function does not create a stylesheet tree, it assumes the
- * provided StylesheetExecutionContext has the stylesheet tree to use. This
- * is set by calling StylesheetExecutionContext::setStylesheetRoot().
- *
- * @param inputSource input source
- * @param outputTarget output source tree
- * @param executionContext current execution context
- * @exception XSLProcessorException
- */
- virtual void
- process(
- const XSLTInputSource& inputSource,
- XSLTResultTarget& outputTarget,
- StylesheetExecutionContext& executionContext) = 0;
-
- /**
- * Given a stylesheet input source, compile the stylesheet into an internal
- * representation.
- *
- * @param stylesheetSource input source for the stylesheet
- * @param constructionContext context for construction of objects
- * @return pointer to the compiled stylesheet object
- * @exception XSLProcessorException
- */
- virtual StylesheetRoot*
- processStylesheet(
- const XSLTInputSource& stylesheetSource,
- StylesheetConstructionContext& constructionContext) = 0;
+ /**
+ * Transform the source tree to the output in the given result tree target.
+ * The processor will process the input source, the stylesheet source,
+ * and transform to the output target.
+ *
+ * @param inputSource input source
+ * @param stylesheetSource stylesheet source
+ * @param outputTarget output source tree
+ * @param constructionContext context for construction of objects
+ * @param executionContext current execution context
+ * @exception XSLProcessorException
+ */
+ virtual void
+ process(
+ const XSLTInputSource& inputSource,
+ const XSLTInputSource& stylesheetSource,
+ XSLTResultTarget& outputTarget,
+ StylesheetConstructionContext& constructionContext,
+ StylesheetExecutionContext& executionContext) = 0;
+
+ /**
+ * Transform the source tree to the output in the given result tree target.
+ * This function does not create a stylesheet tree, it assumes the
+ * provided StylesheetExecutionContext has the stylesheet tree to use. This
+ * is set by calling StylesheetExecutionContext::setStylesheetRoot().
+ *
+ * @param inputSource input source
+ * @param outputTarget output source tree
+ * @param executionContext current execution context
+ * @exception XSLProcessorException
+ */
+ virtual void
+ process(
+ const XSLTInputSource& inputSource,
+ XSLTResultTarget& outputTarget,
+ StylesheetExecutionContext& executionContext) = 0;
+
+ /**
+ * Given a stylesheet input source, compile the stylesheet into an internal
+ * representation.
+ *
+ * @param stylesheetSource input source for the stylesheet
+ * @param constructionContext context for construction of objects
+ * @return pointer to the compiled stylesheet object
+ * @exception XSLProcessorException
+ */
+ virtual StylesheetRoot*
+ processStylesheet(
+ const XSLTInputSource& stylesheetSource,
+ StylesheetConstructionContext& constructionContext) = 0;
- /**
- * Given a URI to an XSL stylesheet, compile the stylesheet into an internal
- * representation.
- *
- * @param xmldocURLString URI to the input XML document
- * @param constructionContext context for construction of objects
- * @return pointer to compiled stylesheet object
- * @exception XSLProcessorException
- */
- virtual StylesheetRoot*
- processStylesheet(
- const XalanDOMString& xsldocURLString,
- StylesheetConstructionContext& constructionContext) = 0;
+ /**
+ * Given a URI to an XSL stylesheet, compile the stylesheet into an internal
+ * representation.
+ *
+ * @param xmldocURLString URI to the input XML document
+ * @param constructionContext context for construction of objects
+ * @return pointer to compiled stylesheet object
+ * @exception XSLProcessorException
+ */
+ virtual StylesheetRoot*
+ processStylesheet(
+ const XalanDOMString& xsldocURLString,
+ StylesheetConstructionContext& constructionContext) = 0;
- /**
- * Reset the state. This needs to be called after a process() call
- * is invoked, if the processor is to be used again.
- */
- virtual void
- reset() = 0;
+ /**
+ * Reset the state. This needs to be called after a process() call
+ * is invoked, if the processor is to be used again.
+ */
+ virtual void
+ reset() = 0;
- /**
- * Given an input source, get the source tree.
- *
- * @param inputSource pointer to input source
- * @return source tree
- */
- virtual XalanNode*
- getSourceTreeFromInput(const XSLTInputSource& inputSource) = 0;
-
- /**
- * Retrieve the root stylesheet.
- *
- * @return pointer to root stylesheet
- */
- virtual const StylesheetRoot*
- getStylesheetRoot() const = 0;
-
- /**
- * Set the root stylesheet.
- *
- * @param theStylesheet pointer to new root stylesheet
- */
- virtual void
- setStylesheetRoot(const StylesheetRoot* theStylesheet) = 0;
-
- /**
- * Set the execution context. Must be set if after calling
- * setStylesheetRoot.
- *
- * @param theExecutionContext pointer to new execution context.
- */
- virtual void
- setExecutionContext(StylesheetExecutionContext* theExecutionContext) = 0;
-
- /**
- * Resolve the params that were pushed by the caller.
- */
- virtual void
- resolveTopLevelParams(StylesheetExecutionContext& executionContext) = 0;
-
- /**
- * Get the XML Parser Liaison that this processor uses.
- *
- * @return XML parser liaison object
- */
- virtual XMLParserLiaison&
- getXMLParserLiaison() const = 0;
-
-
- /**
- * Generate a random namespace prefix guaranteed to be unique.
- *
- * @param theValue A string for returning the new prefix
- */
- virtual void
- getUniqueNamespaceValue(XalanDOMString& theValue) = 0;
+ /**
+ * Given an input source, get the source tree.
+ *
+ * @param inputSource pointer to input source
+ * @return source tree
+ */
+ virtual XalanNode*
+ getSourceTreeFromInput(const XSLTInputSource& inputSource) = 0;
+
+ /**
+ * Retrieve the root stylesheet.
+ *
+ * @return pointer to root stylesheet
+ */
+ virtual const StylesheetRoot*
+ getStylesheetRoot() const = 0;
+
+ /**
+ * Set the root stylesheet.
+ *
+ * @param theStylesheet pointer to new root stylesheet
+ */
+ virtual void
+ setStylesheetRoot(const StylesheetRoot* theStylesheet) = 0;
+
+ /**
+ * Set the execution context. Must be set if after calling
+ * setStylesheetRoot.
+ *
+ * @param theExecutionContext pointer to new execution context.
+ */
+ virtual void
+ setExecutionContext(StylesheetExecutionContext* theExecutionContext) = 0;
+
+ /**
+ * Resolve the params that were pushed by the caller.
+ */
+ virtual void
+ resolveTopLevelParams(StylesheetExecutionContext& executionContext) = 0;
+
+ /**
+ * Get the XML Parser Liaison that this processor uses.
+ *
+ * @return XML parser liaison object
+ */
+ virtual XMLParserLiaison&
+ getXMLParserLiaison() const = 0;
+
+
+ /**
+ * Generate a random namespace prefix guaranteed to be unique.
+ *
+ * @param theValue A string for returning the new prefix
+ */
+ virtual void
+ getUniqueNamespaceValue(XalanDOMString& theValue) = 0;
/**
- * Push a top-level stylesheet parameter. This value can be evaluated via
- * xsl:param-variable.
- *
+ * 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 parameter
* @param value XObject value for parameter
*/
virtual void
setStylesheetParam(
- const XalanDOMString& key,
- XObjectPtr value) = 0;
-
+ const XalanDOMString& key,
+ XObjectPtr value) = 0;
+
/**
- * Push a top-level stylesheet parameter. This value can be evaluated via
- * xsl:param-variable.
- *
- * @param key name of the param
- * @param expression expression that will be evaluated
- */
- virtual void
- setStylesheetParam(
- const XalanDOMString& key,
- const XalanDOMString& expression) = 0;
-
- /**
- * Get the current formatter listener.
- *
- * @return pointer to formatter listener
- */
- virtual FormatterListener*
- getFormatterListener() const = 0;
+ * 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
+ */
+ virtual void
+ setStylesheetParam(
+ const XalanDOMString& key,
+ const XalanDOMString& expression) = 0;
+
+ /**
+ * Clear any stylesheet params.
+ */
+ virtual void
+ clearStylesheetParams() = 0;
+
+ /**
+ * Get the current formatter listener.
+ *
+ * @return pointer to formatter listener
+ */
+ virtual FormatterListener*
+ getFormatterListener() const = 0;
- /**
- * Set the current formatter listener.
- *
- * @param flistener pointer to new formatter listener
- */
- virtual void
- setFormatterListener(FormatterListener* flistener) = 0;
-
- /**
- * Determine the number of trace listeners.
- *
- * @return number of listeners
- */
- virtual size_type
- getTraceListeners() const = 0;
-
- /**
- * Add a trace listener for the purposes of debugging and diagnosis.
- *
- * @param tl pointer to listener to add
- */
- virtual void
- addTraceListener(TraceListener* tl) = 0;
-
- /**
- * Remove a trace listener.
- *
- * @param tl Trace listener to be removed.
- */
- virtual void
- removeTraceListener(TraceListener* tl) = 0;
-
- /**
- * Fire a generate event.
- *
- * @param ge generate event to fire
- */
- virtual void
- fireGenerateEvent(const GenerateEvent& ge) = 0;
-
- /**
- * Fire a trace event.
- *
- * @param te trace event to fire
- */
- virtual void
- fireTraceEvent(const TracerEvent& te) = 0;
-
- /**
- * Fire a selection event.
- *
- * @param se selection event to fire
- */
- virtual void
- fireSelectEvent(const SelectionEvent& se) = 0;
-
- /**
- * If this is set to true, simple traces of template calls are made.
- *
- * @return true if traces made
- */
- virtual bool
- getTraceSelects() const = 0;
-
- /**
- * Compose a diagnostic trace of the current selection
- *
- * @param executionContext The current execution context
- * @param theStylesheetElement The executing stylesheet element
- * @param nl The list of selected nodes
- * @param xpath A pointer to the XPath which generated the list of nodes, if any.
- */
- virtual void
- traceSelect(
- StylesheetExecutionContext& executionContext,
- const ElemTemplateElement& theStylesheetElement,
- const NodeRefListBase& nl,
- const XPath* xpath) const = 0;
-
- /**
- * If the quietConflictWarnings property is set to
- * true, warnings about pattern conflicts won't be
- * printed to the diagnostics stream.
- * True by default.
- *
- * @param b true if conflict warnings should be suppressed.
- */
- virtual void
- setQuietConflictWarnings(bool b) = 0;
-
- /**
- * If this is set, diagnostics will be
- * written to the m_diagnosticsPrintWriter stream. If
- * the value is null, then diagnostics will be turned
- * off.
- *
- * @param pw pointer to print writer
- */
- virtual void
- setDiagnosticsOutput(PrintWriter* pw) = 0;
-
- /**
- * Report a message.
- *
- * @param msg text of message to output
- * @param sourceNode node in source where message occurred
- * @param styleNode node in stylesheet where message occurred
- */
- virtual void
- message(
- const XalanDOMString& msg,
- const XalanNode* sourceNode = 0,
- const ElemTemplateElement* styleNode = 0) const = 0;
-
- /**
- * Report a message.
- *
- * @param msg text of message to output
- * @param locator A LocatorType for error reporting
- * @param sourceNode node in source where message occurred
- */
- virtual void
- message(
- const XalanDOMString& msg,
- const LocatorType& locator,
- const XalanNode* sourceNode = 0) const = 0;
-
- /**
- * Report a warning.
- *
- * @param msg text of message to output
- * @param sourceNode node in source where warning occurred
- * @param styleNode node in stylesheet where warning occurred
- */
- virtual void
- warn(
- const XalanDOMString& msg,
- const XalanNode* sourceNode = 0,
- const ElemTemplateElement* styleNode = 0) const = 0;
-
- /**
- * Report a warning.
- *
- * @param msg text of message to output
- * @param locator A LocatorType for error reporting
- * @param sourceNode node in source where error occurred
- */
- virtual void
- warn(
- const XalanDOMString& msg,
- const LocatorType& locator,
- const XalanNode* sourceNode = 0) const = 0;
-
-
- /**
- * Report an error and throw an exception.
- *
- * @param msg text of message to output
- * @param sourceNode node in source where error occurred
- * @param styleNode node in stylesheet where error occurred
- */
- virtual void
- error(
- const XalanDOMString& msg,
- const XalanNode* sourceNode = 0,
- const ElemTemplateElement* styleNode = 0) const = 0;
-
- /**
- * Report an error and throw an exception.
- *
- * @param msg text of message to output
- * @param locator A LocatorType for error reporting
- * @param sourceNode node in source where error occurred
- */
- virtual void
- error(
- const XalanDOMString& msg,
- const LocatorType& locator,
- const XalanNode* sourceNode = 0) const = 0;
+ /**
+ * Set the current formatter listener.
+ *
+ * @param flistener pointer to new formatter listener
+ */
+ virtual void
+ setFormatterListener(FormatterListener* flistener) = 0;
+
+ /**
+ * Determine the number of trace listeners.
+ *
+ * @return number of listeners
+ */
+ virtual size_type
+ getTraceListeners() const = 0;
+
+ /**
+ * Add a trace listener for the purposes of debugging and diagnosis.
+ *
+ * @param tl pointer to listener to add
+ */
+ virtual void
+ addTraceListener(TraceListener* tl) = 0;
+
+ /**
+ * Remove a trace listener.
+ *
+ * @param tl Trace listener to be removed.
+ */
+ virtual void
+ removeTraceListener(TraceListener* tl) = 0;
+
+ /**
+ * Fire a generate event.
+ *
+ * @param ge generate event to fire
+ */
+ virtual void
+ fireGenerateEvent(const GenerateEvent& ge) = 0;
+
+ /**
+ * Fire a trace event.
+ *
+ * @param te trace event to fire
+ */
+ virtual void
+ fireTraceEvent(const TracerEvent& te) = 0;
+
+ /**
+ * Fire a selection event.
+ *
+ * @param se selection event to fire
+ */
+ virtual void
+ fireSelectEvent(const SelectionEvent& se) = 0;
+
+ /**
+ * If this is set to true, simple traces of template calls are made.
+ *
+ * @return true if traces made
+ */
+ virtual bool
+ getTraceSelects() const = 0;
+
+ /**
+ * Compose a diagnostic trace of the current selection
+ *
+ * @param executionContext The current execution context
+ * @param theStylesheetElement The executing stylesheet element
+ * @param nl The list of selected nodes
+ * @param xpath A pointer to the XPath which generated the list of nodes, if any.
+ */
+ virtual void
+ traceSelect(
+ StylesheetExecutionContext& executionContext,
+ const ElemTemplateElement& theStylesheetElement,
+ const NodeRefListBase& nl,
+ const XPath* xpath) const = 0;
+
+ /**
+ * If the quietConflictWarnings property is set to
+ * true, warnings about pattern conflicts won't be
+ * printed to the diagnostics stream.
+ * True by default.
+ *
+ * @param b true if conflict warnings should be suppressed.
+ */
+ virtual void
+ setQuietConflictWarnings(bool b) = 0;
+
+ /**
+ * If this is set, diagnostics will be
+ * written to the m_diagnosticsPrintWriter stream. If
+ * the value is null, then diagnostics will be turned
+ * off.
+ *
+ * @param pw pointer to print writer
+ */
+ virtual void
+ setDiagnosticsOutput(PrintWriter* pw) = 0;
+
+ /**
+ * Report a message.
+ *
+ * @param msg text of message to output
+ * @param sourceNode node in source where message occurred
+ * @param styleNode node in stylesheet where message occurred
+ */
+ virtual void
+ message(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode = 0,
+ const ElemTemplateElement* styleNode = 0) const = 0;
+
+ /**
+ * Report a message.
+ *
+ * @param msg text of message to output
+ * @param locator A LocatorType for error reporting
+ * @param sourceNode node in source where message occurred
+ */
+ virtual void
+ message(
+ const XalanDOMString& msg,
+ const LocatorType& locator,
+ const XalanNode* sourceNode = 0) const = 0;
+
+ /**
+ * Report a warning.
+ *
+ * @param msg text of message to output
+ * @param sourceNode node in source where warning occurred
+ * @param styleNode node in stylesheet where warning occurred
+ */
+ virtual void
+ warn(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode = 0,
+ const ElemTemplateElement* styleNode = 0) const = 0;
+
+ /**
+ * Report a warning.
+ *
+ * @param msg text of message to output
+ * @param locator A LocatorType for error reporting
+ * @param sourceNode node in source where error occurred
+ */
+ virtual void
+ warn(
+ const XalanDOMString& msg,
+ const LocatorType& locator,
+ const XalanNode* sourceNode = 0) const = 0;
+
+
+ /**
+ * Report an error and throw an exception.
+ *
+ * @param msg text of message to output
+ * @param sourceNode node in source where error occurred
+ * @param styleNode node in stylesheet where error occurred
+ */
+ virtual void
+ error(
+ const XalanDOMString& msg,
+ const XalanNode* sourceNode = 0,
+ const ElemTemplateElement* styleNode = 0) const = 0;
+
+ /**
+ * Report an error and throw an exception.
+ *
+ * @param msg text of message to output
+ * @param locator A LocatorType for error reporting
+ * @param sourceNode node in source where error occurred
+ */
+ virtual void
+ error(
+ const XalanDOMString& msg,
+ const LocatorType& locator,
+ const XalanNode* sourceNode = 0) const = 0;
};
@@ -437,4 +445,4 @@
-#endif // XALAN_XSLTPROCESSOR_HEADER_GUARD
+#endif // XALAN_XSLTPROCESSOR_HEADER_GUARD
Added: xalan/c/trunk/src/xalanc/XSLT/XalanParamHolder.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XSLT/XalanParamHolder.hpp?view=auto&rev=483545
==============================================================================
--- xalan/c/trunk/src/xalanc/XSLT/XalanParamHolder.hpp (added)
+++ xalan/c/trunk/src/xalanc/XSLT/XalanParamHolder.hpp Thu Dec 7 08:53:03 2006
@@ -0,0 +1,97 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#if !defined(XALAN_PARAMHOLDER_HEADER_GUARD)
+#define XALAN_PARAMHOLDER_HEADER_GUARD
+
+
+
+// Base include file. Must be first.
+#include <xalanc/XSLT/XSLTDefinitions.hpp>
+
+
+
+#include <xalanc/XalanDOM/XalanDOMString.hpp>
+
+
+
+#include <xalanc/XPath/XObject.hpp>
+
+
+
+XALAN_CPP_NAMESPACE_BEGIN
+
+
+
+XALAN_USING_XERCES(MemoryManager)
+
+
+
+class XalanParamHolder
+{
+public:
+
+ XalanParamHolder(MemoryManager& theMemoryManager) :
+ m_expression(theMemoryManager),
+ m_value()
+ {
+ }
+
+ XalanParamHolder(
+ const XalanParamHolder& theRHS,
+ MemoryManager& theMemoryManager) :
+ m_expression(theRHS.m_expression, theMemoryManager),
+ m_value(theRHS.m_value)
+ {
+ }
+
+ XalanParamHolder(
+ MemoryManager& theMemoryManager,
+ const XalanDOMString& theString) :
+ m_expression(theString, theMemoryManager),
+ m_value()
+ {
+ }
+
+ XalanParamHolder(
+ MemoryManager& theMemoryManager,
+ XObjectPtr theXObject) :
+ m_expression(theMemoryManager),
+ m_value(theXObject)
+ {
+ }
+
+ XalanDOMString m_expression;
+
+ XObjectPtr m_value;
+
+private:
+
+ // These are not implemented...
+ XalanParamHolder();
+
+ XalanParamHolder(const XalanParamHolder& theRHS);
+};
+
+XALAN_USES_MEMORY_MANAGER(XalanParamHolder);
+
+
+
+XALAN_CPP_NAMESPACE_END
+
+
+
+#endif // XALAN_PARAMHOLDER_HEADER_GUARD
Modified: xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.cpp?view=diff&rev=483545&r1=483544&r2=483545
==============================================================================
--- xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.cpp (original)
+++ xalan/c/trunk/src/xalanc/XalanDOM/XalanDOMString.cpp Thu Dec 7 08:53:03 2006
@@ -35,7 +35,7 @@
-const XalanDOMChar XalanDOMString::s_empty = 0;
+const XalanDOMChar XalanDOMString::s_empty = 0;
#if defined(XALAN_INLINE_INITIALIZATION) && !defined(XALAN_INLINE_INITIALIZATION_IS_DEFINITION_BUG)
const XalanDOMString::size_type XalanDOMString::npos;
@@ -44,61 +44,61 @@
XalanDOMString::XalanDOMString(MemoryManagerType& theManager) :
- m_data(theManager),
- m_size(0)
+ m_data(theManager),
+ m_size(0)
{
}
XalanDOMString::XalanDOMString(
- const XalanDOMString& theSource,
+ const XalanDOMString& theSource,
MemoryManagerType& theManager,
- size_type theStartPosition,
- size_type theCount) :
- m_data(theManager),
- m_size(0)
-{
- if (theSource.length() != 0)
- {
- append(theSource, theStartPosition, theCount);
- }
+ size_type theStartPosition,
+ size_type theCount) :
+ m_data(theManager),
+ m_size(0)
+{
+ if (theSource.length() != 0)
+ {
+ append(theSource, theStartPosition, theCount);
+ }
}
XalanDOMString::XalanDOMString(
- const XalanDOMChar* theString,
+ const XalanDOMChar* theString,
MemoryManagerType& theManager,
- size_type theCount) :
- m_data(theManager),
- m_size(0)
-{
- assert(theString != 0);
-
- if (*theString != 0)
- {
- append(theString, theCount);
- }
+ size_type theCount) :
+ m_data(theManager),
+ m_size(0)
+{
+ assert(theString != 0);
+
+ if (*theString != 0)
+ {
+ append(theString, theCount);
+ }
}
XalanDOMString::XalanDOMString(
- const char* theString,
+ const char* theString,
MemoryManagerType& theManager,
- size_type theCount) :
- m_data(theManager),
- m_size(0)
-{
- assert(theString != 0);
-
- if (*theString != 0)
- {
- append(theString, theCount);
- }
+ size_type theCount) :
+ m_data(theManager),
+ m_size(0)
+{
+ assert(theString != 0);
- invariants();
+ if (*theString != 0)
+ {
+ append(theString, theCount);
+ }
+
+ invariants();
}
XalanDOMString*
@@ -118,448 +118,448 @@
}
XalanDOMString::XalanDOMString(
- size_type theCount,
- XalanDOMChar theChar,
+ size_type theCount,
+ XalanDOMChar theChar,
MemoryManagerType& theManager) :
- m_data(theManager),
- m_size(0)
+ m_data(theManager),
+ m_size(0)
{
- if (theCount != 0)
- {
- XalanDOMCharVectorType(theCount + 1, theChar, theManager).swap(m_data);
+ if (theCount != 0)
+ {
+ XalanDOMCharVectorType(theCount + 1, theChar, theManager).swap(m_data);
- // Null-terminate it...
- m_data.back() = 0;
+ // Null-terminate it...
+ m_data.back() = 0;
- m_size = theCount;
- }
+ m_size = theCount;
+ }
- invariants();
+ invariants();
}
void
XalanDOMString::resize(
- size_type theCount,
- XalanDOMChar theChar)
+ size_type theCount,
+ XalanDOMChar theChar)
{
- invariants();
+ invariants();
+
+ const size_type theOldSize = size();
+
+ if (theCount != theOldSize)
+ {
+ if (theOldSize == 0)
+ {
+ // If the string is of 0 length, resize but add an
+ // extra byte for the terminating byte.
+ m_data.resize(theCount + 1, theChar);
+ }
+ else
+ {
+ // If the string is not of 0 length, resize but
+ // put a copy of theChar where the terminating
+ // byte used to be.
+ m_data.resize(theCount + 1, theChar);
+ }
- const size_type theOldSize = size();
+ m_size = theCount;
- if (theCount != theOldSize)
- {
- if (theOldSize == 0)
- {
- // If the string is of 0 length, resize but add an
- // extra byte for the terminating byte.
- m_data.resize(theCount + 1, theChar);
- }
- else
- {
- // If the string is not of 0 length, resize but
- // put a copy of theChar where the terminating
- // byte used to be.
- m_data.resize(theCount + 1, theChar);
- }
-
- m_size = theCount;
-
- // Terminate...
- m_data.back() = 0;
- }
+ // Terminate...
+ m_data.back() = 0;
+ }
- invariants();
+ invariants();
}
void
XalanDOMString::erase(
- size_type theStartPosition,
- size_type theCount)
+ size_type theStartPosition,
+ size_type theCount)
{
- invariants();
+ invariants();
- const size_type theActualCount =
- theCount == size_type(npos) ? length() - theStartPosition : theCount;
+ const size_type theActualCount =
+ theCount == size_type(npos) ? length() - theStartPosition : theCount;
- if (theStartPosition == 0 && theCount >= size())
- {
- m_data.erase(m_data.begin(), m_data.end());
+ if (theStartPosition == 0 && theCount >= size())
+ {
+ m_data.erase(m_data.begin(), m_data.end());
- m_size = 0;
- }
- else
- {
- const iterator i = getIteratorForPosition(theStartPosition);
+ m_size = 0;
+ }
+ else
+ {
+ const iterator i = getIteratorForPosition(theStartPosition);
- m_data.erase(i, i + (theActualCount));
+ m_data.erase(i, i + (theActualCount));
- const size_type theNewSize = size_type(m_data.size());
+ const size_type theNewSize = size_type(m_data.size());
assert(size_type(m_data.size()) == theNewSize);
- if (theNewSize < 2)
- {
- m_size = 0;
- }
- else
- {
- m_size = theNewSize - 1;
- }
- }
+ if (theNewSize < 2)
+ {
+ m_size = 0;
+ }
+ else
+ {
+ m_size = theNewSize - 1;
+ }
+ }
- invariants();
+ invariants();
}
XalanDOMString&
XalanDOMString::assign(
- const XalanDOMString& theSource,
- size_type thePosition,
- size_type theCount)
-{
- invariants();
-
- assert(thePosition < theSource.size() && thePosition + theCount <= theSource.size());
-
- if (&theSource != this)
- {
- erase();
-
- append(theSource, thePosition, theCount);
- }
- else
- {
- if (thePosition == 0)
- {
- // See if we're being asked to
- // assign everything to ourself,
- // which is a noop...
- if (theCount != m_size)
- {
- // We're being asked to truncate...
- resize(theCount);
- }
- }
- else
- {
- // Yuck. We have to move data...
+ const XalanDOMString& theSource,
+ size_type thePosition,
+ size_type theCount)
+{
+ invariants();
+
+ assert(thePosition < theSource.size() && thePosition + theCount <= theSource.size());
+
+ if (&theSource != this)
+ {
+ erase();
+
+ append(theSource, thePosition, theCount);
+ }
+ else
+ {
+ if (thePosition == 0)
+ {
+ // See if we're being asked to
+ // assign everything to ourself,
+ // which is a noop...
+ if (theCount != m_size)
+ {
+ // We're being asked to truncate...
+ resize(theCount);
+ }
+ }
+ else
+ {
+ // Yuck. We have to move data...
#if defined(XALAN_STRICT_ANSI_HEADERS)
- std::memmove(&*begin(), &*begin() + thePosition, theCount * sizeof(XalanDOMChar));
+ std::memmove(&*begin(), &*begin() + thePosition, theCount * sizeof(XalanDOMChar));
#else
- memmove(&*begin(), &*begin() + thePosition, theCount * sizeof(XalanDOMChar));
+ memmove(&*begin(), &*begin() + thePosition, theCount * sizeof(XalanDOMChar));
#endif
- resize(theCount);
- }
- }
+ resize(theCount);
+ }
+ }
- invariants();
+ invariants();
- return *this;
+ return *this;
}
XalanDOMString&
XalanDOMString::assign(
- iterator theFirstPosition,
- iterator theLastPosition)
+ iterator theFirstPosition,
+ iterator theLastPosition)
{
- invariants();
+ invariants();
- m_data.reserve(theLastPosition - theFirstPosition + 1);
+ m_data.reserve(theLastPosition - theFirstPosition + 1);
- m_data.assign(theFirstPosition, theLastPosition);
+ m_data.assign(theFirstPosition, theLastPosition);
- m_data.push_back(XalanDOMChar(0));
+ m_data.push_back(XalanDOMChar(0));
- m_size = size_type(m_data.size()) - 1;
+ m_size = size_type(m_data.size()) - 1;
assert(m_data.size() - 1 == m_size);
- invariants();
+ invariants();
- return *this;
+ return *this;
}
XalanDOMString&
XalanDOMString::append(
- const XalanDOMChar* theString,
- size_type theCount)
+ const XalanDOMChar* theString,
+ size_type theCount)
{
- const size_type theLength =
- theCount == size_type(npos) ? length(theString) : theCount;
+ const size_type theLength =
+ theCount == size_type(npos) ? length(theString) : theCount;
- if (theLength != 0)
- {
- if (m_data.empty() == true)
- {
- m_data.reserve(theLength + 1);
+ if (theLength != 0)
+ {
+ if (m_data.empty() == true)
+ {
+ m_data.reserve(theLength + 1);
- m_data.insert(m_data.end(), theString, theString + theLength);
+ m_data.insert(m_data.end(), theString, theString + theLength);
- m_data.push_back(0);
+ m_data.push_back(0);
- m_size = theLength;
+ m_size = theLength;
- assert(length() == theLength);
- }
- else
- {
- m_data.insert(getBackInsertIterator(), theString, theString + theLength);
+ assert(length() == theLength);
+ }
+ else
+ {
+ m_data.insert(getBackInsertIterator(), theString, theString + theLength);
- m_size += theCount;
- }
- }
+ m_size += theCount;
+ }
+ }
- invariants();
+ invariants();
- return *this;
+ return *this;
}
static inline void
doTranscode(
- const char* theString,
- XalanDOMString::size_type theCount,
- XalanDOMCharVectorType& theVector,
- bool fTerminate)
-{
- assert(theString != 0);
-
- if (theCount == XalanDOMString::size_type(XalanDOMString::npos))
- {
- if (TranscodeFromLocalCodePage(theString, theVector, fTerminate) == false)
- {
- throw XalanDOMString::TranscodingError();
- }
- }
- else
- {
- if (TranscodeFromLocalCodePage(theString, theCount, theVector, fTerminate) == false)
- {
- throw XalanDOMString::TranscodingError();
- }
- }
+ const char* theString,
+ XalanDOMString::size_type theCount,
+ XalanDOMCharVectorType& theVector,
+ bool fTerminate)
+{
+ assert(theString != 0);
+
+ if (theCount == XalanDOMString::size_type(XalanDOMString::npos))
+ {
+ if (TranscodeFromLocalCodePage(theString, theVector, fTerminate) == false)
+ {
+ throw XalanDOMString::TranscodingError();
+ }
+ }
+ else
+ {
+ if (TranscodeFromLocalCodePage(theString, theCount, theVector, fTerminate) == false)
+ {
+ throw XalanDOMString::TranscodingError();
+ }
+ }
}
XalanDOMString&
XalanDOMString::append(
- const char* theString,
- size_type theCount)
+ const char* theString,
+ size_type theCount)
{
- invariants();
+ invariants();
- const size_type theLength =
- theCount == size_type(npos) ? length(theString) : theCount;
+ const size_type theLength =
+ theCount == size_type(npos) ? length(theString) : theCount;
- if (theLength != 0)
- {
- if (empty() == true)
- {
- doTranscode(theString, theLength, m_data, true);
- }
- else
- {
- XalanDOMCharVectorType theTempVector(getMemoryManager());
+ if (theLength != 0)
+ {
+ if (empty() == true)
+ {
+ doTranscode(theString, theLength, m_data, true);
+ }
+ else
+ {
+ XalanDOMCharVectorType theTempVector(getMemoryManager());
- doTranscode(theString, theLength, theTempVector, false);
+ doTranscode(theString, theLength, theTempVector, false);
- append(&*theTempVector.begin(), size_type(theTempVector.size()));
- }
+ append(&*theTempVector.begin(), size_type(theTempVector.size()));
+ }
- m_size = size_type(m_data.size()) - 1;
+ m_size = size_type(m_data.size()) - 1;
assert(m_data.size() - 1 == m_size);
- }
+ }
- invariants();
+ invariants();
- return *this;
+ return *this;
}
XalanDOMString&
XalanDOMString::append(
- size_type theCount,
- XalanDOMChar theChar)
+ size_type theCount,
+ XalanDOMChar theChar)
{
- invariants();
+ invariants();
- if (m_data.empty() == true)
- {
- m_data.insert(m_data.end(), theCount + 1, theChar);
+ if (m_data.empty() == true)
+ {
+ m_data.insert(m_data.end(), theCount + 1, theChar);
- m_data.back() = 0;
+ m_data.back() = 0;
- m_size = theCount;
+ m_size = theCount;
- assert(length() == theCount);
- }
- else
- {
- m_data.insert(getBackInsertIterator(), theCount, theChar);
+ assert(length() == theCount);
+ }
+ else
+ {
+ m_data.insert(getBackInsertIterator(), theCount, theChar);
- m_size += theCount;
- }
+ m_size += theCount;
+ }
- invariants();
+ invariants();
- return *this;
+ return *this;
}
XalanDOMString&
XalanDOMString::insert(
- size_type thePosition,
- const XalanDOMChar* theString,
- size_type theCount)
+ size_type thePosition,
+ const XalanDOMChar* theString,
+ size_type theCount)
{
- invariants();
+ invariants();
- if (m_data.empty() == true)
- {
- assert(thePosition == 0);
+ if (m_data.empty() == true)
+ {
+ assert(thePosition == 0);
- append(theString, theCount);
+ append(theString, theCount);
- assert(length() == theCount);
- }
- else
- {
- m_data.insert(getIteratorForPosition(thePosition), theString, theString + theCount);
+ assert(length() == theCount);
+ }
+ else
+ {
+ m_data.insert(getIteratorForPosition(thePosition), theString, theString + theCount);
- m_size += theCount;
- }
+ m_size += theCount;
+ }
- invariants();
+ invariants();
- return *this;
+ return *this;
}
XalanDOMString&
XalanDOMString::insert(
- size_type thePosition,
- size_type theCount,
- XalanDOMChar theChar)
+ size_type thePosition,
+ size_type theCount,
+ XalanDOMChar theChar)
{
- invariants();
+ invariants();
- if (m_data.empty() == true)
- {
- assert(thePosition == 0);
+ if (m_data.empty() == true)
+ {
+ assert(thePosition == 0);
- assign(theCount, theChar);
- }
- else
- {
- m_data.insert(getIteratorForPosition(thePosition), theCount, theChar);
+ assign(theCount, theChar);
+ }
+ else
+ {
+ m_data.insert(getIteratorForPosition(thePosition), theCount, theChar);
- m_size += theCount;
- }
+ m_size += theCount;
+ }
- invariants();
+ invariants();
- return *this;
+ return *this;
}
XalanDOMString::iterator
XalanDOMString::insert(
- iterator thePosition,
- XalanDOMChar theChar)
+ iterator thePosition,
+ XalanDOMChar theChar)
{
- invariants();
+ invariants();
- if (m_data.empty() == true)
- {
- assert(thePosition == m_data.end() || thePosition == m_data.begin());
+ if (m_data.empty() == true)
+ {
+ assert(thePosition == m_data.end() || thePosition == m_data.begin());
- assign(1, theChar);
+ assign(1, theChar);
- assert(length() == 1);
+ assert(length() == 1);
thePosition = m_data.begin();
- }
- else
- {
- thePosition = m_data.insert(thePosition, theChar);
+ }
+ else
+ {
+ thePosition = m_data.insert(thePosition, theChar);
- ++m_size;
- }
+ ++m_size;
+ }
assert(*thePosition == theChar);
- invariants();
+ invariants();
- return thePosition;
+ return thePosition;
}
void
XalanDOMString::insert(
- iterator thePosition,
- size_type theCount,
- XalanDOMChar theChar)
+ iterator thePosition,
+ size_type theCount,
+ XalanDOMChar theChar)
{
- invariants();
+ invariants();
- if (m_data.empty() == true)
- {
- assert(thePosition == m_data.end() || thePosition == m_data.begin());
+ if (m_data.empty() == true)
+ {
+ assert(thePosition == m_data.end() || thePosition == m_data.begin());
- assign(theCount, theChar);
+ assign(theCount, theChar);
- assert(length() == theCount);
- }
- else
- {
- m_data.insert(thePosition, theCount, theChar);
+ assert(length() == theCount);
+ }
+ else
+ {
+ m_data.insert(thePosition, theCount, theChar);
- m_size += theCount;
- }
+ m_size += theCount;
+ }
- invariants();
+ invariants();
}
void
XalanDOMString::insert(
- iterator theInsertPosition,
- iterator theFirstPosition,
- iterator theLastPosition)
+ iterator theInsertPosition,
+ iterator theFirstPosition,
+ iterator theLastPosition)
{
- invariants();
+ invariants();
- if (m_data.empty() == true)
- {
- assert(theInsertPosition == m_data.end() || theInsertPosition == m_data.begin());
+ if (m_data.empty() == true)
+ {
+ assert(theInsertPosition == m_data.end() || theInsertPosition == m_data.begin());
- assign(theFirstPosition, theLastPosition);
- }
- else
- {
- m_data.insert(theInsertPosition, theFirstPosition, theLastPosition);
+ assign(theFirstPosition, theLastPosition);
+ }
+ else
+ {
+ m_data.insert(theInsertPosition, theFirstPosition, theLastPosition);
- m_size = size_type(m_data.size()) - 1;
+ m_size = size_type(m_data.size()) - 1;
- assert(m_size == m_data.size() - 1);
- }
+ assert(m_size == m_data.size() - 1);
+ }
- invariants();
+ invariants();
}
@@ -567,83 +567,83 @@
template <class Type, class SizeType>
int
doCompare(
- const Type* theLHS,
- SizeType theLHSLength,
- const Type* theRHS,
- SizeType theRHSLength)
-{
- int theResult = 0;
-
- if (theLHSLength != 0 || theRHSLength != 0)
- {
- Type theLHSChar = Type(0);
- Type theRHSChar = Type(0);
-
- SizeType i = 0;
-
- for(; i < theLHSLength && i < theRHSLength; i++)
- {
- theLHSChar = theLHS[i];
- theRHSChar = theRHS[i];
-
- if (theLHSChar != theRHSChar)
- {
- break;
- }
- }
-
- if (i == theLHSLength)
- {
- // We reached the end of theLHS...
- if (i != theRHSLength)
- {
- // but not the end of theRHS.
- theResult = -1;
- }
- }
- else if (i == theRHSLength)
- {
- // We reached the end of theRHS string...
- if (i != theLHSLength)
- {
- // but not the end of theLHS string.
- theResult = 1;
- }
- }
- else
- {
- // We didn't reach the end of _either_ string, so
- // return the difference between the two characters
- // that caused the problem.
- theResult = theLHSChar - theRHSChar;
- }
- }
+ const Type* theLHS,
+ SizeType theLHSLength,
+ const Type* theRHS,
+ SizeType theRHSLength)
+{
+ int theResult = 0;
+
+ if (theLHSLength != 0 || theRHSLength != 0)
+ {
+ Type theLHSChar = Type(0);
+ Type theRHSChar = Type(0);
+
+ SizeType i = 0;
- return theResult;
+ for(; i < theLHSLength && i < theRHSLength; i++)
+ {
+ theLHSChar = theLHS[i];
+ theRHSChar = theRHS[i];
+
+ if (theLHSChar != theRHSChar)
+ {
+ break;
+ }
+ }
+
+ if (i == theLHSLength)
+ {
+ // We reached the end of theLHS...
+ if (i != theRHSLength)
+ {
+ // but not the end of theRHS.
+ theResult = -1;
+ }
+ }
+ else if (i == theRHSLength)
+ {
+ // We reached the end of theRHS string...
+ if (i != theLHSLength)
+ {
+ // but not the end of theLHS string.
+ theResult = 1;
+ }
+ }
+ else
+ {
+ // We didn't reach the end of _either_ string, so
+ // return the difference between the two characters
+ // that caused the problem.
+ theResult = theLHSChar - theRHSChar;
+ }
+ }
+
+ return theResult;
}
int
-XalanDOMString::compare(const XalanDOMChar* theString) const
+XalanDOMString::compare(const XalanDOMChar* theString) const
{
- invariants();
+ invariants();
- return doCompare(c_str(), length(), theString, length(theString));
+ return doCompare(c_str(), length(), theString, length(theString));
}
int
XalanDOMString::compare(
- size_type thePosition1,
- size_type theCount1,
- const XalanDOMChar* theString,
- size_type theCount2) const
+ size_type thePosition1,
+ size_type theCount1,
+ const XalanDOMChar* theString,
+ size_type theCount2) const
{
- invariants();
+ invariants();
- return doCompare(c_str() + thePosition1, theCount1, theString, theCount2);
+ return doCompare(c_str() + thePosition1, theCount1, theString, theCount2);
}
template<class Type>
@@ -659,159 +659,137 @@
void
XalanDOMString::reset(MemoryManagerType& theManager,
- const char* theString)
+ const char* theString)
{
reset_func(*this, theManager, theString);
}
+
+
void
XalanDOMString::reset(MemoryManagerType& theManager,
const XalanDOMChar* theString)
{
reset_func(*this, theManager, theString);
}
+
+
+
void
-XalanDOMString::transcode(CharVectorType& theResult) const
+XalanDOMString::transcode(CharVectorType& theResult) const
{
- invariants();
+ invariants();
- if (TranscodeToLocalCodePage(c_str(), length(), theResult, true) == false)
- {
- throw TranscodingError();
- }
+ if (TranscodeToLocalCodePage(c_str(), length(), theResult, true) == false)
+ {
+ throw TranscodingError();
+ }
}
static inline XalanDOMString::size_type
-length(const XalanDOMChar* theString)
+length(const XalanDOMChar* theString)
{
- assert(theString != 0);
+ assert(theString != 0);
- const XalanDOMChar* theStringPointer = theString;
+ const XalanDOMChar* theStringPointer = theString;
- while(*theStringPointer != 0)
- {
- theStringPointer++;
- }
+ while(*theStringPointer != 0)
+ {
+ theStringPointer++;
+ }
- return XalanDOMString::size_type(theStringPointer - theString);
+ return XalanDOMString::size_type(theStringPointer - theString);
}
bool
XalanDOMString::equals(
- const XalanDOMChar* theLHS,
- size_type theLHSLength,
- const XalanDOMChar* theRHS,
- size_type theRHSLength)
-{
- if (theLHSLength != theRHSLength)
- {
- return false;
- }
- else if (theLHSLength == 0)
- {
- return true;
- }
- else
- {
- const XalanDOMChar* const theEnd = theLHS + theLHSLength;
-
- while(*theLHS == *theRHS)
- {
- ++theLHS;
-
- if (theLHS == theEnd)
- {
- return true;
- }
- else
- {
- ++theRHS;
- }
- }
+ const XalanDOMChar* theLHS,
+ size_type theLHSLength,
+ const XalanDOMChar* theRHS,
+ size_type theRHSLength)
+{
+ if (theLHSLength != theRHSLength)
+ {
+ return false;
+ }
+ else if (theLHSLength == 0)
+ {
+ return true;
+ }
+ else
+ {
+ const XalanDOMChar* const theEnd = theLHS + theLHSLength;
+
+ while(*theLHS == *theRHS)
+ {
+ ++theLHS;
+
+ if (theLHS == theEnd)
+ {
+ return true;
+ }
+ else
+ {
+ ++theRHS;
+ }
+ }
- return false;
- }
+ return false;
+ }
}
bool
XalanDOMString::equals(
- const XalanDOMString& theLHS,
- const XalanDOMString& theRHS)
+ const XalanDOMString& theLHS,
+ const XalanDOMString& theRHS)
{
- const XalanDOMString::size_type theLHSLength = theLHS.size();
- const XalanDOMString::size_type theRHSLength = theRHS.size();
+ const XalanDOMString::size_type theLHSLength = theLHS.size();
+ const XalanDOMString::size_type theRHSLength = theRHS.size();
- if (theLHSLength != theRHSLength)
- {
- return false;
- }
- else
- {
- return equals(theLHS.c_str(), theLHSLength, theRHS.c_str(), theRHSLength);
- }
+ if (theLHSLength != theRHSLength)
+ {
+ return false;
+ }
+ else
+ {
+ return equals(theLHS.c_str(), theLHSLength, theRHS.c_str(), theRHSLength);
+ }
}
XalanDOMString::size_type
-XalanDOMString::length(const XalanDOMChar* theString)
+XalanDOMString::length(const XalanDOMChar* theString)
{
- return XALAN_CPP_NAMESPACE :: length(theString);
+ return XALAN_CPP_NAMESPACE :: length(theString);
}
XalanDOMString::size_type
-XalanDOMString::length(const char* theString)
+XalanDOMString::length(const char* theString)
{
- assert(theString != 0);
+ assert(theString != 0);
#if defined(XALAN_STRICT_ANSI_HEADERS)
- assert(std::strlen(theString) < size_type(npos));
+ assert(std::strlen(theString) < size_type(npos));
- return size_type(std::strlen(theString));
+ return size_type(std::strlen(theString));
#else
- assert(strlen(theString) < size_type(npos));
+ assert(strlen(theString) < size_type(npos));
- return size_type(strlen(theString));
+ return size_type(strlen(theString));
#endif
}
-
-XalanDOMString::size_type
-XalanDOMString::hash(
- const XalanDOMChar* theString,
- XalanDOMString::size_type theLength)
-{
- assert(theString != 0);
-
- size_type theResult = 0;
-
- const XalanDOMChar* const theEnd = theString + theLength;
-
- while (theString != theEnd)
- {
- theResult += (theResult * 37) + (theResult >> 24) + size_type(*theString);
-
- ++theString;
- }
-
- return theResult;
-}
-
-
-
-
-
-
XALAN_CPP_NAMESPACE_END
@@ -840,18 +818,18 @@
char theSubstitutionChar)
{
- const SourceType* theRealSourceString = theSourceString;
+ const SourceType* theRealSourceString = theSourceString;
- XalanDOMString::size_type theRealSourceStringLength = theSourceStringLength;
+ XalanDOMString::size_type theRealSourceStringLength = theSourceStringLength;
- XalanMemMgrAutoPtrArray<SourceType> theGuard;
+ XalanMemMgrAutoPtrArray<SourceType> theGuard;
- if (theSourceStringIsNullTerminated == true)
- {
- theRealSourceStringLength = XalanDOMString::length(theSourceString);
- }
- else
- {
+ if (theSourceStringIsNullTerminated == true)
+ {
+ theRealSourceStringLength = XalanDOMString::length(theSourceString);
+ }
+ else
+ {
typedef XalanMemMngArrayAllocate<SourceType> ArrayAllocateSourceType;
theGuard.reset( &( theTargetVector.getMemoryManager()),
@@ -875,7 +853,7 @@
assert(theRealSourceString != 0);
- bool fSuccess = false;
+ bool fSuccess = false;
XALAN_USING_XERCES(XMLString)
@@ -932,185 +910,185 @@
}
if (terminate == false)
- {
- while(theTargetVector.back() == TargetType(0))
- {
- theTargetVector.pop_back();
- }
- }
+ {
+ while(theTargetVector.back() == TargetType(0))
+ {
+ theTargetVector.pop_back();
+ }
+ }
}
template <class SourceType, class TargetType>
bool
doXercesTranscode(
- const SourceType* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- bool theSourceStringIsNullTerminated,
- XalanVector<TargetType>& theTargetVector,
- bool terminate)
-{
- const SourceType* theRealSourceString = theSourceString;
-
- XalanDOMString::size_type theRealSourceStringLength = theSourceStringLength;
-
- XalanMemMgrAutoPtrArray<SourceType> theGuard;
-
- if (theSourceStringIsNullTerminated == true)
- {
- theRealSourceStringLength = XalanDOMString::length(theSourceString);
- }
- else
- {
+ const SourceType* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ bool theSourceStringIsNullTerminated,
+ XalanVector<TargetType>& theTargetVector,
+ bool terminate)
+{
+ const SourceType* theRealSourceString = theSourceString;
+
+ XalanDOMString::size_type theRealSourceStringLength = theSourceStringLength;
+
+ XalanMemMgrAutoPtrArray<SourceType> theGuard;
+
+ if (theSourceStringIsNullTerminated == true)
+ {
+ theRealSourceStringLength = XalanDOMString::length(theSourceString);
+ }
+ else
+ {
typedef XalanMemMngArrayAllocate<SourceType> ArrayAllocateSourceType;
theGuard.reset( &( theTargetVector.getMemoryManager()),
ArrayAllocateSourceType::allocate(theRealSourceStringLength + 1, theTargetVector.getMemoryManager()),
theRealSourceStringLength + 1);
- assert(theGuard.get() != 0);
+ assert(theGuard.get() != 0);
+
+ for (XalanDOMString::size_type index = 0; index < theRealSourceStringLength; ++index)
+ {
+ theGuard[index] = theSourceString[index];
+ }
+
+ theGuard[theRealSourceStringLength] = SourceType(0);
- for (XalanDOMString::size_type index = 0; index < theRealSourceStringLength; ++index)
- {
- theGuard[index] = theSourceString[index];
- }
-
- theGuard[theRealSourceStringLength] = SourceType(0);
-
- theRealSourceString = theGuard.get();
- }
-
- // Initially, let's guess the the transcoded string will be of the same
- // length as the UTF-16 string.
- theTargetVector.resize(theRealSourceStringLength + 1, TargetType(0));
-
- assert(theRealSourceString != 0);
-
- unsigned int theAttempts = 0;
- bool fSuccess = false;
-
- do
- {
- XALAN_USING_XERCES(XMLString)
-
- // $$$ ToDo: We should use the Xerces transcoder interface
- // instead of XMLString::transcode(), so we can better control
- // error handling and failures due to inadequate space.
- fSuccess = XMLString::transcode(
- theRealSourceString,
- &*theTargetVector.begin(),
- (unsigned int)(theTargetVector.size() - 1),
+ theRealSourceString = theGuard.get();
+ }
+
+ // Initially, let's guess the the transcoded string will be of the same
+ // length as the UTF-16 string.
+ theTargetVector.resize(theRealSourceStringLength + 1, TargetType(0));
+
+ assert(theRealSourceString != 0);
+
+ unsigned int theAttempts = 0;
+ bool fSuccess = false;
+
+ do
+ {
+ XALAN_USING_XERCES(XMLString)
+
+ // $$$ ToDo: We should use the Xerces transcoder interface
+ // instead of XMLString::transcode(), so we can better control
+ // error handling and failures due to inadequate space.
+ fSuccess = XMLString::transcode(
+ theRealSourceString,
+ &*theTargetVector.begin(),
+ (unsigned int)(theTargetVector.size() - 1),
& (theTargetVector.getMemoryManager()));
- if (fSuccess == false)
- {
- if (theAttempts > 2)
- {
- break;
- }
- else
- {
- ++theAttempts;
-
- theTargetVector.resize(theTargetVector.size() + 10, TargetType(0));
- }
- }
- } while (fSuccess == false);
-
- if (fSuccess == false)
- {
- theTargetVector.clear();
- }
- else if (terminate == false)
- {
- while(theTargetVector.back() == TargetType(0))
- {
- theTargetVector.pop_back();
- }
- }
+ if (fSuccess == false)
+ {
+ if (theAttempts > 2)
+ {
+ break;
+ }
+ else
+ {
+ ++theAttempts;
+
+ theTargetVector.resize(theTargetVector.size() + 10, TargetType(0));
+ }
+ }
+ } while (fSuccess == false);
+
+ if (fSuccess == false)
+ {
+ theTargetVector.clear();
+ }
+ else if (terminate == false)
+ {
+ while(theTargetVector.back() == TargetType(0))
+ {
+ theTargetVector.pop_back();
+ }
+ }
- return fSuccess;
+ return fSuccess;
}
static void
doTranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- bool theSourceStringIsNullTerminated,
- CharVectorType& theTargetVector,
- bool terminate,
+ const XalanDOMChar* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ bool theSourceStringIsNullTerminated,
+ CharVectorType& theTargetVector,
+ bool terminate,
char theSubstitutionChar)
{
// Short circuit if it's a null pointer, or of length 0.
if (!theSourceString || (!theSourceString[0]))
{
- if (terminate == true)
- {
- theTargetVector.resize(1);
-
- theTargetVector.back() = '\0';
- }
- else
- {
- theTargetVector.clear();
- }
- }
- else
- {
- doXercesTranscode(
- theSourceString,
- theSourceStringLength,
- theSourceStringIsNullTerminated,
- theTargetVector,
- terminate,
+ if (terminate == true)
+ {
+ theTargetVector.resize(1);
+
+ theTargetVector.back() = '\0';
+ }
+ else
+ {
+ theTargetVector.clear();
+ }
+ }
+ else
+ {
+ doXercesTranscode(
+ theSourceString,
+ theSourceStringLength,
+ theSourceStringIsNullTerminated,
+ theTargetVector,
+ terminate,
theSubstitutionChar);
- }
+ }
}
static bool
doTranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- bool theSourceStringIsNullTerminated,
- CharVectorType& theTargetVector,
- bool terminate)
+ const XalanDOMChar* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ bool theSourceStringIsNullTerminated,
+ CharVectorType& theTargetVector,
+ bool terminate)
{
// Short circuit if it's a null pointer, or of length 0.
if (!theSourceString || (!theSourceString[0]))
{
- if (terminate == true)
- {
- theTargetVector.resize(1);
-
- theTargetVector.back() = '\0';
- }
- else
- {
- theTargetVector.clear();
- }
+ if (terminate == true)
+ {
+ theTargetVector.resize(1);
+
+ theTargetVector.back() = '\0';
+ }
+ else
+ {
+ theTargetVector.clear();
+ }
return true;
- }
- else
- {
- return doXercesTranscode(
- theSourceString,
- theSourceStringLength,
- theSourceStringIsNullTerminated,
- theTargetVector,
- terminate);
- }
+ }
+ else
+ {
+ return doXercesTranscode(
+ theSourceString,
+ theSourceStringLength,
+ theSourceStringIsNullTerminated,
+ theTargetVector,
+ terminate);
+ }
}
XALAN_DOM_EXPORT_FUNCTION(void)
TranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- CharVectorType& theTargetVector,
- bool terminate,
+ const XalanDOMChar* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ CharVectorType& theTargetVector,
+ bool terminate,
char theSubstitutionChar)
{
- doTranscodeToLocalCodePage(
+ doTranscodeToLocalCodePage(
theSourceString,
theSourceStringLength,
false,
@@ -1123,12 +1101,12 @@
XALAN_DOM_EXPORT_FUNCTION(void)
TranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- CharVectorType& theTargetVector,
- bool terminate,
+ const XalanDOMChar* theSourceString,
+ CharVectorType& theTargetVector,
+ bool terminate,
char theSubstitutionChar)
{
- doTranscodeToLocalCodePage(
+ doTranscodeToLocalCodePage(
theSourceString,
0,
true,
@@ -1139,114 +1117,114 @@
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- CharVectorType& theTargetVector,
- bool terminate)
+ const XalanDOMChar* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ CharVectorType& theTargetVector,
+ bool terminate)
{
- return doTranscodeToLocalCodePage(theSourceString, theSourceStringLength, false, theTargetVector, terminate);
+ return doTranscodeToLocalCodePage(theSourceString, theSourceStringLength, false, theTargetVector, terminate);
}
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeToLocalCodePage(
- const XalanDOMChar* theSourceString,
- CharVectorType& theTargetVector,
- bool terminate)
+ const XalanDOMChar* theSourceString,
+ CharVectorType& theTargetVector,
+ bool terminate)
{
- return doTranscodeToLocalCodePage(theSourceString, 0, true, theTargetVector, terminate);
+ return doTranscodeToLocalCodePage(theSourceString, 0, true, theTargetVector, terminate);
}
static bool
doTranscodeFromLocalCodePage(
- const char* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- bool theSourceStringIsNullTerminated,
- XalanDOMCharVectorType& theTargetVector,
- bool terminate)
+ const char* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ bool theSourceStringIsNullTerminated,
+ XalanDOMCharVectorType& theTargetVector,
+ bool terminate)
{
- typedef XalanDOMString::size_type size_type;
+ typedef XalanDOMString::size_type size_type;
// Short circuit if it's a null pointer, or of length 0.
if (!theSourceString || (!theSourceString[0]))
{
- if (terminate == true)
- {
- theTargetVector.resize(1);
-
- theTargetVector.back() = '\0';
- }
- else
- {
- theTargetVector.clear();
- }
+ if (terminate == true)
+ {
+ theTargetVector.resize(1);
+
+ theTargetVector.back() = '\0';
+ }
+ else
+ {
+ theTargetVector.clear();
+ }
return true;
- }
- else
- {
- return doXercesTranscode(
- theSourceString,
- theSourceStringLength,
- theSourceStringIsNullTerminated,
- theTargetVector,
- terminate);
- }
+ }
+ else
+ {
+ return doXercesTranscode(
+ theSourceString,
+ theSourceStringLength,
+ theSourceStringIsNullTerminated,
+ theTargetVector,
+ terminate);
+ }
}
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeFromLocalCodePage(
- const char* theSourceString,
- XalanDOMString::size_type theSourceStringLength,
- XalanDOMCharVectorType& theTargetVector,
- bool terminate)
+ const char* theSourceString,
+ XalanDOMString::size_type theSourceStringLength,
+ XalanDOMCharVectorType& theTargetVector,
+ bool terminate)
{
- return doTranscodeFromLocalCodePage(theSourceString, theSourceStringLength, false, theTargetVector, terminate);
+ return doTranscodeFromLocalCodePage(theSourceString, theSourceStringLength, false, theTargetVector, terminate);
}
XALAN_DOM_EXPORT_FUNCTION(bool)
TranscodeFromLocalCodePage(
- const char* theSourceString,
- XalanDOMCharVectorType& theTargetVector,
- bool terminate)
+ const char* theSourceString,
+ XalanDOMCharVectorType& theTargetVector,
+ bool terminate)
{
- return doTranscodeFromLocalCodePage(theSourceString, 0, true, theTargetVector, terminate);
+ return doTranscodeFromLocalCodePage(theSourceString, 0, true, theTargetVector, terminate);
}
XALAN_DOM_EXPORT_FUNCTION(const XalanDOMString&)
-TranscodeFromLocalCodePage(const CharVectorType& theSourceString,
+TranscodeFromLocalCodePage(const CharVectorType& theSourceString,
XalanDOMString& result)
{
- if (theSourceString.empty() == true)
- {
+ if (theSourceString.empty() == true)
+ {
result.erase();
return result;
- }
- else
- {
- typedef XalanDOMString::size_type size_type;
-
- const CharVectorType::size_type theSize = theSourceString.size();
-
- if (theSourceString[theSize - 1] == CharVectorType::value_type(0))
- {
- return TranscodeFromLocalCodePage(&*theSourceString.begin(), result , size_type(theSize) - 1);
- }
- else
- {
- return TranscodeFromLocalCodePage(&*theSourceString.begin(), result , size_type(theSize));
- }
- }
+ }
+ else
+ {
+ typedef XalanDOMString::size_type size_type;
+
+ const CharVectorType::size_type theSize = theSourceString.size();
+
+ if (theSourceString[theSize - 1] == CharVectorType::value_type(0))
+ {
+ return TranscodeFromLocalCodePage(&*theSourceString.begin(), result , size_type(theSize) - 1);
+ }
+ else
+ {
+ return TranscodeFromLocalCodePage(&*theSourceString.begin(), result , size_type(theSize));
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org