First cut at signing support.
[shibboleth/cpp-xmltooling.git] / xmltooling / XMLObject.h
1 /*\r
2  *  Copyright 2001-2006 Internet2\r
3  * \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
7  *\r
8  *     http://www.apache.org/licenses/LICENSE-2.0\r
9  *\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
15  */\r
16 \r
17 /**\r
18  * @file XMLObject.h\r
19  * \r
20  * Abstract interface to objects that can be manipulated in and out of XML form. \r
21  */\r
22 \r
23 #if !defined(__xmltooling_xmlobj_h__)\r
24 #define __xmltooling_xmlobj_h__\r
25 \r
26 #include <set>\r
27 #include <list>\r
28 #include <xmltooling/QName.h>\r
29 #include <xmltooling/Namespace.h>\r
30 \r
31 namespace xmltooling {\r
32 \r
33     /**\r
34      * Object that represents an XML Element that has been unmarshalled into this C++ object.\r
35      */\r
36     class XMLTOOL_API XMLObject\r
37     {\r
38         MAKE_NONCOPYABLE(XMLObject);\r
39     public:\r
40         virtual ~XMLObject() {}\r
41         \r
42         /**\r
43          * Creates a copy of the object, along with all of its children.\r
44          * \r
45          * The new object tree will be completely distinct and independent of\r
46          * the original in all respects.\r
47          */\r
48         virtual XMLObject* clone() const=0;\r
49         \r
50         /**\r
51          * Gets the QName for this element.  This QName <strong>MUST</strong> \r
52          * contain the namespace URI, namespace prefix, and local element name.\r
53          * \r
54          * @return constant reference to the QName for this object\r
55          */\r
56         virtual const QName& getElementQName() const=0;\r
57         \r
58         /**\r
59          * Sets the namespace prefix for this element.\r
60          * \r
61          * @param prefix the prefix for this element\r
62          */\r
63         virtual void setElementNamespacePrefix(const XMLCh* prefix)=0;\r
64         \r
65         /**\r
66          * Gets the namespaces that are scoped to this element.\r
67          * \r
68          * The caller MUST NOT modify the set returned, but may use any\r
69          * non-modifying operations or algorithms on it. Iterators will\r
70          * remain valid unless the set member referenced is removed using\r
71          * the removeNamespace method.\r
72          * \r
73          * @return the namespaces that are scoped to this element\r
74          */\r
75         virtual const std::set<Namespace>& getNamespaces() const=0;\r
76         \r
77         /**\r
78          * Adds a namespace to the ones already scoped to this element\r
79          * \r
80          * @param ns the namespace to add\r
81          */\r
82         virtual void addNamespace(const Namespace& ns)=0;\r
83         \r
84         /**\r
85          * Removes a namespace from this element\r
86          * \r
87          * @param ns the namespace to remove\r
88          */\r
89         virtual void removeNamespace(const Namespace& ns)=0;\r
90         \r
91         /**\r
92          * Gets the XML schema type of this element.  This translates to contents the xsi:type\r
93          * attribute for the element.\r
94          * \r
95          * @return XML schema type of this element\r
96          */\r
97         virtual const QName* getSchemaType() const=0;\r
98         \r
99         /**\r
100          * Sets the XML schema type of this element.  This translates to contents the xsi:type\r
101          * attribute for the element.\r
102          * \r
103          * @param type XML schema type of this element\r
104          */\r
105         virtual void setSchemaType(const QName* type)=0;\r
106         \r
107         /**\r
108          * Checks to see if this object has a parent.\r
109          * \r
110          * @return true if the object has a parent, false if not\r
111          */\r
112         virtual bool hasParent() const=0;\r
113         \r
114         /**\r
115          * Gets the parent of this element or null if there is no parent.\r
116          * \r
117          * @return the parent of this element or null\r
118          */\r
119         virtual XMLObject* getParent() const=0;\r
120         \r
121         /**\r
122          * Sets the parent of this element.\r
123          * \r
124          * @param parent the parent of this element\r
125          */\r
126         virtual void setParent(XMLObject* parent)=0;\r
127         \r
128         /**\r
129          * Checks if this XMLObject has children.\r
130          * \r
131          * @return true if this XMLObject has children, false if not\r
132          */\r
133         virtual bool hasChildren() const=0;\r
134         \r
135         /**\r
136          * Returns an unmodifiable list of child objects in the order that they\r
137          * should appear in the serialized representation.\r
138          * \r
139          * The validity of the returned list is not maintained if any non-const\r
140          * operations are performed on the parent object. \r
141          * \r
142          * @return the list of children\r
143          */\r
144         virtual const std::list<XMLObject*>& getOrderedChildren() const=0;\r
145 \r
146     protected:\r
147         XMLObject() {}\r
148     };\r
149 \r
150 };\r
151 \r
152 #endif /* __xmltooling_xmlobj_h__ */\r