Graphite  Version 3
An experimental 3D geometry processing program
assert.h File Reference

Assertion checking mechanism. More...

#include <geogram/basic/common.h>
#include <string>

Go to the source code of this file.

Namespaces

 GEO
 Global Vorpaline namespace.
 

Macros

#define geo_assert(x)
 Verifies that a condition is met. More...
 
#define geo_range_assert(x, min_val, max_val)
 Verifies that a value is in a legal range. More...
 
#define geo_assert_not_reached
 Sets a non reachable point in the program. More...
 
#define geo_debug_assert(x)
 Verifies that a condition is met. More...
 
#define geo_debug_range_assert(x, min_val, max_val)
 Verifies that a value is in a legal range. More...
 
#define geo_debug(x)
 
#define geo_parano_assert(x)
 Verifies that a condition is met. More...
 
#define geo_parano_range_assert(x, min_val, max_val)
 Verifies that a value is in a legal range. More...
 

Enumerations

enum  GEO::AssertMode { GEO::ASSERT_THROW , GEO::ASSERT_ABORT , GEO::ASSERT_BREAKPOINT }
 Assert termination mode. More...
 

Functions

void GEO::set_assert_mode (AssertMode mode)
 Sets assertion mode. More...
 
AssertMode GEO::assert_mode ()
 Returns the current assert termination mode.
 
GEO_NORETURN_DECL void GEO::geo_abort () GEO_NORETURN
 Aborts the program. More...
 
GEO_NORETURN_DECL void GEO::geo_breakpoint () GEO_NORETURN
 Generates a debugger breakpoint programmatically. More...
 
GEO_NORETURN_DECL void GEO::geo_assertion_failed (const std::string &condition_string, const std::string &file, int line) GEO_NORETURN
 Prints an assertion failure. More...
 
GEO_NORETURN_DECL void GEO::geo_range_assertion_failed (double value, double min_value, double max_value, const std::string &file, int line) GEO_NORETURN
 Prints a range assertion failure. More...
 
GEO_NORETURN_DECL void GEO::geo_should_not_have_reached (const std::string &file, int line) GEO_NORETURN
 Prints an unreachable location failure. More...
 

Detailed Description

Assertion checking mechanism.

Definition in file assert.h.

Macro Definition Documentation

◆ geo_assert

#define geo_assert (   x)
Value:
{ \
if(!(x)) { \
GEO::geo_assertion_failed(#x, __FILE__, __LINE__); \
} \
}
GEO_NORETURN_DECL void geo_assertion_failed(const std::string &condition_string, const std::string &file, int line) GEO_NORETURN
Prints an assertion failure.

Verifies that a condition is met.

Checks if the condition x. If the condition is false, it prints an error messages and terminates the program.

Parameters
[in]xthe boolean expression of the condition
See also
geo_assertion_failed()

Definition at line 149 of file assert.h.

◆ geo_assert_not_reached

#define geo_assert_not_reached
Value:
{ \
GEO::geo_should_not_have_reached(__FILE__, __LINE__); \
}
GEO_NORETURN_DECL void geo_should_not_have_reached(const std::string &file, int line) GEO_NORETURN
Prints an unreachable location failure.

Sets a non reachable point in the program.

Definition at line 177 of file assert.h.

◆ geo_debug_assert

#define geo_debug_assert (   x)

Verifies that a condition is met.

Checks if the condition x. If the condition is false, it prints an error messages and terminates the program.

Parameters
[in]xthe boolean expression of the condition
See also
geo_assertion_failed()
Note
This assertion check is only active in debug mode.

Definition at line 196 of file assert.h.

◆ geo_debug_range_assert

#define geo_debug_range_assert (   x,
  min_val,
  max_val 
)

Verifies that a value is in a legal range.

Verifies that value x is in the range [min_value, max_value]. If this is false, it prints an error messages and terminates the program.

Parameters
[in]xthe value to verify
[in]min_valminimum allowed value
[in]max_valmaximum allowed value
See also
geo_range_assertion_failed()
Note
This assertion check is only active in debug mode.

Definition at line 197 of file assert.h.

◆ geo_parano_assert

#define geo_parano_assert (   x)

Verifies that a condition is met.

Checks if the condition x. If the condition is false, it prints an error messages and terminates the program.

Parameters
[in]xthe boolean expression of the condition
See also
geo_assertion_failed()
Note
This assertion check is only active in paranoid mode.

Definition at line 215 of file assert.h.

◆ geo_parano_range_assert

#define geo_parano_range_assert (   x,
  min_val,
  max_val 
)

Verifies that a value is in a legal range.

Verifies that value x is in the range [min_value, max_value]. If this is false, it prints an error messages and terminates the program.

Parameters
[in]xthe value to verify
[in]min_valminimum allowed value
[in]max_valmaximum allowed value
See also
geo_range_assertion_failed()
Note
This assertion check is only active in paranoid mode.

Definition at line 216 of file assert.h.

◆ geo_range_assert

#define geo_range_assert (   x,
  min_val,
  max_val 
)
Value:
{ \
if(((x) < (min_val)) || ((x) > (max_val))) { \
GEO::geo_range_assertion_failed(x, min_val, max_val, \
__FILE__, __LINE__ \
); \
} \
}
GEO_NORETURN_DECL void geo_range_assertion_failed(double value, double min_value, double max_value, const std::string &file, int line) GEO_NORETURN
Prints a range assertion failure.

Verifies that a value is in a legal range.

Verifies that value x is in the range [min_value, max_value]. If this is false, it prints an error messages and terminates the program.

Parameters
[in]xthe value to verify
[in]min_valminimum allowed value
[in]max_valmaximum allowed value
See also
geo_range_assertion_failed()

Definition at line 165 of file assert.h.