]> Dogcows Code - chaz/yoink/blob - src/stlplus/subsystems/message_handler.hpp
testing new non-autotools build system
[chaz/yoink] / src / stlplus / subsystems / message_handler.hpp
1 #ifndef STLPLUS_MESSAGE_HANDLER
2 #define STLPLUS_MESSAGE_HANDLER
3 ////////////////////////////////////////////////////////////////////////////////
4
5 // Author: Andy Rushton
6 // Copyright: (c) Southampton University 1999-2004
7 // (c) Andy Rushton 2004-2009
8 // License: BSD License, see ../docs/license.html
9
10 // A general-purpose message handler using a message file as the source of all text
11
12 ////////////////////////////////////////////////////////////////////////////////
13 #include "subsystems_fixes.hpp"
14 #include "smart_ptr.hpp"
15 #include <iostream>
16 #include <string>
17 #include <vector>
18 #include <stdexcept>
19
20 namespace stlplus
21 {
22
23 ////////////////////////////////////////////////////////////////////////////////
24 // Internals
25
26 class message_handler_base;
27 class message_handler_base_body;
28
29 class message_handler;
30 class message_handler_body;
31
32 class message_context_body;
33
34 ////////////////////////////////////////////////////////////////////////////////
35 // an object representing a file position
36 // used for example when reporting errors when parsing a text file
37
38 class message_position
39 {
40 public:
41 message_position(void);
42 message_position(const std::string& filename, unsigned line, unsigned column);
43 ~message_position(void);
44
45 // access the elements of the position
46 const std::string& filename(void) const;
47 // line number in the range 1..n
48 // so line 0 means uninitialised
49 unsigned line(void) const;
50 // column number in the range 0..m-1
51 unsigned column(void) const;
52
53 // add a column offset to a position
54 message_position operator + (unsigned) const;
55 message_position& operator += (unsigned);
56
57 // tests for valid position
58 bool empty(void) const;
59 bool valid(void) const;
60
61 // vector of two strings
62 // - the first reproducing the source line
63 // - the second an arrow pointing to the correct column
64 // the vector will be empty if the position can't be found
65 std::vector<std::string> show(void) const;
66
67 private:
68 std::string m_filename;
69 unsigned m_line;
70 unsigned m_column;
71 };
72
73 std::string to_string(const message_position& where);
74
75 //////////////////////////////////////////////////////////////////////////////
76 // an object representing an message context
77 // used to control the context stack
78 // on initialisation, the message_context stores the state of the context stack
79 // on destruction it restores the state by popping any context that has been pushed since creation
80
81 class message_context
82 {
83 public:
84 message_context(message_handler_base& handler);
85
86 void set(message_handler_base& handler);
87 void pop(void);
88
89 private:
90 friend class message_context_body;
91 friend class message_handler_base;
92 smart_ptr_nocopy<message_context_body> m_body;
93 };
94
95 ////////////////////////////////////////////////////////////////////////////////
96 // exception classes which can be thrown by the message handler
97
98 // read_error is thrown if the message file read fails
99 class message_handler_read_error : public std::runtime_error
100 {
101 public:
102 message_handler_read_error(const message_position& position, const std::string& reason);
103 ~message_handler_read_error(void) throw();
104
105 const message_position& where(void) const;
106
107 private:
108 message_position m_position;
109 };
110
111 // format_error is thrown if a formatting error occurs trying to create the text for the message
112
113 class message_handler_format_error : public std::runtime_error
114 {
115 public:
116 message_handler_format_error(const std::string& format, unsigned offset);
117 message_handler_format_error(const message_position& pos, const std::string& format, unsigned offset);
118 ~message_handler_format_error(void) throw();
119
120 const message_position& where(void) const;
121 const std::string& format(void) const;
122 unsigned offset(void) const;
123
124 private:
125 message_position m_position;
126 std::string m_format;
127 unsigned m_offset;
128 };
129
130 // id_error is thrown if an error id is requested that could not be found in the message file
131
132 class message_handler_id_error : public std::runtime_error
133 {
134 public:
135 message_handler_id_error(const std::string& id);
136 ~message_handler_id_error(void) throw();
137
138 const std::string& id(void) const;
139
140 private:
141 std::string m_id;
142 };
143
144 // limit_error is thrown when the number of errors reaches the error limit
145
146 class message_handler_limit_error : public std::runtime_error
147 {
148 public:
149 message_handler_limit_error(unsigned limit);
150 ~message_handler_limit_error(void) throw();
151
152 unsigned limit(void) const;
153
154 private:
155 unsigned m_limit; // the limit that was exceeded
156 };
157
158 // fatal_error is thrown when a fatal error is reported
159
160 class message_handler_fatal_error : public std::runtime_error
161 {
162 public:
163 message_handler_fatal_error(const std::string& id);
164 ~message_handler_fatal_error(void) throw();
165
166 const std::string& id(void) const;
167
168 private:
169 std::string m_id;
170 };
171
172 ////////////////////////////////////////////////////////////////////////////////
173 // base version returns message objects as vectors of strings
174 // - it is then up to the user to decide what to do with them
175 // - suitable for use in a GUI for example where the message is displayed in a dialog
176
177 class message_handler_base
178 {
179 public:
180 //////////////////////////////////////////////////////////////////////////////
181 // constructor
182
183 // The first form sets the show flag but doesn't load any message files.
184 // The second and third forms also read message file(s) by calling
185 // add_message_file and therefore can throw exceptions. The first form
186 // defers file reading to explicit calls of add_message_file so does not
187 // throw any exceptions.
188
189 // show determines whether the source file line containing the source of a problem should also be shown
190
191 message_handler_base(bool show = true)
192 throw();
193
194 message_handler_base(const std::string& message_file, bool show = true)
195 throw(message_handler_read_error);
196
197 message_handler_base(const std::vector<std::string>& message_files, bool show = true)
198 throw(message_handler_read_error);
199
200 virtual ~message_handler_base(void)
201 throw();
202
203 //////////////////////////////////////////////////////////////////////////////
204 // message file handling
205
206 // The message file format contains lines of the form:
207 //
208 // <id> <spaces> <text>
209 //
210 // In <id> is a unique mnemonic for the message. It starts with an
211 // alphabetic character and may contain alphanumerics and underscores only.
212 // The <spaces> can be one or more space or tab characters. The <text> is the
213 // remainder of the line and is plain text (not a quoted string). All lines
214 // starting with a non-alphabetic character are assumed to be comments and are
215 // ignored
216
217 // If the message file is missing the function throws read_error with no line
218 // number. If formatting errors were found in the file,then it throws a
219 // read_error with valid line information.
220
221 // Any number of message files can be added and they accumulate
222
223 void add_message_file(const std::string& message_file)
224 throw(message_handler_read_error);
225
226 void add_message_files(const std::vector<std::string>& message_files)
227 throw(message_handler_read_error);
228
229 void add_message(const std::string& id, const std::string& text)
230 throw();
231
232 bool message_present(const std::string& id) const
233 throw();
234
235 //////////////////////////////////////////////////////////////////////////////
236 // format control
237
238 // The status formats - that is, information/warning/error/fatal/context/supplement
239 // formats take a single argument which is the formatted message
240 // For example: "warning: @0"
241 //
242 // Messages may be printed as either simple or positional
243 // simple: just a text message, such as a progress report
244 // positional: a message relating to a source file line
245 // The formatted message text is generated directly for simple messages
246 // However, for positional messages, this text is further substituted
247 // into a positional format string.
248 // The positional format string takes up to 4 arguments:
249 // @0: simple message text
250 // @1: filename
251 // @2: line number
252 // @3: column number
253 // You can miss out a part of this (e.g. the column number)
254 // by simply not including the argument number in the format string
255 // For example: "file: @1, line: @2: @0"
256 //
257 // The default formats are:
258 // information: "@0"
259 // warning: "warning: @0"
260 // error: "error: @0"
261 // fatal: "FATAL: @0"
262 // context: "context: @0"
263 // supplement: "supplement: @0"
264 //
265 // positional: "\"@1\" (@2,@3) : @0"
266
267 void set_information_format(const std::string& format)
268 throw();
269
270 void set_warning_format(const std::string& format)
271 throw();
272
273 void set_error_format(const std::string& format)
274 throw();
275
276 void set_fatal_format(const std::string& format)
277 throw();
278
279 void set_context_format(const std::string& format)
280 throw();
281
282 void set_supplement_format(const std::string& format)
283 throw();
284
285 void set_position_format(const std::string& format)
286 throw();
287
288 //////////////////////////////////////////////////////////////////////////////
289 // source file position display control
290 // show_position indicates that the source file line containing the error
291 // should be shown with the message on subsequent lines
292 // hide_position indicates that the source file line should not be shown
293
294 void show_position(void)
295 throw();
296
297 void hide_position(void)
298 throw();
299
300 //////////////////////////////////////////////////////////////////////////////
301 // Message formatting functions
302 // These functions return a vector of strings containing the completed message
303
304 // There are 6 classes of message: information, context, supplement, warning, error, fatal
305 // The 4 main classes are:
306 // - information: progress messages, status messages etc.
307 // - warning: a problem has been found but there is a sensible way of proceeding
308 // - error: a problem has been found and the operation will fail
309 // processing may continue but only to find further errors
310 // - fatal: an internal (programming) error has been found and the operation is stopping NOW
311 // The remaining two always follow one of the above
312 // - context: give stack-like information of the error context
313 // e.g. if processing include files, the sequence of includes forms a stack
314 // - supplement: give extra information of the error context
315 // e.g. give the set of possible solutions to the problem
316
317 // There are 2 kinds of message: simple, positional
318 // - simple: just a text message
319 // - positional: a message relating to a source file and a specific position in that file
320 // This gives 8 variants.
321 // Note: a positional message with an empty position is treated as a simple message
322
323 // Messages can have arguments.
324 // All arguments are strings.
325 // For each variant there are 5 functions relating to different numbers of arguments.
326 // - general form: takes any number of arguments as a vector of strings
327 // - 0 arguments: takes no arguments
328 // - 1 argument: allows a single argument
329 // - 2 arguments: allows two arguments
330 // - 3 arguments: allows three arguments
331 // For more than 3 arguments, use the general form
332
333 // information messages
334
335 // simple messages
336 std::vector<std::string> information_message(const std::string& id,
337 const std::vector<std::string>& args)
338 throw(message_handler_id_error,message_handler_format_error);
339
340 std::vector<std::string> information_message(const std::string& id)
341 throw(message_handler_id_error,message_handler_format_error);
342
343 std::vector<std::string> information_message(const std::string& id,
344 const std::string& arg1)
345 throw(message_handler_id_error,message_handler_format_error);
346
347 std::vector<std::string> information_message(const std::string& id,
348 const std::string& arg1,
349 const std::string& arg2)
350 throw(message_handler_id_error,message_handler_format_error);
351
352 std::vector<std::string> information_message(const std::string& id,
353 const std::string& arg1,
354 const std::string& arg2,
355 const std::string& arg3)
356 throw(message_handler_id_error,message_handler_format_error);
357
358 // positional messages
359 std::vector<std::string> information_message(const message_position&,
360 const std::string& id,
361 const std::vector<std::string>& args)
362 throw(message_handler_id_error,message_handler_format_error);
363
364 std::vector<std::string> information_message(const message_position&,
365 const std::string& id)
366 throw(message_handler_id_error,message_handler_format_error);
367
368 std::vector<std::string> information_message(const message_position&,
369 const std::string& id,
370 const std::string& arg1)
371 throw(message_handler_id_error,message_handler_format_error);
372
373 std::vector<std::string> information_message(const message_position&,
374 const std::string& id,
375 const std::string& arg1,
376 const std::string& arg2)
377 throw(message_handler_id_error,message_handler_format_error);
378
379 std::vector<std::string> information_message(const message_position&,
380 const std::string& id,
381 const std::string& arg1,
382 const std::string& arg2,
383 const std::string& arg3)
384 throw(message_handler_id_error,message_handler_format_error);
385
386 // warning messages
387
388 // simple messages
389 std::vector<std::string> warning_message(const std::string& id,
390 const std::vector<std::string>& args)
391 throw(message_handler_id_error,message_handler_format_error);
392
393 std::vector<std::string> warning_message(const std::string& id)
394 throw(message_handler_id_error,message_handler_format_error);
395
396 std::vector<std::string> warning_message(const std::string& id,
397 const std::string& arg1)
398 throw(message_handler_id_error,message_handler_format_error);
399
400 std::vector<std::string> warning_message(const std::string& id,
401 const std::string& arg1,
402 const std::string& arg2)
403 throw(message_handler_id_error,message_handler_format_error);
404
405 std::vector<std::string> warning_message(const std::string& id,
406 const std::string& arg1,
407 const std::string& arg2,
408 const std::string& arg3)
409 throw(message_handler_id_error,message_handler_format_error);
410
411 // positional messages
412 std::vector<std::string> warning_message(const message_position&,
413 const std::string& id,
414 const std::vector<std::string>& args)
415 throw(message_handler_id_error,message_handler_format_error);
416
417 std::vector<std::string> warning_message(const message_position&,
418 const std::string& id)
419 throw(message_handler_id_error,message_handler_format_error);
420
421 std::vector<std::string> warning_message(const message_position&,
422 const std::string& id,
423 const std::string& arg1)
424 throw(message_handler_id_error,message_handler_format_error);
425
426 std::vector<std::string> warning_message(const message_position&,
427 const std::string& id,
428 const std::string& arg1,
429 const std::string& arg2)
430 throw(message_handler_id_error,message_handler_format_error);
431
432 std::vector<std::string> warning_message(const message_position&,
433 const std::string& id,
434 const std::string& arg1,
435 const std::string& arg2,
436 const std::string& arg3)
437 throw(message_handler_id_error,message_handler_format_error);
438
439 // error messages
440
441 // simple messages
442 std::vector<std::string> error_message(const std::string& id,
443 const std::vector<std::string>& args)
444 throw(message_handler_id_error,message_handler_format_error);
445
446 std::vector<std::string> error_message(const std::string& id)
447 throw(message_handler_id_error,message_handler_format_error);
448
449 std::vector<std::string> error_message(const std::string& id,
450 const std::string& arg1)
451 throw(message_handler_id_error,message_handler_format_error);
452
453 std::vector<std::string> error_message(const std::string& id,
454 const std::string& arg1,
455 const std::string& arg2)
456 throw(message_handler_id_error,message_handler_format_error);
457
458 std::vector<std::string> error_message(const std::string& id,
459 const std::string& arg1,
460 const std::string& arg2,
461 const std::string& arg3)
462 throw(message_handler_id_error,message_handler_format_error);
463
464 // positional messages
465 std::vector<std::string> error_message(const message_position&,
466 const std::string& id,
467 const std::vector<std::string>& args)
468 throw(message_handler_id_error,message_handler_format_error);
469
470 std::vector<std::string> error_message(const message_position&,
471 const std::string& id)
472 throw(message_handler_id_error,message_handler_format_error);
473
474 std::vector<std::string> error_message(const message_position&,
475 const std::string& id,
476 const std::string& arg1)
477 throw(message_handler_id_error,message_handler_format_error);
478
479 std::vector<std::string> error_message(const message_position&,
480 const std::string& id,
481 const std::string& arg1,
482 const std::string& arg2)
483 throw(message_handler_id_error,message_handler_format_error);
484
485 std::vector<std::string> error_message(const message_position&,
486 const std::string& id,
487 const std::string& arg1,
488 const std::string& arg2,
489 const std::string& arg3)
490 throw(message_handler_id_error,message_handler_format_error);
491
492 // fatal messages
493 // Note that these do not throw the fatal_error exception because that would prevent the message being reported
494 // the caller should throw the exception after reporting the message
495
496 // simple messages
497 std::vector<std::string> fatal_message(const std::string& id,
498 const std::vector<std::string>& args)
499 throw(message_handler_id_error,message_handler_format_error);
500
501 std::vector<std::string> fatal_message(const std::string& id)
502 throw(message_handler_id_error,message_handler_format_error);
503
504 std::vector<std::string> fatal_message(const std::string& id,
505 const std::string& arg1)
506 throw(message_handler_id_error,message_handler_format_error);
507
508 std::vector<std::string> fatal_message(const std::string& id,
509 const std::string& arg1,
510 const std::string& arg2)
511 throw(message_handler_id_error,message_handler_format_error);
512
513 std::vector<std::string> fatal_message(const std::string& id,
514 const std::string& arg1,
515 const std::string& arg2,
516 const std::string& arg3)
517 throw(message_handler_id_error,message_handler_format_error);
518
519 // positional messages
520 std::vector<std::string> fatal_message(const message_position&,
521 const std::string& id,
522 const std::vector<std::string>& args)
523 throw(message_handler_id_error,message_handler_format_error);
524
525 std::vector<std::string> fatal_message(const message_position&,
526 const std::string& id)
527 throw(message_handler_id_error,message_handler_format_error);
528
529 std::vector<std::string> fatal_message(const message_position&,
530 const std::string& id,
531 const std::string& arg1)
532 throw(message_handler_id_error,message_handler_format_error);
533
534 std::vector<std::string> fatal_message(const message_position&,
535 const std::string& id,
536 const std::string& arg1,
537 const std::string& arg2)
538 throw(message_handler_id_error,message_handler_format_error);
539
540 std::vector<std::string> fatal_message(const message_position&,
541 const std::string& id,
542 const std::string& arg1,
543 const std::string& arg2,
544 const std::string& arg3)
545 throw(message_handler_id_error,message_handler_format_error);
546
547 // supplement messages - these must be pushed *before* the message that they apply to
548
549 // simple messages
550 void push_supplement(const std::string& id,
551 const std::vector<std::string>& args)
552 throw(message_handler_id_error,message_handler_format_error);
553
554 void push_supplement(const std::string& id)
555 throw(message_handler_id_error,message_handler_format_error);
556
557 void push_supplement(const std::string& id,
558 const std::string& arg1)
559 throw(message_handler_id_error,message_handler_format_error);
560
561 void push_supplement(const std::string& id,
562 const std::string& arg1,
563 const std::string& arg2)
564 throw(message_handler_id_error,message_handler_format_error);
565
566 void push_supplement(const std::string& id,
567 const std::string& arg1,
568 const std::string& arg2,
569 const std::string& arg3)
570 throw(message_handler_id_error,message_handler_format_error);
571
572 // positional messages
573 void push_supplement(const message_position&,
574 const std::string& id,
575 const std::vector<std::string>& args)
576 throw(message_handler_id_error,message_handler_format_error);
577
578 void push_supplement(const message_position&,
579 const std::string& id)
580 throw(message_handler_id_error,message_handler_format_error);
581
582 void push_supplement(const message_position&,
583 const std::string& id,
584 const std::string& arg1)
585 throw(message_handler_id_error,message_handler_format_error);
586
587 void push_supplement(const message_position&,
588 const std::string& id,
589 const std::string& arg1,
590 const std::string& arg2)
591 throw(message_handler_id_error,message_handler_format_error);
592
593 void push_supplement(const message_position&,
594 const std::string& id,
595 const std::string& arg1,
596 const std::string& arg2,
597 const std::string& arg3)
598 throw(message_handler_id_error,message_handler_format_error);
599
600 //////////////////////////////////////////////////////////////////////////////
601 // context stack - allows supplementary messages to be printed after each message showing where it came from
602 // for example, an message whilst inlining a function could be followed by a "function called from..." message
603
604 // simple context messages
605 void push_context(const std::string& id,
606 const std::vector<std::string>& args)
607 throw(message_handler_id_error,message_handler_format_error);
608
609 void push_context(const std::string& id)
610 throw(message_handler_id_error,message_handler_format_error);
611
612 void push_context(const std::string& id,
613 const std::string& arg1)
614 throw(message_handler_id_error,message_handler_format_error);
615
616 void push_context(const std::string& id,
617 const std::string& arg1,
618 const std::string& arg2)
619 throw(message_handler_id_error,message_handler_format_error);
620
621 void push_context(const std::string& id,
622 const std::string& arg1,
623 const std::string& arg2,
624 const std::string& arg3)
625 throw(message_handler_id_error,message_handler_format_error);
626
627 // positional context messages
628 void push_context(const message_position&,
629 const std::string& id,
630 const std::vector<std::string>& args)
631 throw(message_handler_id_error,message_handler_format_error);
632
633 void push_context(const message_position&,
634 const std::string& id)
635 throw(message_handler_id_error,message_handler_format_error);
636
637 void push_context(const message_position&,
638 const std::string& id,
639 const std::string& arg1)
640 throw(message_handler_id_error,message_handler_format_error);
641
642 void push_context(const message_position&,
643 const std::string& id,
644 const std::string& arg1,
645 const std::string& arg2)
646 throw(message_handler_id_error,message_handler_format_error);
647
648 void push_context(const message_position&,
649 const std::string& id,
650 const std::string& arg1,
651 const std::string& arg2,
652 const std::string& arg3)
653 throw(message_handler_id_error,message_handler_format_error);
654
655 unsigned context_depth(void) const
656 throw();
657
658 // remove the last level of context if there is one
659 void pop_context(void)
660 throw();
661 // remove context messages to the specified depth
662 void pop_context(unsigned)
663 throw();
664
665 // push the context and save it in the message_context handle. When the
666 // message_context handle goes out of scope, the context is popped
667 // automatically
668
669 // simple context messages
670 message_context auto_push_context(const std::string& id,
671 const std::vector<std::string>& args)
672 throw(message_handler_id_error,message_handler_format_error);
673
674 message_context auto_push_context(const std::string& id)
675 throw(message_handler_id_error,message_handler_format_error);
676
677 message_context auto_push_context(const std::string& id,
678 const std::string& arg1)
679 throw(message_handler_id_error,message_handler_format_error);
680
681 message_context auto_push_context(const std::string& id,
682 const std::string& arg1,
683 const std::string& arg2)
684 throw(message_handler_id_error,message_handler_format_error);
685
686 message_context auto_push_context(const std::string& id,
687 const std::string& arg1,
688 const std::string& arg2,
689 const std::string& arg3)
690 throw(message_handler_id_error,message_handler_format_error);
691
692 // positional context messages
693 message_context auto_push_context(const message_position&,
694 const std::string& id,
695 const std::vector<std::string>& args)
696 throw(message_handler_id_error,message_handler_format_error);
697
698 message_context auto_push_context(const message_position&,
699 const std::string& id)
700 throw(message_handler_id_error,message_handler_format_error);
701
702 message_context auto_push_context(const message_position&,
703 const std::string& id,
704 const std::string& arg1)
705 throw(message_handler_id_error,message_handler_format_error);
706
707 message_context auto_push_context(const message_position&,
708 const std::string& id,
709 const std::string& arg1,
710 const std::string& arg2)
711 throw(message_handler_id_error,message_handler_format_error);
712
713 message_context auto_push_context(const message_position&,
714 const std::string& id,
715 const std::string& arg1,
716 const std::string& arg2,
717 const std::string& arg3)
718 throw(message_handler_id_error,message_handler_format_error);
719
720 private:
721 friend class message_handler_base_body;
722 smart_ptr_nocopy<message_handler_base_body> m_base_body;
723 };
724
725 ////////////////////////////////////////////////////////////////////////////////
726 // iostream-based derivative uses the above base class to generate messages then uses iostream to print them
727 // Note: since this is a public derivative, all message_handler_base operations are also available
728
729 class message_handler : public message_handler_base
730 {
731 public:
732 //////////////////////////////////////////////////////////////////////////////
733 // constructor
734
735 // The device is the output on which to print the error. For command-line tools
736 // it will be either std::cout (standard output) or std::cerr (standard error) from
737 // <iostream>.
738
739 // The second and third form also reads a message file by calling
740 // add_message_file and therefore can throw exceptions. The first form
741 // defers file reading to explicit calls of add_message_file so does not
742 // throw any exceptions.
743
744 // limit sets the error limit - zero disables this feature
745 // show determines whether the source file line containing the error should also be shown
746
747 message_handler(std::ostream& device,unsigned limit = 0,bool show = true)
748 throw();
749
750 message_handler(std::ostream& device,
751 const std::string& message_file,unsigned limit = 0,bool show = true)
752 throw(message_handler_read_error);
753
754 message_handler(std::ostream& device,
755 const std::vector<std::string>& message_files,unsigned limit = 0,bool show = true)
756 throw(message_handler_read_error);
757
758 ~message_handler(void)
759 throw();
760
761 //////////////////////////////////////////////////////////////////////////////
762 // error count and error limits
763
764 void set_error_limit(unsigned error_limit)
765 throw();
766
767 unsigned error_limit(void) const
768 throw();
769
770 void reset_error_count(void)
771 throw();
772
773 unsigned error_count(void) const
774 throw();
775
776 //////////////////////////////////////////////////////////////////////////////
777 // access the output device for whatever reason (for example, to ensure that
778 // text output goes wherever the messages go)
779
780 std::ostream& device(void);
781
782 //////////////////////////////////////////////////////////////////////////////
783 // Message reporting functions
784 // These are based on the error formatting functions in the baseclass
785
786 // information messages
787
788 // simple messages
789 bool information(const std::string& id,
790 const std::vector<std::string>& args)
791 throw(message_handler_id_error,message_handler_format_error);
792
793 bool information(const std::string& id)
794 throw(message_handler_id_error,message_handler_format_error);
795
796 bool information(const std::string& id,
797 const std::string& arg1)
798 throw(message_handler_id_error,message_handler_format_error);
799
800 bool information(const std::string& id,
801 const std::string& arg1,
802 const std::string& arg2)
803 throw(message_handler_id_error,message_handler_format_error);
804
805 bool information(const std::string& id,
806 const std::string& arg1,
807 const std::string& arg2,
808 const std::string& arg3)
809 throw(message_handler_id_error,message_handler_format_error);
810
811 // positional messages
812 bool information(const message_position&,
813 const std::string& id,
814 const std::vector<std::string>& args)
815 throw(message_handler_id_error,message_handler_format_error);
816
817 bool information(const message_position&,
818 const std::string& id)
819 throw(message_handler_id_error,message_handler_format_error);
820
821 bool information(const message_position&,
822 const std::string& id,
823 const std::string& arg1)
824 throw(message_handler_id_error,message_handler_format_error);
825
826 bool information(const message_position&,
827 const std::string& id,
828 const std::string& arg1,
829 const std::string& arg2)
830 throw(message_handler_id_error,message_handler_format_error);
831
832 bool information(const message_position&,
833 const std::string& id,
834 const std::string& arg1,
835 const std::string& arg2,
836 const std::string& arg3)
837 throw(message_handler_id_error,message_handler_format_error);
838
839 // warning messages
840
841 // simple messages
842 bool warning(const std::string& id,
843 const std::vector<std::string>& args)
844 throw(message_handler_id_error,message_handler_format_error);
845
846 bool warning(const std::string& id)
847 throw(message_handler_id_error,message_handler_format_error);
848
849 bool warning(const std::string& id,
850 const std::string& arg1)
851 throw(message_handler_id_error,message_handler_format_error);
852
853 bool warning(const std::string& id,
854 const std::string& arg1,
855 const std::string& arg2)
856 throw(message_handler_id_error,message_handler_format_error);
857
858 bool warning(const std::string& id,
859 const std::string& arg1,
860 const std::string& arg2,
861 const std::string& arg3)
862 throw(message_handler_id_error,message_handler_format_error);
863
864 // positional messages
865 bool warning(const message_position&,
866 const std::string& id,
867 const std::vector<std::string>& args)
868 throw(message_handler_id_error,message_handler_format_error);
869
870 bool warning(const message_position&,
871 const std::string& id)
872 throw(message_handler_id_error,message_handler_format_error);
873
874 bool warning(const message_position&,
875 const std::string& id,
876 const std::string& arg1)
877 throw(message_handler_id_error,message_handler_format_error);
878
879 bool warning(const message_position&,
880 const std::string& id,
881 const std::string& arg1,
882 const std::string& arg2)
883 throw(message_handler_id_error,message_handler_format_error);
884
885 bool warning(const message_position&,
886 const std::string& id,
887 const std::string& arg1,
888 const std::string& arg2,
889 const std::string& arg3)
890 throw(message_handler_id_error,message_handler_format_error);
891
892 // error messages
893
894 // simple messages
895 bool error(const std::string& id,
896 const std::vector<std::string>& args)
897 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
898
899 bool error(const std::string& id)
900 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
901
902 bool error(const std::string& id,
903 const std::string& arg1)
904 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
905
906 bool error(const std::string& id,
907 const std::string& arg1,
908 const std::string& arg2)
909 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
910
911 bool error(const std::string& id,
912 const std::string& arg1,
913 const std::string& arg2,
914 const std::string& arg3)
915 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
916
917 // positional messages
918 bool error(const message_position&,
919 const std::string& id,
920 const std::vector<std::string>& args)
921 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
922
923 bool error(const message_position&,
924 const std::string& id)
925 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
926
927 bool error(const message_position&,
928 const std::string& id,
929 const std::string& arg1)
930 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
931
932 bool error(const message_position&,
933 const std::string& id,
934 const std::string& arg1,
935 const std::string& arg2)
936 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
937
938 bool error(const message_position&,
939 const std::string& id,
940 const std::string& arg1,
941 const std::string& arg2,
942 const std::string& arg3)
943 throw(message_handler_id_error,message_handler_format_error,message_handler_limit_error);
944
945 // fatal messages
946 // These report the error and then always throw the fatal_error exception
947
948 // simple messages
949 bool fatal(const std::string& id,
950 const std::vector<std::string>& args)
951 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
952
953 bool fatal(const std::string& id)
954 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
955
956 bool fatal(const std::string& id,
957 const std::string& arg1)
958 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
959
960 bool fatal(const std::string& id,
961 const std::string& arg1,
962 const std::string& arg2)
963 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
964
965 bool fatal(const std::string& id,
966 const std::string& arg1,
967 const std::string& arg2,
968 const std::string& arg3)
969 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
970
971 // positional messages
972 bool fatal(const message_position&,
973 const std::string& id,
974 const std::vector<std::string>& args)
975 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
976
977 bool fatal(const message_position&,
978 const std::string& id)
979 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
980
981 bool fatal(const message_position&,
982 const std::string& id,
983 const std::string& arg1)
984 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
985
986 bool fatal(const message_position&,
987 const std::string& id,
988 const std::string& arg1,
989 const std::string& arg2)
990 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
991
992 bool fatal(const message_position&,
993 const std::string& id,
994 const std::string& arg1,
995 const std::string& arg2,
996 const std::string& arg3)
997 throw(message_handler_id_error,message_handler_format_error,message_handler_fatal_error);
998
999 //////////////////////////////////////////////////////////////////////////////
1000 // plain text output
1001 // provides a simple way of outputting text from the program to the same device as the messages
1002 // Each call of plaintext is treated as a line of text and has a newline appended
1003
1004 bool plaintext (const std::string& text);
1005
1006 private:
1007 friend class message_handler_body;
1008 smart_ptr_nocopy<message_handler_body> m_body;
1009 };
1010
1011 ////////////////////////////////////////////////////////////////////////////////
1012
1013 } // end namespace stlplus
1014
1015 #endif
This page took 0.076659 seconds and 4 git commands to generate.