vrpRouting
0.3
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
55
#ifndef __STRING
56
#define __STRING(x) #x
57
#endif
58
59
#define __TOSTRING(x) __STRING(x)
60
61
92
#ifdef NDEBUG
93
#define pgassert(expr) ((void)0)
94
#else
95
#define pgassert(expr) \
96
((expr) \
97
? static_cast<void>(0) \
98
: throw AssertFailedException( \
99
"AssertFailedException: " __STRING(expr) \
100
" at " __FILE__ ":" __TOSTRING(__LINE__) + get_backtrace() ) )
101
#endif
102
115
#ifdef NDEBUG
116
#define pgassertwm(expr, msg) ((void)0)
117
#else
118
#define pgassertwm(expr, msg) \
119
((expr) \
120
? static_cast<void>(0) \
121
: throw AssertFailedException( \
122
"AssertFailedException: " __STRING(expr) \
123
" at " __FILE__ ":" __TOSTRING(__LINE__) + get_backtrace(msg) ) )
124
#endif
125
134
std::string
get_backtrace
();
135
std::string
get_backtrace
(
const
std::string &);
136
140
class
AssertFailedException
:
public
std::exception {
141
private
:
142
const
std::string
str
;
143
144
public
:
145
virtual
const
char
*
what
()
const
throw();
146
explicit
AssertFailedException
(std::
string
msg);
147
virtual ~
AssertFailedException
() throw() {}
148
};
149
150
#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:142
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:140
include
cpp_common
pgr_assert.h
Generated on Tue Nov 15 2022 03:49:51 for vrpRouting by
1.8.17