source: XMLIO_V2/external/src/POCO/XML/SAXException.cpp @ 80

Last change on this file since 80 was 80, checked in by ymipsl, 14 years ago

ajout lib externe

  • Property svn:eol-style set to native
File size: 4.8 KB
Line 
1//
2// SAXException.cpp
3//
4// $Id: //poco/1.3/XML/src/SAXException.cpp#1 $
5//
6// Library: XML
7// Package: SAX
8// Module:  SAX
9//
10// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
11// and Contributors.
12//
13// Permission is hereby granted, free of charge, to any person or organization
14// obtaining a copy of the software and accompanying documentation covered by
15// this license (the "Software") to use, reproduce, display, distribute,
16// execute, and transmit the Software, and to prepare derivative works of the
17// Software, and to permit third-parties to whom the Software is furnished to
18// do so, all subject to the following:
19//
20// The copyright notices in the Software and this entire statement, including
21// the above license grant, this restriction and the following disclaimer,
22// must be included in all copies of the Software, in whole or in part, and
23// all derivative works of the Software, unless such copies or derivative
24// works are solely in the form of machine-executable object code generated by
25// a source language processor.
26//
27// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
28// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
29// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
30// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
31// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
32// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
33// DEALINGS IN THE SOFTWARE.
34//
35
36
37#include <Poco/SAX/SAXException.h>
38#include <Poco/SAX/Locator.h>
39#include <typeinfo>
40#include <sstream>
41
42
43namespace Poco {
44namespace XML {
45
46
47POCO_IMPLEMENT_EXCEPTION(SAXException, XMLException, "SAX Exception")
48POCO_IMPLEMENT_EXCEPTION(SAXNotRecognizedException, SAXException, "Unrecognized SAX feature or property identifier")
49POCO_IMPLEMENT_EXCEPTION(SAXNotSupportedException, SAXException, "Unsupported SAX feature or property identifier")
50
51
52SAXParseException::SAXParseException(const std::string& msg, const Locator& loc):
53        SAXException(buildMessage(msg, loc.getPublicId(), loc.getSystemId(), loc.getLineNumber(), loc.getColumnNumber())),
54        _publicId(loc.getPublicId()),
55        _systemId(loc.getSystemId()),
56        _lineNumber(loc.getLineNumber()),
57        _columnNumber(loc.getColumnNumber())
58{
59}
60
61
62SAXParseException::SAXParseException(const std::string& msg, const Locator& loc, const Poco::Exception& exc):
63        SAXException(buildMessage(msg, loc.getPublicId(), loc.getSystemId(), loc.getLineNumber(), loc.getColumnNumber()), exc),
64        _publicId(loc.getPublicId()),
65        _systemId(loc.getSystemId()),
66        _lineNumber(loc.getLineNumber()),
67        _columnNumber(loc.getColumnNumber())
68{
69}
70
71       
72SAXParseException::SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber):
73        SAXException(buildMessage(msg, publicId, systemId, lineNumber, columnNumber)),
74        _publicId(publicId),
75        _systemId(systemId),
76        _lineNumber(lineNumber),
77        _columnNumber(columnNumber)
78{
79}
80
81
82SAXParseException::SAXParseException(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber, const Poco::Exception& exc):
83        SAXException(buildMessage(msg, publicId, systemId, lineNumber, columnNumber), exc),
84        _publicId(publicId),
85        _systemId(systemId),
86        _lineNumber(lineNumber),
87        _columnNumber(columnNumber)
88{
89}
90
91
92SAXParseException::SAXParseException(const SAXParseException& exc):
93        SAXException(exc),
94        _publicId(exc._publicId),
95        _systemId(exc._systemId),
96        _lineNumber(exc._lineNumber),
97        _columnNumber(exc._columnNumber)
98{
99}
100
101
102SAXParseException::~SAXParseException() throw()
103{
104}
105
106
107SAXParseException& SAXParseException::operator = (const SAXParseException& exc)
108{
109        if (&exc != this)
110        {
111                SAXException::operator = (exc);
112                _publicId     = exc._publicId;
113                _systemId     = exc._systemId;
114                _lineNumber   = exc._lineNumber;
115                _columnNumber = exc._columnNumber;
116        }
117        return *this;
118}
119
120       
121const char* SAXParseException::name() const throw()
122{
123        return "SAXParseException";
124}
125
126
127const char* SAXParseException::className() const throw()
128{
129        return typeid(*this).name();
130}
131
132
133Poco::Exception* SAXParseException::clone() const
134{
135        return new SAXParseException(*this);
136}
137
138
139void SAXParseException::rethrow() const
140{
141        throw *this;
142}
143
144
145std::string SAXParseException::buildMessage(const std::string& msg, const XMLString& publicId, const XMLString& systemId, int lineNumber, int columnNumber)
146{
147        std::ostringstream result;
148        if (!msg.empty()) result << msg << " ";
149        result << "in ";
150        if (!systemId.empty())
151                result << "'" << fromXMLString(systemId) << "', ";
152        else if (!publicId.empty())
153                result << "'" << fromXMLString(publicId) << "', ";
154        if (lineNumber > 0)
155                result << "line " << lineNumber << " column " << columnNumber;
156        return result.str();
157}
158
159
160} } // namespace Poco::XML
Note: See TracBrowser for help on using the repository browser.