2 * Copyright 2001-2007 Internet2
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * @file xmltooling/AttributeExtensibleXMLObject.h
20 * An XMLObject that supports arbitrary attributes
23 #ifndef __xmltooling_attrextxmlobj_h__
24 #define __xmltooling_attrextxmlobj_h__
26 #include <xmltooling/XMLObject.h>
28 #if defined (_MSC_VER)
29 #pragma warning( push )
30 #pragma warning( disable : 4250 4251 )
33 namespace xmltooling {
36 * An XMLObject that supports arbitrary attributes.
38 class XMLTOOL_API AttributeExtensibleXMLObject : public virtual XMLObject
41 AttributeExtensibleXMLObject() {}
44 virtual ~AttributeExtensibleXMLObject() {}
47 * Gets the value of an XML attribute of the object.
49 * @param qualifiedName qualified name of the attribute
50 * @return the attribute value, or NULL
52 virtual const XMLCh* getAttribute(const QName& qualifiedName) const=0;
55 * Sets (or clears) an XML attribute of the object.
57 * @param qualifiedName qualified name of the attribute
58 * @param value value to set, or NULL to clear
59 * @param ID true iff the attribute is an XML ID
61 virtual void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false)=0;
64 * Gets an immutable map of the extended XML attributes of the object.
66 * This set is not guaranteed to (and generally will not) include
67 * attributes defined directly on the object's "type".
69 virtual const std::map<QName,XMLCh*>& getExtensionAttributes() const=0;
72 * Gets an immutable list of all the ID attributes currently registered.
74 * @return list of all the ID attributes currently registered
76 static const std::set<QName>& getRegisteredIDAttributes() {
77 return m_idAttributeSet;
81 * Tests whether an XML attribute is registered as an XML ID.
83 * @return true iff the attribute name matches a registered XML ID attribute
85 static bool isRegisteredIDAttribute(const QName& name) {
86 return m_idAttributeSet.find(name)!=m_idAttributeSet.end();
90 * Registers a new attribute as being of XML ID type.
92 * @param name the qualified attribute name
94 static void registerIDAttribute(const QName& name) {
95 m_idAttributeSet.insert(name);
99 * Deregisters an ID attribute.
101 * @param name the qualified attribute name
103 static void deregisterIDAttribute(const QName& name) {
104 m_idAttributeSet.erase(name);
108 * Deregisters all ID attributes.
110 static void deregisterIDAttributes() {
111 m_idAttributeSet.clear();
115 /** Set of attributes to treat as XML IDs. */
116 static std::set<QName> m_idAttributeSet;
121 #if defined (_MSC_VER)
122 #pragma warning( pop )
125 #endif /* __xmltooling_attrextxmlobj_h__ */