LibOFX: messages.cpp Source File

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
27 SGMLApplication::OpenEntityPtr entity_ptr;
28 SGMLApplication::Position position;
30 int ofx_PARSER_msg = false;
31 int ofx_DEBUG_msg = false;
32 int ofx_DEBUG1_msg = false;
33 int ofx_DEBUG2_msg = false;
34 int ofx_DEBUG3_msg = false;
35 int ofx_DEBUG4_msg = false;
36 int ofx_DEBUG5_msg = false;
37 int ofx_STATUS_msg = false;
38 int ofx_INFO_msg = false;
39 int ofx_WARNING_msg = false;
40 int ofx_ERROR_msg = false;
41 int ofx_show_position = true;
43 void 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
61 int 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 }
ofx_DEBUG_msg
int ofx_DEBUG_msg
Definition: messages.cpp:31
ofx_DEBUG5_msg
int ofx_DEBUG5_msg
Definition: messages.cpp:36
position
SGMLApplication::Position position
Definition: messages.cpp:28
INFO
Definition: messages.hh:32
DEBUG3
Definition: messages.hh:28
STATUS
Definition: messages.hh:31
ofx_STATUS_msg
int ofx_STATUS_msg
Definition: messages.cpp:37
DEBUG2
Definition: messages.hh:27
ofx_WARNING_msg
int ofx_WARNING_msg
Definition: messages.cpp:39
ofx_INFO_msg
int ofx_INFO_msg
Definition: messages.cpp:38
ofx_DEBUG2_msg
int ofx_DEBUG2_msg
Definition: messages.cpp:33
WARNING
Definition: messages.hh:33
DEBUG4
Definition: messages.hh:29
message_out
int message_out(OfxMsgType error_type, const string message)
Message output function.
Definition: messages.cpp:61
PARSER
Definition: messages.hh:35
entity_ptr
SGMLApplication::OpenEntityPtr entity_ptr
Definition: messages.cpp:27
DEBUG
Definition: messages.hh:25
OfxMsgType
OfxMsgType
Definition: messages.hh:23
ofx_DEBUG3_msg
int ofx_DEBUG3_msg
Definition: messages.cpp:34
ofx_show_position
int ofx_show_position
Definition: messages.cpp:41
DEBUG5
Definition: messages.hh:30
ofx_utilities.hh
Various simple functions for type conversion & al.
ERROR
Definition: messages.hh:34
ofx_DEBUG4_msg
int ofx_DEBUG4_msg
Definition: messages.cpp:35
DEBUG1
Definition: messages.hh:26
ofx_PARSER_msg
int ofx_PARSER_msg
Definition: messages.cpp:30
ofx_DEBUG1_msg
int ofx_DEBUG1_msg
Definition: messages.cpp:32
ofx_ERROR_msg
int ofx_ERROR_msg
Definition: messages.cpp:40
messages.hh
Message IO functionality.