Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Exceptions.h
Go to the documentation of this file.
1 /******************************************************************************
2 *
3 * Copyright Saab AB, 2005-2013 (http://safir.sourceforge.net)
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 #include <boost/static_assert.hpp>
36 namespace Safir
37 {
38 namespace Dob
39 {
40 namespace Typesystem
41 {
47  namespace Internal
48  {
58 #ifdef _MSC_VER
59 #pragma warning (push)
60 #pragma warning (disable:4251)
61 #endif
62 
64  public std::exception
65  {
66  public:
79  CommonExceptionBase(const std::wstring & message,
80  const std::wstring & fileName, //Use the __WFILE__ macro
81  const Dob::Typesystem::Int64 lineNumber); //Use the __LINE__ macro
82 
86  virtual ~CommonExceptionBase() throw();
87 
97  const std::wstring GetExceptionInfo() const;
98 
111  const std::wstring & GetMessage() const {return m_Message;}
112 
118  virtual const std::wstring GetName() const = 0;
119 
125  const std::wstring & GetFileName() const {return m_FileName;}
126 
132  const Dob::Typesystem::Int64 GetLineNumber() const {return m_LineNumber;}
133 
150  virtual const char * what() const throw();
151 
162  virtual TypeId GetTypeId() const = 0;
163 
164  private:
165  Dob::Typesystem::Int64 m_LineNumber;
166  std::wstring m_FileName;
167  std::wstring m_Message;
168 
174  mutable std::string m_ConvertedMessage;
175  };
176 
177 #ifdef _MSC_VER
178 #pragma warning (pop)
179 #endif
180 
181  }
182 
192  {
193  public:
206  FundamentalException(const std::wstring & message,
207  const std::wstring & fileName, //Use the __WFILE__ macro
208  const Dob::Typesystem::Int64 lineNumber); //Use the __LINE__ macro
209 
211  static const TypeId ExceptionTypeId = 5177142987005172374LL;
212 
213  //override of CommonExceptionBase::GetTypeId
214  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
215  };
216 
225  {
226  public:
239  Exception(const std::wstring & message,
240  const std::wstring & fileName, //Use the __WFILE__ macro
241  const Dob::Typesystem::Int64 lineNumber); //Use the __LINE__ macro
242 
244  static const TypeId ExceptionTypeId = 8409897425067168944LL;
245 
246  //override of CommonExceptionBase::GetTypeId
247  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
248  };
249 
255  public FundamentalException
256  {
257  public:
270  IllegalValueException(const std::wstring & message,
271  const std::wstring & fileName, //Use the __WFILE__ macro
272  const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
273  FundamentalException(message,fileName,lineNumber) {}
274 
275  //override of CommonExceptionBase::GetName
276  const std::wstring GetName() const {return L"Safir.Dob.Typesystem.IllegalValueException";}
277 
279  static const TypeId ExceptionTypeId = -3653935143986901894LL;
280 
281  //override of CommonExceptionBase::GetTypeId
282  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
283  };
284 
290  public FundamentalException
291  {
292  public:
305  IncompatibleTypesException(const std::wstring & message,
306  const std::wstring & fileName, //Use the __WFILE__ macro
307  const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
308  FundamentalException(message,fileName,lineNumber) {}
309 
310  //override of CommonExceptionBase::GetName
311  const std::wstring GetName() const {return L"Safir.Dob.Typesystem.IncompatibleTypesException";}
312 
314  static const TypeId ExceptionTypeId = -5150658527844777416LL;
315 
316  //override of CommonExceptionBase::GetTypeId
317  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
318  };
319 
325  public FundamentalException
326  {
327  public:
340  ConfigurationErrorException(const std::wstring & message,
341  const std::wstring & fileName, //Use the __WFILE__ macro
342  const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
343  FundamentalException(message,fileName,lineNumber) {}
344 
345  //override of CommonExceptionBase::GetName
346  const std::wstring GetName() const {return L"Safir.Dob.Typesystem.ConfigurationErrorException";}
347 
349  static const TypeId ExceptionTypeId = 2909620812590558895LL;
350 
351  //override of CommonExceptionBase::GetTypeId
352  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
353  };
354 
361  public FundamentalException
362  {
363  public:
376  SoftwareViolationException(const std::wstring & message,
377  const std::wstring & fileName, //Use the __WFILE__ macro
378  const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
379  FundamentalException(message,fileName,lineNumber) {}
380 
381  //override of CommonExceptionBase::GetName
382  const std::wstring GetName() const {return L"Safir.Dob.Typesystem.SoftwareViolationException";}
383 
385  static const TypeId ExceptionTypeId = -2318636033853590373LL;
386 
387  //override of CommonExceptionBase::GetTypeId
388  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
389  };
390 
395  public FundamentalException
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  //override of CommonExceptionBase::GetName
416  const std::wstring GetName() const {return L"Safir.Dob.Typesystem.NullException";}
417 
419  static const TypeId ExceptionTypeId = -6392953138294149211LL;
420 
421  //override of CommonExceptionBase::GetTypeId
422  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
423  };
424 
425 
431  public FundamentalException
432  {
433  public:
446  ReadOnlyException(const std::wstring & message,
447  const std::wstring & fileName, //Use the __WFILE__ macro
448  const Dob::Typesystem::Int64 lineNumber)://Use the __LINE__ macro
449  FundamentalException(message,fileName,lineNumber) {}
450 
451  //override of CommonExceptionBase::GetName
452  const std::wstring GetName() const {return L"Safir.Dob.Typesystem.ReadOnlyException";}
453 
455  static const TypeId ExceptionTypeId = -4804695341042352897LL;
456 
457  //override of CommonExceptionBase::GetTypeId
458  virtual TypeId GetTypeId() const {return ExceptionTypeId;}
459  };
460 }
461 }
462 }
463 #endif
IllegalValueException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition: Exceptions.h:270
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:388
const std::wstring GetName() const
Get the exception name.
Definition: Exceptions.h:382
Used when there is an error that implies that there is something wrong in the configuration.
Definition: Exceptions.h:324
ConfigurationErrorException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition: Exceptions.h:340
const std::wstring GetName() const
Get the exception name.
Definition: Exceptions.h:452
DOTS_CPP_API Dob::Typesystem::TypeId GetTypeId(const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::MemberIndex member)
Get type id of object or enumeration member.
const std::wstring & GetMessage() const
Get the message about why the exception occurred.
Definition: Exceptions.h:111
This is the base class of all (non-Fundamental) Exceptions.
Definition: Exceptions.h:223
SoftwareViolationException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition: Exceptions.h:376
Meant to be used when something goes very wrong.
Definition: Exceptions.h:360
This is the base class of all Fundamental Exceptions.
Definition: Exceptions.h:190
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:458
DotsC_Int64 Int64
64 bit integer type.
Definition: Defs.h:70
DotsC_TypeId TypeId
A unique type identifier.
Definition: Defs.h:219
NullException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition: Exceptions.h:410
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:214
ReadOnlyException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition: Exceptions.h:446
const std::wstring GetName() const
Get the exception name.
Definition: Exceptions.h:311
const Dob::Typesystem::Int64 GetLineNumber() const
Get the line number that the exception occurred on.
Definition: Exceptions.h:132
const std::wstring GetName() const
Get the exception name.
Definition: Exceptions.h:346
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:352
A parameter in the call was invalid.
Definition: Exceptions.h:254
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:317
Thrown when an application attempts to get the value of a member that is null.
Definition: Exceptions.h:394
const std::wstring & GetFileName() const
Get the name of the file where the exception occurred.
Definition: Exceptions.h:125
const std::wstring GetName() const
Get the exception name.
Definition: Exceptions.h:416
IncompatibleTypesException(const std::wstring &message, const std::wstring &fileName, const Dob::Typesystem::Int64 lineNumber)
Constructor with exception information.
Definition: Exceptions.h:305
const std::wstring GetName() const
Get the exception name.
Definition: Exceptions.h:276
Common functionality for the exception hierarchy of the DOB typesystem.
Definition: Exceptions.h:63
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:282
#define DOTS_CPP_API
Definition: Defs.h:33
DOTS_CPP_API std::wstring GetName(const Dob::Typesystem::TypeId typeId, const Dob::Typesystem::MemberIndex member)
Get the name of the specified member as it was defined in the xml description.
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:422
virtual TypeId GetTypeId() const
Get the type id of this exception.
Definition: Exceptions.h:247
Used when someone tries to set a property that is mapped to something that cannot be changed...
Definition: Exceptions.h:430
This exception is thrown if a class cannot be cast to the expected type.
Definition: Exceptions.h:289