SourceForge.net Logo
XQException.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2001-2008
3  * DecisionSoft Limited. All rights reserved.
4  * Copyright (c) 2004-2008
5  * Oracle. All rights reserved.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  *
19  * $Id$
20  */
21 
22 #ifndef XQEXCEPTION_HPP
23 #define XQEXCEPTION_HPP
24 
25 #include <xqilla/framework/XQillaExport.hpp>
26 #include <xqilla/utils/XStr.hpp>
27 
28 #define XQThrow(type, function, reason) throw type(function, reason, this, __FILE__, __LINE__)
29 #define XQThrow2(type, function, reason) throw type(function, reason, 0, __FILE__, __LINE__)
30 #define XQThrow3(type, function, reason, location) throw type(function, reason, location, __FILE__, __LINE__)
31 #define XQSimpleThrow(reason, xqfile, xqline, xqcolumn) throw XQException(reason, xqfile, xqline, (unsigned int)xqcolumn, __FILE__, __LINE__)
32 
33 class LocationInfo;
34 
35 class XQILLA_API XQException
36 {
37 public:
38  XQException(const XMLCh *reason, const XMLCh* file, unsigned int line, unsigned int column, const char *cppFile, unsigned int cppLine);
39  XQException(const XQException &);
40  virtual ~XQException();
41 
42  const XMLCh *getType() const { return type_; }
43  const XMLCh *getError() const { return error_; }
44 
45  const XMLCh *getXQueryFile() const { return xqFile_; }
46  unsigned int getXQueryLine() const { return xqLine_; }
47  unsigned int getXQueryColumn() const { return xqColumn_; }
48 
49  void setXQueryPosition(const XMLCh *file, unsigned int line, unsigned int column);
50  void setXQueryPosition(const LocationInfo *info);
51 
52  const XMLCh *getCppFunction() const { return cppFunction_; }
53  const char *getCppFile() const { return cppFile_; }
54  unsigned int getCppLine() const { return cppLine_; }
55 
56  void printDebug(const XMLCh* const context) const;
57 
58 protected:
59  XQException(const XMLCh* const type, const XMLCh* const functionName, const XMLCh* const reason, const LocationInfo *info, const char *cppFile, unsigned int cppLine);
60 
61 private:
62  XQException &operator=(const XQException &);
63 
64  XMLCh* type_;
65  XMLCh* error_;
66 
67  XMLCh* cppFunction_;
68  const char *cppFile_;
69  unsigned int cppLine_;
70 
71  unsigned int xqLine_, xqColumn_;
72  XMLCh* xqFile_;
73 };
74 
75 #endif
76