00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050 #if !defined(_DBG_H__INCLUDED_)
00051 #define _DBG_H__INCLUDED_
00052
00053 #include <windows.h>
00054
00055 static const int MAX_PREFIX_LENGTH = 128;
00056
00057 #if !defined(NDEBUG)
00058
00059
00067 class ADbg
00068 {
00069 public:
00075 ADbg(int level = 0);
00076
00080 virtual ~ADbg();
00081
00089 int OutPut(int level, const char * format,...);
00090
00097 int OutPut(const char * format,...);
00098
00104 inline int setLevel(const int level) {
00105 int prev_level = my_level;
00106 my_level = level;
00107 return prev_level;
00108 }
00109
00115 inline bool setIncludeTime(const bool included = true) {
00116 bool prev_include = my_time_included;
00117 my_time_included = included;
00118 return prev_include;
00119 }
00120
00126 bool setDebugFile(const char * NewFilename);
00127
00134 bool unsetDebugFile();
00135
00141 inline bool setUseFile(const bool usefile = true) {
00142 bool prev_use = my_use_file;
00143 my_use_file = usefile;
00144 return my_use_file;
00145 }
00146
00152 inline const char * setPrefix(const char * string) {
00153 return strncpy(prefix, string, MAX_PREFIX_LENGTH);
00154 }
00155
00156 private:
00157 int my_level;
00158 bool my_time_included;
00159 bool my_use_file;
00160 bool my_debug_output;
00161
00162 int _OutPut(const char * format,va_list params);
00163
00164 char prefix[MAX_PREFIX_LENGTH];
00165
00166 HANDLE hFile;
00167 };
00168
00169 #else // !defined(NDEBUG)
00170
00171
00172
00173 class ADbg
00174 {
00175 public:
00176 ADbg(int level = 0){}
00177 virtual ~ADbg() {}
00178
00179 inline int OutPut(int level, const char * format,...) {
00180 return 0;
00181 }
00182
00183 inline int OutPut(const char * format,...) {
00184 return 0;
00185 }
00186
00187 inline int setLevel(const int level) {
00188 return level;
00189 }
00190
00191 inline bool setIncludeTime(const bool included = true) {
00192 return true;
00193 }
00194
00195 inline bool setDebugFile(const char * NewFilename) {
00196 return true;
00197 }
00198
00199 inline bool unsetDebugFile() {
00200 return true;
00201 }
00202
00203 inline bool setUseFile(const bool usefile = true) {
00204 return true;
00205 }
00206
00207 inline const char * setPrefix(const char * string) {
00208 return string;
00209 }
00210 };
00211
00212 #endif // !defined(NDEBUG)
00213
00214 #endif // !defined(_DBG_H__INCLUDED_)