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