0429461f5a59221efbdbc8e226bbd32e9114cc77
[shibboleth/cpp-xmltooling.git] / xmltooling / AbstractAttributeExtensibleXMLObject.h
1 /*
2  *  Copyright 2001-2009 Internet2
3  * 
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 /**
18  * @file xmltooling/AbstractAttributeExtensibleXMLObject.h
19  * 
20  * AbstractXMLObject mixin that implements AttributeExtensibleXMLObject
21  */
22
23 #ifndef __xmltooling_absattrextxmlobj_h__
24 #define __xmltooling_absattrextxmlobj_h__
25
26 #include <xmltooling/AbstractXMLObject.h>
27 #include <xmltooling/AttributeExtensibleXMLObject.h>
28
29 #include <map>
30
31 #if defined (_MSC_VER)
32     #pragma warning( push )
33     #pragma warning( disable : 4250 4251 )
34 #endif
35
36 namespace xmltooling {
37
38     /**
39      * AbstractXMLObject mixin that implements AttributeExtensibleXMLObject.
40      * Inherit from this class to add support for attribute wildcarding.
41      */
42     class XMLTOOL_API AbstractAttributeExtensibleXMLObject
43         : public virtual AttributeExtensibleXMLObject, public virtual AbstractXMLObject
44     {
45     public:
46         virtual ~AbstractAttributeExtensibleXMLObject();
47         
48         // Virtual function overrides.
49         const XMLCh* getAttribute(const QName& qualifiedName) const;
50         void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false);
51         const std::map<QName,XMLCh*>& getExtensionAttributes() const;
52         const XMLCh* getXMLID() const;
53     
54      protected:
55         AbstractAttributeExtensibleXMLObject();
56
57         /** Copy constructor. */
58         AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src);
59
60         /**
61          * Assists in the unmarshalling of extension attributes.
62          * 
63          * @param attribute the DOM attribute node being unmarshalled
64          */
65         void unmarshallExtensionAttribute(const xercesc::DOMAttr* attribute);
66
67         /**
68          * Assists in the marshalling of extension attributes.
69          * 
70          * @param domElement    the DOM element against which to marshall the attributes
71          */
72         void marshallExtensionAttributes(xercesc::DOMElement* domElement) const;
73     
74     private:
75         /** Map of arbitrary attributes. */
76         std::map<QName,XMLCh*> m_attributeMap;
77         
78         /** Points to the last attribute designated as an XML ID. */
79         std::map<QName,XMLCh*>::const_iterator m_idAttribute;
80     };
81     
82 };
83
84 #if defined (_MSC_VER)
85     #pragma warning( pop )
86 #endif
87
88 #endif /* __xmltooling_absattrextxmlobj_h__ */