1 | #ifndef DOMException_HEADER_GUARD_ |
---|
2 | #define DOMException_HEADER_GUARD_ |
---|
3 | |
---|
4 | /* |
---|
5 | * Licensed to the Apache Software Foundation (ASF) under one or more |
---|
6 | * contributor license agreements. See the NOTICE file distributed with |
---|
7 | * this work for additional information regarding copyright ownership. |
---|
8 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
---|
9 | * (the "License"); you may not use this file except in compliance with |
---|
10 | * the License. You may obtain a copy of the License at |
---|
11 | * |
---|
12 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
13 | * |
---|
14 | * Unless required by applicable law or agreed to in writing, software |
---|
15 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
17 | * See the License for the specific language governing permissions and |
---|
18 | * limitations under the License. |
---|
19 | */ |
---|
20 | |
---|
21 | /* |
---|
22 | * $Id: DOMException.hpp 568078 2007-08-21 11:43:25Z amassari $ |
---|
23 | */ |
---|
24 | |
---|
25 | #include <xercesc/util/XercesDefs.hpp> |
---|
26 | #include <xercesc/util/PlatformUtils.hpp> |
---|
27 | |
---|
28 | XERCES_CPP_NAMESPACE_BEGIN |
---|
29 | |
---|
30 | |
---|
31 | /** |
---|
32 | * DOM operations only raise exceptions in "exceptional" circumstances, i.e., |
---|
33 | * when an operation is impossible to perform (either for logical reasons, |
---|
34 | * because data is lost, or because the implementation has become unstable). |
---|
35 | * In general, DOM methods return specific error values in ordinary |
---|
36 | * processing situations, such as out-of-bound errors when using |
---|
37 | * <code>DOMNodeList</code>. |
---|
38 | * <p>Implementations should raise other exceptions under other circumstances. |
---|
39 | * For example, implementations should raise an implementation-dependent |
---|
40 | * exception if a <code>null</code> argument is passed. |
---|
41 | * <p>Some languages and object systems do not support the concept of |
---|
42 | * exceptions. For such systems, error conditions may be indicated using |
---|
43 | * native error reporting mechanisms. For some bindings, for example, |
---|
44 | * methods may return error codes similar to those listed in the |
---|
45 | * corresponding method descriptions. |
---|
46 | * <p>See also the <a href='http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113'>Document Object Model (DOM) Level 2 Core Specification</a>. |
---|
47 | * @since DOM Level 1 |
---|
48 | */ |
---|
49 | |
---|
50 | class MemoryManager; |
---|
51 | |
---|
52 | class CDOM_EXPORT DOMException { |
---|
53 | public: |
---|
54 | // ----------------------------------------------------------------------- |
---|
55 | // Constructors |
---|
56 | // ----------------------------------------------------------------------- |
---|
57 | /** @name Constructors */ |
---|
58 | //@{ |
---|
59 | /** |
---|
60 | * Default constructor for DOMException. |
---|
61 | * |
---|
62 | */ |
---|
63 | DOMException(); |
---|
64 | |
---|
65 | /** |
---|
66 | * Constructor which takes an error code and a message. |
---|
67 | * |
---|
68 | * @param code The error code which indicates the exception |
---|
69 | * @param message The string containing the error message |
---|
70 | * @param memoryManager The memory manager used to (de)allocate memory |
---|
71 | */ |
---|
72 | DOMException( |
---|
73 | short code |
---|
74 | , const XMLCh* message |
---|
75 | , MemoryManager* const memoryManager = XMLPlatformUtils::fgMemoryManager |
---|
76 | ); |
---|
77 | |
---|
78 | /** |
---|
79 | * Copy constructor. |
---|
80 | * |
---|
81 | * @param other The object to be copied. |
---|
82 | */ |
---|
83 | DOMException(const DOMException &other); |
---|
84 | |
---|
85 | //@} |
---|
86 | |
---|
87 | // ----------------------------------------------------------------------- |
---|
88 | // Destructors |
---|
89 | // ----------------------------------------------------------------------- |
---|
90 | /** @name Destructor. */ |
---|
91 | //@{ |
---|
92 | /** |
---|
93 | * Destructor for DOMException. |
---|
94 | * |
---|
95 | */ |
---|
96 | virtual ~DOMException(); |
---|
97 | //@} |
---|
98 | |
---|
99 | public: |
---|
100 | // ----------------------------------------------------------------------- |
---|
101 | // Class Types |
---|
102 | // ----------------------------------------------------------------------- |
---|
103 | /** @name Public Contants */ |
---|
104 | //@{ |
---|
105 | /** |
---|
106 | * ExceptionCode |
---|
107 | * |
---|
108 | * <p><code>INDEX_SIZE_ERR:</code> |
---|
109 | * If index or size is negative, or greater than the allowed value.</p> |
---|
110 | * |
---|
111 | * <p><code>DOMSTRING_SIZE_ERR:</code> |
---|
112 | * If the specified range of text does not fit into a DOMString.</p> |
---|
113 | * |
---|
114 | * <p><code>HIERARCHY_REQUEST_ERR:</code> |
---|
115 | * If any node is inserted somewhere it doesn't belong.</p> |
---|
116 | * |
---|
117 | * <p><code>WRONG_DOCUMENT_ERR:</code> |
---|
118 | * If a node is used in a different document than the one that created it |
---|
119 | * (that doesn't support it).</p> |
---|
120 | * |
---|
121 | * <p><code>INVALID_CHARACTER_ERR:</code> |
---|
122 | * If an invalid or illegal character is specified, such as in a name. See |
---|
123 | * production 2 in the XML specification for the definition of a legal |
---|
124 | * character, and production 5 for the definition of a legal name |
---|
125 | * character.</p> |
---|
126 | * |
---|
127 | * <p><code>NO_DATA_ALLOWED_ERR:</code> |
---|
128 | * If data is specified for a node which does not support data.</p> |
---|
129 | * |
---|
130 | * <p><code>NO_MODIFICATION_ALLOWED_ERR:</code> |
---|
131 | * If an attempt is made to modify an object where modifications are not |
---|
132 | * allowed.</p> |
---|
133 | * |
---|
134 | * <p><code>NOT_FOUND_ERR:</code> |
---|
135 | * If an attempt is made to reference a node in a context where it does |
---|
136 | * not exist.</p> |
---|
137 | * |
---|
138 | * <p><code>NOT_SUPPORTED_ERR:</code> |
---|
139 | * If the implementation does not support the requested type of object or |
---|
140 | * operation.</p> |
---|
141 | * |
---|
142 | * <p><code>INUSE_ATTRIBUTE_ERR:</code> |
---|
143 | * If an attempt is made to add an attribute that is already in use |
---|
144 | * elsewhere.</p> |
---|
145 | * |
---|
146 | * The above are since DOM Level 1 |
---|
147 | * @since DOM Level 1 |
---|
148 | * |
---|
149 | * <p><code>INVALID_STATE_ERR:</code> |
---|
150 | * If an attempt is made to use an object that is not, or is no longer, |
---|
151 | * usable.</p> |
---|
152 | * |
---|
153 | * <p><code>SYNTAX_ERR:</code> |
---|
154 | * If an invalid or illegal string is specified.</p> |
---|
155 | * |
---|
156 | * <p><code>INVALID_MODIFICATION_ERR:</code> |
---|
157 | * If an attempt is made to modify the type of the underlying object.</p> |
---|
158 | * |
---|
159 | * <p><code>NAMESPACE_ERR:</code> |
---|
160 | * If an attempt is made to create or change an object in a way which is |
---|
161 | * incorrect with regard to namespaces.</p> |
---|
162 | * |
---|
163 | * <p><code>INVALID_ACCESS_ERR:</code> |
---|
164 | * If a parameter or an operation is not supported by the underlying |
---|
165 | * object. |
---|
166 | * |
---|
167 | * The above are since DOM Level 2 |
---|
168 | * @since DOM Level 2 |
---|
169 | * |
---|
170 | * <p><code>VALIDATION_ERR:</code> |
---|
171 | * If a call to a method such as <code>insertBefore</code> or |
---|
172 | * <code>removeChild</code> would make the <code>Node</code> invalid |
---|
173 | * with respect to "partial validity", this exception would be raised |
---|
174 | * and the operation would not be done. |
---|
175 | * |
---|
176 | * The above is since DOM Level 2 |
---|
177 | * @since DOM Level 3 |
---|
178 | */ |
---|
179 | enum ExceptionCode { |
---|
180 | INDEX_SIZE_ERR = 1, |
---|
181 | DOMSTRING_SIZE_ERR = 2, |
---|
182 | HIERARCHY_REQUEST_ERR = 3, |
---|
183 | WRONG_DOCUMENT_ERR = 4, |
---|
184 | INVALID_CHARACTER_ERR = 5, |
---|
185 | NO_DATA_ALLOWED_ERR = 6, |
---|
186 | NO_MODIFICATION_ALLOWED_ERR = 7, |
---|
187 | NOT_FOUND_ERR = 8, |
---|
188 | NOT_SUPPORTED_ERR = 9, |
---|
189 | INUSE_ATTRIBUTE_ERR = 10, |
---|
190 | INVALID_STATE_ERR = 11, |
---|
191 | SYNTAX_ERR = 12, |
---|
192 | INVALID_MODIFICATION_ERR = 13, |
---|
193 | NAMESPACE_ERR = 14, |
---|
194 | INVALID_ACCESS_ERR = 15, |
---|
195 | VALIDATION_ERR = 16 |
---|
196 | }; |
---|
197 | //@} |
---|
198 | |
---|
199 | // ----------------------------------------------------------------------- |
---|
200 | // Getter |
---|
201 | // ----------------------------------------------------------------------- |
---|
202 | inline const XMLCh* getMessage() const; |
---|
203 | |
---|
204 | // ----------------------------------------------------------------------- |
---|
205 | // Class Types |
---|
206 | // ----------------------------------------------------------------------- |
---|
207 | /** @name Public variables */ |
---|
208 | //@{ |
---|
209 | /** |
---|
210 | * A code value, from the set defined by the ExceptionCode enum, |
---|
211 | * indicating the type of error that occured. |
---|
212 | */ |
---|
213 | ExceptionCode code; |
---|
214 | |
---|
215 | /** |
---|
216 | * A string value. Applications may use this field to hold an error |
---|
217 | * message. The field value is not set by the DOM implementation, |
---|
218 | * meaning that the string will be empty when an exception is first |
---|
219 | * thrown. |
---|
220 | */ |
---|
221 | const XMLCh *msg; |
---|
222 | //@} |
---|
223 | |
---|
224 | protected: |
---|
225 | |
---|
226 | MemoryManager* fMemoryManager; |
---|
227 | |
---|
228 | private: |
---|
229 | |
---|
230 | /** |
---|
231 | * A boolean value. |
---|
232 | * If the message is provided by the applications, it is not |
---|
233 | * adopted. |
---|
234 | * If the message is resolved by the DOM implementation, it is |
---|
235 | * owned. |
---|
236 | */ |
---|
237 | bool fMsgOwned; |
---|
238 | |
---|
239 | private: |
---|
240 | // ----------------------------------------------------------------------- |
---|
241 | // Unimplemented constructors and operators |
---|
242 | // ----------------------------------------------------------------------- |
---|
243 | DOMException & operator = (const DOMException &); |
---|
244 | }; |
---|
245 | |
---|
246 | inline const XMLCh* DOMException::getMessage() const |
---|
247 | { |
---|
248 | return msg; |
---|
249 | } |
---|
250 | |
---|
251 | XERCES_CPP_NAMESPACE_END |
---|
252 | |
---|
253 | #endif |
---|