1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
|
/***************************************************************************
ofx_messages.cpp
-------------------
copyright : (C) 2002 by Benoit Gr�goire
email : benoitg@coeus.ca
***************************************************************************/
/**@file
* \brief Message IO functionality
*/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#include <iostream>
#include <stdlib.h>
#include <string>
#include "ParserEventGeneratorKit.h"
#include "ofx_utilities.hh"
#include "messages.hh"
#include "config.h"
#include "libofx.h"
SGMLApplication::OpenEntityPtr entity_ptr; /**< Global for determining the line number in OpenSP */
SGMLApplication::Position position; /**< Global for determining the line number in OpenSP */
int ofx_PARSER_msg = false; /**< If set to true, parser events will be printed to the console */
int ofx_DEBUG_msg = false;/**< If set to true, general debug messages will be printed to the console */
int ofx_DEBUG1_msg = false;/**< If set to true, debug level 1 messages will be printed to the console */
int ofx_DEBUG2_msg = false;/**< If set to true, debug level 2 messages will be printed to the console */
int ofx_DEBUG3_msg = false;/**< If set to true, debug level 3 messages will be printed to the console */
int ofx_DEBUG4_msg = false;/**< If set to true, debug level 4 messages will be printed to the console */
int ofx_DEBUG5_msg = false;/**< If set to true, debug level 5 messages will be printed to the console */
int ofx_STATUS_msg = false;/**< If set to true, status messages will be printed to the console */
int ofx_INFO_msg = false;/**< If set to true, information messages will be printed to the console */
int ofx_WARNING_msg = false;/**< If set to true, warning messages will be printed to the console */
int ofx_ERROR_msg = false;/**< If set to true, error messages will be printed to the console */
int ofx_show_position = true;/**< If set to true, the line number will be shown after any error */
void show_line_number()
{
extern SGMLApplication::OpenEntityPtr entity_ptr;
extern SGMLApplication::Position position;
if (ofx_show_position == true)
{
SGMLApplication::Location *location = new SGMLApplication::Location(entity_ptr, position);
cerr << "(Above message occured on Line " << location->lineNumber << ", Column " << location->columnNumber << ")" << endl;
delete location;
}
}
/**
Prints a message to stdout, if the corresponding message OfxMsgType given in the parameters is enabled
*/
int message_out(OfxMsgType error_type, const string message)
{
switch (error_type)
{
case DEBUG :
if (ofx_DEBUG_msg == true)
{
cerr << "LibOFX DEBUG: " << message << "\n";
show_line_number();
}
break;
case DEBUG1 :
if (ofx_DEBUG1_msg == true)
{
cerr << "LibOFX DEBUG1: " << message << "\n";
show_line_number();
}
break;
case DEBUG2 :
if (ofx_DEBUG2_msg == true)
{
cerr << "LibOFX DEBUG2: " << message << "\n";
show_line_number();
}
break;
case DEBUG3 :
if (ofx_DEBUG3_msg == true)
{
cerr << "LibOFX DEBUG3: " << message << "\n";
show_line_number();
}
break;
case DEBUG4 :
if (ofx_DEBUG4_msg == true)
{
cerr << "LibOFX DEBUG4: " << message << "\n";
show_line_number();
}
break;
case DEBUG5 :
if (ofx_DEBUG5_msg == true)
{
cerr << "LibOFX DEBUG5: " << message << "\n";
show_line_number();
}
break;
case STATUS :
if (ofx_STATUS_msg == true)
{
cerr << "LibOFX STATUS: " << message << "\n";
show_line_number();
}
break;
case INFO :
if (ofx_INFO_msg == true)
{
cerr << "LibOFX INFO: " << message << "\n";
show_line_number();
}
break;
case WARNING :
if (ofx_WARNING_msg == true)
{
cerr << "LibOFX WARNING: " << message << "\n";
show_line_number();
}
break;
case ERROR :
if (ofx_ERROR_msg == true)
{
cerr << "LibOFX ERROR: " << message << "\n";
show_line_number();
}
break;
case PARSER :
if (ofx_PARSER_msg == true)
{
cerr << "LibOFX PARSER: " << message << "\n";
show_line_number();
}
break;
default:
cerr << "LibOFX UNKNOWN ERROR CLASS, This is a bug in LibOFX\n";
show_line_number();
}
return 0;
}
|