Main Page   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

ADbg.h

Go to the documentation of this file.
00001 /************************************************************************
00002 BSD License post 1999 : 
00003 
00004 Copyright (c) 2001, Steve Lhomme
00005 All rights reserved.
00006 
00007 Redistribution and use in source and binary forms, with or without
00008 modification, are permitted provided that the following conditions are met: 
00009 
00010 - Redistributions of source code must retain the above copyright notice, this
00011 list of conditions and the following disclaimer.
00012 
00013 - Redistributions in binary form must reproduce the above copyright notice, 
00014 this list of conditions and the following disclaimer in the documentation
00015 and/or other materials provided with the distribution. 
00016 
00017 - The name of the author may not be used to endorse or promote products derived
00018 from this software without specific prior written permission. 
00019 
00020 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 
00021 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
00022 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO 
00023 EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 
00024 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
00025 OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 
00026 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 
00028 IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 
00029 OF SUCH DAMAGE. 
00030 ************************************************************************/
00031 
00032 
00033 /*
00034 
00035 newer versions from http://mukoli.free.fr/
00036 
00037 $Id: ADbg.h,v 1.3 2001/08/11 09:31:57 robux4 Exp $ 
00038 
00039 
00040 $Log: ADbg.h,v $
00041 Revision 1.3  2001/08/11 09:31:57  robux4
00042 Updated for version 1.4.0
00043 
00044 Revision 1.2  2001/07/31 18:49:39  robux4
00045 Initial Doxygen doc support
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 // define the working debugging class
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 // define a class that does nothing (no output)
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_)

Generated at Tue Aug 21 21:10:48 2001 for out_lame by doxygen1.2.9.1 written by Dimitri van Heesch, © 1997-2001