LibOFX
messages.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           ofx_messages.cpp
00003                              -------------------
00004     copyright            : (C) 2002 by Benoit Gr�goire
00005     email                : benoitg@coeus.ca
00006 ***************************************************************************/
00010 /***************************************************************************
00011  *                                                                         *
00012  *   This program is free software; you can redistribute it and/or modify  *
00013  *   it under the terms of the GNU General Public License as published by  *
00014  *   the Free Software Foundation; either version 2 of the License, or     *
00015  *   (at your option) any later version.                                   *
00016  *                                                                         *
00017  ***************************************************************************/
00018 #include <iostream>
00019 #include <stdlib.h>
00020 #include <string>
00021 #include "ParserEventGeneratorKit.h"
00022 #include "ofx_utilities.hh"
00023 #include "messages.hh"
00024 #include "config.h"
00025 #include "libofx.h"
00026 
00027 SGMLApplication::OpenEntityPtr entity_ptr; 
00028 SGMLApplication::Position position; 
00030 int ofx_PARSER_msg = false; 
00031 int ofx_DEBUG_msg = false;
00032 int ofx_DEBUG1_msg = false;
00033 int ofx_DEBUG2_msg = false;
00034 int ofx_DEBUG3_msg = false;
00035 int ofx_DEBUG4_msg = false;
00036 int ofx_DEBUG5_msg = false;
00037 int ofx_STATUS_msg = false;
00038 int ofx_INFO_msg = false;
00039 int ofx_WARNING_msg = false;
00040 int ofx_ERROR_msg = false;
00041 int ofx_show_position = true;
00043 void show_line_number()
00044 {
00045   extern SGMLApplication::OpenEntityPtr entity_ptr;
00046   extern SGMLApplication::Position position;
00047 
00048 
00049   if (ofx_show_position == true)
00050   {
00051     SGMLApplication::Location *location = new SGMLApplication::Location(entity_ptr, position);
00052     cerr << "(Above message occured on Line " << location->lineNumber << ", Column " << location->columnNumber << ")" << endl;
00053     delete location;
00054   }
00055 }
00056 
00060 int message_out(OfxMsgType error_type, const string message)
00061 {
00062 
00063 
00064   switch  (error_type)
00065   {
00066   case DEBUG :
00067     if (ofx_DEBUG_msg == true)
00068     {
00069       cerr << "LibOFX DEBUG: " << message << "\n";
00070       show_line_number();
00071     }
00072     break;
00073   case DEBUG1 :
00074     if (ofx_DEBUG1_msg == true)
00075     {
00076       cerr << "LibOFX DEBUG1: " << message << "\n";
00077       show_line_number();
00078     }
00079     break;
00080   case DEBUG2 :
00081     if (ofx_DEBUG2_msg == true)
00082     {
00083       cerr << "LibOFX DEBUG2: " << message << "\n";
00084       show_line_number();
00085     }
00086     break;
00087   case DEBUG3 :
00088     if (ofx_DEBUG3_msg == true)
00089     {
00090       cerr << "LibOFX DEBUG3: " << message << "\n";
00091       show_line_number();
00092     }
00093     break;
00094   case DEBUG4 :
00095     if (ofx_DEBUG4_msg == true)
00096     {
00097       cerr << "LibOFX DEBUG4: " << message << "\n";
00098       show_line_number();
00099     }
00100     break;
00101   case DEBUG5 :
00102     if (ofx_DEBUG5_msg == true)
00103     {
00104       cerr << "LibOFX DEBUG5: " << message << "\n";
00105       show_line_number();
00106     }
00107     break;
00108   case STATUS :
00109     if (ofx_STATUS_msg == true)
00110     {
00111       cerr << "LibOFX STATUS: " << message << "\n";
00112       show_line_number();
00113     }
00114     break;
00115   case INFO :
00116     if (ofx_INFO_msg == true)
00117     {
00118       cerr << "LibOFX INFO: " << message << "\n";
00119       show_line_number();
00120     }
00121     break;
00122   case WARNING :
00123     if (ofx_WARNING_msg == true)
00124     {
00125       cerr << "LibOFX WARNING: " << message << "\n";
00126       show_line_number();
00127     }
00128     break;
00129   case ERROR :
00130     if (ofx_ERROR_msg == true)
00131     {
00132       cerr << "LibOFX ERROR: " << message << "\n";
00133       show_line_number();
00134     }
00135     break;
00136   case PARSER :
00137     if (ofx_PARSER_msg == true)
00138     {
00139       cerr << "LibOFX PARSER: " << message << "\n";
00140       show_line_number();
00141     }
00142     break;
00143   default:
00144     cerr << "LibOFX UNKNOWN ERROR CLASS, This is a bug in LibOFX\n";
00145     show_line_number();
00146   }
00147 
00148   return 0;
00149 }
00150