xalan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbert...@apache.org
Subject svn commit: r690862 - in /xalan/c/trunk/src/xalanc/PlatformSupport: DOMStringHelper.cpp ProblemListenerBase.cpp ProblemListenerBase.hpp
Date Mon, 01 Sep 2008 06:54:37 GMT
Author: dbertoni
Date: Sun Aug 31 23:54:36 2008
New Revision: 690862

URL: http://svn.apache.org/viewvc?rev=690862&view=rev
Log:
Major error reporting cleanup.

Added:
    xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.cpp
    xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.hpp
Modified:
    xalan/c/trunk/src/xalanc/PlatformSupport/DOMStringHelper.cpp

Modified: xalan/c/trunk/src/xalanc/PlatformSupport/DOMStringHelper.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/PlatformSupport/DOMStringHelper.cpp?rev=690862&r1=690861&r2=690862&view=diff
==============================================================================
--- xalan/c/trunk/src/xalanc/PlatformSupport/DOMStringHelper.cpp (original)
+++ xalan/c/trunk/src/xalanc/PlatformSupport/DOMStringHelper.cpp Sun Aug 31 23:54:36 2008
@@ -747,14 +747,14 @@
 
 
 
-template <class Type, class SizeType, class FunctionType>
+template <class Type, class FunctionType>
 int
 doCollationCompare(
 			const Type*		theLHS,
 			const Type*		theRHS,
 			FunctionType	theTransformFunction)
 {
-    SizeType	i = 0;
+    size_t  i = 0;
 
     Type  theLHSChar;
     Type  theRHSChar;

Added: xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.cpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.cpp?rev=690862&view=auto
==============================================================================
--- xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.cpp (added)
+++ xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.cpp Sun Aug 31 23:54:36 2008
@@ -0,0 +1,156 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.
+ */
+
+
+
+// Class header file.
+#include "ProblemListenerBase.hpp"
+
+
+
+#include "xalanc/XalanDOM/XalanNode.hpp"
+
+
+
+#include "PrintWriter.hpp"
+#include "XalanLocator.hpp"
+#include "XalanMessageLoader.hpp"
+#include "XSLException.hpp"
+
+
+
+XALAN_CPP_NAMESPACE_BEGIN
+
+
+
+ProblemListenerBase::ProblemListenerBase()
+{
+}
+
+
+
+ProblemListenerBase::~ProblemListenerBase()
+{
+}
+
+
+
+void
+ProblemListenerBase::defaultFormat(
+            PrintWriter&            pw,
+			eSource					source,
+			eClassification			classification,
+			const XalanDOMString&	msg,
+            const Locator*          locator,
+			const XalanNode*		sourceNode)
+{
+    MemoryManager&  theManager = pw.getMemoryManager();
+
+    XalanDOMString  theTypeBuffer(theManager);
+
+    XalanMessageLoader::getMessage(
+        theTypeBuffer,
+        s_messageCodes[source][classification]);
+
+    XalanDOMString  theBuffer(theManager);
+
+    const XalanDOMChar* const uri = XalanLocator::getSystemId(locator);
+    const XalanFileLoc lineNo = XalanLocator::getLineNumber(locator);
+    const XalanFileLoc charOffset = XalanLocator::getLineNumber(locator);
+
+    XSLException::defaultFormat(
+        msg.c_str(),
+        msg.length(),
+        uri,
+        uri == 0 ? 0 : length(uri),
+        lineNo,
+        charOffset,
+        theTypeBuffer.c_str(),
+        theTypeBuffer.length(),
+        theBuffer);
+
+    pw.println(theBuffer);
+
+    if (0 != sourceNode)
+    {
+        pw.println(
+            XalanMessageLoader::getMessage(
+                theBuffer,
+                XalanMessages::SourceTreeNode_1Param,
+                sourceNode->getNodeName()));
+    }
+}
+
+
+
+void
+ProblemListenerBase::defaultFormat(
+            PrintWriter&            pw,
+			eSource					source,
+			eClassification			classification,
+			const XalanDOMString&	msg,
+			const XalanNode*		sourceNode)
+{
+    MemoryManager&  theManager = pw.getMemoryManager();
+
+    XalanDOMString  theBuffer(theManager);
+
+    pw.print(
+        XalanMessageLoader::getMessage(
+            theBuffer,
+            s_messageCodes[source][classification]));
+
+    pw.print(": ");
+
+    pw.println(msg);
+
+    if (0 != sourceNode)
+    {
+        pw.println(
+            XalanMessageLoader::getMessage(
+                theBuffer,
+                XalanMessages::SourceTreeNode_1Param,
+                sourceNode->getNodeName()));
+    }
+}
+
+
+
+const XalanMessages::Codes  ProblemListenerBase::s_messageCodes[eSourceCount][eClassificationCount]
=
+{
+    {
+        XalanMessages::XMLMessage,
+        XalanMessages::XMLWarning,
+        XalanMessages::XMLError,
+    },
+    {
+        XalanMessages::XSLTMessage,
+        XalanMessages::XSLTWarning,
+        XalanMessages::XSLTError,
+    },
+    {
+        XalanMessages::XPathMessage,
+        XalanMessages::XPathWarning,
+        XalanMessages::XPathError,
+    }
+};
+
+
+
+
+XALAN_CPP_NAMESPACE_END

Added: xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.hpp
URL: http://svn.apache.org/viewvc/xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.hpp?rev=690862&view=auto
==============================================================================
--- xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.hpp (added)
+++ xalan/c/trunk/src/xalanc/PlatformSupport/ProblemListenerBase.hpp Sun Aug 31 23:54:36 2008
@@ -0,0 +1,165 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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_PROBLEMLISTENERBASE_HEADER_GUARD)
+#define XALAN_PROBLEMLISTENERBASE_HEADER_GUARD
+
+
+
+// Base include file.  Must be first.
+#include "xalanc/PlatformSupport/PlatformSupportDefinitions.hpp"
+
+
+
+#include "LocalMsgIndex.hpp"
+
+
+
+XALAN_DECLARE_XERCES_CLASS(Locator)
+
+
+
+XALAN_CPP_NAMESPACE_BEGIN
+
+
+
+XALAN_USING_XERCES(Locator)
+
+
+class XalanDOMString;
+class XalanNode;
+class PrintWriter;
+
+
+
+/**
+ * This is the abstract class that is used when reporting a problem
+ * some kind, that requires a message, an error or a warning.
+ */
+class XALAN_PLATFORMSUPPORT_EXPORT ProblemListenerBase
+{
+public:
+
+	// Sources of problem.  The upper case versions
+    // of these enums are deprecated.
+	enum eSource { eXMLPARSER      = 0,
+                   eXMLParser      = 0,
+				   eXSLPROCESSOR   = 1,
+				   eXSLTProcessor  = 1,
+				   eXPATH          = 2,
+				   eXPath          = 2,
+                   eSourceCount };
+
+    // A typedef for compatibility.
+    typedef eSource    eProblemSource;
+
+	// Severity of problem.  The upper case versions
+    // of these enums are deprecated.
+	enum eClassification {	eMESSAGE    = 0,
+                            eMessage    = 0,
+							eWARNING    = 1,
+							eWarning    = 1,
+							eERROR      = 2,
+							eError      = 2,
+                            eClassificationCount };
+
+	ProblemListenerBase();
+
+	virtual
+	~ProblemListenerBase();
+
+	/**
+	 * Function that is called when a problem event occurs.
+     *
+	 * @param source Either eXMLParser, eXSLProcessor, or eXPATH.
+	 * @param classification Either eMessage, eWarning, or eError.
+     * @param locator The current Locator instance for the stylesheet.  Maybe be a null pointer.
+     * @param sourceNode The current source node, if any.
+	 * @param msg The error message.
+	 */
+	virtual void
+	problem(
+			eSource		            source,
+			eClassification			classification,
+			const XalanDOMString&	msg,
+            const Locator*          locator,
+			const XalanNode*		sourceNode) = 0;
+
+    /**
+ 	 * Function that is called when a problem event occurs.  This version
+     * assumes location information is already formatted into the message.
+     * 
+     * @param   source         either eXMLPARSER, eXSLPROCESSOR, or eXPATH
+     * @param   classification either eMESSAGE, eERROR or eWARNING
+	 * @param   msg            string message explaining the problem.
+	 */
+	virtual void
+	problem(
+            eSource                 source,
+            eClassification         classification,
+			const XalanDOMString&	msg,
+			const XalanNode*		sourceNode) = 0;
+
+	/**
+	 * Function to format a problem call to a PrintWriter instance.
+     * This is a bare-bones implementation that uses localized strings.
+     *
+	 * @param pw The PrintWriter instance to use.
+	 * @param source Either eXMLParser, eXSLProcessor, or eXPATH.
+	 * @param classification Either eMessage, eWarning, or eError.
+     * @param locator The current Locator instance for the stylesheet.  Maybe be a null pointer.
+     * @param sourceNode The current source node, if any.
+	 * @param msg The error message.
+	 */
+	static void
+	defaultFormat(
+            PrintWriter&            pw,
+			eSource					source,
+			eClassification			classification,
+			const XalanDOMString&	msg,
+            const Locator*          locator,
+			const XalanNode*		sourceNode);
+
+    /**
+	 * Function to format a problem call to a PrintWriter instance.
+     * This is a bare-bones implementation that uses localized strings.
+     *
+	 * @param pw The PrintWriter instance to use.
+     * @param   source         either eXMLPARSER, eXSLPROCESSOR, or eXPATH
+     * @param   classification either eMESSAGE, eERROR or eWARNING
+	 * @param   msg            string message explaining the problem.
+	 */
+	static void
+	defaultFormat(
+            PrintWriter&            pw,
+			eSource					source,
+			eClassification			classification,
+			const XalanDOMString&	msg,
+			const XalanNode*		sourceNode);
+
+protected:
+
+    static const XalanMessages::Codes s_messageCodes[eSourceCount][eClassificationCount];
+};
+
+
+
+XALAN_CPP_NAMESPACE_END
+
+
+
+#endif	// XALAN_PROBLEMLISTENER_HEADER_GUARD



---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org


Mime
View raw message