00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef _LIB_MESSAGE_MESSAGE_H_
00019 #define _LIB_MESSAGE_MESSAGE_H_ 1
00020
00058 #include <lib/tl/tlstring.h>
00059 #include <lib/lex/location.h>
00060 #include <lib/serror.h>
00061
00062
00070 class Message
00071 {
00072 public:
00085 enum Type
00086 {
00087 MTNone = 0x00000000,
00088 MTFatal = 0x00000001,
00089 MTError = 0x00000002,
00090 MTWarning = 0x00000004,
00091 MTAnyDebug = 0xfffffff8,
00092 MTAllNonDebug= 0x00000007,
00093 MTAll = 0xffffffff,
00094 };
00095
00096 private:
00097 TLString msgstr;
00098
00099
00100 SCLocationRange loc;
00101 Type mtype;
00102
00103 public:
00105 inline Message(Type t) : msgstr(),loc(),mtype(t) {}
00107 inline Message(const Message &m) :
00108 msgstr(m.msgstr),loc(m.loc),mtype(m.mtype) {}
00110 inline Message(Type t,const TLString &msg) :
00111 msgstr(msg),loc(),mtype(t) {}
00113 inline Message(Type t,const TLString &msg,const SCLocation &l) :
00114 msgstr(msg),loc(l,SCLocation()),mtype(t) {}
00116 inline Message(Type t,const TLString &msg,const SCLocationRange &l) :
00117 msgstr(msg),loc(l),mtype(t) {}
00124 Message(const SError &e,const SCLocation &l=SCLocation());
00126 inline ~Message() {}
00127
00129 inline Message &operator=(const Message &m)
00130 { msgstr=m.msgstr; loc=m.loc; mtype=m.mtype; return(*this); }
00131
00133 inline Type type() const
00134 { return(mtype); }
00135
00137 inline const SCLocation &location() const
00138 { return(loc.loc0); }
00139
00141 inline const SCLocationRange &LocationRange() const
00142 { return(loc); }
00143
00145 inline const TLString &msg() const
00146 { return(msgstr); }
00147
00149 inline bool MatchesTypeMask(Type t) const
00150 { return(t & mtype); }
00151 };
00152
00153
00154
00155
00156 #ifndef _LIB_MESSAGE_HANDLER_H_
00157 #include <lib/message/manager.h>
00158 #endif
00159
00161 void _vaMessage(Message::Type t,const SCLocationRange &loc,const char *fmt,
00162 va_list ap);
00163
00165
00166 extern void Fatal(const char *fmt,...)
00167 _fnformat_(__printf__,1,2);
00168 extern void Error(const char *fmt,...)
00169 _fnformat_(__printf__,1,2);
00170 extern void Error(const SCLocation &loc,const char *fmt,...)
00171 _fnformat_(__printf__,2,3);
00172 extern void Error(const SCLocationRange &loc,const char *fmt,...)
00173 _fnformat_(__printf__,2,3);
00174 extern void Warning(const char *fmt,...)
00175 _fnformat_(__printf__,1,2);
00176 extern void Warning(const SCLocation &loc,const char *fmt,...)
00177 _fnformat_(__printf__,2,3);
00178 extern void Warning(const SCLocationRange &loc,const char *fmt,...)
00179 _fnformat_(__printf__,2,3);
00180 extern void _Debug(Message::Type t,const char *fmt,...)
00181 _fnformat_(__printf__,2,3);
00182 extern void _Debug(Message::Type t,const SCLocation &loc,const char *fmt,...)
00183 _fnformat_(__printf__,3,4);
00184 extern void _Debug(Message::Type t,const SCLocationRange &loc,
00185 const char *fmt,...)
00186 _fnformat_(__printf__,3,4);
00188
00190 #define Debug(t,args...) \
00191 do { if(MessageManager::IsRequestedType((Message::Type)t)) \
00192 _Debug((Message::Type)t,args); } while(0)
00193
00194 #endif