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