Distinguish between visibly used and unused namespaces.
[shibboleth/cpp-xmltooling.git] / xmltooling / Namespace.h
index 9a1b55a..8ac6382 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.
@@ -15,7 +15,7 @@
  */
 
 /**
- * @file Namespace.h
+ * @file xmltooling/Namespace.h
  * 
  * Representing XML namespace attributes 
  */
@@ -43,23 +43,12 @@ namespace xmltooling {
          * @param uri               namespace URI
          * @param prefix            namespace prefix (without the colon)
          * @param alwaysDeclare     true iff the namespace should always be declared regardless of in-scope declarations
+         * @param visiblyUsed       true iff the namespace is visibly used by an XMLObject its attached to
          */
-        Namespace(const XMLCh* uri=NULL, const XMLCh* prefix=NULL, bool alwaysDeclare=false);
+        Namespace(const XMLCh* uri=NULL, const XMLCh* prefix=NULL, bool alwaysDeclare=false, bool visiblyUsed=true);
         
         ~Namespace();
-#ifndef HAVE_GOOD_STL
-        /**
-         * Deep copy constructor
-         */
-        Namespace(const Namespace& src);
-
-        /**
-         * Deep assignment operator
-         */
-        Namespace& operator=(const Namespace& src);
-#endif
         
-#ifdef HAVE_GOOD_STL
         /**
          * Returns the namespace prefix
          * @return  Null-terminated Unicode string containing the prefix, without the colon
@@ -71,25 +60,18 @@ namespace xmltooling {
          * @return  Null-terminated Unicode string containing the URI
          */
         const XMLCh* getNamespaceURI() const { return m_uri.c_str(); }
-#else
-        /**
-         * Returns the namespace prefix
-         * @return  Null-terminated Unicode string containing the prefix, without the colon
-         */
-        const XMLCh* getNamespacePrefix() const { return m_prefix; }
 
         /**
-         * Returns the namespace URI
-         * @return  Null-terminated Unicode string containing the URI
+         * Returns true iff the namespace should always be declared regardless of in-scope declarations
+         * @return the alwaysDeclared setting
          */
-        const XMLCh* getNamespaceURI() const { return m_uri; }
-#endif
+        const bool alwaysDeclare() const { return m_pinned; }
 
         /**
-         * Returns true iff the namespace should always be declared regardless of in-scope declarations
-         * @return the alwaysDeclared setting
+         * Returns true iff the namespace is visibly used by an XMLObject its attached to
+         * @return the visiblyUsed setting
          */
-        const bool alwaysDeclare() const { return m_pinned; } 
+        const bool visiblyUsed() const { return m_visiblyUsed; }
 
         /**
          * Sets the namespace prefix
@@ -109,15 +91,16 @@ namespace xmltooling {
          */
         void setAlwaysDeclare(bool alwaysDeclare) { m_pinned = alwaysDeclare; } 
         
+        /**
+         * Sets the visiblyUsed property
+         * @param visiblyUsed     true iff the namespace is visibly used by an XMLObject its attached to
+         */
+        void setVisiblyUsed(bool visiblyUsed) { m_visiblyUsed = visiblyUsed; }
+
     private:
-        bool m_pinned;
-#ifdef HAVE_GOOD_STL
+        bool m_pinned,m_visiblyUsed;
         xstring m_uri;
         xstring m_prefix;
-#else
-        XMLCh* m_uri;
-        XMLCh* m_prefix;
-#endif
     };
 
 #if defined (_MSC_VER)
@@ -135,14 +118,12 @@ namespace xmltooling {
      */
     extern XMLTOOL_API bool operator<(const Namespace& op1, const Namespace& op2);
 
-#ifndef HAVE_GOOD_STL
     /**
      * Returns true iff op1's namespace and prefix are equal to op2's namespace and prefix.
      * @param op1   First namspace to compare
      * @param op2   Second namespace to compare
      */
     extern XMLTOOL_API bool operator==(const Namespace& op1, const Namespace& op2);
-#endif
 
 };