NuTo
Numerics Tool
Debug.h
Go to the documentation of this file.
1 #pragma once
2 
3 #ifdef NDEBUG
4 #define DBG_POSITION ;
5 #define DBG_POSITION_INFO(v) ;
6 #define DBG_PRINT_VAL(v) ;
7 #define DBG_PRINT_VEC(v) ;
8 
9 #else // NDEBUG
10 
11 #include <iostream>
12 #include <boost/foreach.hpp>
13 #include <boost/typeof/typeof.hpp>
14 
15 #define DBG_OPENER std::cout << __FILE__ << ":" << __LINE__ << ":\t"
16 
17 #define DBG_POSITION DBG_OPENER << std::endl;
18 
19 #define DBG_POSITION_INFO(v) DBG_OPENER << "'\"" << (v) << "\"" << std::endl;
20 
21 #define DBG_PRINT_VAL(v) DBG_OPENER << "'" << #v << "' = \"" << (v) << "\"" << std::endl << std::endl;
22 
23 #define DBG_PRINT_VEC(v) \
24  DBG_OPENER << "Entries of: \"" << #v << "\"" << std::endl; \
25  { \
26  std::size_t dbg_i(0); \
27  BOOST_FOREACH (BOOST_TYPEOF(*boost::begin(v)) const& x, v) \
28  std::cout << #v << "[" << dbg_i++ << "] : \"" << x << "\"" << std::endl; \
29  } \
30  std::cout << std::endl << std::endl;
31 
32 #endif // NDEBUG