LibOFX

- Main Page
- Namespaces
- Data Structures
- Files

- File List
- Globals

# 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
    00025 SGMLApplication::OpenEntityPtr entity_ptr;
    00026 SGMLApplication::Position position;
    00028 volatile int ofx_PARSER_msg = false;
    00029 volatile int ofx_DEBUG_msg = false;
    00030 volatile int ofx_DEBUG1_msg = false;
    00031 volatile int ofx_DEBUG2_msg = false;
    00032 volatile int ofx_DEBUG3_msg = false;
    00033 volatile int ofx_DEBUG4_msg = false;
    00034 volatile int ofx_DEBUG5_msg = false;
    00035 volatile int ofx_STATUS_msg = false;
    00036 volatile int ofx_INFO_msg = false;
    00037 volatile int ofx_WARNING_msg = false;
    00038 volatile int ofx_ERROR_msg = false;
    00039 volatile int ofx_show_position = true;
    00041 void show_line_number()
    00042 {
    00043   extern SGMLApplication::OpenEntityPtr entity_ptr;
    00044   extern SGMLApplication::Position position;
    00045
    00046
    00047   if ((ofx_show_position == true))
    00048   {
    00049     SGMLApplication::Location *location = new SGMLApplication::Location(entity_ptr, position);
    00050     cerr << "(Above message occured on Line " << location->lineNumber << ", Column " << location->columnNumber << ")" << endl;
    00051     delete location;
    00052   }
    00053 }
    00054
    00058 int message_out(OfxMsgType error_type, const string message)
    00059 {
    00060
    00061
    00062   switch  (error_type)
    00063   {
    00064   case DEBUG :
    00065     if (ofx_DEBUG_msg == true)
    00066     {
    00067       cerr << "LibOFX DEBUG: " << message << "\n";
    00068       show_line_number();
    00069     }
    00070     break;
    00071   case DEBUG1 :
    00072     if (ofx_DEBUG1_msg == true)
    00073     {
    00074       cerr << "LibOFX DEBUG1: " << message << "\n";
    00075       show_line_number();
    00076     }
    00077     break;
    00078   case DEBUG2 :
    00079     if (ofx_DEBUG2_msg == true)
    00080     {
    00081       cerr << "LibOFX DEBUG2: " << message << "\n";
    00082       show_line_number();
    00083     }
    00084     break;
    00085   case DEBUG3 :
    00086     if (ofx_DEBUG3_msg == true)
    00087     {
    00088       cerr << "LibOFX DEBUG3: " << message << "\n";
    00089       show_line_number();
    00090     }
    00091     break;
    00092   case DEBUG4 :
    00093     if (ofx_DEBUG4_msg == true)
    00094     {
    00095       cerr << "LibOFX DEBUG4: " << message << "\n";
    00096       show_line_number();
    00097     }
    00098     break;
    00099   case DEBUG5 :
    00100     if (ofx_DEBUG5_msg == true)
    00101     {
    00102       cerr << "LibOFX DEBUG5: " << message << "\n";
    00103       show_line_number();
    00104     }
    00105     break;
    00106   case STATUS :
    00107     if (ofx_STATUS_msg == true)
    00108     {
    00109       cerr << "LibOFX STATUS: " << message << "\n";
    00110       show_line_number();
    00111     }
    00112     break;
    00113   case INFO :
    00114     if (ofx_INFO_msg == true)
    00115     {
    00116       cerr << "LibOFX INFO: " << message << "\n";
    00117       show_line_number();
    00118     }
    00119     break;
    00120   case WARNING :
    00121     if (ofx_WARNING_msg == true)
    00122     {
    00123       cerr << "LibOFX WARNING: " << message << "\n";
    00124       show_line_number();
    00125     }
    00126     break;
    00127   case ERROR :
    00128     if (ofx_ERROR_msg == true)
    00129     {
    00130       cerr << "LibOFX ERROR: " << message << "\n";
    00131       show_line_number();
    00132     }
    00133     break;
    00134   case PARSER :
    00135     if (ofx_PARSER_msg == true)
    00136     {
    00137       cerr << "LibOFX PARSER: " << message << "\n";
    00138       show_line_number();
    00139     }
    00140     break;
    00141   default:
    00142     cerr << "LibOFX UNKNOWN ERROR CLASS, This is a bug in LibOFX\n";
    00143     show_line_number();
    00144   }
    00145
    00146   return 0;
    00147 }
    00148