You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by au...@apache.org on 2001/02/23 15:55:13 UTC
cvs commit: xml-xalan/c/Tests/Harness XMLFileReporter.cpp XMLFileReporter.hpp
auriemma 01/02/23 06:55:12
Modified: c/Tests/Harness XMLFileReporter.cpp XMLFileReporter.hpp
Log:
New XMLFileLogger method for C++ version: logElement() base on work by Shane Curcuru.
Revision Changes Path
1.4 +33 -0 xml-xalan/c/Tests/Harness/XMLFileReporter.cpp
Index: XMLFileReporter.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/Tests/Harness/XMLFileReporter.cpp,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- XMLFileReporter.cpp 2001/02/07 15:37:14 1.3
+++ XMLFileReporter.cpp 2001/02/23 14:55:12 1.4
@@ -266,6 +266,39 @@
void
+XMLFileReporter::logElement(int level, const XalanDOMString& element, Hashtable attrs,const XalanDOMString& msg)
+{
+ if (isReady()
+ && (element.empty() == 0)
+ && (attrs.empty() == 0)
+ )
+ {
+ char tmp[20];
+ sprintf(tmp, "%d", level);
+
+ printToFile("<" + escapestring(element) + " " + ATTR_LEVEL + "=\""
+ + tmp + "\"");
+
+
+ Hashtable::iterator theEnd = attrs.end();
+
+ for(Hashtable::iterator i = attrs.begin(); i != theEnd; ++i)
+ {
+
+ printToFile((*i).first + "=\""
+ + (*i).second + "\"");
+ }
+
+ printToFile(XalanDOMString(">"));
+ if (msg.empty() != 0)
+ printToFile(escapestring(msg));
+ printToFile("</" + escapestring(element) + ">");
+ }
+}
+
+
+
+void
XMLFileReporter::logStatistic (int level, long lVal, double dVal, const XalanDOMString& msg)
{
char tmp[20];
1.3 +27 -1 xml-xalan/c/Tests/Harness/XMLFileReporter.hpp
Index: XMLFileReporter.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/Tests/Harness/XMLFileReporter.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- XMLFileReporter.hpp 2001/02/07 15:37:14 1.2
+++ XMLFileReporter.hpp 2001/02/23 14:55:12 1.3
@@ -65,11 +65,12 @@
//#include <util/PlatformUtils.hpp>
#include <PlatformSupport/DOMStringHelper.hpp>
+#include<map>
/**
* Reporter that saves output to a simple XML-format file.
* @author Shane_Curcuru@lotus.com
- * @version $Id: XMLFileReporter.hpp,v 1.2 2001/02/07 15:37:14 pauldick Exp $
+ * @version $Id: XMLFileReporter.hpp,v 1.3 2001/02/23 14:55:12 auriemma Exp $
*/
#if defined HARNESS_EXPORTS
@@ -85,6 +86,13 @@
public:
+#if defined(XALAN_NO_NAMESPACES)
+ typedef map<XalanDOMString, XalanDOMString, less<XalanDOMString> > Hashtable;
+#else
+ typedef std::map<XalanDOMString, XalanDOMString> Hashtable;
+#endif
+
+
/** Simple constructor, does not perform initialization. */
XMLFileReporter();
@@ -205,6 +213,24 @@
void logStatistic (int level, long lVal, double dVal, const char* msg)
{
logStatistic(level, lVal, dVal, XalanDOMString(msg));
+ }
+
+ /**
+ * Logs out a element to results with specified severity.
+ * Uses user-supplied element name and attribute list. Currently
+ * attribute values and msg are forced .toString(). Also,
+ * 'level' is forced to be the first attribute of the element.
+ * @param level severity of message.
+ * @param element name of enclosing element
+ * @param attrs hash of name=value attributes; note that the
+ * caller must ensure they're legal XML
+ * @param msg comment to log out.
+ */
+ void logElement(int level, const XalanDOMString& element, Hashtable attrs, const XalanDOMString& msg);
+
+ void logElement(int level, const char* element, Hashtable attrs, const char* msg)
+ {
+ logElement(level, XalanDOMString(element), attrs, XalanDOMString(msg));
}
/**