src/exception.cpp

Go to the documentation of this file.
00001 /*
00002 * Copyright (c) 2006 by Kirill Kolodyazhniy.
00003 * See the file "license.terms" for information on usage and redistribution
00004 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
00005 */
00006 
00007 #include "exception.h"
00008 namespace MWidgets
00009 {
00010 
00011         /*************************************************************************************/
00012         char Exception::desc_buf[1024];
00013         int Exception::tempLine=0;
00014         std::string Exception::tempSrc="";
00015         /*************************************************************************************/
00016         Exception::Exception(const char* d,const char* f,int l)
00017         {
00018                 desc=d;
00019                 src=f;
00020                 line=l;
00021                 char buf[256];
00022                 itoa(line,buf,10);
00023                 std::string message="Exception [ ";
00024                 message+=desc;
00025                 message+=" ] ";
00026                 message+="in ";
00027                 message+=src;
00028                 message+=" on line ";
00029                 message+=buf;
00030                 desc=message;
00031         };
00032         /*************************************************************************************/
00033         Exception::Exception(Exception right,const char* d,const char* f,int l)
00034         {
00035                 desc=d;
00036                 src=f;
00037                 line=l;
00038                 char buf[256];
00039                 itoa(line,buf,10);
00040                 std::string message="Exception [ ";
00041                 message+=desc;
00042                 message+=" ] ";
00043                 message+="in ";
00044                 message+=src;
00045                 message+=" on line ";
00046                 message+=buf;
00047                 desc=message;
00048                 AddMsg(right.Msg().c_str());
00049         };
00050         /*************************************************************************************/
00051         void Exception::PreCreate(char* f,int l)
00052         {
00053                 tempLine=l;
00054                 tempSrc=f;
00055         };
00056         /*************************************************************************************/
00057         Exception Exception::Create(char* format,...)
00058         {
00059                 char desc_buf[1024];
00060                 desc_buf[0]=0;
00061                 va_list args;
00062                 va_start(args,format);
00063                 vsprintf(desc_buf,format,args);
00064                 va_end(args);
00065                 return Exception(&desc_buf[0],tempSrc.c_str(),tempLine);
00066         };
00067         /*************************************************************************************/
00068         std::string Exception::Msg()
00069         {
00070                 return desc;
00071         };
00072         /*************************************************************************************/
00073         void Exception::AddMsg(const char* str)
00074         {
00075                 desc+="\n";
00076                 desc+=str;
00077         };
00078         /*************************************************************************************/
00079 };

Generated on Thu Oct 26 13:47:45 2006 for MWidgets by  doxygen 1.4.7