2 * Licensed to the University Corporation for Advanced Internet
3 * Development, Inc. (UCAID) under one or more contributor license
4 * agreements. See the NOTICE file distributed with this work for
5 * additional information regarding copyright ownership.
7 * UCAID licenses this file to you under the Apache License,
8 * Version 2.0 (the "License"); you may not use this file except
9 * in compliance with the License. You may obtain a copy of the
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
17 * either express or implied. See the License for the specific
18 * language governing permissions and limitations under the License.
22 * @file xmltooling/AttributeExtensibleXMLObject.h
24 * An XMLObject that supports arbitrary attributes
27 #ifndef __xmltooling_attrextxmlobj_h__
28 #define __xmltooling_attrextxmlobj_h__
30 #include <xmltooling/XMLObject.h>
32 #if defined (_MSC_VER)
33 #pragma warning( push )
34 #pragma warning( disable : 4250 4251 )
37 namespace xmltooling {
40 * An XMLObject that supports arbitrary attributes.
42 class XMLTOOL_API AttributeExtensibleXMLObject : public virtual XMLObject
45 AttributeExtensibleXMLObject();
48 virtual ~AttributeExtensibleXMLObject();
51 * Gets the value of an XML attribute of the object.
53 * @param qualifiedName qualified name of the attribute
54 * @return the attribute value, or nullptr
56 virtual const XMLCh* getAttribute(const QName& qualifiedName) const=0;
59 * Sets (or clears) an XML attribute of the object.
61 * @param qualifiedName qualified name of the attribute
62 * @param value value to set, or nullptr to clear
63 * @param ID true iff the attribute is an XML ID
65 virtual void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false)=0;
68 * Sets a QName-valued XML attribute of the object.
70 * @param qualifiedName qualified name of the attribute
71 * @param value value to set
73 virtual void setAttribute(const QName& qualifiedName, const QName& value);
76 * Gets an immutable map of the extended XML attributes of the object.
78 * This set is not guaranteed to (and generally will not) include
79 * attributes defined directly on the object's "type".
81 virtual const std::map<QName,XMLCh*>& getExtensionAttributes() const=0;
84 * Gets an immutable list of all the ID attributes currently registered.
86 * @return list of all the ID attributes currently registered
88 static const std::set<QName>& getRegisteredIDAttributes();
91 * Tests whether an XML attribute is registered as an XML ID.
93 * @return true iff the attribute name matches a registered XML ID attribute
95 static bool isRegisteredIDAttribute(const QName& name);
98 * Registers a new attribute as being of XML ID type.
100 * @param name the qualified attribute name
102 static void registerIDAttribute(const QName& name);
105 * Deregisters an ID attribute.
107 * @param name the qualified attribute name
109 static void deregisterIDAttribute(const QName& name);
112 * Deregisters all ID attributes.
114 static void deregisterIDAttributes();
117 /** Set of attributes to treat as XML IDs. */
118 static std::set<QName> m_idAttributeSet;
123 #if defined (_MSC_VER)
124 #pragma warning( pop )
127 #endif /* __xmltooling_attrextxmlobj_h__ */