SimpleITK  
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 #include <memory> // For shared_ptr.
25 
26 #ifndef sitkMacro_h
27 #error "sitkMacro.h must be included before sitkExceptionObject.h"
28 #endif // sitkMacro_h
29 #ifndef sitkCommon_h
30 #error "sitkCommon.h must be included before sitkExceptionObject.h"
31 #endif // sitkCommon_h
32 
33 
34 namespace itk
35 {
36 
37 // forward declaration for encapsulation
38 class ExceptionObject;
39 
40 namespace simple
41 {
42 
43 #ifdef _MSC_VER
44 // Ignore the following warning:
45 // sitkExceptionObject.h(46,1): warning C4275: non dll-interface class
46 // 'std::exception' used as base for dll-interface class
47 // 'itk::simple::GenericException'
48 #pragma warning( push )
49 #pragma warning(disable:4275)
50 #endif
51 
56  public std::exception
57 {
58 public:
61  GenericException() noexcept;
62  GenericException( const GenericException &e ) noexcept;
63 
65  GenericException(const char *file, unsigned int lineNumber) noexcept;
66 
68  GenericException(const std::string & file, unsigned int lineNumber) noexcept;
69 
71  GenericException(const std::string & file,
72  unsigned int lineNumber,
73  const std::string & desc) noexcept;
74 
76  ~GenericException() noexcept override;
77 
79  GenericException & operator=(const GenericException & orig);
80 
82  virtual bool operator==(const GenericException & orig) const;
83 
84 
86  std::string ToString() const;
87 
88  const char * what() const noexcept override;
89 
90  virtual const char * GetNameOfClass() const;
91 
92  virtual const char * GetLocation() const;
93 
94  virtual const char * GetDescription() const;
95 
97  virtual const char * GetFile() const;
98 
100  virtual unsigned int GetLine() const;
101 
102 private:
103  std::shared_ptr<const ExceptionObject> m_PimpleException;
104 };
105 
106 #ifdef _MSC_VER
107 #pragma warning( pop )
108 #endif
109 
110 }
111 }
112 
113 #endif // sitkExceptionObject_h
sitkCommon.h
sitkMacro.h
SITKCommon_EXPORT
#define SITKCommon_EXPORT
Definition: sitkCommon.h:41
GetNameOfClass
virtual const char * GetNameOfClass() const
itk::operator==
bool operator==(const Index< VDimension > &one, const Index< VDimension > &two)
itk
itk::simple::GenericException::m_PimpleException
std::shared_ptr< const ExceptionObject > m_PimpleException
Definition: sitkExceptionObject.h:103
itk::simple::GenericException
The base SimpleITK exception class.
Definition: sitkExceptionObject.h:55