Distinguish between visibly used and unused namespaces.
[shibboleth/cpp-xmltooling.git] / xmltooling / Namespace.cpp
index 57ca9d6..179579b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  Copyright 2001-2007 Internet2
+ *  Copyright 2001-2010 Internet2
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -27,76 +27,33 @@ using namespace xmltooling;
 
 using xercesc::XMLString;
 
-Namespace::Namespace(const XMLCh* uri, const XMLCh* prefix, bool alwaysDeclare) : m_pinned(alwaysDeclare)
+Namespace::Namespace(const XMLCh* uri, const XMLCh* prefix, bool alwaysDeclare, bool visiblyUsed)
+    : m_pinned(alwaysDeclare), m_visiblyUsed(visiblyUsed)
 {
-#ifndef HAVE_GOOD_STL
-    m_uri=m_prefix=NULL;
-#endif
     setNamespaceURI(uri);
     setNamespacePrefix(prefix);
 }
 
 Namespace::~Namespace()
 {
-#ifndef HAVE_GOOD_STL
-    XMLString::release(&m_uri);
-    XMLString::release(&m_prefix);
-#endif
 }
 
 void Namespace::setNamespacePrefix(const XMLCh* prefix)
 {
-#ifdef HAVE_GOOD_STL
     if (prefix)
         m_prefix=prefix;
     else
         m_prefix.erase();
-#else
-    if (m_prefix)
-        XMLString::release(&m_prefix);
-    m_prefix=XMLString::replicate(prefix);
-#endif
 }
 
 void Namespace::setNamespaceURI(const XMLCh* uri)
 {
-#ifdef HAVE_GOOD_STL
     if (uri)
         m_uri=uri;
     else
         m_uri.erase();
-#else
-    if (m_uri)
-        XMLString::release(&m_uri);
-    m_uri=XMLString::replicate(uri);
-#endif
 }
 
-#ifndef HAVE_GOOD_STL
-Namespace::Namespace(const Namespace& src)
-{
-    m_uri=XMLString::replicate(src.getNamespaceURI());
-    m_prefix=XMLString::replicate(src.getNamespacePrefix());
-    m_pinned=src.alwaysDeclare();
-}
-
-Namespace& Namespace::operator=(const Namespace& src)
-{
-    m_uri=XMLString::replicate(src.getNamespaceURI());
-    m_prefix=XMLString::replicate(src.getNamespacePrefix());
-    m_pinned=src.alwaysDeclare();
-    return *this;
-}
-
-bool xmltooling::operator==(const Namespace& op1, const Namespace& op2)
-{
-    if (&op1 == &op2)
-        return true;
-    return (XMLString::equals(op1.getNamespaceURI(),op2.getNamespaceURI()) &&
-            XMLString::equals(op1.getNamespacePrefix(),op2.getNamespacePrefix()));
-}
-#endif
-
 bool xmltooling::operator<(const Namespace& op1, const Namespace& op2)
 {
     int i=XMLString::compareString(op1.getNamespaceURI(),op2.getNamespaceURI());
@@ -107,3 +64,9 @@ bool xmltooling::operator<(const Namespace& op1, const Namespace& op2)
     else
         return false;
 }
+
+bool xmltooling::operator==(const Namespace& op1, const Namespace& op2)
+{
+    return (XMLString::equals(op1.getNamespacePrefix(), op2.getNamespacePrefix()) &&
+            XMLString::equals(op1.getNamespaceURI(), op2.getNamespaceURI()));
+}