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, 2018 Oracle and/or its affiliates. All rights reserved.
5  *
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 
20 #ifndef XQEXCEPTION_HPP
21 #define XQEXCEPTION_HPP
22 
23 #include <xqilla/framework/XQillaExport.hpp>
24 #include <xqilla/utils/XStr.hpp>
25 
26 #define XQThrow(type, function, reason) throw type(function, reason, this, __FILE__, __LINE__)
27 #define XQThrow2(type, function, reason) throw type(function, reason, 0, __FILE__, __LINE__)
28 #define XQThrow3(type, function, reason, location) throw type(function, reason, location, __FILE__, __LINE__)
29 #define XQSimpleThrow(reason, xqfile, xqline, xqcolumn) throw XQException(reason, xqfile, xqline, (unsigned int)xqcolumn, __FILE__, __LINE__)
30 
31 class LocationInfo;
32 
33 class XQILLA_API XQException
34 {
35 public:
36  XQException(const XMLCh *reason, const XMLCh* file, unsigned int line, unsigned int column, const char *cppFile, unsigned int cppLine);
37  XQException(const XQException &);
38  virtual ~XQException();
39 
40  const XMLCh *getType() const { return type_; }
41  const XMLCh *getError() const { return error_; }
42 
43  const XMLCh *getXQueryFile() const { return xqFile_; }
44  unsigned int getXQueryLine() const { return xqLine_; }
45  unsigned int getXQueryColumn() const { return xqColumn_; }
46 
47  void setXQueryPosition(const XMLCh *file, unsigned int line, unsigned int column);
48  void setXQueryPosition(const LocationInfo *info);
49 
50  const XMLCh *getCppFunction() const { return cppFunction_; }
51  const char *getCppFile() const { return cppFile_; }
52  unsigned int getCppLine() const { return cppLine_; }
53 
54  void printDebug(const XMLCh* const context) const;
55 
56 protected:
57  XQException(const XMLCh* const type, const XMLCh* const functionName, const XMLCh* const reason, const LocationInfo *info, const char *cppFile, unsigned int cppLine);
58 
59 private:
60  XQException &operator=(const XQException &);
61 
62  XMLCh* type_;
63  XMLCh* error_;
64 
65  XMLCh* cppFunction_;
66  const char *cppFile_;
67  unsigned int cppLine_;
68 
69  unsigned int xqLine_, xqColumn_;
70  XMLCh* xqFile_;
71 };
72 
73 #endif
74 
const XMLCh * getXQueryFile() const
Definition: XQException.hpp:43
const XMLCh * getError() const
Definition: XQException.hpp:41
const char * getCppFile() const
Definition: XQException.hpp:51
unsigned int getXQueryColumn() const
Definition: XQException.hpp:45
Definition: XQException.hpp:33
unsigned int getCppLine() const
Definition: XQException.hpp:52
const XMLCh * getType() const
Definition: XQException.hpp:40
const XMLCh * getCppFunction() const
Definition: XQException.hpp:50
A class that gives records a location in the query.
Definition: LocationInfo.hpp:29
unsigned int getXQueryLine() const
Definition: XQException.hpp:44