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
34namespace itk
35{
36
37// forward declaration for encapsulation
38class ExceptionObject;
39
40namespace 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
55class SITKCommon_EXPORT GenericException : public std::exception
56{
57public:
60 GenericException() noexcept;
62
64 GenericException(const char * file, unsigned int lineNumber) noexcept;
65
67 GenericException(const std::string & file, unsigned int lineNumber) noexcept;
68
70 GenericException(const std::string & file, unsigned int lineNumber, const std::string & desc) noexcept;
71
73 ~GenericException() noexcept override;
74
77 operator=(const GenericException & orig);
78
80 virtual bool
81 operator==(const GenericException & orig) const;
82
83
85 std::string
86 ToString() const;
87
88 const char *
89 what() const noexcept override;
90
91 virtual const char *
93
94 virtual const char *
95 GetLocation() const;
96
97 virtual const char *
99
101 virtual const char *
102 GetFile() const;
103
105 virtual unsigned int
106 GetLine() const;
107
108private:
110};
111
112#ifdef _MSC_VER
113# pragma warning(pop)
114#endif
115
116} // namespace simple
117} // namespace itk
118
119#endif // sitkExceptionObject_h
virtual const char * GetNameOfClass() const
virtual const char * GetLocation() const
virtual const char * GetFile() const
std::shared_ptr< const ExceptionObject > m_PimpleException
const char * what() const noexcept override
virtual unsigned int GetLine() const
std::string ToString() const
virtual const char * GetDescription() const
STL namespace.
#define SITKCommon_EXPORT
Definition sitkCommon.h:41