2 * Copyright 2001-2009 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/AbstractAttributeExtensibleXMLObject.h
20 * AbstractXMLObject mixin that implements AttributeExtensibleXMLObject
23 #ifndef __xmltooling_absattrextxmlobj_h__
24 #define __xmltooling_absattrextxmlobj_h__
26 #include <xmltooling/AbstractXMLObject.h>
27 #include <xmltooling/AttributeExtensibleXMLObject.h>
31 #if defined (_MSC_VER)
32 #pragma warning( push )
33 #pragma warning( disable : 4250 4251 )
36 namespace xmltooling {
39 * AbstractXMLObject mixin that implements AttributeExtensibleXMLObject.
40 * Inherit from this class to add support for attribute wildcarding.
42 class XMLTOOL_API AbstractAttributeExtensibleXMLObject
43 : public virtual AttributeExtensibleXMLObject, public virtual AbstractXMLObject
46 virtual ~AbstractAttributeExtensibleXMLObject();
48 const XMLCh* getAttribute(const QName& qualifiedName) const {
49 std::map<QName,XMLCh*>::const_iterator i=m_attributeMap.find(qualifiedName);
50 return (i==m_attributeMap.end()) ? NULL : i->second;
53 void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false);
55 const std::map<QName,XMLCh*>& getExtensionAttributes() const {
56 return m_attributeMap;
59 const XMLCh* getXMLID() const {
60 return (m_idAttribute == m_attributeMap.end()) ? NULL : m_idAttribute->second;
64 AbstractAttributeExtensibleXMLObject() {
65 m_idAttribute = m_attributeMap.end();
68 /** Copy constructor. */
69 AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src);
72 * Assists in the unmarshalling of extension attributes.
74 * @param attribute the DOM attribute node being unmarshalled
76 void unmarshallExtensionAttribute(const xercesc::DOMAttr* attribute);
79 * Assists in the marshalling of extension attributes.
81 * @param domElement the DOM element against which to marshall the attributes
83 void marshallExtensionAttributes(xercesc::DOMElement* domElement) const;
86 /** Map of arbitrary attributes. */
87 std::map<QName,XMLCh*> m_attributeMap;
89 /** Points to the last attribute designated as an XML ID. */
90 std::map<QName,XMLCh*>::const_iterator m_idAttribute;
95 #if defined (_MSC_VER)
96 #pragma warning( pop )
99 #endif /* __xmltooling_absattrextxmlobj_h__ */