Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

/ray/src/lib/message/message.cc

Go to the documentation of this file.
00001 /*
00002  * lib/message/message.cc
00003  * 
00004  * Message handling "system" for errors, warnings and verbose messages. 
00005  * Implementation of message class (the message itself). 
00006  * 
00007  * Copyright (c) 2004 by Wolfgang Wieser ] wwieser (a) gmx <*> de [ 
00008  * 
00009  * This file may be distributed and/or modified under the terms of the 
00010  * GNU General Public License version 2 as published by the Free Software 
00011  * Foundation. (See COPYING.GPL for details.)
00012  * 
00013  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00014  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00015  * 
00016  */
00017 
00018 
00019 #include "message.h"
00020 #include "manager.h"
00021 
00022 
00023 // Internally used for all the printf-like messages. 
00024 void _vaMessage(Message::Type t,const SCLocationRange &loc,
00025     const char *fmt,va_list ap)
00026 {
00027     // Do printf formatting: 
00028     TLString str;
00029     str.vsprintf(fmt,ap);
00030     
00031     // Create message object. 
00032     Message m(t,str,loc);
00033     
00034     // Submit message. 
00035     MessageManager::PostMessage(m);
00036 }
00037 
00038 
00039 void Fatal(const char *fmt,...)
00040 {
00041     // Bail out early for uninteresting messages. 
00042     if(!MessageManager::IsRequestedType(Message::MTFatal))  return;
00043     // ...actually a fatal error message should never be "uninteresting"...
00044     
00045     va_list ap;
00046     va_start(ap,fmt);
00047     _vaMessage(Message::MTFatal,SCLocationRange(),fmt,ap);
00048     va_end(ap);
00049 }
00050 
00051 void Error(const char *fmt,...)
00052 {
00053     // Bail out early for uninteresting messages. 
00054     if(!MessageManager::IsRequestedType(Message::MTError))  return;
00055     
00056     va_list ap;
00057     va_start(ap,fmt);
00058     _vaMessage(Message::MTError,SCLocationRange(),fmt,ap);
00059     va_end(ap);
00060 }
00061 
00062 void Error(const SCLocation &loc,const char *fmt,...)
00063 {
00064     // Bail out early for uninteresting messages. 
00065     if(!MessageManager::IsRequestedType(Message::MTError))  return;
00066     
00067     va_list ap;
00068     va_start(ap,fmt);
00069     _vaMessage(Message::MTError,SCLocationRange(loc,SCLocation()),fmt,ap);
00070     va_end(ap);
00071 }
00072 
00073 void Error(const SCLocationRange &loc,const char *fmt,...)
00074 {
00075     // Bail out early for uninteresting messages. 
00076     if(!MessageManager::IsRequestedType(Message::MTError))  return;
00077     
00078     va_list ap;
00079     va_start(ap,fmt);
00080     _vaMessage(Message::MTError,loc,fmt,ap);
00081     va_end(ap);
00082 }
00083 
00084 void Warning(const char *fmt,...)
00085 {
00086     // Bail out early for uninteresting messages. 
00087     if(!MessageManager::IsRequestedType(Message::MTWarning))  return;
00088     
00089     va_list ap;
00090     va_start(ap,fmt);
00091     _vaMessage(Message::MTWarning,SCLocationRange(),fmt,ap);
00092     va_end(ap);
00093 }
00094 
00095 void Warning(const SCLocation &loc,const char *fmt,...)
00096 {
00097     // Bail out early for uninteresting messages. 
00098     if(!MessageManager::IsRequestedType(Message::MTWarning))  return;
00099     
00100     va_list ap;
00101     va_start(ap,fmt);
00102     _vaMessage(Message::MTWarning,SCLocationRange(loc,SCLocation()),fmt,ap);
00103     va_end(ap);
00104 }
00105 
00106 void Warning(const SCLocationRange &loc,const char *fmt,...)
00107 {
00108     // Bail out early for uninteresting messages. 
00109     if(!MessageManager::IsRequestedType(Message::MTWarning))  return;
00110     
00111     va_list ap;
00112     va_start(ap,fmt);
00113     _vaMessage(Message::MTWarning,loc,fmt,ap);
00114     va_end(ap);
00115 }
00116 
00117 void _Debug(Message::Type t,const char *fmt,...)
00118 {
00119     if(!MessageManager::IsRequestedType(t))  return;
00120     va_list ap; va_start(ap,fmt);
00121     _vaMessage(t,SCLocationRange(),fmt,ap);
00122     va_end(ap);
00123 }
00124 void _Debug(Message::Type t,const SCLocation &loc,const char *fmt,...)
00125 {
00126     if(!MessageManager::IsRequestedType(t))  return;
00127     va_list ap; va_start(ap,fmt);
00128     _vaMessage(t,SCLocationRange(loc,SCLocation()),fmt,ap);
00129     va_end(ap);
00130 }
00131 void _Debug(Message::Type t,const SCLocationRange &loc,const char *fmt,...)
00132 {
00133     if(!MessageManager::IsRequestedType(t))  return;
00134     va_list ap; va_start(ap,fmt); _vaMessage(t,loc,fmt,ap); va_end(ap);
00135 }
00136 
00137 //------------------------------------------------------------------------------
00138 
00139 Message::Message(const SError &e,const SCLocation &l) : 
00140     msgstr(e.msg()),
00141     loc(l,SCLocation()),
00142     mtype(e.code()>0 ? Message::MTError : 
00143         (e.code()<0 ? Message::MTWarning : Message::MTNone))
00144 {
00145     // empty
00146 }

Generated on Sat Feb 19 22:33:45 2005 for Ray by doxygen 1.3.5