00001 /*************************************************************************** 00002 *cr 00003 *cr (C) Copyright 1995-2019 The Board of Trustees of the 00004 *cr University of Illinois 00005 *cr All Rights Reserved 00006 *cr 00007 ***************************************************************************/ 00008 00009 /*************************************************************************** 00010 * RCS INFORMATION: 00011 * 00012 * $RCSfile: Inform.h,v $ 00013 * $Author: johns $ $Locker: $ $State: Exp $ 00014 * $Revision: 1.34 $ $Date: 2020/10/22 03:40:41 $ 00015 * 00016 *************************************************************************** 00017 * DESCRIPTION: 00018 * 00019 * Inform - takes messages and displays them to the given ostream. 00020 * 00021 ***************************************************************************/ 00022 #ifndef INFORM_H 00023 #define INFORM_H 00024 00025 // largest message (in bytes) that can be kept 00026 #define MAX_MSG_SIZE (1024 * 8) 00027 00028 #if defined(_WIN64) 00029 #include <stddef.h> // ptrdiff_t and size_t 00030 #endif 00031 00036 class Inform { 00037 private: 00038 char *name; 00039 char buf[MAX_MSG_SIZE]; 00040 #if defined(VMDTKCON) 00041 int loglvl; 00042 #endif 00043 int muted; 00044 00045 public: 00046 #if defined(VMDTKCON) 00047 Inform(const char *, int lvl); 00048 #else 00049 Inform(const char *); 00050 #endif 00051 ~Inform(); 00052 Inform &send(); 00053 Inform &reset(); 00054 00056 Inform& operator<<(const char *); 00057 Inform& operator<<(char); 00058 Inform& operator<<(int); 00059 Inform& operator<<(unsigned int); 00060 Inform& operator<<(long); 00061 Inform& operator<<(unsigned long); 00062 #if defined(_WIN64) 00063 // LLP64 platforms have to separately support ptrdiff_t and size_t, 00064 // since they are aliased to "long long" or other types rather than "long" 00065 Inform& operator<<(ptrdiff_t); 00066 Inform& operator<<(size_t); 00067 #endif 00068 00069 Inform& operator<<(double); 00070 Inform& operator<<(Inform& (*f)(Inform &)); 00071 00072 void mute() { muted = 1; } 00073 void unmute() { muted = 0; } 00074 00076 const char *text() const { 00077 return buf; 00078 } 00079 }; 00080 00081 extern Inform& sendmsg(Inform&); 00082 extern Inform& ends(Inform&); 00083 00084 // XXX these are global 00085 extern Inform msgInfo; 00086 extern Inform msgWarn; 00087 extern Inform msgErr; 00088 00089 #endif // INFORM_H 00090