source: icXML/icXML-devel/src/xercesc/dom/DOMException.hpp @ 6297

Last change on this file since 6297 was 2722, checked in by cameron, 7 years ago

Original Xerces files with import mods for icxercesc

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