PGROUTING
3.2
pgr_assert.h
Go to the documentation of this file.
1
/*PGR-GNU*****************************************************************
2
3
FILE: pgr_assert
4
5
Copyright 2015~ Vicky Vergara <
[email protected]
>
6
Copyright 2014 Stephen Woodbridge <
[email protected]
>
7
8
------
9
10
This program is free software; you can redistribute it and/or modify
11
it under the terms of the GNU General Public License as published by
12
the Free Software Foundation; either version 2 of the License, or
13
(at your option) any later version.
14
15
This program 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 this program; if not, write to the Free Software
22
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23
24
********************************************************************PGR-GNU*/
25
26
#ifndef INCLUDE_CPP_COMMON_PGR_ASSERT_H_
27
#define INCLUDE_CPP_COMMON_PGR_ASSERT_H_
28
#pragma once
29
30
#include <string>
31
#include <exception>
32
33
#ifdef assert
34
#undef assert
35
#endif
36
37
54
#ifndef __STRING
55
#define __STRING(x) #x
56
#endif
57
58
#define __TOSTRING(x) __STRING(x)
59
60
91
#ifdef NDEBUG
92
#define pgassert(expr) ((void)0)
93
#else
94
#define pgassert(expr) \
95
((expr) \
96
? static_cast<void>(0) \
97
: throw AssertFailedException( \
98
"AssertFailedException: " __STRING(expr) \
99
" at " __FILE__ ":" __TOSTRING(__LINE__) + get_backtrace() ) )
100
#endif
101
114
#ifdef NDEBUG
115
#define pgassertwm(expr, msg) ((void)0)
116
#else
117
#define pgassertwm(expr, msg) \
118
((expr) \
119
? static_cast<void>(0) \
120
: throw AssertFailedException( \
121
"AssertFailedException: " __STRING(expr) \
122
" at " __FILE__ ":" __TOSTRING(__LINE__) + get_backtrace(msg) ) )
123
#endif
124
133
std::string
get_backtrace
();
134
std::string
get_backtrace
(
const
std::string &);
135
139
class
AssertFailedException
:
public
std::exception {
140
private
:
141
const
std::string
str
;
142
143
public
:
144
virtual
const
char
*
what
()
const
throw();
145
explicit
AssertFailedException
(std::
string
msg);
146
virtual ~
AssertFailedException
() throw() {}
147
};
148
149
#endif // INCLUDE_CPP_COMMON_PGR_ASSERT_H_
AssertFailedException::what
virtual const char * what() const
Definition:
pgr_assert.cpp:67
AssertFailedException::str
const std::string str
Holds what() we got as message.
Definition:
pgr_assert.h:141
get_backtrace
std::string get_backtrace()
returns the execution path of the trace
Definition:
pgr_assert.cpp:40
AssertFailedException
Extends std::exception and is the exception that we throw if an assert fails.
Definition:
pgr_assert.h:139
include
cpp_common
pgr_assert.h
Generated on Tue May 25 2021 15:09:48 for PGROUTING by
1.8.17