Moved DOM methods up the tree, add copy c'tors, KeyInfo sample
authorScott Cantor <cantor.2@osu.edu>
Wed, 29 Mar 2006 07:46:23 +0000 (07:46 +0000)
committerScott Cantor <cantor.2@osu.edu>
Wed, 29 Mar 2006 07:46:23 +0000 (07:46 +0000)
37 files changed:
.cdtproject
doxyfile
xmltooling/AbstractAttributeExtensibleXMLObject.cpp
xmltooling/AbstractAttributeExtensibleXMLObject.h
xmltooling/AbstractDOMCachingXMLObject.cpp
xmltooling/AbstractDOMCachingXMLObject.h
xmltooling/AbstractElementProxy.h
xmltooling/AbstractXMLObject.cpp
xmltooling/AbstractXMLObject.h
xmltooling/DOMCachingXMLObject.h [deleted file]
xmltooling/Makefile.am
xmltooling/XMLObject.h
xmltooling/XMLToolingConfig.cpp
xmltooling/base.h
xmltooling/exceptions.h
xmltooling/impl/AnyElement.cpp
xmltooling/impl/AnyElement.h
xmltooling/impl/UnknownElement.h
xmltooling/internal.h
xmltooling/io/AbstractXMLObjectMarshaller.h
xmltooling/io/AbstractXMLObjectUnmarshaller.h
xmltooling/signature/KeyInfo.h [new file with mode: 0644]
xmltooling/signature/Signature.h
xmltooling/signature/impl/KeyInfoImpl.cpp [new file with mode: 0644]
xmltooling/signature/impl/KeyInfoImpl.h [new file with mode: 0644]
xmltooling/signature/impl/XMLSecSignature.h [deleted file]
xmltooling/signature/impl/XMLSecSignatureImpl.cpp [moved from xmltooling/signature/impl/XMLSecSignature.cpp with 83% similarity]
xmltooling/signature/impl/XMLSecSignatureImpl.h [new file with mode: 0644]
xmltooling/util/ParserPool.h
xmltooling/util/XMLObjectChildrenList.h
xmltooling/validation/AbstractValidatingXMLObject.cpp
xmltooling/validation/AbstractValidatingXMLObject.h
xmltooling/validation/Validator.h
xmltooling/version.h
xmltooling/xmltooling.vcproj
xmltoolingtest/UnmarshallingTest.h
xmltoolingtest/XMLObjectBaseTestCase.h

index 3d9715b..87a1045 100644 (file)
@@ -4,7 +4,7 @@
 <cdtproject id="org.eclipse.cdt.make.core.make">\r
 <extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>\r
 <extension id="org.eclipse.cdt.core.PE" point="org.eclipse.cdt.core.BinaryParser"/>\r
-<extension id="org.eclipse.cdt.core.domsourceindexer" point="org.eclipse.cdt.core.CIndexer"/>\r
+<extension id="org.eclipse.cdt.core.nullindexer" point="org.eclipse.cdt.core.CIndexer"/>\r
 <data>\r
 <item id="scannerConfiguration">\r
 <autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>\r
index 035cf62..070f613 100644 (file)
--- a/doxyfile
+++ b/doxyfile
@@ -83,12 +83,7 @@ WARN_LOGFILE           =
 # configuration options related to the input files
 #---------------------------------------------------------------------------
 INPUT                  = C:/cvs/cpp-xmltooling/xmltooling
-FILE_PATTERNS          = *.c \
-                         *.cc \
-                         *.cxx \
-                         *.cpp \
-                         *.c++ \
-                         *.d \
+FILE_PATTERNS          = *.d \
                          *.java \
                          *.ii \
                          *.ixx \
@@ -111,7 +106,7 @@ FILE_PATTERNS          = *.c \
                          *.dox \
                          *.py
 RECURSIVE              = YES
-EXCLUDE                = 
+EXCLUDE                = C:/cvs/cpp-xmltooling/xmltooling/signature/impl
 EXCLUDE_SYMLINKS       = NO
 EXCLUDE_PATTERNS       = 
 EXAMPLE_PATH           = 
@@ -211,7 +206,7 @@ PERLMOD_MAKEVAR_PREFIX =
 # Configuration options related to the preprocessor   
 #---------------------------------------------------------------------------
 ENABLE_PREPROCESSING   = YES
-MACRO_EXPANSION        = NO
+MACRO_EXPANSION        = YES
 EXPAND_ONLY_PREDEF     = NO
 SEARCH_INCLUDES        = YES
 INCLUDE_PATH           = C:\cvs\cpp-xmltooling
index 7362956..4052b6e 100644 (file)
@@ -41,6 +41,14 @@ AbstractAttributeExtensibleXMLObject::~AbstractAttributeExtensibleXMLObject()
     for_each(m_attributeMap.begin(),m_attributeMap.end(),_release());\r
 }\r
 \r
+AbstractAttributeExtensibleXMLObject::AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src)\r
+    : AbstractXMLObject(src)\r
+{\r
+    for (map<QName,XMLCh*>::const_iterator i=src.m_attributeMap.begin(); i!=src.m_attributeMap.end(); i++) {\r
+        m_attributeMap[i->first] = XMLString::replicate(i->second);\r
+    }\r
+}\r
+\r
 void AbstractAttributeExtensibleXMLObject::setAttribute(QName& qualifiedName, const XMLCh* value)\r
 {\r
     map<QName,XMLCh*>::iterator i=m_attributeMap.find(qualifiedName);\r
index e474ff8..09bfb7c 100644 (file)
 /**\r
  * @file AbstractAttributeExtensibleXMLObject.h\r
  * \r
- * An abstract implementation of a DOM-caching AttributeExtensibleXMLObject \r
+ * An abstract implementation of an AttributeExtensibleXMLObject \r
  */\r
 \r
-#if !defined(__xmltooling_absattrextxmlobj_h__)\r
+#ifndef __xmltooling_absattrextxmlobj_h__\r
 #define __xmltooling_absattrextxmlobj_h__\r
 \r
 #include <map>\r
 namespace xmltooling {\r
 \r
     /**\r
-     * An abstract implementation of a DOM-caching AttributeExtensibleXMLObject.\r
+     * An abstract implementation of an AttributeExtensibleXMLObject.\r
      */\r
-    class XMLTOOL_API AbstractAttributeExtensibleXMLObject : public virtual AttributeExtensibleXMLObject, public virtual AbstractDOMCachingXMLObject\r
+    class XMLTOOL_API AbstractAttributeExtensibleXMLObject : public virtual AttributeExtensibleXMLObject, public virtual AbstractXMLObject\r
     {\r
     public:\r
         virtual ~AbstractAttributeExtensibleXMLObject();\r
         \r
-        /**\r
-         * @see AttributeExtensibleXMLObject::getAttribute()\r
-         */\r
         virtual const XMLCh* getAttribute(QName& qualifiedName) const {\r
             std::map<QName,XMLCh*>::const_iterator i=m_attributeMap.find(qualifiedName);\r
             return (i==m_attributeMap.end()) ? NULL : i->second;\r
         }\r
         \r
-        /**\r
-         * @see AttributeExtensibleXMLObject::setAttribute()\r
-         */\r
         virtual void setAttribute(QName& qualifiedName, const XMLCh* value);\r
     \r
      protected:\r
         AbstractAttributeExtensibleXMLObject() {}\r
 \r
+        /** Copy constructor. */\r
+        AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src);\r
+\r
+        /** Map of arbitrary attributes. */\r
         std::map<QName,XMLCh*> m_attributeMap;\r
     };\r
     \r
index d97301d..3eacc8a 100644 (file)
@@ -64,28 +64,24 @@ void AbstractDOMCachingXMLObject::releaseDOM() const
 \r
 void AbstractDOMCachingXMLObject::releaseParentDOM(bool propagateRelease) const\r
 {\r
-    DOMCachingXMLObject* domCachingParent = dynamic_cast<DOMCachingXMLObject*>(getParent());\r
-    if (domCachingParent) {\r
-        if (domCachingParent->getDOM()) {\r
-            Category::getInstance(XMLTOOLING_LOGCAT".DOM").debug(\r
-                "releasing cached DOM representation for parent object with propagation set to %s",\r
-                propagateRelease ? "true" : "false"\r
-                );\r
-            domCachingParent->releaseDOM();\r
-            if (propagateRelease)\r
-                domCachingParent->releaseParentDOM(propagateRelease);\r
-        }\r
+    if (getParent() && getParent()->getDOM()) {\r
+        Category::getInstance(XMLTOOLING_LOGCAT".DOM").debug(\r
+            "releasing cached DOM representation for parent object with propagation set to %s",\r
+            propagateRelease ? "true" : "false"\r
+            );\r
+        getParent()->releaseDOM();\r
+        if (propagateRelease)\r
+            getParent()->releaseParentDOM(propagateRelease);\r
     }\r
 }\r
 \r
 class _release : public binary_function<XMLObject*,bool,void> {\r
 public:\r
     void operator()(XMLObject* obj, bool propagate) const {\r
-        DOMCachingXMLObject* domCaching = dynamic_cast<DOMCachingXMLObject*>(obj);\r
-        if (domCaching) {\r
-            domCaching->releaseDOM();\r
+        if (obj) {\r
+            obj->releaseDOM();\r
             if (propagate)\r
-                domCaching->releaseChildrenDOM(propagate);\r
+                obj->releaseChildrenDOM(propagate);\r
         }\r
     }\r
 };\r
@@ -136,28 +132,3 @@ XMLObject* AbstractDOMCachingXMLObject::clone() const
     }\r
     return NULL;\r
 }\r
-\r
-XMLObject* AbstractDOMCachingXMLObject::prepareForAssignment(XMLObject* oldValue, XMLObject* newValue) {\r
-\r
-    if (newValue && newValue->hasParent())\r
-        throw XMLObjectException("child XMLObject cannot be added - it is already the child of another XMLObject");\r
-\r
-    if (!oldValue) {\r
-        if (newValue) {\r
-            releaseThisandParentDOM();\r
-            newValue->setParent(this);\r
-            return newValue;\r
-        }\r
-        else {\r
-            return NULL;\r
-        }\r
-    }\r
-\r
-    if (oldValue != newValue) {\r
-        delete oldValue;\r
-        releaseThisandParentDOM();\r
-        newValue->setParent(this);\r
-    }\r
-\r
-    return newValue;\r
-}\r
index edfc1bf..f143695 100644 (file)
 /**\r
  * @file AbstractDOMCachingXMLObject.h\r
  * \r
- * Extension of AbstractXMLObject that implements a DOMCachingXMLObject. \r
+ * Extension of AbstractXMLObject that adds DOM caching methods\r
  */\r
 \r
 #if !defined(__xmltooling_abstractdomxmlobj_h__)\r
 #define __xmltooling_abstractdomxmlobj_h__\r
 \r
 #include <xmltooling/AbstractXMLObject.h>\r
-#include <xmltooling/DOMCachingXMLObject.h>\r
 \r
 #if defined (_MSC_VER)\r
     #pragma warning( push )\r
 namespace xmltooling {\r
 \r
     /**\r
-     * Extension of AbstractXMLObject that implements a DOMCachingXMLObject.\r
+     * Extension of AbstractXMLObject that adds DOM caching methods\r
      */\r
-    class XMLTOOL_API AbstractDOMCachingXMLObject : public virtual AbstractXMLObject, public virtual DOMCachingXMLObject\r
+    class XMLTOOL_API AbstractDOMCachingXMLObject : public virtual AbstractXMLObject\r
     {\r
     public:\r
         virtual ~AbstractDOMCachingXMLObject();\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::getDOM()\r
-         */\r
         DOMElement* getDOM() const {\r
             return m_dom;\r
         }\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::setDOM()\r
-         */\r
         void setDOM(DOMElement* dom, bool bindDocument=false) const;\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::setDocument()\r
-         */\r
         void setDocument(DOMDocument* doc) const {\r
             if (m_document)\r
                 m_document->release();\r
             m_document=doc;\r
         }\r
     \r
-        /**\r
-         * @see DOMCachingXMLObject::releaseDOM()\r
-         */\r
         virtual void releaseDOM() const;\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::releaseParentDOM()\r
-         */\r
         virtual void releaseParentDOM(bool propagateRelease=true) const;\r
         \r
-        /**\r
-         * @see DOMCachingXMLObject::releaseChildrenDOM()\r
-         */\r
         virtual void releaseChildrenDOM(bool propagateRelease=true) const;\r
     \r
-        /**\r
-         * A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).\r
-         */\r
-        void releaseThisandParentDOM() const {\r
-            if (m_dom) {\r
-                releaseDOM();\r
-                releaseParentDOM(true);\r
-            }\r
-        }\r
-    \r
-        /**\r
-         * A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().\r
-         */\r
-        void releaseThisAndChildrenDOM() const {\r
-            if (m_dom) {\r
-                releaseChildrenDOM(true);\r
-                releaseDOM();\r
-            }\r
-        }\r
-    \r
-        /**\r
-         * @see XMLObject::clone()\r
-         */\r
         XMLObject* clone() const;\r
 \r
      protected:\r
         AbstractDOMCachingXMLObject() : m_dom(NULL), m_document(NULL) {}\r
 \r
+        /** Copy constructor. */\r
+        AbstractDOMCachingXMLObject(const AbstractDOMCachingXMLObject& src)\r
+            : AbstractXMLObject(src), m_dom(NULL), m_document(NULL) {}\r
+\r
         /**\r
          * If a DOM representation exists, this clones it into a new document.\r
          * \r
@@ -113,43 +75,6 @@ namespace xmltooling {
          */\r
         DOMElement* cloneDOM(DOMDocument* doc=NULL) const;\r
 \r
-        /**\r
-         * A helper function for derived classes.\r
-         * This 'normalizes' newString, and then if it is different from oldString,\r
-         * it invalidates the DOM, frees the old string, and return the new.\r
-         * If not different, it frees the new string and just returns the old value.\r
-         * \r
-         * @param oldValue - the current value\r
-         * @param newValue - the new value\r
-         * \r
-         * @return the value that should be assigned\r
-         */\r
-        XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue) {\r
-            XMLCh* newString = XMLString::replicate(newValue);\r
-            XMLString::trim(newString);\r
-            if (!XMLString::equals(oldValue,newValue)) {\r
-                releaseThisandParentDOM();\r
-                XMLString::release(&oldValue);\r
-                return newString;\r
-            }\r
-            XMLString::release(&newString);\r
-            return oldValue;            \r
-        }\r
-\r
-        /**\r
-         * A helper function for derived classes, for assignment of (singleton) XML objects.\r
-         * \r
-         * It is indifferent to whether either the old or the new version of the value is null. \r
-         * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate\r
-         * \r
-         * @param oldValue - current value\r
-         * @param newValue - proposed new value\r
-         * @return the value to assign \r
-         * \r
-         * @throws XMLObjectException if the new child already has a parent.\r
-         */\r
-        XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);\r
-\r
     private:\r
         mutable DOMElement* m_dom;\r
         mutable DOMDocument* m_document;\r
index a00b9df..9829410 100644 (file)
 /**\r
  * @file AbstractElementProxy.h\r
  * \r
- * An abstract implementation of a DOM-caching ElementProxy \r
+ * An abstract implementation of an ElementProxy \r
  */\r
 \r
-#if !defined(__xmltooling_abseleproxy_h__)\r
+#ifndef __xmltooling_abseleproxy_h__\r
 #define __xmltooling_abseleproxy_h__\r
 \r
 #include <xmltooling/AbstractDOMCachingXMLObject.h>\r
 namespace xmltooling {\r
 \r
     /**\r
-     * An abstract implementation of a DOM-caching ExtensibleXMLObject.\r
+     * An abstract implementation of an ExtensibleXMLObject.\r
      */\r
-    class XMLTOOL_API AbstractElementProxy : public virtual ElementProxy, public virtual AbstractDOMCachingXMLObject\r
+    class XMLTOOL_API AbstractElementProxy : public virtual ElementProxy, public virtual AbstractXMLObject\r
     {\r
     public:\r
         virtual ~AbstractElementProxy() {}\r
         \r
-        /**\r
-         * @see ElementProxy::getTextContent()\r
-         */\r
         virtual const XMLCh* getTextContent() const {\r
             return m_value;\r
         }\r
         \r
-        /**\r
-         * @see ElementProxy::setTextContent()\r
-         */\r
         virtual void setTextContent(const XMLCh* value);\r
         \r
-\r
-        /**\r
-         * @see ElementProxy::getXMLObjects()\r
-         */\r
         virtual ListOf(XMLObject) getXMLObjects();\r
     \r
      protected:\r
         AbstractElementProxy() : m_value(NULL) {}\r
+        \r
+        /** Copy constructor. */\r
+        AbstractElementProxy(const AbstractElementProxy& src)\r
+            : AbstractXMLObject(src), m_value(XMLString::replicate(src.m_value)) {}\r
 \r
     private:\r
         XMLCh* m_value;\r
index cc9381a..4e0005b 100644 (file)
@@ -22,6 +22,7 @@
 \r
 #include "internal.h"\r
 #include "AbstractXMLObject.h"\r
+#include "exceptions.h"\r
 \r
 #include <algorithm>\r
 #include <log4cpp/Category.hh>\r
@@ -39,3 +40,35 @@ AbstractXMLObject::AbstractXMLObject(const XMLCh* namespaceURI, const XMLCh* ele
 {\r
     addNamespace(Namespace(namespaceURI, namespacePrefix));\r
 }\r
+\r
+AbstractXMLObject::AbstractXMLObject(const AbstractXMLObject& src)\r
+    : m_namespaces(src.m_namespaces), m_log(src.m_log), m_parent(NULL), m_elementQname(src.m_elementQname), m_typeQname(NULL)\r
+{\r
+    if (src.m_typeQname)\r
+        m_typeQname=new QName(*src.m_typeQname);\r
+}\r
+\r
+XMLObject* AbstractXMLObject::prepareForAssignment(XMLObject* oldValue, XMLObject* newValue) {\r
+\r
+    if (newValue && newValue->hasParent())\r
+        throw XMLObjectException("child XMLObject cannot be added - it is already the child of another XMLObject");\r
+\r
+    if (!oldValue) {\r
+        if (newValue) {\r
+            releaseThisandParentDOM();\r
+            newValue->setParent(this);\r
+            return newValue;\r
+        }\r
+        else {\r
+            return NULL;\r
+        }\r
+    }\r
+\r
+    if (oldValue != newValue) {\r
+        delete oldValue;\r
+        releaseThisandParentDOM();\r
+        newValue->setParent(this);\r
+    }\r
+\r
+    return newValue;\r
+}\r
index 917bb22..6beecfd 100644 (file)
@@ -40,46 +40,28 @@ namespace xmltooling {
     public:\r
         virtual ~AbstractXMLObject();\r
 \r
-        /**\r
-         * @see XMLObject::getElementQName()\r
-         */\r
         const QName& getElementQName() const {\r
             return m_elementQname;\r
         }\r
 \r
-        /**\r
-         * @see XMLObject::getNamespaces()\r
-         */\r
         const std::set<Namespace>& getNamespaces() const {\r
             return m_namespaces;\r
         }\r
     \r
-        /**\r
-         * @see XMLObject::addNamespace()\r
-         */\r
         void addNamespace(const Namespace& ns) const {\r
             if (ns.alwaysDeclare() || m_namespaces.find(ns)==m_namespaces.end()) {\r
                 m_namespaces.insert(ns);\r
             }\r
         }\r
     \r
-        /**\r
-         * @see XMLObject::removeNamespace()\r
-         */\r
         void removeNamespace(const Namespace& ns) {\r
             m_namespaces.erase(ns);\r
         }\r
         \r
-        /**\r
-         * @see XMLObject::getSchemaType()\r
-         */\r
         const QName* getSchemaType() const {\r
             return m_typeQname;\r
         }\r
     \r
-        /**\r
-         * @see XMLObject::setSchemaType()\r
-         */\r
         void setSchemaType(const QName* type) {\r
             delete m_typeQname;\r
             m_typeQname = NULL;\r
@@ -89,37 +71,22 @@ namespace xmltooling {
             }\r
         }\r
     \r
-        /**\r
-         * @see XMLObject::hasParent()\r
-         */\r
         bool hasParent() const {\r
             return m_parent != NULL;\r
         }\r
      \r
-        /**\r
-         * @see XMLObject::getParent()\r
-         */\r
         XMLObject* getParent() const {\r
             return m_parent;\r
         }\r
     \r
-        /**\r
-         * @see XMLObject::setParent()\r
-         */\r
         void setParent(XMLObject* parent) {\r
             m_parent = parent;\r
         }\r
 \r
-        /**\r
-         * @see XMLObject::hasChildren()\r
-         */\r
         bool hasChildren() const {\r
             return !m_children.empty();\r
         }\r
 \r
-        /**\r
-         * @see XMLObject::getOrderedChildren()\r
-         */\r
         const std::list<XMLObject*>& getOrderedChildren() const {\r
             return m_children;\r
         }\r
@@ -134,6 +101,46 @@ namespace xmltooling {
          */\r
         AbstractXMLObject(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL);\r
 \r
+        /** Copy constructor. */\r
+        AbstractXMLObject(const AbstractXMLObject& src);\r
+        \r
+        /**\r
+         * A helper function for derived classes.\r
+         * This 'normalizes' newString, and then if it is different from oldString,\r
+         * it invalidates the DOM, frees the old string, and return the new.\r
+         * If not different, it frees the new string and just returns the old value.\r
+         * \r
+         * @param oldValue - the current value\r
+         * @param newValue - the new value\r
+         * \r
+         * @return the value that should be assigned\r
+         */\r
+        XMLCh* prepareForAssignment(XMLCh* oldValue, const XMLCh* newValue) {\r
+            XMLCh* newString = XMLString::replicate(newValue);\r
+            XMLString::trim(newString);\r
+            if (!XMLString::equals(oldValue,newValue)) {\r
+                releaseThisandParentDOM();\r
+                XMLString::release(&oldValue);\r
+                return newString;\r
+            }\r
+            XMLString::release(&newString);\r
+            return oldValue;            \r
+        }\r
+\r
+        /**\r
+         * A helper function for derived classes, for assignment of (singleton) XML objects.\r
+         * \r
+         * It is indifferent to whether either the old or the new version of the value is null. \r
+         * This method will do a safe compare of the objects and will also invalidate the DOM if appropriate\r
+         * \r
+         * @param oldValue - current value\r
+         * @param newValue - proposed new value\r
+         * @return the value to assign \r
+         * \r
+         * @throws XMLObjectException if the new child already has a parent.\r
+         */\r
+        XMLObject* prepareForAssignment(XMLObject* oldValue, XMLObject* newValue);\r
+\r
         /**\r
          * Underlying list of child objects.\r
          * Manages the lifetime of the children.\r
diff --git a/xmltooling/DOMCachingXMLObject.h b/xmltooling/DOMCachingXMLObject.h
deleted file mode 100644 (file)
index 895527d..0000000
+++ /dev/null
@@ -1,87 +0,0 @@
-/*\r
- *  Copyright 2001-2006 Internet2\r
- * \r
- * Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * @file DOMCachingXMLObject.h\r
- * \r
- * An XMLObject that can cached a DOM representation of itself. \r
- */\r
-\r
-#if !defined(__xmltooling_domxmlobj_h__)\r
-#define __xmltooling_domxmlobj_h__\r
-\r
-#include <xercesc/dom/DOM.hpp>\r
-#include <xmltooling/XMLObject.h>\r
-\r
-using namespace xercesc;\r
-\r
-namespace xmltooling {\r
-\r
-    /**\r
-     * An XMLObject that can cached a DOM representation of itself.\r
-     */\r
-    class XMLTOOL_API DOMCachingXMLObject : public virtual XMLObject\r
-    {\r
-    public:\r
-        DOMCachingXMLObject() {}\r
-        virtual ~DOMCachingXMLObject() {}\r
-        \r
-        /**\r
-         * Gets the DOM representation of this XMLObject, if one exists.\r
-         * \r
-         * @return the DOM representation of this XMLObject\r
-         */\r
-        virtual DOMElement* getDOM() const=0;\r
-        \r
-        /**\r
-         * Sets the DOM representation of this XMLObject.\r
-         * \r
-         * @param dom       DOM representation of this XMLObject\r
-         * @param bindDocument  true if the object should take ownership of the associated Document\r
-         */\r
-        virtual void setDOM(DOMElement* dom, bool bindDocument=false) const=0;\r
-    \r
-        /**\r
-         * Assigns ownership of a DOM document to the XMLObject.\r
-         * This binds the lifetime of the document to the lifetime of the object.\r
-         * \r
-         * @param doc DOM document bound to this object \r
-         */\r
-        virtual void setDocument(DOMDocument* doc) const=0;\r
-\r
-        /**\r
-         * Releases the DOM representation of this XMLObject, if there is one.\r
-         */\r
-        virtual void releaseDOM() const=0;\r
-        \r
-        /**\r
-         * Releases the DOM representation of this XMLObject's parent.\r
-         * \r
-         * @param propagateRelease true if all ancestors of this element should release their DOM\r
-         */\r
-        virtual void releaseParentDOM(bool propagateRelease=true) const=0;\r
-        \r
-        /**\r
-         * Releases the DOM representation of this XMLObject's children.\r
-         * \r
-         * @param propagateRelease true if all descendants of this element should release their DOM\r
-         */\r
-        virtual void releaseChildrenDOM(bool propagateRelease=true) const=0;\r
-    };\r
-    \r
-};\r
-\r
-#endif /* __xmltooling_domxmlobj_h__ */\r
index 4e89a59..d9765bb 100644 (file)
@@ -21,7 +21,6 @@ libxmltoolinginclude_HEADERS = \
     AttributeExtensibleXMLObject.h \
     base.h \
     config_pub.h \
-    DOMCachingXMLObject.h \
     ElementProxy.h \
     exceptions.h \
     ILockable.h \
@@ -42,6 +41,7 @@ ioinclude_HEADERS = \
     io/AbstractXMLObjectUnmarshaller.h \
 
 siginclude_HEADERS = \
+    signature/KeyInfo.h \
     signature/Signature.h \
     signature/SigningContext.h \
     signature/VerifyingContext.h
@@ -58,11 +58,13 @@ valinclude_HEADERS = \
 
 noinst_HEADERS = \
     internal.h \
-    signature/impl/XMLSecSignature.h
+    signature/impl/KeyInfoImpl.h \
+    signature/impl/XMLSecSignatureImpl.h \
 
 if BUILD_XMLSEC
 xmlsec_sources = \
-    signature/impl/XMLSecSignature.cpp
+    signature/impl/KeyInfoImpl.cpp \
+    signature/impl/XMLSecSignatureImpl.cpp
 else
 xmlsec_sources =
 endif
index 1624b35..09e72c9 100644 (file)
@@ -52,10 +52,19 @@ namespace xmltooling {
     {\r
         MAKE_NONCOPYABLE(MarshallingContext);\r
     public:\r
+        /**\r
+         * Default constructor.\r
+         */\r
         MarshallingContext() {}\r
         ~MarshallingContext() {}\r
 \r
 #ifndef XMLTOOLING_NO_XMLSEC\r
+        /**\r
+         * Builds a marshalling context with an initial signature/context pair.\r
+         * \r
+         * @param sig   a signature object\r
+         * @param ctx   the signing context to associate with the signature \r
+         */\r
         MarshallingContext(Signature* sig, const SigningContext* ctx) {\r
             m_signingContexts.push_back(std::make_pair(sig,ctx));\r
         }\r
@@ -70,7 +79,6 @@ namespace xmltooling {
      */\r
     class XMLTOOL_API XMLObject\r
     {\r
-        MAKE_NONCOPYABLE(XMLObject);\r
     public:\r
         virtual ~XMLObject() {}\r
         \r
@@ -172,6 +180,68 @@ namespace xmltooling {
         virtual const std::list<XMLObject*>& getOrderedChildren() const=0;\r
 \r
         /**\r
+         * Gets the DOM representation of this XMLObject, if one exists.\r
+         * \r
+         * @return the DOM representation of this XMLObject\r
+         */\r
+        virtual DOMElement* getDOM() const=0;\r
+        \r
+        /**\r
+         * Sets the DOM representation of this XMLObject.\r
+         * \r
+         * @param dom       DOM representation of this XMLObject\r
+         * @param bindDocument  true if the object should take ownership of the associated Document\r
+         */\r
+        virtual void setDOM(DOMElement* dom, bool bindDocument=false) const=0;\r
+    \r
+        /**\r
+         * Assigns ownership of a DOM document to the XMLObject.\r
+         * This binds the lifetime of the document to the lifetime of the object.\r
+         * \r
+         * @param doc DOM document bound to this object \r
+         */\r
+        virtual void setDocument(DOMDocument* doc) const=0;\r
+\r
+        /**\r
+         * Releases the DOM representation of this XMLObject, if there is one.\r
+         */\r
+        virtual void releaseDOM() const=0;\r
+        \r
+        /**\r
+         * Releases the DOM representation of this XMLObject's parent.\r
+         * \r
+         * @param propagateRelease true if all ancestors of this element should release their DOM\r
+         */\r
+        virtual void releaseParentDOM(bool propagateRelease=true) const=0;\r
+        \r
+        /**\r
+         * Releases the DOM representation of this XMLObject's children.\r
+         * \r
+         * @param propagateRelease true if all descendants of this element should release their DOM\r
+         */\r
+        virtual void releaseChildrenDOM(bool propagateRelease=true) const=0;\r
+\r
+        /**\r
+         * A convenience method that is equal to calling releaseDOM() then releaseParentDOM(true).\r
+         */\r
+        void releaseThisandParentDOM() const {\r
+            if (getDOM()) {\r
+                releaseDOM();\r
+                releaseParentDOM(true);\r
+            }\r
+        }\r
+    \r
+        /**\r
+         * A convenience method that is equal to calling releaseChildrenDOM(true) then releaseDOM().\r
+         */\r
+        void releaseThisAndChildrenDOM() const {\r
+            if (getDOM()) {\r
+                releaseChildrenDOM(true);\r
+                releaseDOM();\r
+            }\r
+        }\r
+\r
+        /**\r
          * Marshalls the XMLObject, and its children, into a DOM element.\r
          * If a document is supplied, then it will be used to create the resulting elements.\r
          * If the document does not have a Document Element set, then the resulting\r
@@ -219,6 +289,8 @@ namespace xmltooling {
 \r
     protected:\r
         XMLObject() {}\r
+    private:\r
+        XMLObject& operator=(const XMLObject& src);\r
     };\r
 \r
 #if defined (_MSC_VER)\r
index a8680be..f4936ad 100644 (file)
  */
 
 #include "internal.h"
+
+#define XMLTOOLING_DEFINE_CONSTANTS
+#include <xercesc/util/XMLUniDefs.hpp>
+
 #include "exceptions.h"
 #include "XMLToolingConfig.h"
 #include "impl/UnknownElement.h"
-#include "signature/impl/XMLSecSignature.h"
+#include "signature/impl/KeyInfoImpl.h"
+#include "signature/impl/XMLSecSignatureImpl.h"
 #include "util/NDC.h"
+#include "util/XMLConstants.h"
 
 #ifdef HAVE_DLFCN_H
 # include <dlfcn.h>
@@ -54,7 +60,7 @@ DECL_EXCEPTION_FACTORY(UnknownAttributeException);
 DECL_EXCEPTION_FACTORY(ValidationException);
 DECL_EXCEPTION_FACTORY(SignatureException);
 
-namespace {
+namespace xmltooling {
    XMLToolingInternalConfig g_config;
 }
 
@@ -150,6 +156,7 @@ bool XMLToolingInternalConfig::init()
 
         // default registrations
         XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder());
+        XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,KeyInfo::LOCAL_NAME),new KeyInfoBuilderImpl());
 #ifndef XMLTOOLING_NO_XMLSEC
         XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME),new XMLSecSignatureBuilder());
 #endif
index ab86bc7..9aa9bd9 100644 (file)
@@ -21,7 +21,7 @@
  * Must be included prior to including any other header
  */
 
-#if !defined(__xmltooling_base_h__)
+#ifndef __xmltooling_base_h__
 #define __xmltooling_base_h__
 
 #if defined (_MSC_VER) || defined(__BORLANDC__)
@@ -36,7 +36,6 @@
  */
 
 // Windows and GCC4 Symbol Visibility Macros
-
 #ifdef WIN32
   #define XMLTOOL_IMPORT __declspec(dllimport)
   #define XMLTOOL_EXPORT __declspec(dllexport)
   #define XMLTOOL_EXCEPTIONAPI(api)
 #endif
 
-// Macro to block copy c'tor and assignment operator for a class
+#ifndef NULL
+#define NULL    0
+#endif
+
+/**
+ * Blocks copy c'tor and assignment operator for a class.
+ */
 #define MAKE_NONCOPYABLE(type) \
     private: \
         type(const type&); \
         type& operator=(const type&);
 
-#ifndef NULL
-#define NULL    0
-#endif
+/**
+ * Begins the declaration of an XMLObject specialization.
+ * Basic boilerplate includes a protected constructor, empty virtual destructor,
+ * and Unicode constants for the default associated element's name and prefix.
+ * 
+ * @param cname the name of the class to declare
+ * @param base  the base class to derive from using public virtual inheritance
+ */
+#define BEGIN_XMLOBJECT(cname,base) \
+    class XMLTOOL_API cname : public virtual base, public virtual ValidatingXMLObject { \
+    protected: \
+        cname() {} \
+    public: \
+        virtual ~cname() {} \
+        /##** Type-specific clone method. */ \
+        virtual cname* clone##cname() const=0; \
+        /##** Element prefix */ \
+        static const XMLCh PREFIX[]; \
+        /##** Element local name */ \
+        static const XMLCh LOCAL_NAME[]
+
+/**
+ * Ends the declaration of an XMLObject specialization.
+ */
+#define END_XMLOBJECT }
+
+/**
+ * Declares abstract get/set methods for a named XML attribute.
+ * 
+ * @param proper    the proper name of the attribute
+ * @param upcased   the upcased name of the attribute
+ */
+#define DECL_XMLOBJECT_ATTRIB(proper,upcased) \
+    /##** proper attribute name */ \
+    static const XMLCh upcased##_ATTRIB_NAME[]; \
+    /##** Returns the proper attribute. */ \
+    virtual const XMLCh* get##proper() const=0; \
+    /##** Sets the proper attribute. */ \
+    virtual void set##proper(const XMLCh* proper)=0
+
+/**
+ * Implements get/set methods and a private member for a named XML attribute.
+ * 
+ * @param proper    the proper name of the attribute
+ */
+#define IMPL_XMLOBJECT_ATTRIB(proper) \
+    private: \
+        XMLCh* m_##proper; \
+    public: \
+        const XMLCh* get##proper() const { \
+            return m_##proper; \
+        } \
+        void set##proper(const XMLCh* proper) { \
+            m_##proper = prepareForAssignment(m_##proper,proper); \
+        }
+
+/**
+ * Implements cloning methods for an XMLObject specialization implementation class.
+ * 
+ * @param cname    the name of the XMLObject specialization
+ */
+#define IMPL_XMLOBJECT_CLONE(cname) \
+    cname* clone##cname() const { \
+        return clone(); \
+    } \
+    cname* clone() const { \
+        auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone()); \
+        cname##Impl* ret=dynamic_cast<cname##Impl*>(domClone.get()); \
+        if (ret) { \
+            domClone.release(); \
+            return ret; \
+        } \
+        return new cname##Impl(*this); \
+    }
+
+/**
+ * Begins the declaration of an XMLObjectBuilder specialization.
+ * Basic boilerplate includes an empty virtual destructor, and
+ * a default builder.
+ * 
+ * @param cname the name of the XMLObject specialization
+ */
+#define BEGIN_XMLOBJECTBUILDER(cname) \
+    /##** Builder for cname objects. */ \
+    class XMLTOOL_API cname##Builder : public xmltooling::XMLObjectBuilder { \
+    public: \
+        virtual ~cname##Builder() {} \
+        /##** Default builder. */ \
+        virtual cname* buildObject() const=0
+
+/**
+ * Ends the declaration of an XMLObjectBuilder specialization.
+ */
+#define END_XMLOBJECTBUILDER }
+
+/**
+ * Begins the declaration of an XMLObjectBuilder specialization implementation class.
+ * 
+ * @param cname         the name of the XMLObject specialization
+ * @param namespaceURI  the XML namespace of the default associated element
+ */
+#define BEGIN_XMLOBJECTBUILDERIMPL(cname,namespaceURI) \
+    class XMLTOOL_DLLLOCAL cname##BuilderImpl : public cname##Builder { \
+    public: \
+        cname* buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix=NULL) const; \
+        cname* buildObject() const { \
+            return buildObject(namespaceURI,cname::LOCAL_NAME,cname::PREFIX); \
+        }
+
+/**
+ * Ends the declaration of an XMLObjectBuilder specialization implementation class.
+ */
+#define END_XMLOBJECTBUILDERIMPL }
 
 #include <utility>
 
@@ -102,7 +217,7 @@ namespace xmltooling {
         }
     }
 
-    /*
+    /**
      * Functor for cleaning up heap objects in containers.
      */
     template<class T> struct cleanup
@@ -122,7 +237,7 @@ namespace xmltooling {
         void operator()(const T* ptr) {delete const_cast<T*>(ptr);}
     };
 
-    /*
+    /**
      * Functor for cleaning up heap objects in key/value containers.
      */
     template<class A,class B> struct cleanup_pair
index 4d343e5..6e82e1e 100644 (file)
@@ -20,7 +20,7 @@
  * Exception classes\r
  */\r
  \r
-#if !defined(__xmltooling_exceptions_h__)\r
+#ifndef __xmltooling_exceptions_h__\r
 #define __xmltooling_exceptions_h__\r
 \r
 #include <map>\r
  * \r
  * @param name  the exception class\r
  * @param base  the base class\r
+ * @param desc\r
  */\r
-#define DECL_XMLTOOLING_EXCEPTION(name,base) \\r
+#define DECL_XMLTOOLING_EXCEPTION(name,base,desc) \\r
+    /##** desc */ \\r
     class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) name : public xmltooling::base { \\r
     public: \\r
+        /##** base##::##base(const char*,const xmltooling::params&) */ \\r
         name(const char* msg=NULL, const xmltooling::params& p=xmltooling::params()) \\r
             : xmltooling::base(msg,p) {} \\r
+        /##** base##::##base(const char*,const xmltooling::namedparams&) */ \\r
         name(const char* msg, const xmltooling::namedparams& p) \\r
             : xmltooling::base(msg,p) {} \\r
+        /##** base##::##base(const std::string&,const xmltooling::params&) */ \\r
         name(const std::string& msg, const xmltooling::params& p=xmltooling::params()) \\r
             : xmltooling::base(msg,p) {} \\r
+        /##** base##::##base(const std::string&,const xmltooling::namedparams&) */ \\r
         name(const std::string& msg, const xmltooling::namedparams& p) \\r
             : xmltooling::base(msg,p) {} \\r
         virtual ~name() {} \\r
@@ -102,6 +108,7 @@ namespace xmltooling {
         const std::vector<const char*>& get() const {return v;}\r
         \r
     protected:\r
+        /** Contains the parameters being passed. */\r
         std::vector<const char*> v;\r
     };\r
     \r
@@ -124,14 +131,16 @@ namespace xmltooling {
         namedparams(int count,...);\r
     };\r
 \r
+    class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) XMLToolingException;\r
+    \r
+    /** A factory function that returns an empty exception object of a given type. */\r
+    typedef XMLToolingException* ExceptionFactory();\r
+    \r
     /**\r
      * Base exception class, supports parametrized messages and XML serialization.\r
      * Parameters are prefixed with a dollar sign ($) and can be positional ($1)\r
      * or named ($info).\r
      */\r
-    class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) XMLToolingException;\r
-    typedef XMLToolingException* ExceptionFactory();\r
-    \r
     class XMLTOOL_EXCEPTIONAPI(XMLTOOL_API) XMLToolingException\r
     {\r
     public:\r
@@ -326,14 +335,14 @@ namespace xmltooling {
         static ExceptionFactoryMap m_factoryMap;\r
     };\r
 \r
-    DECL_XMLTOOLING_EXCEPTION(XMLParserException,XMLToolingException);\r
-    DECL_XMLTOOLING_EXCEPTION(XMLObjectException,XMLToolingException);\r
-    DECL_XMLTOOLING_EXCEPTION(MarshallingException,XMLToolingException);\r
-    DECL_XMLTOOLING_EXCEPTION(UnmarshallingException,XMLToolingException);\r
-    DECL_XMLTOOLING_EXCEPTION(UnknownElementException,XMLToolingException);\r
-    DECL_XMLTOOLING_EXCEPTION(UnknownAttributeException,XMLToolingException);\r
-    DECL_XMLTOOLING_EXCEPTION(ValidationException,XMLToolingException);\r
-    DECL_XMLTOOLING_EXCEPTION(SignatureException,XMLToolingException);\r
+    DECL_XMLTOOLING_EXCEPTION(XMLParserException,XMLToolingException,Exceptions related to XML parsing);\r
+    DECL_XMLTOOLING_EXCEPTION(XMLObjectException,XMLToolingException,Exceptions in basic object usage);\r
+    DECL_XMLTOOLING_EXCEPTION(MarshallingException,XMLToolingException,Exceptions during object marshalling);\r
+    DECL_XMLTOOLING_EXCEPTION(UnmarshallingException,XMLToolingException,Exceptions during object unmarshalling);\r
+    DECL_XMLTOOLING_EXCEPTION(UnknownElementException,XMLToolingException,Exceptions due to processing of unknown element content);\r
+    DECL_XMLTOOLING_EXCEPTION(UnknownAttributeException,XMLToolingException,Exceptions due to processing of unknown attributes);\r
+    DECL_XMLTOOLING_EXCEPTION(ValidationException,XMLToolingException,Exceptions during object validation);\r
+    DECL_XMLTOOLING_EXCEPTION(SignatureException,XMLToolingException,Exceptions in signature processing);\r
 \r
 };\r
 \r
index a467741..8ed8a8d 100644 (file)
@@ -15,7 +15,7 @@
  */
 
 /**
- * @file AnyElement.h
+ * AnyElement.cpp
  * 
  * Advanced anyType implementation suitable for deep processing of unknown content.
  */
@@ -47,13 +47,15 @@ namespace xmltooling {
     /**
      * Implements a smart wrapper around unknown DOM content.
      */
-    class XMLTOOL_DLLLOCAL AnyElementImpl : public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject,
+    class XMLTOOL_DLLLOCAL AnyElementImpl : public AbstractDOMCachingXMLObject,
+        public AbstractElementProxy, public AbstractAttributeExtensibleXMLObject,
         public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller
     {
     public:
+        virtual ~AnyElementImpl() {}
+
         AnyElementImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix)
             : AbstractXMLObject(nsURI, localName, prefix) {}
-        virtual ~AnyElementImpl() {}
         
         AnyElementImpl* clone() const {
             auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
@@ -63,18 +65,17 @@ namespace xmltooling {
                 return ret;
             }
 
-            ret=new AnyElementImpl(
-                getElementQName().getNamespaceURI(),getElementQName().getLocalPart(),getElementQName().getPrefix()
-                );
-            ret->m_namespaces=m_namespaces;
-            for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
-                ret->m_attributeMap[i->first]=XMLString::replicate(i->second);
-            }
-            ret->setTextContent(getTextContent());
-            xmltooling::clone(m_children, ret->m_children);
-            return ret;
+            return new AnyElementImpl(*this);
         }
 
+    protected:
+        AnyElementImpl(const AnyElementImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),
+            AbstractElementProxy(src), AbstractAttributeExtensibleXMLObject(src) {
+            for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {
+                getXMLObjects().push_back((*i) ? (*i)->clone() : NULL);
+            }
+        }       
+        
         void marshallAttributes(DOMElement* domElement) const {
             for (map<QName,XMLCh*>::const_iterator i=m_attributeMap.begin(); i!=m_attributeMap.end(); i++) {
                 DOMAttr* attr=domElement->getOwnerDocument()->createAttributeNS(i->first.getNamespaceURI(),i->first.getLocalPart());
index 8fd619f..27654a0 100644 (file)
 namespace xmltooling {
 
     /**
-     * Implements a smart wrapper around unknown DOM content.
-     */
-    class XMLTOOL_DLLLOCAL AnyElementImpl;
-
-    /**
      * Builder for AnyElementImpl objects.
+     * Use as the default builder when you want to wrap each unknown element and
+     * process the DOM content through xmltooling interfaces. 
      */
     class XMLTOOL_API AnyElementBuilder : public XMLObjectBuilder
     {
     public:
-        /**
-         * @see XMLObjectBuilder::buildObject(const XMLCh*,const XMLCh*,const XMLCh*)
-         */
         XMLObject* buildObject(
             const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL
             ) const;
index 0ad445d..dd7f3be 100644 (file)
@@ -37,9 +37,7 @@
 \r
 namespace xmltooling {\r
 \r
-    /**\r
-     * Implements a thin wrapper around unknown DOM content.\r
-     */\r
+    /// @cond off\r
     class XMLTOOL_DLLLOCAL UnknownElementImpl : public AbstractDOMCachingXMLObject\r
     {\r
     public:\r
@@ -67,17 +65,16 @@ namespace xmltooling {
 \r
         void serialize(std::string& s) const;\r
     };\r
-\r
+    /// @endcond\r
+    \r
     /**\r
      * Builder for UnknownElementImpl objects.\r
+     * Use as the default builder when you want unknown DOM content treated as raw/ignored XML.\r
      */\r
     class XMLTOOL_API UnknownElementBuilder : public XMLObjectBuilder\r
     {\r
     public:\r
-        /**\r
-         * @see XMLObjectBuilder::buildObject(const XMLCh*,const XMLCh*,const XMLCh*)\r
-         */\r
-        UnknownElementImpl* buildObject(\r
+        XMLObject* buildObject(\r
             const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL\r
             ) const {\r
             return new UnknownElementImpl(namespaceURI,elementLocalName,namespacePrefix);\r
index a6c87cb..0be6bdb 100644 (file)
@@ -46,6 +46,7 @@
 
 namespace xmltooling {
     
+    /// @cond OFF
     class XMLToolingInternalConfig : public xmltooling::XMLToolingConfig
     {
     public:
@@ -80,6 +81,8 @@ namespace xmltooling {
         void* m_lock;
         //PlugManager m_plugMgr;
     };
+    /// @endcond
+
 };
 
 #endif /* __xmltooling_internal_h__ */
index e7c6647..82d1621 100644 (file)
@@ -35,19 +35,13 @@ namespace xmltooling {
     /**\r
      * A thread-safe abstract marshaller.\r
      */\r
-    class XMLTOOL_API AbstractXMLObjectMarshaller : public virtual AbstractDOMCachingXMLObject\r
+    class XMLTOOL_API AbstractXMLObjectMarshaller : public virtual AbstractXMLObject\r
     {\r
     public:\r
         virtual ~AbstractXMLObjectMarshaller() {}\r
 \r
-        /**\r
-         * @see XMLObject::marshall(DOMDocument*,const MarshallingContext*)\r
-         */\r
         DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
 \r
-        /**\r
-         * @see XMLObject::marshall(DOMElement*,const MarshallingContext*)\r
-         */\r
         DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
         \r
     protected:\r
index b85ce01..0853f15 100644 (file)
@@ -35,14 +35,11 @@ namespace xmltooling {
     /**\r
      * A thread-safe abstract unmarshaller.\r
      */\r
-    class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual AbstractDOMCachingXMLObject\r
+    class XMLTOOL_API AbstractXMLObjectUnmarshaller : public virtual AbstractXMLObject\r
     {\r
     public:\r
         virtual ~AbstractXMLObjectUnmarshaller() {}\r
 \r
-        /**\r
-         * @see XMLObject::unmarshall()\r
-         */\r
         XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
             \r
     protected:\r
diff --git a/xmltooling/signature/KeyInfo.h b/xmltooling/signature/KeyInfo.h
new file mode 100644 (file)
index 0000000..a27ca97
--- /dev/null
@@ -0,0 +1,57 @@
+/*\r
+ *  Copyright 2001-2006 Internet2\r
+ * \r
+ * Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * @file KeyInfo.h\r
+ * \r
+ * XMLObjects representing XML Digital Signature, version 20020212, KeyInfo element\r
+ * and related content.\r
+ */\r
+\r
+#ifndef __xmltooling_keyinfo_h__\r
+#define __xmltooling_keyinfo_h__\r
+\r
+#include <xmltooling/ElementProxy.h>\r
+#include <xmltooling/XMLObjectBuilder.h>\r
+#include <xmltooling/validation/ValidatingXMLObject.h>\r
+\r
+namespace xmltooling {\r
+\r
+    /**\r
+     * XMLObject representing XML Digital Signature, version 20020212, KeyInfo element.\r
+     */\r
+    BEGIN_XMLOBJECT(KeyInfo,ElementProxy);\r
+        DECL_XMLOBJECT_ATTRIB(Id,ID);\r
+    END_XMLOBJECT;\r
+\r
+    BEGIN_XMLOBJECTBUILDER(KeyInfo);\r
+    END_XMLOBJECTBUILDER;\r
+\r
+#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
+    const XMLCh KeyInfo::LOCAL_NAME[] = {\r
+        chLatin_K, chLatin_e, chLatin_y, chLatin_I, chLatin_n, chLatin_f, chLatin_o, chNull\r
+    }; \r
+    const XMLCh KeyInfo::PREFIX[] = {\r
+        chLatin_d, chLatin_s, chNull\r
+    };\r
+    const XMLCh KeyInfo::ID_ATTRIB_NAME[] = {\r
+        chLatin_I, chLatin_d, chNull\r
+    };\r
+#endif\r
+\r
+};\r
+\r
+#endif /* __xmltooling_keyinfo_h__ */\r
index 1794722..bf886fc 100644 (file)
@@ -79,6 +79,15 @@ namespace xmltooling {
         Signature() {}\r
     };\r
 \r
+#ifdef XMLTOOLING_DEFINE_CONSTANTS\r
+    const XMLCh Signature::LOCAL_NAME[] = {\r
+        chLatin_S, chLatin_i, chLatin_g, chLatin_n, chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chNull\r
+    }; \r
+    const XMLCh Signature::PREFIX[] = {\r
+        chLatin_d, chLatin_s, chNull\r
+    };\r
+#endif\r
+\r
     /**\r
      * Builder for Signature objects.\r
      */\r
@@ -88,7 +97,7 @@ namespace xmltooling {
         virtual ~SignatureBuilder() {}\r
 \r
         /**\r
-         * Default typed builder method.\r
+         * Default builder.\r
          */\r
         virtual Signature* buildObject() const=0;\r
     };\r
diff --git a/xmltooling/signature/impl/KeyInfoImpl.cpp b/xmltooling/signature/impl/KeyInfoImpl.cpp
new file mode 100644 (file)
index 0000000..d49d0ba
--- /dev/null
@@ -0,0 +1,102 @@
+/*\r
+*  Copyright 2001-2006 Internet2\r
+ * \r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * XMLSecSignatureImpl.cpp\r
+ * \r
+ * Signature class for XMLSec-based signature-handling\r
+ */\r
+\r
+#include "internal.h"\r
+#include "AbstractElementProxy.h"\r
+#include "exceptions.h"\r
+#include "io/AbstractXMLObjectMarshaller.h"\r
+#include "io/AbstractXMLObjectUnmarshaller.h"\r
+#include "signature/impl/KeyInfoImpl.h"\r
+#include "util/NDC.h"\r
+#include "util/XMLHelper.h"\r
+#include "validation/AbstractValidatingXMLObject.h"\r
+\r
+#include <log4cpp/Category.hh>\r
+\r
+using namespace xmltooling;\r
+using namespace log4cpp;\r
+using namespace std;\r
+\r
+#if defined (_MSC_VER)\r
+    #pragma warning( push )\r
+    #pragma warning( disable : 4250 4251 )\r
+#endif\r
+\r
+namespace xmltooling {\r
+    \r
+    class XMLTOOL_DLLLOCAL KeyInfoImpl : public KeyInfo, public AbstractDOMCachingXMLObject, public AbstractElementProxy,\r
+        public AbstractValidatingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller\r
+    {\r
+    public:\r
+        virtual ~KeyInfoImpl() {}\r
+\r
+        KeyInfoImpl(const XMLCh* nsURI, const XMLCh* localName, const XMLCh* prefix)\r
+            : AbstractXMLObject(nsURI, localName, prefix), m_Id(NULL) {}\r
+            \r
+        KeyInfoImpl(const KeyInfoImpl& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),\r
+            AbstractElementProxy(src), AbstractValidatingXMLObject(src), m_Id(XMLString::replicate(src.m_Id)) {\r
+            for (list<XMLObject*>::const_iterator i=src.m_children.begin(); i!=src.m_children.end(); i++) {\r
+                getXMLObjects().push_back((*i) ? (*i)->clone() : NULL);\r
+            }\r
+        }\r
+        \r
+        IMPL_XMLOBJECT_ATTRIB(Id);\r
+        IMPL_XMLOBJECT_CLONE(KeyInfo);\r
+\r
+    protected:\r
+        void marshallAttributes(DOMElement* domElement) const {\r
+            if(getId()) {\r
+                domElement->setAttributeNS(NULL, ID_ATTRIB_NAME, getId());\r
+                domElement->setIdAttributeNS(NULL, ID_ATTRIB_NAME);\r
+            }\r
+        }\r
+\r
+        void marshallElementContent(DOMElement* domElement) const {\r
+            if(getTextContent()) {\r
+                domElement->appendChild(domElement->getOwnerDocument()->createTextNode(getTextContent()));\r
+            }\r
+        }\r
+\r
+        void processChildElement(XMLObject* childXMLObject, const DOMElement* root) {\r
+            getXMLObjects().push_back(childXMLObject);\r
+        }\r
+\r
+        void processAttribute(const DOMAttr* attribute) {\r
+            if (XMLHelper::isNodeNamed(attribute, NULL, ID_ATTRIB_NAME))\r
+                setId(attribute->getValue());\r
+        }\r
+\r
+        void processElementContent(const XMLCh* elementContent) {\r
+            setTextContent(elementContent);\r
+        }\r
+    };\r
+    \r
+};\r
+\r
+#if defined (_MSC_VER)\r
+    #pragma warning( pop )\r
+#endif\r
+\r
+KeyInfo* KeyInfoBuilderImpl::buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix) const\r
+{\r
+    return new KeyInfoImpl(ns,name,prefix);\r
+}\r
diff --git a/xmltooling/signature/impl/KeyInfoImpl.h b/xmltooling/signature/impl/KeyInfoImpl.h
new file mode 100644 (file)
index 0000000..98d0ac9
--- /dev/null
@@ -0,0 +1,36 @@
+/*\r
+*  Copyright 2001-2006 Internet2\r
+ * \r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * KeyInfoImpl.h\r
+ * \r
+ * Builder class for KeyInfo \r
+ */\r
+\r
+#ifndef __xmltooling_keyinfoimpl_h__\r
+#define __xmltooling_keyinfoimpl_h__\r
+\r
+#include <xmltooling/signature/KeyInfo.h>\r
+#include <xmltooling/util/XMLConstants.h>\r
+\r
+namespace xmltooling {\r
+\r
+    BEGIN_XMLOBJECTBUILDERIMPL(KeyInfo,XMLConstants::XMLSIG_NS);\r
+    END_XMLOBJECTBUILDERIMPL;\r
+\r
+};\r
+\r
+#endif /* __xmltooling_keyinfoimpl_h__ */\r
diff --git a/xmltooling/signature/impl/XMLSecSignature.h b/xmltooling/signature/impl/XMLSecSignature.h
deleted file mode 100644 (file)
index 276bbab..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*\r
-*  Copyright 2001-2006 Internet2\r
- * \r
-* Licensed under the Apache License, Version 2.0 (the "License");\r
- * you may not use this file except in compliance with the License.\r
- * You may obtain a copy of the License at\r
- *\r
- *     http://www.apache.org/licenses/LICENSE-2.0\r
- *\r
- * Unless required by applicable law or agreed to in writing, software\r
- * distributed under the License is distributed on an "AS IS" BASIS,\r
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
- * See the License for the specific language governing permissions and\r
- * limitations under the License.\r
- */\r
-\r
-/**\r
- * XMLSecSignature.h\r
- * \r
- * Signature classes for XMLSec-based signature-handling\r
- */\r
-\r
-#if !defined(__xmltooling_xmlsecsig_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
-#define __xmltooling_xmlsecsig_h__\r
-\r
-#include "internal.h"\r
-#include "impl/UnknownElement.h"\r
-#include "signature/Signature.h"\r
-#include "util/XMLConstants.h"\r
-\r
-#include <string>\r
-\r
-#if defined (_MSC_VER)\r
-    #pragma warning( push )\r
-    #pragma warning( disable : 4250 4251 )\r
-#endif\r
-\r
-namespace xmltooling {\r
-\r
-    class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
-    {\r
-    public:\r
-        XMLSecSignatureImpl() : UnknownElementImpl(XMLConstants::XMLSIG_NS, Signature::LOCAL_NAME, XMLConstants::XMLSIG_PREFIX),\r
-            m_signature(NULL), m_c14n(NULL), m_sm(NULL) {}\r
-        virtual ~XMLSecSignatureImpl();\r
-        \r
-        void releaseDOM();\r
-        XMLObject* clone() const;\r
-\r
-        DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
-        DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
-        XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
-        \r
-        // Getters\r
-        const XMLCh* getCanonicalizationMethod() const { return m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC; }\r
-        const XMLCh* getSignatureAlgorithm() const { return m_sm ? m_sm : DSIGConstants::s_unicodeStrURIRSA_SHA1; }\r
-\r
-        // Setters\r
-        void setCanonicalizationMethod(const XMLCh* c14n) { m_c14n = prepareForAssignment(m_c14n,c14n); }\r
-        void setSignatureAlgorithm(const XMLCh* sm) { m_sm = prepareForAssignment(m_sm,sm); }\r
-\r
-        void sign(const SigningContext& ctx);\r
-        void verify(const VerifyingContext& ctx) const;\r
-\r
-    private:\r
-        mutable DSIGSignature* m_signature;\r
-        XMLCh* m_c14n;\r
-        XMLCh* m_sm;\r
-    };\r
-\r
-    class XMLTOOL_DLLLOCAL XMLSecSignatureBuilder : public virtual XMLObjectBuilder\r
-    {\r
-    public:\r
-        XMLSecSignatureImpl* buildObject(\r
-            const XMLCh* namespaceURI, const XMLCh* elementLocalName, const XMLCh* namespacePrefix=NULL\r
-            ) const {\r
-            if (!XMLString::equals(namespaceURI,XMLConstants::XMLSIG_NS) || !XMLString::equals(elementLocalName, Signature::LOCAL_NAME))\r
-                throw XMLObjectException("XMLSecSignatureBuilder requires standard Signature element name.");\r
-            return buildObject();\r
-        }\r
-        \r
-        XMLSecSignatureImpl* buildObject() const {\r
-            return new XMLSecSignatureImpl();\r
-        }\r
-    };\r
-\r
-};\r
-\r
-#if defined (_MSC_VER)\r
-    #pragma warning( pop )\r
-#endif\r
-\r
-#endif /* __xmltooling_xmlsecsig_h__ */\r
  */\r
 \r
 /**\r
- * XMLSecSignature.cpp\r
+ * XMLSecSignatureImpl.cpp\r
  * \r
- * Signature classes for XMLSec-based signature-handling\r
+ * Signature class for XMLSec-based signature-handling\r
  */\r
 \r
 #include "internal.h"\r
 #include "exceptions.h"\r
-#include "signature/impl/XMLSecSignature.h"\r
+#include "impl/UnknownElement.h"\r
+#include "signature/impl/XMLSecSignatureImpl.h"\r
 #include "util/NDC.h"\r
+#include "util/XMLConstants.h"\r
 #include "util/XMLHelper.h"\r
 \r
 #include <log4cpp/Category.hh>\r
 #include <xercesc/framework/MemBufInputSource.hpp>\r
 #include <xercesc/framework/Wrapper4InputSource.hpp>\r
-#include <xercesc/util/XMLUniDefs.hpp>\r
 #include <xsec/dsig/DSIGKeyInfoX509.hpp>\r
 #include <xsec/enc/XSECCryptoException.hpp>\r
 #include <xsec/framework/XSECException.hpp>\r
@@ -38,13 +39,49 @@ using namespace xmltooling;
 using namespace log4cpp;\r
 using namespace std;\r
 \r
-const XMLCh xmltooling::Signature::LOCAL_NAME[] = {\r
-    chLatin_S, chLatin_i, chLatin_g, chLatin_n, chLatin_a, chLatin_t, chLatin_u, chLatin_r, chLatin_e, chNull\r
-}; \r
+#if defined (_MSC_VER)\r
+    #pragma warning( push )\r
+    #pragma warning( disable : 4250 4251 )\r
+#endif\r
+\r
+namespace xmltooling {\r
+    \r
+    class XMLTOOL_DLLLOCAL XMLSecSignatureImpl : public UnknownElementImpl, public virtual Signature\r
+    {\r
+    public:\r
+        XMLSecSignatureImpl() : UnknownElementImpl(XMLConstants::XMLSIG_NS, Signature::LOCAL_NAME, XMLConstants::XMLSIG_PREFIX),\r
+            m_signature(NULL), m_c14n(NULL), m_sm(NULL) {}\r
+        virtual ~XMLSecSignatureImpl();\r
+        \r
+        void releaseDOM();\r
+        XMLObject* clone() const;\r
 \r
-const XMLCh xmltooling::Signature::PREFIX[] = {\r
-    chLatin_d, chLatin_s, chNull\r
-}; \r
+        DOMElement* marshall(DOMDocument* document=NULL, MarshallingContext* ctx=NULL) const;\r
+        DOMElement* marshall(DOMElement* parentElement, MarshallingContext* ctx=NULL) const;\r
+        XMLObject* unmarshall(DOMElement* element, bool bindDocument=false);\r
+        \r
+        // Getters\r
+        const XMLCh* getCanonicalizationMethod() const { return m_c14n ? m_c14n : DSIGConstants::s_unicodeStrURIEXC_C14N_NOC; }\r
+        const XMLCh* getSignatureAlgorithm() const { return m_sm ? m_sm : DSIGConstants::s_unicodeStrURIRSA_SHA1; }\r
+\r
+        // Setters\r
+        void setCanonicalizationMethod(const XMLCh* c14n) { m_c14n = prepareForAssignment(m_c14n,c14n); }\r
+        void setSignatureAlgorithm(const XMLCh* sm) { m_sm = prepareForAssignment(m_sm,sm); }\r
+\r
+        void sign(const SigningContext& ctx);\r
+        void verify(const VerifyingContext& ctx) const;\r
+\r
+    private:\r
+        mutable DSIGSignature* m_signature;\r
+        XMLCh* m_c14n;\r
+        XMLCh* m_sm;\r
+    };\r
+    \r
+};\r
+\r
+#if defined (_MSC_VER)\r
+    #pragma warning( pop )\r
+#endif\r
 \r
 XMLSecSignatureImpl::~XMLSecSignatureImpl()\r
 {\r
@@ -363,3 +400,15 @@ XMLObject* XMLSecSignatureImpl::unmarshall(DOMElement* element, bool bindDocumen
     setDOM(element, bindDocument);\r
     return this;\r
 }\r
+\r
+Signature* XMLSecSignatureBuilder::buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix) const\r
+{\r
+    if (!XMLString::equals(ns,XMLConstants::XMLSIG_NS) || !XMLString::equals(name,Signature::LOCAL_NAME))\r
+        throw XMLObjectException("XMLSecSignatureBuilder requires standard Signature element name.");\r
+    return buildObject();\r
+}\r
+\r
+Signature* XMLSecSignatureBuilder::buildObject() const\r
+{\r
+    return new XMLSecSignatureImpl();\r
+}\r
diff --git a/xmltooling/signature/impl/XMLSecSignatureImpl.h b/xmltooling/signature/impl/XMLSecSignatureImpl.h
new file mode 100644 (file)
index 0000000..6bcc4eb
--- /dev/null
@@ -0,0 +1,39 @@
+/*\r
+*  Copyright 2001-2006 Internet2\r
+ * \r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+ * you may not use this file except in compliance with the License.\r
+ * You may obtain a copy of the License at\r
+ *\r
+ *     http://www.apache.org/licenses/LICENSE-2.0\r
+ *\r
+ * Unless required by applicable law or agreed to in writing, software\r
+ * distributed under the License is distributed on an "AS IS" BASIS,\r
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+ * See the License for the specific language governing permissions and\r
+ * limitations under the License.\r
+ */\r
+\r
+/**\r
+ * XMLSecSignatureImpl.h\r
+ * \r
+ * Builder class for XMLSec-based signature-handling\r
+ */\r
+\r
+#if !defined(__xmltooling_xmlsecsig_h__) && !defined(XMLTOOLING_NO_XMLSEC)\r
+#define __xmltooling_xmlsecsig_h__\r
+\r
+#include <xmltooling/signature/Signature.h>\r
+\r
+namespace xmltooling {\r
+\r
+    class XMLTOOL_DLLLOCAL XMLSecSignatureBuilder : public SignatureBuilder\r
+    {\r
+    public:\r
+        Signature* buildObject(const XMLCh* ns, const XMLCh* name, const XMLCh* prefix=NULL) const;\r
+        Signature* buildObject() const;\r
+    };\r
+\r
+};\r
+\r
+#endif /* __xmltooling_xmlsecsig_h__ */\r
index a15b6de..34fbdd9 100644 (file)
@@ -94,7 +94,7 @@ namespace xmltooling {
          */\r
         bool loadCatalog(const XMLCh* pathname);\r
         \r
-        /*\r
+        /**\r
          * Load a schema explicitly from a local file.\r
          * \r
          * Note that "successful processing" does not imply that the schema is valid,\r
@@ -147,7 +147,10 @@ namespace xmltooling {
          * @param systemId  optional system identifier to attach to the stream\r
          */\r
         StreamInputSource(std::istream& is, const char* systemId=NULL) : InputSource(systemId), m_is(is) {}\r
+        /// @cond off\r
         virtual BinInputStream* makeStream() const { return new StreamBinInputStream(m_is); }\r
+        /// @endcond\r
+\r
 \r
     private:\r
         std::istream& m_is;\r
index 9de1579..32dd9d7 100644 (file)
  * STL-compatible container wrapper
  */
 
-#if !defined(__xmltooling_list_h__)
+#ifndef __xmltooling_list_h__
 #define __xmltooling_list_h__
 
-#include <xmltooling/DOMCachingXMLObject.h>
 #include <xmltooling/exceptions.h>
 
+/**
+ * Shorthand for an XMLObjectChildrenList wrapped around a vector
+ * 
+ * @param type  the type of object in the vector
+ */
 #define VectorOf(type) xmltooling::XMLObjectChildrenList< std::vector<type*> >
+
+/**
+ * Shorthand for an XMLObjectChildrenList wrapped around a list
+ * 
+ * @param type  the type of object in the list
+ */
 #define ListOf(type) xmltooling::XMLObjectChildrenList< std::list<type*> >
+
+/**
+ * Shorthand for an XMLObjectChildrenList wrapped around a deque
+ * 
+ * @param type  the type of object in the deque
+ */
 #define DequeOf(type) xmltooling::XMLObjectChildrenList< std::deque<type*> >
 
 namespace xmltooling {
@@ -42,6 +58,7 @@ namespace xmltooling {
     template <class _Ty>
     class XMLObjectChildrenIterator
     {
+        /// @cond OFF
         typename _Ty::iterator m_iter;
         template <class _Tx, class _Tz> friend class XMLObjectChildrenList;
     public:
@@ -135,6 +152,7 @@ namespace xmltooling {
                    // test for iterator inequality
                    return (!(m_iter == _Right.m_iter));
            }
+        /// @endcond
     };
 
     /**
@@ -151,6 +169,7 @@ namespace xmltooling {
         XMLObject* m_parent;
 
        public:
+        /// @cond OFF
         typedef typename Container::value_type value_type;
         typedef typename Container::reference reference;
         typedef typename Container::const_reference const_reference;
@@ -160,6 +179,7 @@ namespace xmltooling {
         // We override the iterator types with our constrained wrapper.
         typedef XMLObjectChildrenIterator<Container> iterator;
         typedef XMLObjectChildrenIterator<Container> const_iterator;
+        /// @endcond
 
         /**
          * Constructor to expose a typed collection of children backed by a list of a base type.
@@ -177,6 +197,8 @@ namespace xmltooling {
             ) : m_parent(parent), m_container(sublist), m_list(backing), m_fence(ins_fence) {
         }
 
+        /// @cond OFF
+
         size_type size() const {
             // return length of sequence
             return m_container.size();
@@ -263,20 +285,14 @@ namespace xmltooling {
             if (_Val->getParent())
                 throw XMLObjectException("Child object already has a parent.");
             _Val->setParent(m_parent);
-            DOMCachingXMLObject* dc=dynamic_cast<DOMCachingXMLObject*>(_Val);
-            if (dc) {
-                dc->releaseParentDOM(true);
-            }
+            _Val->releaseParentDOM(true);
         }
 
         void removeParent(const_reference _Val) {
             if (_Val->getParent()!=m_parent)
                 throw XMLObjectException("Child object not owned by this parent.");
             _Val->setParent(NULL);
-            DOMCachingXMLObject* dc=dynamic_cast<DOMCachingXMLObject*>(m_parent);
-            if (dc) {
-                dc->releaseParentDOM(true);
-            }
+            m_parent->releaseParentDOM(true);
         }
 
         void removeChild(const_reference _Val) {
@@ -288,6 +304,7 @@ namespace xmltooling {
                 }
             }
         }
+        /// @endcond
     };
 
 };
index 78f5cbb..fb2bfde 100644 (file)
@@ -35,6 +35,14 @@ AbstractValidatingXMLObject::ValidatorWrapper::~ValidatorWrapper()
     for_each(v.begin(),v.end(),cleanup<Validator>());\r
 }\r
 \r
+AbstractValidatingXMLObject::AbstractValidatingXMLObject(const AbstractValidatingXMLObject& src) : AbstractXMLObject(src)\r
+{\r
+    if (src.m_validators) {\r
+        m_validators=new ValidatorWrapper();\r
+        xmltooling::clone(src.m_validators->v,m_validators->v);\r
+    }\r
+}\r
+\r
 AbstractValidatingXMLObject::~AbstractValidatingXMLObject()\r
 {\r
     delete m_validators;\r
index 2e8d27b..0eda2c6 100644 (file)
@@ -59,6 +59,9 @@ namespace xmltooling {
     protected:\r
         AbstractValidatingXMLObject() : m_validators(NULL) {}\r
 \r
+        /** Copy constructor. */\r
+        AbstractValidatingXMLObject(const AbstractValidatingXMLObject& src);\r
+\r
     private:\r
         struct XMLTOOL_DLLLOCAL ValidatorWrapper {\r
             ~ValidatorWrapper(); \r
index 0734030..6962bb8 100644 (file)
@@ -55,6 +55,13 @@ namespace xmltooling {
         virtual void validate(const XMLObject* xmlObject) const=0;\r
 \r
         /**\r
+         * Returns a copy of the validator.\r
+         *\r
+         * @return the new validator\r
+         */\r
+        virtual Validator* clone() const=0;\r
+\r
+        /**\r
          * Evaluates the registered validators against the given XMLObject and it's children.\r
          * \r
          * @param xmlObject the XMLObject tree to validate\r
index adf0181..21bc63b 100644 (file)
@@ -15,7 +15,7 @@
  */\r
 \r
 /**\r
- * @file version.h\r
+ * version.h\r
  * \r
  * Library version macros and constants \r
  */\r
index d095368..14d79d6 100644 (file)
                                        Name="impl"\r
                                        >\r
                                        <File\r
-                                               RelativePath=".\signature\impl\XMLSecSignature.cpp"\r
+                                               RelativePath=".\signature\impl\KeyInfoImpl.cpp"\r
+                                               >\r
+                                       </File>\r
+                                       <File\r
+                                               RelativePath=".\signature\impl\XMLSecSignatureImpl.cpp"\r
                                                >\r
                                        </File>\r
                                </Filter>\r
                                >\r
                        </File>\r
                        <File\r
-                               RelativePath=".\DOMCachingXMLObject.h"\r
-                               >\r
-                       </File>\r
-                       <File\r
                                RelativePath=".\ElementProxy.h"\r
                                >\r
                        </File>\r
                                        Name="impl"\r
                                        >\r
                                        <File\r
-                                               RelativePath=".\signature\impl\XMLSecSignature.h"\r
+                                               RelativePath=".\signature\impl\KeyInfoImpl.h"\r
+                                               >\r
+                                       </File>\r
+                                       <File\r
+                                               RelativePath=".\signature\impl\XMLSecSignatureImpl.h"\r
                                                >\r
                                        </File>\r
                                </Filter>\r
index fe8487b..248671d 100644 (file)
@@ -130,6 +130,30 @@ public:
         TSM_ASSERT_EQUALS("Child's schema type was not expected value", m_qtype, *(kids.back()->getSchemaType()));\r
     }\r
 \r
+    void testUnmarshallingWithClone() {\r
+        TS_TRACE("testUnmarshallingWithClone");\r
+\r
+        string path=data_path + "SimpleXMLObjectWithChildren.xml";\r
+        ifstream fs(path.c_str());\r
+        DOMDocument* doc=nonvalidatingPool->parse(fs);\r
+        TS_ASSERT(doc!=NULL);\r
+\r
+        const XMLObjectBuilder* b = XMLObjectBuilder::getBuilder(doc->getDocumentElement());\r
+        TS_ASSERT(b!=NULL);\r
+\r
+        auto_ptr<SimpleXMLObject> sxObject(\r
+            dynamic_cast<SimpleXMLObject*>(b->buildFromDocument(doc))\r
+            );\r
+        TS_ASSERT(sxObject.get()!=NULL);\r
+\r
+        sxObject->releaseThisAndChildrenDOM();\r
+        auto_ptr<SimpleXMLObject> clonedObject(sxObject->clone());\r
+\r
+        VectorOf(SimpleXMLObject) kids=clonedObject->getSimpleXMLObjects();\r
+        TSM_ASSERT_EQUALS("Number of child elements was not expected value", 3, kids.size());\r
+        TSM_ASSERT_EQUALS("Child's schema type was not expected value", m_qtype, *(kids.back()->getSchemaType()));\r
+    }\r
+\r
     void testUnmarshallingWithUnknownChild() {\r
         TS_TRACE("testUnmarshallingWithUnknownChild");\r
 \r
index f59c1a3..f74e9a5 100644 (file)
@@ -43,8 +43,21 @@ extern string data_path;
     #pragma warning( disable : 4250 4251 )
 #endif
 
-class SimpleXMLObject : public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller
+class SimpleXMLObject : public AbstractDOMCachingXMLObject, public AbstractXMLObjectMarshaller, public AbstractXMLObjectUnmarshaller
 {
+protected:
+    SimpleXMLObject(const SimpleXMLObject& src) : AbstractXMLObject(src), AbstractDOMCachingXMLObject(src),
+        m_id(XMLString::replicate(src.m_id)), m_value(XMLString::replicate(src.m_value)) {
+#ifndef XMLTOOLING_NO_XMLSEC
+        m_children.push_back(NULL);
+        m_signature=m_children.begin();
+#endif
+        VectorOf(SimpleXMLObject) mine=getSimpleXMLObjects();
+        for (vector<SimpleXMLObject*>::const_iterator i=src.m_simples.begin(); i!=src.m_simples.end(); i++) {
+            mine.push_back((*i) ? (*i)->clone() : NULL);
+        }
+    }
+
 public:
     static const XMLCh NAMESPACE[];
     static const XMLCh NAMESPACE_PREFIX[];
@@ -66,7 +79,18 @@ public:
         XMLString::release(&m_id);
         XMLString::release(&m_value);
     }
-    
+
+    SimpleXMLObject* clone() const {
+        auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
+        SimpleXMLObject* ret=dynamic_cast<SimpleXMLObject*>(domClone.get());
+        if (ret) {
+            domClone.release();
+            return ret;
+        }
+
+        return new SimpleXMLObject(*this);
+    }
+
     const XMLCh* getId() const { return m_id; }
     void setId(const XMLCh* id) { m_id=prepareForAssignment(m_id,id); }
 
@@ -86,23 +110,8 @@ public:
     VectorOf(SimpleXMLObject) getSimpleXMLObjects() {
         return VectorOf(SimpleXMLObject)(this, m_simples, &m_children, m_children.end());
     }
-    
-    SimpleXMLObject* clone() const {
-        auto_ptr<XMLObject> domClone(AbstractDOMCachingXMLObject::clone());
-        SimpleXMLObject* ret=dynamic_cast<SimpleXMLObject*>(domClone.get());
-        if (ret) {
-            domClone.release();
-            return ret;
-        }
-
-        ret=new SimpleXMLObject();
-        ret->m_namespaces=m_namespaces;
-        ret->setId(m_id);
-        ret->setValue(m_value);
-        xmltooling::clone(m_children, ret->m_children);
-        return ret;
-    }
 
+protected:
     void marshallAttributes(DOMElement* domElement) const {
         if(getId()) {
             domElement->setAttributeNS(NULL, SimpleXMLObject::ID_ATTRIB_NAME, getId());