Add parametrized messaging and serialization to exceptions.
[shibboleth/cpp-xmltooling.git] / xmltooling / XMLToolingConfig.cpp
index 9bd8b3e..a8680be 100644 (file)
@@ -21,6 +21,7 @@
  */
 
 #include "internal.h"
+#include "exceptions.h"
 #include "XMLToolingConfig.h"
 #include "impl/UnknownElement.h"
 #include "signature/impl/XMLSecSignature.h"
@@ -44,6 +45,15 @@ using namespace log4cpp;
 using namespace xmltooling;
 using namespace std;
 
+DECL_EXCEPTION_FACTORY(XMLParserException);
+DECL_EXCEPTION_FACTORY(XMLObjectException);
+DECL_EXCEPTION_FACTORY(MarshallingException);
+DECL_EXCEPTION_FACTORY(UnmarshallingException);
+DECL_EXCEPTION_FACTORY(UnknownElementException);
+DECL_EXCEPTION_FACTORY(UnknownAttributeException);
+DECL_EXCEPTION_FACTORY(ValidationException);
+DECL_EXCEPTION_FACTORY(SignatureException);
+
 namespace {
    XMLToolingInternalConfig g_config;
 }
@@ -140,14 +150,17 @@ bool XMLToolingInternalConfig::init()
 
         // default registrations
         XMLObjectBuilder::registerDefaultBuilder(new UnknownElementBuilder());
-        Marshaller::registerDefaultMarshaller(new UnknownElementMarshaller());
-        Unmarshaller::registerDefaultUnmarshaller(new UnknownElementUnmarshaller());
 #ifndef XMLTOOLING_NO_XMLSEC
-        QName dsig(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME);
-        XMLObjectBuilder::registerBuilder(dsig,new XMLSecSignatureBuilder());
-        Marshaller::registerMarshaller(dsig,new XMLSecSignatureMarshaller());
-        Unmarshaller::registerUnmarshaller(dsig,new XMLSecSignatureUnmarshaller());
+        XMLObjectBuilder::registerBuilder(QName(XMLConstants::XMLSIG_NS,Signature::LOCAL_NAME),new XMLSecSignatureBuilder());
 #endif
+        REGISTER_EXCEPTION_FACTORY(XMLParserException);
+        REGISTER_EXCEPTION_FACTORY(XMLObjectException);
+        REGISTER_EXCEPTION_FACTORY(MarshallingException);
+        REGISTER_EXCEPTION_FACTORY(UnmarshallingException);
+        REGISTER_EXCEPTION_FACTORY(UnknownElementException);
+        REGISTER_EXCEPTION_FACTORY(UnknownAttributeException);
+        REGISTER_EXCEPTION_FACTORY(ValidationException);
+        REGISTER_EXCEPTION_FACTORY(SignatureException);
     }
     catch (const xercesc::XMLException&) {
         log.fatal("caught exception while initializing Xerces");
@@ -161,8 +174,6 @@ bool XMLToolingInternalConfig::init()
 void XMLToolingInternalConfig::term()
 {
     XMLObjectBuilder::destroyBuilders();
-    Marshaller::destroyMarshallers();
-    Unmarshaller::destroyUnmarshallers();
 
     for (vector<void*>::reverse_iterator i=m_libhandles.rbegin(); i!=m_libhandles.rend(); i++) {
 #if defined(WIN32)