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$
20 */
21
22
23 // ---------------------------------------------------------------------------
24 // Includes
25 // ---------------------------------------------------------------------------
26 #include <xercesc/util/XMLString.hpp>
27 #include <xercesc/sax/Locator.hpp>
28 #include <xercesc/sax/SAXParseException.hpp>
29
30 XERCES_CPP_NAMESPACE_BEGIN
31
32 // ---------------------------------------------------------------------------
33 // SAXParseException: Constructors and Destructor
34 // ---------------------------------------------------------------------------
SAXParseException(const XMLCh * const message,const Locator & locator,MemoryManager * const manager)35 SAXParseException::SAXParseException(const XMLCh* const message
36 , const Locator& locator
37 , MemoryManager* const manager) :
38 SAXException(message, manager)
39 , fColumnNumber(locator.getColumnNumber())
40 , fLineNumber(locator.getLineNumber())
41 , fPublicId(XMLString::replicate(locator.getPublicId(), manager))
42 , fSystemId(XMLString::replicate(locator.getSystemId(), manager))
43 {
44 }
45
SAXParseException(const XMLCh * const message,const XMLCh * const publicId,const XMLCh * const systemId,const XMLFileLoc lineNumber,const XMLFileLoc columnNumber,MemoryManager * const manager)46 SAXParseException::SAXParseException(const XMLCh* const message
47 , const XMLCh* const publicId
48 , const XMLCh* const systemId
49 , const XMLFileLoc lineNumber
50 , const XMLFileLoc columnNumber
51 , MemoryManager* const manager) :
52 SAXException(message, manager)
53 , fColumnNumber(columnNumber)
54 , fLineNumber(lineNumber)
55 , fPublicId(XMLString::replicate(publicId, manager))
56 , fSystemId(XMLString::replicate(systemId, manager))
57 {
58 }
59
SAXParseException(const SAXParseException & toCopy)60 SAXParseException::SAXParseException(const SAXParseException& toCopy) :
61
62 SAXException(toCopy)
63 , fColumnNumber(toCopy.fColumnNumber)
64 , fLineNumber(toCopy.fLineNumber)
65 , fPublicId(0)
66 , fSystemId(0)
67 {
68 fPublicId = XMLString::replicate(toCopy.fPublicId, toCopy.fMemoryManager);
69 fSystemId = XMLString::replicate(toCopy.fSystemId, toCopy.fMemoryManager);
70 }
71
~SAXParseException()72 SAXParseException::~SAXParseException()
73 {
74 fMemoryManager->deallocate(fPublicId);//XMLString::release(&fPublicId);
75 fMemoryManager->deallocate(fSystemId);//XMLString::release(&fSystemId);
76 }
77
78
79 // ---------------------------------------------------------------------------
80 // SAXParseException: Public operators
81 // ---------------------------------------------------------------------------
82 SAXParseException&
operator =(const SAXParseException & toAssign)83 SAXParseException::operator=(const SAXParseException& toAssign)
84 {
85 if (this == &toAssign)
86 return *this;
87
88 fMemoryManager->deallocate(fPublicId);//XMLString::release(&fPublicId);
89 fMemoryManager->deallocate(fSystemId);//XMLString::release(&fSystemId);
90
91 this->SAXException::operator =(toAssign);
92 fColumnNumber = toAssign.fColumnNumber;
93 fLineNumber = toAssign.fLineNumber;
94
95 fPublicId = XMLString::replicate(toAssign.fPublicId, fMemoryManager);
96 fSystemId = XMLString::replicate(toAssign.fSystemId, fMemoryManager);
97
98 return *this;
99 }
100
101
102 // ---------------------------------------------------------------------------
103 // SAXParseException: Getter methods
104 // ---------------------------------------------------------------------------
getPublicId() const105 const XMLCh* SAXParseException::getPublicId() const
106 {
107 return fPublicId;
108 }
109
getSystemId() const110 const XMLCh* SAXParseException::getSystemId() const
111 {
112 return fSystemId;
113 }
114
getLineNumber() const115 XMLFileLoc SAXParseException::getLineNumber() const
116 {
117 return fLineNumber;
118 }
119
getColumnNumber() const120 XMLFileLoc SAXParseException::getColumnNumber() const
121 {
122 return fColumnNumber;
123 }
124
125 XERCES_CPP_NAMESPACE_END
126