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/AbstractAttributeExtensibleXMLObject.h
20 * AbstractXMLObject mixin that implements AttributeExtensibleXMLObject
23 #ifndef __xmltooling_absattrextxmlobj_h__
24 #define __xmltooling_absattrextxmlobj_h__
27 #include <xmltooling/AbstractXMLObject.h>
28 #include <xmltooling/AttributeExtensibleXMLObject.h>
30 #if defined (_MSC_VER)
31 #pragma warning( push )
32 #pragma warning( disable : 4250 4251 )
35 namespace xmltooling {
38 * AbstractXMLObject mixin that implements AttributeExtensibleXMLObject.
39 * Inherit from this class to add support for attribute wildcarding.
41 class XMLTOOL_API AbstractAttributeExtensibleXMLObject
42 : public virtual AttributeExtensibleXMLObject, public virtual AbstractXMLObject
45 virtual ~AbstractAttributeExtensibleXMLObject();
47 const XMLCh* getAttribute(const QName& qualifiedName) const {
48 std::map<QName,XMLCh*>::const_iterator i=m_attributeMap.find(qualifiedName);
49 return (i==m_attributeMap.end()) ? NULL : i->second;
52 void setAttribute(const QName& qualifiedName, const XMLCh* value, bool ID=false);
54 const std::map<QName,XMLCh*>& getExtensionAttributes() const {
55 return m_attributeMap;
58 const XMLCh* getXMLID() const {
59 return (m_idAttribute == m_attributeMap.end()) ? NULL : m_idAttribute->second;
63 AbstractAttributeExtensibleXMLObject() {
64 m_idAttribute = m_attributeMap.end();
67 /** Copy constructor. */
68 AbstractAttributeExtensibleXMLObject(const AbstractAttributeExtensibleXMLObject& src);
71 * Assists in the unmarshalling of extension attributes.
73 * @param attribute the DOM attribute node being unmarshalled
75 void unmarshallExtensionAttribute(const xercesc::DOMAttr* attribute);
78 * Assists in the marshalling of extension attributes.
80 * @param domElement the DOM element against which to marshall the attributes
82 void marshallExtensionAttributes(xercesc::DOMElement* domElement) const;
85 /** Map of arbitrary attributes. */
86 std::map<QName,XMLCh*> m_attributeMap;
88 /** Points to the last attribute designated as an XML ID. */
89 std::map<QName,XMLCh*>::const_iterator m_idAttribute;
94 #if defined (_MSC_VER)
95 #pragma warning( pop )
98 #endif /* __xmltooling_absattrextxmlobj_h__ */