SimpleITK  2.0.0
sitkExceptionObject.h
Go to the documentation of this file.
1 /*=========================================================================
2 *
3 * Copyright NumFOCUS
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0.txt
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 #ifndef sitkExceptionObject_h
19 #define sitkExceptionObject_h
20 
21 #include "sitkMacro.h"
22 #include "sitkCommon.h"
23 
24 #ifndef sitkMacro_h
25 #error "sitkMacro.h must be included before sitkExceptionObject.h"
26 #endif // sitkMacro_h
27 #ifndef sitkCommon_h
28 #error "sitkCommon.h must be included before sitkExceptionObject.h"
29 #endif // sitkCommon_h
30 
31 
32 namespace itk
33 {
34 
35 // forward declaration for encapsulation
36 class ExceptionObject;
37 
38 namespace simple
39 {
40 
41 #ifdef _MSC_VER
42 // Ignore the following warning:
43 // sitkExceptionObject.h(46,1): warning C4275: non dll-interface class
44 // 'std::exception' used as base for dll-interface class
45 // 'itk::simple::GenericException'
46 #pragma warning( push )
47 #pragma warning(disable:4275)
48 #endif
49 
54  public std::exception
55 {
56 public:
59  GenericException() noexcept;
60  GenericException( const GenericException &e ) noexcept;
61 
63  GenericException(const char *file, unsigned int lineNumber) noexcept;
64 
66  GenericException(const std::string & file, unsigned int lineNumber) noexcept;
67 
69  GenericException(const std::string & file,
70  unsigned int lineNumber,
71  const std::string & desc) noexcept;
72 
74  ~GenericException() noexcept override;
75 
77  GenericException & operator=(const GenericException & orig);
78 
80  virtual bool operator==(const GenericException & orig) const;
81 
82 
84  std::string ToString() const;
85 
86  const char * what() const noexcept override;
87 
88  virtual const char * GetNameOfClass() const;
89 
90  virtual const char * GetLocation() const;
91 
92  virtual const char * GetDescription() const;
93 
95  virtual const char * GetFile() const;
96 
98  virtual unsigned int GetLine() const;
99 
100 private:
101  const ExceptionObject *m_PimpleException;
102 };
103 
104 #ifdef _MSC_VER
105 #pragma warning( pop )
106 #endif
107 
108 }
109 }
110 
111 #endif // sitkExceptionObject_h
itk::simple::GenericException::m_PimpleException
const ExceptionObject * m_PimpleException
Definition: sitkExceptionObject.h:101
sitkCommon.h
sitkMacro.h
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
itk
itk::operator==
bool operator==(const NeighborhoodAllocator< TPixel > &lhs, const NeighborhoodAllocator< TPixel > &rhs)
itk::simple::GenericException
The base SimpleITK exception class.
Definition: sitkExceptionObject.h:53