Safir SDK Core
Loading...
Searching...
No Matches
Exceptions.h
Go to the documentation of this file.
1/******************************************************************************
2*
3* Copyright Saab AB, 2005-2013 (http://safirsdkcore.com)
4*
5* Created by: Joel Ottosson / stjoot
6*
7*******************************************************************************
8*
9* This file is part of Safir SDK Core.
10*
11* Safir SDK Core is free software: you can redistribute it and/or modify
12* it under the terms of version 3 of the GNU General Public License as
13* published by the Free Software Foundation.
14*
15* Safir SDK Core is distributed in the hope that it will be useful,
16* but WITHOUT ANY WARRANTY; without even the implied warranty of
17* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18* GNU General Public License for more details.
19*
20* You should have received a copy of the GNU General Public License
21* along with Safir SDK Core. If not, see <http://www.gnu.org/licenses/>.
22*
23******************************************************************************/
24
25#ifndef _dots_exception_h
26#define _dots_exception_h
27
28//Definition of __WFILE__ which is the wide-string equivalent of __FILE__
29#define WIDEN2(x) L ## x
30#define WIDEN(x) WIDEN2(x)
31#define __WFILE__ WIDEN(__FILE__)
32
33#include <string>
35
36//Undefine stupid macro that windows.h defines. Just in case someone has included it
37//before including us.
38#ifdef GetMessage
39#undef GetMessage
40#endif
41
42
43namespace Safir
44{
45namespace Dob
46{
47namespace Typesystem
48{
54 namespace Internal
55 {
65#ifdef _MSC_VER
66#pragma warning (push)
67#pragma warning (disable:4251)
68#pragma warning (disable:4275)
69#endif
70
72 public std::exception
73 {
74 public:
87 CommonExceptionBase(const std::wstring & message,
88 const std::wstring & fileName, //Use the __WFILE__ macro
89 const Dob::Typesystem::Int64 lineNumber); //Use the __LINE__ macro
90
94 virtual ~CommonExceptionBase() throw();
95
105 const std::wstring GetExceptionInfo() const;
106
119 const std::wstring & GetMessage() const {return m_Message;}
120
126 virtual const std::wstring GetName() const = 0;
127
133 const std::wstring & GetFileName() const {return m_FileName;}
134
140 Dob::Typesystem::Int64 GetLineNumber() const {return m_LineNumber;}
141
158 const char * what() const throw() override;
159
170 virtual TypeId GetTypeId() const = 0;
171
172 private:
173 Dob::Typesystem::Int64 m_LineNumber;
174 std::wstring m_FileName;
175 std::wstring m_Message;
176
182 mutable std::string m_ConvertedMessage;
183 };
184
185#ifdef _MSC_VER
186#pragma warning (pop)
187#endif
188
189 }
190
200 {
201 public:
214 FundamentalException(const std::wstring & message,
215 const std::wstring & fileName, //Use the __WFILE__ macro
216 const Dob::Typesystem::Int64 lineNumber); //Use the __LINE__ macro
217
219 static const TypeId ExceptionTypeId = 5177142987005172374LL;
220
221 //override of CommonExceptionBase::GetTypeId
222 TypeId GetTypeId() const override {return ExceptionTypeId;}
223 };
224
233 {
234 public:
247 Exception(const std::wstring & message,
248 const std::wstring & fileName, //Use the __WFILE__ macro
249 const Dob::Typesystem::Int64 lineNumber); //Use the __LINE__ macro
250
252 static const TypeId ExceptionTypeId = 8409897425067168944LL;
253
254 //override of CommonExceptionBase::GetTypeId
255 TypeId GetTypeId() const override {return ExceptionTypeId;}
256 };
257
264 {
265 public:
278 IllegalValueException(const std::wstring & message,
279 const std::wstring & fileName, //Use the __WFILE__ macro
280 const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
281 FundamentalException(message,fileName,lineNumber) {}
282
283 const std::wstring GetName() const override {return L"Safir.Dob.Typesystem.IllegalValueException";}
284
286 static const TypeId ExceptionTypeId = -3653935143986901894LL;
287
288 TypeId GetTypeId() const override {return ExceptionTypeId;}
289 };
290
297 {
298 public:
311 IncompatibleTypesException(const std::wstring & message,
312 const std::wstring & fileName, //Use the __WFILE__ macro
313 const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
314 FundamentalException(message,fileName,lineNumber) {}
315
316 const std::wstring GetName() const override {return L"Safir.Dob.Typesystem.IncompatibleTypesException";}
317
319 static const TypeId ExceptionTypeId = -5150658527844777416LL;
320
321 TypeId GetTypeId() const override {return ExceptionTypeId;}
322 };
323
330 {
331 public:
344 ConfigurationErrorException(const std::wstring & message,
345 const std::wstring & fileName, //Use the __WFILE__ macro
346 const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
347 FundamentalException(message,fileName,lineNumber) {}
348
349 const std::wstring GetName() const override {return L"Safir.Dob.Typesystem.ConfigurationErrorException";}
350
352 static const TypeId ExceptionTypeId = 2909620812590558895LL;
353
354 TypeId GetTypeId() const override {return ExceptionTypeId;}
355 };
356
364 {
365 public:
378 SoftwareViolationException(const std::wstring & message,
379 const std::wstring & fileName, //Use the __WFILE__ macro
380 const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
381 FundamentalException(message,fileName,lineNumber) {}
382
383 const std::wstring GetName() const override {return L"Safir.Dob.Typesystem.SoftwareViolationException";}
384
386 static const TypeId ExceptionTypeId = -2318636033853590373LL;
387
388 TypeId GetTypeId() const override {return ExceptionTypeId;}
389 };
390
396 {
397 public:
410 NullException(const std::wstring & message,
411 const std::wstring & fileName, //Use the __WFILE__ macro
412 const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
413 FundamentalException(message,fileName,lineNumber) {}
414
415 const std::wstring GetName() const override {return L"Safir.Dob.Typesystem.NullException";}
416
418 static const TypeId ExceptionTypeId = -6392953138294149211LL;
419
420 TypeId GetTypeId() const override {return ExceptionTypeId;}
421 };
422
423
430 {
431 public:
444 ReadOnlyException(const std::wstring & message,
445 const std::wstring & fileName, //Use the __WFILE__ macro
446 const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
447 FundamentalException(message,fileName,lineNumber) {}
448
449 const std::wstring GetName() const override {return L"Safir.Dob.Typesystem.ReadOnlyException";}
450
452 static const TypeId ExceptionTypeId = -4804695341042352897LL;
453
454 TypeId GetTypeId() const override {return ExceptionTypeId;}
455 };
456}
457}
458}
459#endif
This namespace contains all the functionality and definitions of the SAFIR SDK.
Definition Backdoor.h:31
DotsC_Int64 Int64
64 bit integer type.
Definition Defs.h:69
DotsC_TypeId TypeId
A unique type identifier.
Definition Defs.h:218
Common functionality for the exception hierarchy of the DOB typesystem.
Definition Exceptions.h:73
virtual ~CommonExceptionBase()
Destroy the exception.
const char * what() const override
Get the GetExceptionInfo as a UTF8 encoded string.
const std::wstring & GetFileName() const
Get the name of the file where the exception occurred.
Definition Exceptions.h:133
CommonExceptionBase(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
virtual const std::wstring GetName() const =0
Get the exception name.
Dob::Typesystem::Int64 GetLineNumber() const
Get the line number that the exception occurred on.
Definition Exceptions.h:140
This is the base class of all Fundamental Exceptions.
Definition Exceptions.h:200
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:222
FundamentalException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
This is the base class of all (non-Fundamental) Exceptions.
Definition Exceptions.h:233
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:255
Exception(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
A parameter in the call was invalid.
Definition Exceptions.h:264
IllegalValueException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition Exceptions.h:278
const std::wstring GetName() const override
Get the exception name.
Definition Exceptions.h:283
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:288
This exception is thrown if a class cannot be cast to the expected type.
Definition Exceptions.h:297
const std::wstring GetName() const override
Get the exception name.
Definition Exceptions.h:316
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:321
IncompatibleTypesException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition Exceptions.h:311
Used when there is an error that implies that there is something wrong in the configuration.
Definition Exceptions.h:330
ConfigurationErrorException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition Exceptions.h:344
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:354
const std::wstring GetName() const override
Get the exception name.
Definition Exceptions.h:349
Meant to be used when something goes very wrong.
Definition Exceptions.h:364
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:388
SoftwareViolationException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition Exceptions.h:378
const std::wstring GetName() const override
Get the exception name.
Definition Exceptions.h:383
Thrown when an application attempts to get the value of a member that is null.
Definition Exceptions.h:396
NullException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition Exceptions.h:410
const std::wstring GetName() const override
Get the exception name.
Definition Exceptions.h:415
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:420
Used when someone tries to set a property that is mapped to something that cannot be changed.
Definition Exceptions.h:430
const std::wstring GetName() const override
Get the exception name.
Definition Exceptions.h:449
ReadOnlyException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition Exceptions.h:444
TypeId GetTypeId() const override
Get the type id of this exception.
Definition Exceptions.h:454
#define DOTS_CPP_API
Definition Defs.h:33