pgRouting  2.2
pgRouting extends the PostGIS / PostgreSQL geospatial database to provide geospatial routing functionality.
 All Classes Functions Variables Pages
pgr_assert.h
1 /*PGR-MIT******************************************************************
2  *
3  * file pgr_assert.h
4  *
5  * Copyright 2014 Stephen Woodbridge <woodbri@imaptools.com>
6  * Copyright 2014 Vicky Vergara <vicky_vergara@hotmail.com>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the MIT License. Please file MIT-LICENSE for details.
10  *
11  *****************************************************************PGR-MIT*/
12 
13 
14 
24 #ifndef SRC_COMMON_SRC_PGR_ASSERT_H_
25 #define SRC_COMMON_SRC_PGR_ASSERT_H_
26 
27 #include <exception>
28 
29 #ifdef assert
30 #undef assert
31 #endif
32 
33 #ifndef __STRING
34 #define __STRING(x) #x
35 #endif
36 
37 #define __TOSTRING(x) __STRING(x)
38 
69 #ifdef NDEBUG
70 #define assert(expr) ((void)0)
71 #else
72 #define assert(expr) \
73  ((expr) \
74  ? static_cast<void>(0) \
75  : throw AssertFailedException("AssertFailedException: " __STRING(expr) " at " __FILE__ ":" __TOSTRING(__LINE__) ))
76 #endif
77 
78 
82 class AssertFailedException : public std::exception {
83  private:
84  const char *str;
85 
86  public:
87  virtual const char *what() const throw();
88  explicit AssertFailedException(const char *_str);
89 };
90 
91 #endif // SRC_COMMON_SRC_PGR_ASSERT_H_
const char * str
str Holds the what() string for the exception.
Definition: pgr_assert.h:84
Extends std::exception and is the exception that we throw if an assert fails.
Definition: pgr_assert.h:82