00001 #ifndef BASE_DEBUG_H
00002 #define BASE_DEBUG_H
00003 #include "Env.h"
00004 #include <stdarg.h>
00005 #include <iostream>
00006
00007
00008
00009
00010
00011
00012
00013 #define DPF Spr::DebugPrintf::GetInstance()->FileLine(__FILE__, __LINE__)
00014
00015
00016
00017
00018 #define DSTR (Spr::DebugPrintf::GetInstance()->Stream())
00019
00020 #include <assert.h>
00021
00022 namespace Spr {
00023
00024 class SPR_DLL DebugPrintf{
00025 public:
00026 static DebugPrintf* GetInstance();
00027 struct SPR_DLL PrintfFunc{
00028 const char* file;
00029 int line;
00030 PrintfFunc(const char* f, int l):file(f), line(l){}
00031 int SPR_CDECL operator() (const char*, ...);
00032 };
00033 PrintfFunc FileLine(const char* f=0, int l=-1){
00034 return PrintfFunc(f, l);
00035 }
00036 std::ostream& Stream();
00037 static void Set(void (*out)(const char*));
00038 };
00039
00040 #if 0 // プログラムの動作を詳細に報告させるなら 1
00041 #define TRACEALL DebugPrintf
00042 #else
00043 #define TRACEALL (void*)
00044 #endif
00045
00046 #if defined(_DEBUG) && !defined(NO_DEBUG_EVAL)
00047 #define DEBUG_EVAL(x) x
00048 #else
00049 #define DEBUG_EVAL(x)
00050 #endif
00051 }
00052
00053 #endif