More boostisms
[shibboleth/cpp-xmltooling.git] / xmltooling / AttributeExtensibleXMLObject.h
1 /**
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.
6  *
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
10  * License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  */
20
21 /**
22  * @file xmltooling/AttributeExtensibleXMLObject.h
23  * 
24  * An XMLObject that supports arbitrary attributes 
25  */
26
27 #ifndef __xmltooling_attrextxmlobj_h__
28 #define __xmltooling_attrextxmlobj_h__
29
30 #include <xmltooling/XMLObject.h>
31
32 #if defined (_MSC_VER)
33     #pragma warning( push )
34     #pragma warning( disable : 4250 4251 )
35 #endif
36
37 namespace xmltooling {
38
39     /**
40      * An XMLObject that supports arbitrary attributes.
41      */
42     class XMLTOOL_API AttributeExtensibleXMLObject : public virtual XMLObject
43     {
44     protected:
45         AttributeExtensibleXMLObject();
46         
47     public:
48         virtual ~AttributeExtensibleXMLObject();
49         
50         /**
51          * Gets the value of an XML attribute of the object.
52          * 
53          * @param   qualifiedName   qualified name of the attribute   
54          * @return the attribute value, or nullptr
55          */
56         virtual const XMLCh* getAttribute(const QName& qualifiedName) const=0;
57         
58         /**
59          * Sets (or clears) an XML attribute of the object.
60          * 
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
64          */
65         virtual void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false)=0;
66
67         /**
68          * Sets a QName-valued XML attribute of the object.
69          * 
70          * @param qualifiedName qualified name of the attribute   
71          * @param value         value to set
72          */
73         virtual void setAttribute(const QName& qualifiedName, const QName& value);
74
75         /**
76          * Gets an immutable map of the extended XML attributes of the object.
77          * 
78          * This set is not guaranteed to (and generally will not) include
79          * attributes defined directly on the object's "type".
80          */
81         virtual const std::map<QName,XMLCh*>& getExtensionAttributes() const=0;
82         
83         /**
84          * Gets an immutable list of all the ID attributes currently registered.
85          * 
86          * @return list of all the ID attributes currently registered
87          */
88         static const std::set<QName>& getRegisteredIDAttributes();
89         
90         /**
91          * Tests whether an XML attribute is registered as an XML ID.
92          * 
93          * @return true iff the attribute name matches a registered XML ID attribute 
94          */
95         static bool isRegisteredIDAttribute(const QName& name);
96     
97         /**
98          * Registers a new attribute as being of XML ID type.
99          * 
100          * @param name the qualified attribute name
101          */
102         static void registerIDAttribute(const QName& name);
103
104         /**
105          * Deregisters an ID attribute.
106          * 
107          * @param name the qualified attribute name
108          */
109         static void deregisterIDAttribute(const QName& name);
110         
111         /**
112          * Deregisters all ID attributes.
113          */
114         static void deregisterIDAttributes();
115
116     private:
117         /** Set of attributes to treat as XML IDs. */
118         static std::set<QName> m_idAttributeSet;
119     };
120     
121 };
122
123 #if defined (_MSC_VER)
124     #pragma warning( pop )
125 #endif
126
127 #endif /* __xmltooling_attrextxmlobj_h__ */