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 #ifdef LIBOFX_DLL
28 # define LIBOFX_API __declspec(dllexport)
29 #else
30 # define LIBOFX_API
31 #endif
32
33 SGMLApplication::OpenEntityPtr entity_ptr;
34 SGMLApplication::Position position;
36 LIBOFX_API int ofx_PARSER_msg = false;
37 LIBOFX_API int ofx_DEBUG_msg = false;
38 LIBOFX_API int ofx_DEBUG1_msg = false;
39 LIBOFX_API int ofx_DEBUG2_msg = false;
40 LIBOFX_API int ofx_DEBUG3_msg = false;
41 LIBOFX_API int ofx_DEBUG4_msg = false;
42 LIBOFX_API int ofx_DEBUG5_msg = false;
43 LIBOFX_API int ofx_STATUS_msg = false;
44 LIBOFX_API int ofx_INFO_msg = false;
45 LIBOFX_API int ofx_WARNING_msg = false;
46 LIBOFX_API int ofx_ERROR_msg = true;
47 LIBOFX_API int ofx_show_position = true;
49 void show_line_number()
50 {
51 extern SGMLApplication::OpenEntityPtr entity_ptr;
52 extern SGMLApplication::Position position;
53
54
55 if (ofx_show_position == true)
56 {
57 SGMLApplication::Location *location = new SGMLApplication::Location(entity_ptr, position);
58 if (location->lineNumber < LONG_MAX)
59 std::cerr << "(Above message occurred on Line " << location->lineNumber << ", Column " << location->columnNumber << ")" << std::endl;
60 delete location;
61 }
62 }
63
67 int message_out(OfxMsgType error_type, const std::string message)
68 {
69
70
71 switch (error_type)
72 {
73 case DEBUG :
74 if (ofx_DEBUG_msg == true)
75 {
76 std::cerr << "LibOFX DEBUG: " << message << "\n";
77 show_line_number();
78 }
79 break;
80 case DEBUG1 :
81 if (ofx_DEBUG1_msg == true)
82 {
83 std::cerr << "LibOFX DEBUG1: " << message << "\n";
84 show_line_number();
85 }
86 break;
87 case DEBUG2 :
88 if (ofx_DEBUG2_msg == true)
89 {
90 std::cerr << "LibOFX DEBUG2: " << message << "\n";
91 show_line_number();
92 }
93 break;
94 case DEBUG3 :
95 if (ofx_DEBUG3_msg == true)
96 {
97 std::cerr << "LibOFX DEBUG3: " << message << "\n";
98 show_line_number();
99 }
100 break;
101 case DEBUG4 :
102 if (ofx_DEBUG4_msg == true)
103 {
104 std::cerr << "LibOFX DEBUG4: " << message << "\n";
105 show_line_number();
106 }
107 break;
108 case DEBUG5 :
109 if (ofx_DEBUG5_msg == true)
110 {
111 std::cerr << "LibOFX DEBUG5: " << message << "\n";
112 show_line_number();
113 }
114 break;
115 case STATUS :
116 if (ofx_STATUS_msg == true)
117 {
118 std::cerr << "LibOFX STATUS: " << message << "\n";
119 show_line_number();
120 }
121 break;
122 case INFO :
123 if (ofx_INFO_msg == true)
124 {
125 std::cerr << "LibOFX INFO: " << message << "\n";
126 show_line_number();
127 }
128 break;
129 case WARNING :
130 if (ofx_WARNING_msg == true)
131 {
132 std::cerr << "LibOFX WARNING: " << message << "\n";
133 show_line_number();
134 }
135 break;
136 case ERROR :
137 if (ofx_ERROR_msg == true)
138 {
139 std::cerr << "LibOFX ERROR: " << message << "\n";
140 show_line_number();
141 }
142 break;
143 case PARSER :
144 if (ofx_PARSER_msg == true)
145 {
146 std::cerr << "LibOFX PARSER: " << message << "\n";
147 show_line_number();
148 }
149 break;
150 default:
151 std::cerr << "LibOFX UNKNOWN ERROR CLASS, This is a bug in LibOFX\n";
152 show_line_number();
153 }
154
155 return 0;
156 }
ofx_DEBUG1_msg
LIBOFX_API int ofx_DEBUG1_msg
Definition: messages.cpp:38
DEBUG5
@ DEBUG5
Definition: messages.hh:37
OfxMsgType
OfxMsgType
Definition: messages.hh:23
ofx_STATUS_msg
LIBOFX_API int ofx_STATUS_msg
Definition: messages.cpp:43
ERROR
@ ERROR
Definition: messages.hh:41
DEBUG1
@ DEBUG1
Definition: messages.hh:33
ofx_DEBUG5_msg
LIBOFX_API int ofx_DEBUG5_msg
Definition: messages.cpp:42
ofx_utilities.hh
Various simple functions for type conversion & al.
ofx_WARNING_msg
LIBOFX_API int ofx_WARNING_msg
Definition: messages.cpp:45
ofx_ERROR_msg
LIBOFX_API int ofx_ERROR_msg
Definition: messages.cpp:46
ofx_DEBUG4_msg
LIBOFX_API int ofx_DEBUG4_msg
Definition: messages.cpp:41
message_out
int message_out(OfxMsgType error_type, const std::string message)
Message output function.
Definition: messages.cpp:67
ofx_DEBUG_msg
LIBOFX_API int ofx_DEBUG_msg
Definition: messages.cpp:37
ofx_INFO_msg
LIBOFX_API int ofx_INFO_msg
Definition: messages.cpp:44
INFO
@ INFO
Definition: messages.hh:39
ofx_PARSER_msg
LIBOFX_API int ofx_PARSER_msg
Definition: messages.cpp:36
position
SGMLApplication::Position position
Definition: messages.cpp:34
DEBUG3
@ DEBUG3
Definition: messages.hh:35
ofx_DEBUG3_msg
LIBOFX_API int ofx_DEBUG3_msg
Definition: messages.cpp:40
STATUS
@ STATUS
Definition: messages.hh:38
DEBUG2
@ DEBUG2
Definition: messages.hh:34
WARNING
@ WARNING
Definition: messages.hh:40
ofx_show_position
LIBOFX_API int ofx_show_position
Definition: messages.cpp:47
messages.hh
Message IO functionality.
PARSER
@ PARSER
Definition: messages.hh:42
entity_ptr
SGMLApplication::OpenEntityPtr entity_ptr
Definition: messages.cpp:33
DEBUG
@ DEBUG
Definition: messages.hh:32
ofx_DEBUG2_msg
LIBOFX_API int ofx_DEBUG2_msg
Definition: messages.cpp:39
DEBUG4
@ DEBUG4
Definition: messages.hh:36