convert line ends
[canaan.git] / prj / tech / libsrc / lg / dbgpp.h
blobadfec1a5469c10e4623209e0fadcf22fc99664e8
1 // $Header: x:/prj/tech/libsrc/lg/RCS/dbgpp.h 1.5 1996/10/10 12:11:38 TOML Exp $
2 // $Log: dbgpp.h $
3 // Revision 1.5 1996/10/10 12:11:38 TOML
4 // msvc
5 //
6 // Revision 1.4 1996/01/24 10:48:59 DAVET
7 // Added cplusplus stuff
8 //
9 // Revision 1.3 1995/03/15 22:27:15 ept
10 // Added Errorpp and WarnUserpp to things defined when DBG_ON not set.
12 // Revision 1.2 1994/12/06 22:39:46 lmfeeney
13 // correct args for Errorpp
15 // Revision 1.1 1994/08/12 17:18:41 jak
16 // Initial revision
19 #ifndef _DBGPP_H
20 #define _DBGPP_H
22 #include <iostream.h>
23 #include <strstrea.h>
24 extern "C" {
25 #include <dbg.h>
27 #ifdef __cplusplus
28 extern "C" {
29 #endif // cplusplus
32 class dbgostrstream : public ostrstream
34 public:
35 dbgostrstream() {}
36 #ifdef __WATCOMC__
37 dbgostrstream( char *str, int len, ios::openmode mode = ios::out ) :
38 #else
39 dbgostrstream( char *str, int len, ios::open_mode mode = ios::out ) :
40 #endif
41 ostrstream(str,len,mode) {}
42 void flush_to_dbg( int reportType, int errCode, int src );
43 dbgostrstream &prefix( int reportType );
44 ~dbgostrstream() {}
45 } ;
47 // The debug stream object itself
48 extern dbgostrstream dbgppStream;
50 #ifdef DBG_ON
52 #define Errorpp(n,msg) ((dbgppStream.prefix(DBG_ERROR) << msg),dbgppStream.flush_to_dbg(DBG_ERROR,n,0))
53 #define WarnUserpp(msg) ((dbgppStream.prefix(DBG_WARNUSER) << msg),dbgppStream.flush_to_dbg(DBG_WARNUSER,0,0))
55 #ifdef WARN_ON
56 #define Warningpp(msg) ((dbgppStream.prefix(DBG_WARNING) << msg),dbgppStream.flush_to_dbg(DBG_WARNING,0,0))
57 #define Assrtpp(expr,msg) if (!(expr)) Warningpp(msg) ; else
58 #else
59 #define Warningpp(msg) do {} while (0)
60 #define Assertpp(expr,msg) do {} while (0)
61 #endif
63 #ifdef SPEW_ON
64 #define Spewpp(src,msg) do { if (DbgSpewTest(src)) ((dbgppStream.prefix(DBG_SPEW) << msg),dbgppStream.flush_to_dbg(DBG_SPEW,0,(src))); } while (0)
65 #else
66 #define Spewpp(src,msg) do {} while (0)
67 #endif
69 #else
71 // If DBG_ON not defined, most macros and functions are macro'ed to
72 // nothing or (0). A few functions remain
74 #define Errorpp(n,msg) ((dbgppStream.prefix(DBG_ERROR) << msg),dbgppStream.flush_to_dbg(DBG_ERROR,n,0))
75 #define WarnUserpp(msg) ((dbgppStream.prefix(DBG_WARNUSER) << msg),dbgppStream.flush_to_dbg(DBG_WARNUSER,0,0))
76 #define Warningpp(msg)
77 #define Assertpp(expr,msg)
78 #define Spewpp(src,msg)
80 #endif // DBG_ON
82 #ifdef __cplusplus
84 #endif // cplusplus
86 #endif // _DBGPP_H