Added built-in ID attribute support to base classes.
[shibboleth/cpp-xmltooling.git] / xmltooling / AttributeExtensibleXMLObject.h
index 2d1472f..8ba087b 100644 (file)
 \r
 using namespace xercesc;\r
 \r
+#if defined (_MSC_VER)\r
+    #pragma warning( push )\r
+    #pragma warning( disable : 4250 4251 )\r
+#endif\r
+\r
 namespace xmltooling {\r
 \r
     /**\r
@@ -34,27 +39,80 @@ namespace xmltooling {
      */\r
     class XMLTOOL_API AttributeExtensibleXMLObject : public virtual XMLObject\r
     {\r
-    public:\r
+    protected:\r
         AttributeExtensibleXMLObject() {}\r
+        \r
+    public:\r
         virtual ~AttributeExtensibleXMLObject() {}\r
         \r
         /**\r
-         * Gets the value of an XML attribute of the object\r
+         * Gets the value of an XML attribute of the object.\r
          * \r
          * @param   qualifiedName   qualified name of the attribute   \r
          * @return the attribute value, or NULL\r
          */\r
-        virtual const XMLCh* getAttribute(QName& qualifiedName) const=0;\r
+        virtual const XMLCh* getAttribute(const QName& qualifiedName) const=0;\r
         \r
         /**\r
-         * Sets (or clears) an XML attribute of the object \r
+         * Sets (or clears) an XML attribute of the object.\r
          * \r
          * @param qualifiedName qualified name of the attribute   \r
          * @param value         value to set, or NULL to clear\r
+         * @param ID            true iff the attribute is an XML ID\r
          */\r
-        virtual void setAttribute(QName& qualifiedName, const XMLCh* value)=0;\r
+        virtual void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false)=0;\r
+\r
+        /**\r
+         * Gets an immutable map of the extended XML attributes of the object.\r
+         * \r
+         * This set is not guaranteed to (and generally will not) include\r
+         * attributes defined directly on the object's "type".\r
+         */\r
+        virtual const std::map<QName,XMLCh*>& getExtensionAttributes() const=0;\r
+        \r
+        /**\r
+         * Gets an immutable list of all the ID attributes currently registered.\r
+         * \r
+         * @return list of all the ID attributes currently registered\r
+         */\r
+        static const std::set<QName>& getRegisteredIDAttributes() {\r
+            return m_idAttributeSet;\r
+        }\r
+    \r
+        /**\r
+         * Registers a new attribute as being of XML ID type.\r
+         * \r
+         * @param name the qualified attribute name\r
+         */\r
+        static void registerIDAttribute(const QName& name) {\r
+            m_idAttributeSet.insert(name);\r
+        }\r
+\r
+        /**\r
+         * Deregisters an ID attribute.\r
+         * \r
+         * @param name the qualified attribute name\r
+         */\r
+        static void deregisterIDAttribute(const QName& name) {\r
+            m_idAttributeSet.erase(name);\r
+        }\r
+        \r
+        /**\r
+         * Deregisters all ID attributes.\r
+         */\r
+        static void deregisterIDAttributes() {\r
+            m_idAttributeSet.clear();\r
+        }\r
+\r
+    private:\r
+        /** Set of attributes to treat as XML IDs. */\r
+        static std::set<QName> m_idAttributeSet;\r
     };\r
     \r
 };\r
 \r
+#if defined (_MSC_VER)\r
+    #pragma warning( pop )\r
+#endif\r
+\r
 #endif /* __xmltooling_attrextxmlobj_h__ */\r