2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
18 * @file AbstractXMLObject.h
\r
20 * An abstract implementation of XMLObject.
\r
23 #if !defined(__xmltooling_abstractxmlobj_h__)
\r
24 #define __xmltooling_abstractxmlobj_h__
\r
26 #include <xmltooling/XMLObject.h>
\r
28 #if defined (_MSC_VER)
\r
29 #pragma warning( push )
\r
30 #pragma warning( disable : 4250 4251 )
\r
33 namespace xmltooling {
\r
36 * An abstract implementation of XMLObject.
\r
38 class XMLTOOL_API AbstractXMLObject : public virtual XMLObject
\r
41 virtual ~AbstractXMLObject();
\r
44 * @see XMLObject::getElementQName()
\r
46 const QName& getElementQName() const {
\r
47 return m_elementQname;
\r
51 * @see XMLObject::getNamespaces()
\r
53 const std::set<Namespace>& getNamespaces() const {
\r
54 return m_namespaces;
\r
58 * @see XMLObject::addNamespace()
\r
60 void addNamespace(const Namespace& ns) const {
\r
61 if (ns.alwaysDeclare() || m_namespaces.find(ns)==m_namespaces.end()) {
\r
62 m_namespaces.insert(ns);
\r
67 * @see XMLObject::removeNamespace()
\r
69 void removeNamespace(const Namespace& ns) {
\r
70 m_namespaces.erase(ns);
\r
74 * @see XMLObject::getSchemaType()
\r
76 const QName* getSchemaType() const {
\r
81 * @see XMLObject::setSchemaType()
\r
83 void setSchemaType(const QName* type) {
\r
87 m_typeQname = new QName(*type);
\r
88 addNamespace(Namespace(type->getNamespaceURI(), type->getPrefix()));
\r
93 * @see XMLObject::hasParent()
\r
95 bool hasParent() const {
\r
96 return m_parent != NULL;
\r
100 * @see XMLObject::getParent()
\r
102 XMLObject* getParent() const {
\r
107 * @see XMLObject::setParent()
\r
109 void setParent(XMLObject* parent) {
\r
114 * @see XMLObject::hasChildren()
\r
116 bool hasChildren() const {
\r
117 return !m_children.empty();
\r
121 * @see XMLObject::getOrderedChildren()
\r
123 const std::list<XMLObject*>& getOrderedChildren() const {
\r
131 * @param namespaceURI the namespace the element is in
\r
132 * @param elementLocalName the local name of the XML element this Object represents
\r
133 * @param namespacePrefix the namespace prefix to use
\r
135 AbstractXMLObject(const XMLCh* namespaceURI=NULL, const XMLCh* elementLocalName=NULL, const XMLCh* namespacePrefix=NULL);
\r
138 * Underlying list of child objects.
\r
139 * Manages the lifetime of the children.
\r
141 std::list<XMLObject*> m_children;
\r
144 * Set of namespaces associated with the object.
\r
146 mutable std::set<Namespace> m_namespaces;
\r
154 XMLObject* m_parent;
\r
155 QName m_elementQname;
\r
156 QName* m_typeQname;
\r
161 #if defined (_MSC_VER)
\r
162 #pragma warning( pop )
\r
165 #endif /* __xmltooling_abstractxmlobj_h__ */
\r