~ubuntu-branches/ubuntu/gutsy/poco/gutsy

« back to all changes in this revision

Viewing changes to XML/include/Poco/SAX/SAXException.h

  • Committer: Bazaar Package Importer
  • Author(s): Krzysztof Burghardt
  • Date: 2007-04-27 18:33:48 UTC
  • Revision ID: james.westby@ubuntu.com-20070427183348-xgnpct0qd6a2ip34
Tags: upstream-1.2.9
ImportĀ upstreamĀ versionĀ 1.2.9

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//
 
2
// SAXException.h
 
3
//
 
4
// $Id: //poco/1.2/XML/include/Poco/SAX/SAXException.h#1 $
 
5
//
 
6
// Library: XML
 
7
// Package: SAX
 
8
// Module:  SAX
 
9
//
 
10
// SAX exception classes.
 
11
//
 
12
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
 
13
// and Contributors.
 
14
//
 
15
// Permission is hereby granted, free of charge, to any person or organization
 
16
// obtaining a copy of the software and accompanying documentation covered by
 
17
// this license (the "Software") to use, reproduce, display, distribute,
 
18
// execute, and transmit the Software, and to prepare derivative works of the
 
19
// Software, and to permit third-parties to whom the Software is furnished to
 
20
// do so, all subject to the following:
 
21
// 
 
22
// The copyright notices in the Software and this entire statement, including
 
23
// the above license grant, this restriction and the following disclaimer,
 
24
// must be included in all copies of the Software, in whole or in part, and
 
25
// all derivative works of the Software, unless such copies or derivative
 
26
// works are solely in the form of machine-executable object code generated by
 
27
// a source language processor.
 
28
// 
 
29
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
30
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
31
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
 
32
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
 
33
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
 
34
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 
35
// DEALINGS IN THE SOFTWARE.
 
36
//
 
37
 
 
38
 
 
39
#ifndef SAX_SAXException_INCLUDED
 
40
#define SAX_SAXException_INCLUDED
 
41
 
 
42
 
 
43
#include "Poco/XML/XML.h"
 
44
#include "Poco/XML/XMLException.h"
 
45
#include "Poco/XML/XMLString.h"
 
46
 
 
47
 
 
48
namespace Poco {
 
49
namespace XML {
 
50
 
 
51
 
 
52
POCO_DECLARE_EXCEPTION(XML_API, SAXException, XMLException)
 
53
        /// The base class for all SAX-related exceptions like SAXParseException,
 
54
        /// SAXNotRecognizedException or SAXNotSupportedException.
 
55
        /// 
 
56
        /// This class can contain basic error or warning information from either the XML parser 
 
57
        /// or the application: a parser writer or application writer can subclass it to provide 
 
58
        /// additional functionality. SAX handlers may throw this exception or any exception subclassed 
 
59
        /// from it.
 
60
        /// 
 
61
        /// If the application needs to pass through other types of exceptions, it must wrap those exceptions 
 
62
        /// in a SAXException or an exception derived from a SAXException.
 
63
        /// 
 
64
        /// If the parser or application needs to include information about a specific location in an XML 
 
65
        /// document, it should use the SAXParseException subclass.
 
66
 
 
67
 
 
68
POCO_DECLARE_EXCEPTION(XML_API, SAXNotRecognizedException, SAXException)
 
69
        /// Exception class for an unrecognized identifier.
 
70
        /// 
 
71
        /// An XMLReader will throw this exception when it finds an unrecognized feature or property 
 
72
        /// identifier; SAX applications and extensions may use this class for other, similar purposes.
 
73
 
 
74
 
 
75
POCO_DECLARE_EXCEPTION(XML_API, SAXNotSupportedException, SAXException)
 
76
        /// Exception class for an unsupported operation.
 
77
        /// 
 
78
        /// An XMLReader will throw this exception when it recognizes a feature or property identifier, 
 
79
        /// but cannot perform the requested operation (setting a state or value). Other SAX2 applications 
 
80
        /// and extensions may use this class for similar purposes.
 
81
 
 
82
 
 
83
class Locator;
 
84
 
 
85
 
 
86
class XML_API SAXParseException: public SAXException
 
87
        /// Encapsulate an XML parse error or warning.
 
88
        ///
 
89
        /// This exception may include information for locating the error in the original XML document, 
 
90
        /// as if it came from a Locator object. Note that although the application will receive a 
 
91
        /// SAXParseException as the argument to the handlers in the ErrorHandler interface, the application 
 
92
        /// is not actually required to throw the exception; instead, it can simply read the information in it 
 
93
        /// and take a different action.
 
94
        /// 
 
95
        /// Since this exception is a subclass of SAXException, it inherits the ability to wrap another exception.
 
96
{
 
97
public: 
 
98
        SAXParseException(const std::string& msg, const Locator& loc);
 
99
                /// Create a new SAXParseException from a message and a Locator.
 
100
 
 
101
        SAXParseException(const std::string& msg, const Locator& loc, const Poco::Exception& exc);
 
102
                /// Wrap an existing exception in a SAXParseException.
 
103
 
 
104
        SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber);
 
105
                /// Create a new SAXParseException with an embedded exception.
 
106
                /// 
 
107
                /// This constructor is most useful for parser writers.
 
108
                /// All parameters except the message are as if they were provided by a Locator. 
 
109
                /// For example, if the system identifier is a URL (including relative filename), 
 
110
                /// the caller must resolve it fully before creating the exception.
 
111
 
 
112
        SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber, const Poco::Exception& exc);
 
113
                /// Create a new SAXParseException.
 
114
                /// 
 
115
                /// This constructor is most useful for parser writers.
 
116
                /// All parameters except the message are as if they were provided by a Locator. 
 
117
                /// For example, if the system identifier is a URL (including relative filename), 
 
118
                /// the caller must resolve it fully before creating the exception.
 
119
 
 
120
        SAXParseException(const SAXParseException& exc);
 
121
                /// Creates a new SAXParseException from another one.
 
122
 
 
123
        ~SAXParseException() throw();
 
124
                /// Destroy the exception.
 
125
 
 
126
        SAXParseException& operator = (const SAXParseException& exc);
 
127
                /// Assignment operator.
 
128
                
 
129
        const char* name() const throw();
 
130
                /// Returns a static string describing the exception.
 
131
 
 
132
        const char* className() const throw();
 
133
                /// Returns the name of the exception class.
 
134
 
 
135
        Poco::Exception* clone() const;
 
136
                /// Creates an exact copy of the exception.
 
137
                
 
138
        void rethrow() const;
 
139
                /// (Re)Throws the exception.
 
140
 
 
141
        const XMLString& getPublicId() const;
 
142
                /// Get the public identifier of the entity where the exception occurred.
 
143
                
 
144
        const XMLString& getSystemId() const;
 
145
                /// Get the system identifier of the entity where the exception occurred.
 
146
                
 
147
        int getLineNumber() const;
 
148
                /// The line number of the end of the text where the exception occurred.
 
149
                /// The first line is line 1.
 
150
                
 
151
        int getColumnNumber() const;
 
152
                /// The column number of the end of the text where the exception occurred.
 
153
                /// The first column in a line is position 1.
 
154
 
 
155
protected:
 
156
        static std::string buildMessage(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber);
 
157
        
 
158
private:
 
159
        SAXParseException();
 
160
 
 
161
        XMLString _publicId;
 
162
        XMLString _systemId;
 
163
        int       _lineNumber;
 
164
        int       _columnNumber;
 
165
};
 
166
 
 
167
 
 
168
//
 
169
// inlines
 
170
//
 
171
inline const XMLString& SAXParseException::getPublicId() const
 
172
{
 
173
        return _publicId;
 
174
}
 
175
 
 
176
 
 
177
inline const XMLString& SAXParseException::getSystemId() const
 
178
{
 
179
        return _systemId;
 
180
}
 
181
 
 
182
 
 
183
inline int SAXParseException::getLineNumber() const
 
184
{
 
185
        return _lineNumber;
 
186
}
 
187
 
 
188
 
 
189
inline int SAXParseException::getColumnNumber() const
 
190
{
 
191
        return _columnNumber;
 
192
}
 
193
 
 
194
 
 
195
} } // namespace Poco::XML
 
196
 
 
197
 
 
198
#endif // SAX_SAXException_INCLUDED