Xalan-C++ API Reference  1.12.0
XSLException.hpp
Go to the documentation of this file.
1 /*
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */
18 #if !defined(XSLEXCEPTION_HEADER_GUARD_1357924680)
19 #define XSLEXCEPTION_HEADER_GUARD_1357924680
20 
21 
22 
23 // Base include file. Must be first.
25 
26 
27 
30 
31 
32 
33 namespace XALAN_CPP_NAMESPACE {
34 
35 
36 
37 typedef xercesc::Locator LocatorType;
38 using xercesc::Locator;
39 
40 
41 
43 {
44 public:
45 
46  /**
47  * Constructor
48  *
49  * @param theMessage The message to display when exception thrown
50  * @param theManager The MemoryManager instance to use.
51  * @param theLocator The locator instance for error reporting, if any.
52  */
54  const XalanDOMString& theMessage,
55  MemoryManager& theManager,
56  const Locator* theLocator);
57 
58  /**
59  * Constructor. Use this constructor when the message has
60  * already been formatted.
61  *
62  * @param theMessage The message to display when exception thrown
63  * @param theManager The MemoryManager instance to use.
64  */
66  const XalanDOMString& theMessage,
67  MemoryManager& theManager);
68 
69  XSLException(const XSLException& other);
70 
71  virtual
72  ~XSLException();
73 
74  /**
75  * Retrieve type of exception
76  *
77  * @return type of exception
78  */
79  virtual const XalanDOMChar*
80  getType() const = 0;
81 
82  /**
83  * Retrieve message for exception
84  *
85  * @return exception message
86  */
87  const XalanDOMString&
88  getMessage() const
89  {
90  return m_message;
91  }
92 
93  /**
94  * Get the URI for the associated document, if any
95  *
96  * @return The URI.
97  */
98  const XalanDOMString&
99  getURI() const
100  {
101  return m_uri;
102  }
103 
104  /**
105  * Retrieve the line number.
106  *
107  * @return the line number
108  */
109  XalanFileLoc
111  {
112  return m_lineNumber;
113  }
114 
115  /**
116  * Retrieve the column number.
117  *
118  * @return the column number
119  */
120  XalanFileLoc
122  {
123  return m_columnNumber;
124  }
125 
126  const MemoryManager&
128  {
129  return m_memoryManager;
130  }
131 
132  MemoryManager&
134  {
135  return m_memoryManager;
136  }
137 
139  defaultFormat(XalanDOMString& theBuffer) const;
140 
141  static XalanDOMString&
143  const XalanDOMString& theMessage,
144  const XalanDOMString& theURI,
145  XalanFileLoc theLineNumber,
146  XalanFileLoc theColumnNumber,
147  const XalanDOMChar* theType,
148  XalanDOMString& theBuffer)
149  {
150  return defaultFormat(
151  theMessage.c_str(),
152  theMessage.size(),
153  theURI.c_str(),
154  theURI.size(),
155  theLineNumber,
156  theColumnNumber,
157  theType,
158  XalanDOMString::length(theType),
159  theBuffer);
160  }
161 
162  static XalanDOMString&
164  const XalanDOMChar* theMessage,
165  const XalanDOMChar* theURI,
166  XalanFileLoc theLineNumber,
167  XalanFileLoc theColumnNumber,
168  const XalanDOMChar* theType,
169  XalanDOMString& theBuffer)
170  {
171  assert(theMessage != 0);
172 
173  return defaultFormat(
174  theMessage,
175  XalanDOMString::length(theMessage),
176  theURI,
177  theURI == 0 ? 0 : XalanDOMString::length(theURI),
178  theLineNumber,
179  theColumnNumber,
180  theType,
181  theType == 0 ? 0 : XalanDOMString::length(theType),
182  theBuffer);
183  }
184 
185  static XalanDOMString&
186  defaultFormat(
187  const XalanDOMChar* theMessage,
188  const XalanDOMString::size_type theMessageLength,
189  const XalanDOMChar* theURI,
190  const XalanDOMString::size_type theURILength,
191  XalanFileLoc theLineNumber,
192  XalanFileLoc theColumnNumber,
193  const XalanDOMChar* theType,
194  const XalanDOMString::size_type theTypeLength,
195  XalanDOMString& theBuffer);
196 
197 protected:
198 
199  MemoryManager& m_memoryManager;
200 
201 private:
202 
203  const XalanDOMString m_message;
204  const XalanDOMString m_uri;
205 
206  const XalanFileLoc m_lineNumber;
207  const XalanFileLoc m_columnNumber;
208 
209  // When true, the message has already formatted.
210  const bool m_formatted;
211 };
212 
213 
214 
215 }
216 
217 
218 
219 #endif // XSLEXCEPTION_HEADER_GUARD_1357924680
xalanc::XSLException::defaultFormat
static XalanDOMString & defaultFormat(const XalanDOMChar *theMessage, const XalanDOMChar *theURI, XalanFileLoc theLineNumber, XalanFileLoc theColumnNumber, const XalanDOMChar *theType, XalanDOMString &theBuffer)
Definition: XSLException.hpp:163
XALAN_CPP_NAMESPACE
#define XALAN_CPP_NAMESPACE
Xalan-C++ namespace, including major and minor version.
Definition: XalanVersion.hpp:76
xalanc::XSLException::getMemoryManager
MemoryManager & getMemoryManager()
Definition: XSLException.hpp:133
xalanc::XSLException::getColumnNumber
XalanFileLoc getColumnNumber() const
Retrieve the column number.
Definition: XSLException.hpp:121
xalanc::XSLException::getURI
const XalanDOMString & getURI() const
Get the URI for the associated document, if any.
Definition: XSLException.hpp:99
xalanc::XalanDOMString::size
size_type size() const
Definition: XalanDOMString.hpp:201
DOMStringHelper.hpp
XALAN_PLATFORMSUPPORT_EXPORT
#define XALAN_PLATFORMSUPPORT_EXPORT
Definition: PlatformSupportDefinitions.hpp:35
PlatformSupportDefinitions.hpp
xalanc::XSLException
Definition: XSLException.hpp:42
xalanc::XSLException::getMemoryManager
const MemoryManager & getMemoryManager() const
Definition: XSLException.hpp:127
xalanc::length
XalanDOMString::size_type length(const XalanDOMString &theString)
Get the length of a XalanDOMString.
Definition: DOMStringHelper.hpp:235
XalanLocator.hpp
xalanc::XSLException::getMessage
const XalanDOMString & getMessage() const
Retrieve message for exception.
Definition: XSLException.hpp:88
xalanc::XalanDOMString::c_str
const XalanDOMChar * c_str() const
Definition: XalanDOMString.hpp:344
xalanc::XSLException::getLineNumber
XalanFileLoc getLineNumber() const
Retrieve the line number.
Definition: XSLException.hpp:110
xalanc::XalanDOMString::size_type
XalanSize_t size_type
Definition: XalanDOMString.hpp:57
xalanc::XSLException::m_memoryManager
MemoryManager & m_memoryManager
Definition: XSLException.hpp:199
xalanc::XalanDOMString
Definition: XalanDOMString.hpp:45
xalanc::XSLException::defaultFormat
static XalanDOMString & defaultFormat(const XalanDOMString &theMessage, const XalanDOMString &theURI, XalanFileLoc theLineNumber, XalanFileLoc theColumnNumber, const XalanDOMChar *theType, XalanDOMString &theBuffer)
Definition: XSLException.hpp:142
xalanc::LocatorType
xercesc::Locator LocatorType
Definition: ExecutionContext.hpp:47