Main Page | Modules | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members

adsoio.h

Go to the documentation of this file.
00001 /*****************************************************************************
00002  * $Id: adsoio.h,v 1.10 2003/07/11 14:13:31 schou Exp $
00003  * Author: Jakob Schou Jensen <schou@sourceforge.net>
00004  * Licence: GPL
00005  *
00006  * Description: Adso io functions
00007  *
00008  ****************************************************************************/
00009 
00015 #ifndef ADSOIO_H
00016 #define ADSOIO_H
00017 #include <adsobase.h>
00018 
00019 //#define DEBUG 1
00020 
00021 #define iFatal fatal
00022 #define iError error
00023 #define iWarning warning
00024 
00025 void setOutputCallBack(void (*cbf)(char*)); // set all call backs
00026 void setErrorCallBack(void (*cbf)(char*));
00027 void setMessageCallBack(void (*cbf)(char*));
00028 void setPrintCallBack(void (*cbf)(char*));
00029 void error(int level, char *fmt,...);
00030 void error(char *fmt,...);
00031 void fatal(char *fmt,...);
00032 void warning(char *fmt,...);
00033 void message(char *fmt,...);
00034 void setVerboseLevel(int level);
00035 void print(int level, char *fmt,...);
00036 void print(char *fmt,...);
00037 void eprint(char *fmt,...);
00038 void info(char *fmt,...);
00039 void debugmsg(char *type, char *fmt,...);
00040 int errorMessageFlag();
00041 
00042 #ifdef ADSO_WINDOWS
00043 
00044 int snprintf(char *str, size_t size, const char *format, ...);
00045 
00046 #ifdef DEBUG
00047 #define DEBUGMSG(str) debugmsg(__FILE__,str)
00048 #define DEBUGMSGV1(fmt,v1) debugmsg(__FILE__,fmt,v1)
00049 #define DEBUGMSGV2(fmt,v1,v2) debugmsg(__FILE__,fmt,v1,v2)
00050 #define DEBUGMSGV3(fmt,v1,v2,v3) debugmsg(__FILE__,fmt,v1,v3)
00051 #define DEBUGMSGV4(fmt,v1,v2,v3,v4) debugmsg(__FILE__,fmt,v1,v3,v4)
00052 #define DEBUGMSGV5(fmt,v1,v2,v3,v4,v5) debugmsg(__FILE__,fmt,v1,v3,v4,v5)
00053 #else
00054 #define DEBUGMSG(str)
00055 #define DEBUGMSGV1(fmt,v1)
00056 #define DEBUGMSGV2(fmt,v1,v2)
00057 #define DEBUGMSGV3(fmt,v1,v2,v3)
00058 #define DEBUGMSGV4(fmt,v1,v2,v3,v4)
00059 #define DEBUGMSGV5(fmt,v1,v2,v3,v4,v5)
00060 #endif
00061 
00062 #else // ADSO_WINDOWS
00063 
00064 #ifdef DEBUG
00065 #define DEBUGMSG(...) debugmsg(__FILE__,__VA_ARGS__)
00066 #else
00067 #define DEBUGMSG(...)
00068 #endif
00069 
00070 #define DEBUGMSGV1 DEBUGMSG
00071 #define DEBUGMSGV2 DEBUGMSG
00072 #define DEBUGMSGV3 DEBUGMSG
00073 #define DEBUGMSGV4 DEBUGMSG
00074 #define DEBUGMSGV5 DEBUGMSG
00075 
00076 #endif // ADSO_WINDOWS
00077 
00078 class AdsoProgress {
00079   int total;
00080   int val;
00081   char *title;
00082 
00083 public:
00084   void update(int count){
00085     int v = (100*count)/total;
00086     if(v > val){
00087       if(title) print("\r%s [%d%%]",title,v);
00088       else print("\r[%d%%]",v);
00089       fflush(stdout);
00090       val = v;
00091     }
00092   }
00093 
00094   void done(){ 
00095     if(title) print("\r%s       \n",title);
00096     else print("\r       \r");
00097     fflush(stdout);
00098   }
00099 
00100   AdsoProgress(int tc, char *str){ 
00101     title = str;
00102     total = tc;
00103     val = 0;
00104     if(title) print("%s [0%%]",title);
00105     else print("[0%%]");
00106     fflush(stdout);
00107   }
00108 };
00109 
00110 #endif
00111 

Generated on Mon Jul 21 10:44:47 2003 for Rover by doxygen 1.3.2