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 2002/10/03 03:33:09 UTC
cvs commit: xml-xalan/c/src/XercesParserLiaison XercesParserLiaison.cpp XercesParserLiaison.hpp
dbertoni 2002/10/02 18:33:09
Modified: c/src/XercesParserLiaison XercesParserLiaison.cpp
XercesParserLiaison.hpp
Log:
Integration of new Xerces DOM wrapper.
Revision Changes Path
1.50 +60 -7 xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.cpp
Index: XercesParserLiaison.cpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.cpp,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- XercesParserLiaison.cpp 15 Aug 2002 01:00:08 -0000 1.49
+++ XercesParserLiaison.cpp 3 Oct 2002 01:33:09 -0000 1.50
@@ -2,7 +2,7 @@
* The Apache Software License, Version 1.1
*
*
- * Copyright (c) 1999-2001 The Apache Software Foundation. All rights
+ * Copyright (c) 1999-2002 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -97,6 +97,7 @@
#include "XercesDocumentBridge.hpp"
+#include "XercesDocumentWrapper.hpp"
#include "XercesDOMSupport.hpp"
@@ -153,10 +154,13 @@
using std::for_each;
#endif
- // Delete any live documents.
- for_each(m_documentMap.begin(),
- m_documentMap.end(),
- makeMapValueDeleteFunctor(m_documentMap));
+ // Delete any live documents...
+ for(DocumentMapType::iterator i = m_documentMap.begin();
+ i != m_documentMap.end();
+ ++i)
+ {
+ delete (*i).first;
+ }
m_documentMap.clear();
@@ -441,13 +445,35 @@
+XalanDocument*
+XercesParserLiaison::createDocument(
+ const DOMDocument* theXercesDocument,
+ bool threadSafe,
+ bool buildWrapper)
+{
+ return doCreateDocument(theXercesDocument, threadSafe, buildWrapper);
+}
+
+
+
XercesDocumentBridge*
XercesParserLiaison::mapDocument(const XalanDocument* theDocument) const
{
const DocumentMapType::const_iterator i =
m_documentMap.find(theDocument);
- return i != m_documentMap.end() ? (*i).second : 0;
+ return i != m_documentMap.end() ? (*i).second.m_isDeprecated == true ? (*i).second.m_bridge : 0 : 0;
+}
+
+
+
+XercesDocumentWrapper*
+XercesParserLiaison::mapDocumentToWrapper(const XalanDocument* theDocument) const
+{
+ const DocumentMapType::const_iterator i =
+ m_documentMap.find(theDocument);
+
+ return i != m_documentMap.end() ? (*i).second.m_isDeprecated == false ? (*i).second.m_wrapper : 0 : 0;
}
@@ -458,7 +484,18 @@
const DocumentMapType::const_iterator i =
m_documentMap.find(theDocument);
- return i != m_documentMap.end() ? (*i).second->getXercesDocument() : DOM_Document();
+ return i != m_documentMap.end() ? (*i).second.m_isDeprecated == true ? (*i).second.m_bridge->getXercesDocument() : DOM_Document() : DOM_Document();
+}
+
+
+
+const DOMDocument*
+XercesParserLiaison::mapToXercesDocument(const XalanDocument* theDocument) const
+{
+ const DocumentMapType::const_iterator i =
+ m_documentMap.find(theDocument);
+
+ return i != m_documentMap.end() ? (*i).second.m_isDeprecated == false ? (*i).second.m_wrapper->getXercesDocument() : 0 : 0;
}
@@ -651,6 +688,22 @@
{
XercesDocumentBridge* const theNewDocument =
new XercesDocumentBridge(theXercesDocument, threadSafe, buildBridge);
+
+ m_documentMap[theNewDocument] = theNewDocument;
+
+ return theNewDocument;
+}
+
+
+
+XercesDocumentWrapper*
+XercesParserLiaison::doCreateDocument(
+ const DOMDocument* theXercesDocument,
+ bool threadSafe,
+ bool buildWrapper)
+{
+ XercesDocumentWrapper* const theNewDocument =
+ new XercesDocumentWrapper(theXercesDocument, threadSafe, buildWrapper);
m_documentMap[theNewDocument] = theNewDocument;
1.36 +102 -5 xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.hpp
Index: XercesParserLiaison.hpp
===================================================================
RCS file: /home/cvs/xml-xalan/c/src/XercesParserLiaison/XercesParserLiaison.hpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- XercesParserLiaison.hpp 15 Aug 2002 01:00:08 -0000 1.35
+++ XercesParserLiaison.hpp 3 Oct 2002 01:33:09 -0000 1.36
@@ -79,6 +79,7 @@
class DOM_Document;
+class DOMDocument;
class DOMParser;
class DOMSupport;
class EntityResolver;
@@ -86,6 +87,7 @@
class SAXParser;
class XercesDOMSupport;
class XercesDocumentBridge;
+class XercesDocumentWrapper;
class XSLProcessor;
@@ -320,46 +322,96 @@
setExternalNoNamespaceSchemaLocation(const XalanDOMChar* location);
/**
+ * This API is deprecated.
+ *
* Create a XalanDocument proxy for an existing Xerces document.
* The parser liaison owns the instance, and you must not delete
* it. The liaison will delete it when reset() is called, or the
* liaison is destroyed.
*
+ * @deprecated This API is deprecated.
* @param theXercesDocument The Xerces document.
* @param threadSafe If true, read access to the tree will be thread-safe (implies buildBridge == true).
* @param buildBridge If true, the entire bridge structure is built.
* @return a pointer to a new XalanDocument-derived instance.
*/
- virtual XalanDocument*
+ XalanDocument*
createDocument(
const DOM_Document& theXercesDocument,
bool threadSafe = false,
bool buildBridge = false);
- /**
+ /**
+ * Create a XalanDocument proxy for an existing Xerces document.
+ * The parser liaison owns the instance, and you must not delete
+ * it. The liaison will delete it when reset() is called, or the
+ * liaison is destroyed.
+ *
+ * @param theXercesDocument The Xerces document.
+ * @param threadSafe If true, read access to the tree will be thread-safe (implies buildBridge == true).
+ * @param buildWrapper If true, the entire wrapper structure is built.
+ * @return a pointer to a new XalanDocument-derived instance.
+ */
+ XalanDocument*
+ createDocument(
+ const DOMDocument* theXercesDocument,
+ bool threadSafe = false,
+ bool buildWrapper = false);
+
+ /**
+ * This API is deprecated.
+ *
* Map a pointer to a XalanDocument instance to its implementation
* class pointer. Normally, you should have no reason for doing
* this. The liaison will return a null pointer if it did not
* create the instance passed.
*
+ * @deprecated This API is deprecated.
* @param theDocument A pointer to a XalanDocument instance.
* @return A pointer to the XercesDocumentBridge instance.
*/
XercesDocumentBridge*
mapDocument(const XalanDocument* theDocument) const;
+ /**
+ * Map a pointer to a XalanDocument instance to its implementation
+ * class pointer. Normally, you should have no reason for doing
+ * this. The liaison will return a null pointer if it did not
+ * create the instance passed.
+ *
+ * @param theDocument A pointer to a XalanDocument instance.
+ * @return A pointer to the XercesDocumentWrapper instance.
+ */
+ XercesDocumentWrapper*
+ mapDocumentToWrapper(const XalanDocument* theDocument) const;
+
/**
+ * This API is deprecated.
+ *
* Map a pointer to a XalanDocument instance to its corresponding
* class pointer. Normally, you should have no reason for doing
* this. The liaison will return a null pointer if it did not
* create the instance passed.
*
+ * @deprecated This API is deprecated.
* @param theDocument A pointer to a XalanDocument instance.
* @return A pointer to the XercesDocumentBridge instance.
*/
DOM_Document
mapXercesDocument(const XalanDocument* theDocument) const;
+ /**
+ * Map a pointer to a XalanDocument instance to its corresponding
+ * class pointer. Normally, you should have no reason for doing
+ * this. The liaison will return a null pointer if it did not
+ * create the instance passed.
+ *
+ * @param theDocument A pointer to a XalanDocument instance.
+ * @return A pointer to the XercesDocumentBridge instance.
+ */
+ const DOMDocument*
+ mapToXercesDocument(const XalanDocument* theDocument) const;
+
// Implementations for SAX ErrorHandler
virtual void
@@ -374,13 +426,44 @@
virtual void
resetErrors();
+ struct DocumentEntry
+ {
+ bool m_isDeprecated;
+
+ union
+ {
+ XercesDocumentBridge* m_bridge;
+ XercesDocumentWrapper* m_wrapper;
+ };
+
+ DocumentEntry&
+ operator=(XercesDocumentBridge* theBridge)
+ {
+ m_isDeprecated = true;
+
+ m_bridge = theBridge;
+
+ return *this;
+ }
+
+ DocumentEntry&
+ operator=(XercesDocumentWrapper* theWrapper)
+ {
+ m_isDeprecated = false;
+
+ m_wrapper = theWrapper;
+
+ return *this;
+ }
+ };
+
#if defined(XALAN_NO_NAMESPACES)
typedef map<const XalanDocument*,
- XercesDocumentBridge*,
+ DocumentEntry,
less<const XalanDocument*> > DocumentMapType;
#else
typedef std::map<const XalanDocument*,
- XercesDocumentBridge*> DocumentMapType;
+ DocumentEntry> DocumentMapType;
#endif
/**
@@ -472,11 +555,25 @@
* @param buildBridge If true, the entire bridge structure is built.
* @return a pointer to a new XercesDocumentBridge instance.
*/
- virtual XercesDocumentBridge*
+ XercesDocumentBridge*
doCreateDocument(
const DOM_Document& theXercesDocument,
bool threadSafe,
bool buildBridge);
+
+ /**
+ * Create a XalanDocument proxy for an existing Xerces document.
+ *
+ * @param theXercesDocument The Xerces document.
+ * @param threadSafe If true, read access to the tree will be thread-safe (implies buildBridge == true).
+ * @param buildWrapper If true, the entire bridge structure is built.
+ * @return a pointer to a new XercesDocumentWrapper instance.
+ */
+ XercesDocumentWrapper*
+ doCreateDocument(
+ const DOMDocument* theXercesDocument,
+ bool threadSafe,
+ bool buildWrapper);
private:
---------------------------------------------------------------------
To unsubscribe, e-mail: xalan-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xalan-cvs-help@xml.apache.org