SourceForge.net Logo

XQException.hpp

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001, 2008,
00003  *     DecisionSoft Limited. All rights reserved.
00004  * Copyright (c) 2004, 2011,
00005  *     Oracle and/or its affiliates. All rights reserved.
00006  *
00007  * Licensed under the Apache License, Version 2.0 (the "License");
00008  * you may not use this file except in compliance with the License.
00009  * You may obtain a copy of the License at
00010  *
00011  *     http://www.apache.org/licenses/LICENSE-2.0
00012  *
00013  * Unless required by applicable law or agreed to in writing, software
00014  * distributed under the License is distributed on an "AS IS" BASIS,
00015  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00016  * See the License for the specific language governing permissions and
00017  * limitations under the License.
00018  */
00019 
00020 #ifndef XQEXCEPTION_HPP
00021 #define XQEXCEPTION_HPP
00022 
00023 #include <xqilla/framework/XQillaExport.hpp>
00024 #include <xqilla/utils/XStr.hpp>
00025 
00026 #define XQThrow(type, function, reason) throw type(function, reason, this, __FILE__, __LINE__)
00027 #define XQThrow2(type, function, reason) throw type(function, reason, 0, __FILE__, __LINE__)
00028 #define XQThrow3(type, function, reason, location) throw type(function, reason, location, __FILE__, __LINE__)
00029 #define XQSimpleThrow(reason, xqfile, xqline, xqcolumn) throw XQException(reason, xqfile, xqline, (unsigned int)xqcolumn, __FILE__, __LINE__)
00030 
00031 class LocationInfo;
00032 
00033 class XQILLA_API XQException
00034 {
00035 public:
00036   XQException(const XMLCh *reason, const XMLCh* file, unsigned int line, unsigned int column, const char *cppFile, unsigned int cppLine);
00037   XQException(const XQException &);
00038   virtual ~XQException();
00039 
00040   const XMLCh *getType() const { return type_; }
00041   const XMLCh *getError() const { return error_; }
00042 
00043   const XMLCh *getXQueryFile() const { return xqFile_; }
00044   unsigned int getXQueryLine() const { return xqLine_; }
00045   unsigned int getXQueryColumn() const { return xqColumn_; }
00046 
00047   void setXQueryPosition(const XMLCh *file, unsigned int line, unsigned int column);
00048   void setXQueryPosition(const LocationInfo *info);
00049 
00050   const XMLCh *getCppFunction() const { return cppFunction_; }
00051   const char *getCppFile() const { return cppFile_; }
00052   unsigned int getCppLine() const { return cppLine_; }
00053 
00054   void printDebug(const XMLCh* const context) const;
00055 
00056 protected:
00057   XQException(const XMLCh* const type, const XMLCh* const functionName, const XMLCh* const reason, const LocationInfo *info, const char *cppFile, unsigned int cppLine);
00058 
00059 private:
00060   XQException &operator=(const XQException &);
00061   
00062   XMLCh* type_;
00063   XMLCh* error_;
00064 
00065   XMLCh* cppFunction_;
00066   const char *cppFile_;
00067   unsigned int cppLine_;
00068 
00069   unsigned int xqLine_, xqColumn_;
00070   XMLCh* xqFile_;
00071 };
00072 
00073 #endif
00074