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
33SGMLApplication::OpenEntityPtr entity_ptr;
34SGMLApplication::Position position;
35
36LIBOFX_API int ofx_PARSER_msg = false;
37LIBOFX_API int ofx_DEBUG_msg = false;
38LIBOFX_API int ofx_DEBUG1_msg = false;
39LIBOFX_API int ofx_DEBUG2_msg = false;
40LIBOFX_API int ofx_DEBUG3_msg = false;
41LIBOFX_API int ofx_DEBUG4_msg = false;
42LIBOFX_API int ofx_DEBUG5_msg = false;
43LIBOFX_API int ofx_STATUS_msg = false;
44LIBOFX_API int ofx_INFO_msg = false;
45LIBOFX_API int ofx_WARNING_msg = false;
46LIBOFX_API int ofx_ERROR_msg = true;
47LIBOFX_API int ofx_show_position = true;
48
49void 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
67int 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}
LIBOFX_API int ofx_DEBUG1_msg
Definition messages.cpp:38
SGMLApplication::Position position
Definition messages.cpp:34
LIBOFX_API int ofx_DEBUG2_msg
Definition messages.cpp:39
LIBOFX_API int ofx_STATUS_msg
Definition messages.cpp:43
LIBOFX_API int ofx_DEBUG_msg
Definition messages.cpp:37
LIBOFX_API int ofx_show_position
Definition messages.cpp:47
LIBOFX_API int ofx_DEBUG5_msg
Definition messages.cpp:42
LIBOFX_API int ofx_INFO_msg
Definition messages.cpp:44
SGMLApplication::OpenEntityPtr entity_ptr
Definition messages.cpp:33
int message_out(OfxMsgType error_type, const std::string message)
Message output function.
Definition messages.cpp:67
LIBOFX_API int ofx_WARNING_msg
Definition messages.cpp:45
LIBOFX_API int ofx_DEBUG4_msg
Definition messages.cpp:41
LIBOFX_API int ofx_DEBUG3_msg
Definition messages.cpp:40
LIBOFX_API int ofx_PARSER_msg
Definition messages.cpp:36
LIBOFX_API int ofx_ERROR_msg
Definition messages.cpp:46
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.