libshevek

- Main Page
- Classes
- Files

- File List

src/debug.hh

    00001 /* debug.hh - debugging macros
    00002  * Copyright 2003 Bas Wijnen <wijnen@debian.org>
    00003  *
    00004  * This program is free software: you can redistribute it and/or modify
    00005  * it under the terms of the GNU General Public License as published by
    00006  * the Free Software Foundation, either version 3 of the License, or
    00007  * (at your option) any later version.
    00008  *
    00009  * This program is distributed in the hope that it will be useful,
    00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  * GNU General Public License for more details.
    00013  *
    00014  * You should have received a copy of the GNU General Public License
    00015  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
    00016  */
    00017
    00018 #ifndef SHEVEK_DEBUG_HH
    00019 #define SHEVEK_DEBUG_HH
    00020
    00021 #include <iostream>
    00022 #include <iomanip>
    00023 #include <string>
    00024 #include <ctype.h>
    00025
    00026 #ifdef NDEBUG
    00027
    00028 #define startfunc
    00029 #define dbg(x)
    00030
    00031 #else // !defined (NDEBUG)
    00032
    00033 namespace shevek
    00034 {
    00035   extern bool _debug_dbg, _debug_startfunc;
    00037
    00040   void dump (std::string const &data, std::ostream &target, char def = '.');
    00041 }
    00042
    00044
    00048 #define startfunc \
    00049 do { if (shevek::_debug_startfunc) std::cerr << "Debug: entering " \
    00050   << __PRETTY_FUNCTION__ << '\n'; } while (0)
    00051
    00053
    00056 #define dbg(x) do { if (shevek::_debug_dbg) std::cerr << __FILE__ << ':' \
    00057         << __LINE__ << '(' << __FUNCTION__ << "): " << x << '\n'; } while (0)
    00058
    00059 #endif // !defined (NDEBUG)
    00060
    00061 #endif // defined (SHEVEK_DEBUG_HH)