1 #ifndef STLPLUS_MESSAGE_HANDLER
2 #define STLPLUS_MESSAGE_HANDLER
3 ////////////////////////////////////////////////////////////////////////////////
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
10 // A general-purpose message handler using a message file as the source of all text
12 ////////////////////////////////////////////////////////////////////////////////
13 #include "subsystems_fixes.hpp"
14 #include "smart_ptr.hpp"
23 ////////////////////////////////////////////////////////////////////////////////
26 class message_handler_base
;
27 class message_handler_base_body
;
29 class message_handler
;
30 class message_handler_body
;
32 class message_context_body
;
34 ////////////////////////////////////////////////////////////////////////////////
35 // an object representing a file position
36 // used for example when reporting errors when parsing a text file
38 class message_position
41 message_position(void);
42 message_position(const std::string
& filename
, unsigned line
, unsigned column
);
43 ~message_position(void);
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;
53 // add a column offset to a position
54 message_position
operator + (unsigned) const;
55 message_position
& operator += (unsigned);
57 // tests for valid position
58 bool empty(void) const;
59 bool valid(void) const;
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;
68 std::string m_filename
;
73 std::string
to_string(const message_position
& where
);
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
84 message_context(message_handler_base
& handler
);
86 void set(message_handler_base
& handler
);
90 friend class message_context_body
;
91 friend class message_handler_base
;
92 smart_ptr_nocopy
<message_context_body
> m_body
;
95 ////////////////////////////////////////////////////////////////////////////////
96 // exception classes which can be thrown by the message handler
98 // read_error is thrown if the message file read fails
99 class message_handler_read_error
: public std::runtime_error
102 message_handler_read_error(const message_position
& position
, const std::string
& reason
);
103 ~message_handler_read_error(void) throw();
105 const message_position
& where(void) const;
108 message_position m_position
;
111 // format_error is thrown if a formatting error occurs trying to create the text for the message
113 class message_handler_format_error
: public std::runtime_error
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();
120 const message_position
& where(void) const;
121 const std::string
& format(void) const;
122 unsigned offset(void) const;
125 message_position m_position
;
126 std::string m_format
;
130 // id_error is thrown if an error id is requested that could not be found in the message file
132 class message_handler_id_error
: public std::runtime_error
135 message_handler_id_error(const std::string
& id
);
136 ~message_handler_id_error(void) throw();
138 const std::string
& id(void) const;
144 // limit_error is thrown when the number of errors reaches the error limit
146 class message_handler_limit_error
: public std::runtime_error
149 message_handler_limit_error(unsigned limit
);
150 ~message_handler_limit_error(void) throw();
152 unsigned limit(void) const;
155 unsigned m_limit
; // the limit that was exceeded
158 // fatal_error is thrown when a fatal error is reported
160 class message_handler_fatal_error
: public std::runtime_error
163 message_handler_fatal_error(const std::string
& id
);
164 ~message_handler_fatal_error(void) throw();
166 const std::string
& id(void) const;
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
177 class message_handler_base
180 //////////////////////////////////////////////////////////////////////////////
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.
189 // show determines whether the source file line containing the source of a problem should also be shown
191 message_handler_base(bool show
= true)
194 message_handler_base(const std::string
& message_file
, bool show
= true)
195 throw(message_handler_read_error
);
197 message_handler_base(const std::vector
<std::string
>& message_files
, bool show
= true)
198 throw(message_handler_read_error
);
200 virtual ~message_handler_base(void)
203 //////////////////////////////////////////////////////////////////////////////
204 // message file handling
206 // The message file format contains lines of the form:
208 // <id> <spaces> <text>
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
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.
221 // Any number of message files can be added and they accumulate
223 void add_message_file(const std::string
& message_file
)
224 throw(message_handler_read_error
);
226 void add_message_files(const std::vector
<std::string
>& message_files
)
227 throw(message_handler_read_error
);
229 void add_message(const std::string
& id
, const std::string
& text
)
232 bool message_present(const std::string
& id
) const
235 //////////////////////////////////////////////////////////////////////////////
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"
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
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"
257 // The default formats are:
259 // warning: "warning: @0"
260 // error: "error: @0"
261 // fatal: "FATAL: @0"
262 // context: "context: @0"
263 // supplement: "supplement: @0"
265 // positional: "\"@1\" (@2,@3) : @0"
267 void set_information_format(const std::string
& format
)
270 void set_warning_format(const std::string
& format
)
273 void set_error_format(const std::string
& format
)
276 void set_fatal_format(const std::string
& format
)
279 void set_context_format(const std::string
& format
)
282 void set_supplement_format(const std::string
& format
)
285 void set_position_format(const std::string
& format
)
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
294 void show_position(void)
297 void hide_position(void)
300 //////////////////////////////////////////////////////////////////////////////
301 // Message formatting functions
302 // These functions return a vector of strings containing the completed message
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
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
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
333 // information 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
);
340 std::vector
<std::string
> information_message(const std::string
& id
)
341 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
393 std::vector
<std::string
> warning_message(const std::string
& id
)
394 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
446 std::vector
<std::string
> error_message(const std::string
& id
)
447 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
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
);
501 std::vector
<std::string
> fatal_message(const std::string
& id
)
502 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
547 // supplement messages - these must be pushed *before* the message that they apply to
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
);
554 void push_supplement(const std::string
& id
)
555 throw(message_handler_id_error
,message_handler_format_error
);
557 void push_supplement(const std::string
& id
,
558 const std::string
& arg1
)
559 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
578 void push_supplement(const message_position
&,
579 const std::string
& id
)
580 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
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
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
);
609 void push_context(const std::string
& id
)
610 throw(message_handler_id_error
,message_handler_format_error
);
612 void push_context(const std::string
& id
,
613 const std::string
& arg1
)
614 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
633 void push_context(const message_position
&,
634 const std::string
& id
)
635 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
655 unsigned context_depth(void) const
658 // remove the last level of context if there is one
659 void pop_context(void)
661 // remove context messages to the specified depth
662 void pop_context(unsigned)
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
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
);
674 message_context
auto_push_context(const std::string
& id
)
675 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
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
);
698 message_context
auto_push_context(const message_position
&,
699 const std::string
& id
)
700 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
721 friend class message_handler_base_body
;
722 smart_ptr_nocopy
<message_handler_base_body
> m_base_body
;
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
729 class message_handler
: public message_handler_base
732 //////////////////////////////////////////////////////////////////////////////
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
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.
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
747 message_handler(std::ostream
& device
,unsigned limit
= 0,bool show
= true)
750 message_handler(std::ostream
& device
,
751 const std::string
& message_file
,unsigned limit
= 0,bool show
= true)
752 throw(message_handler_read_error
);
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
);
758 ~message_handler(void)
761 //////////////////////////////////////////////////////////////////////////////
762 // error count and error limits
764 void set_error_limit(unsigned error_limit
)
767 unsigned error_limit(void) const
770 void reset_error_count(void)
773 unsigned error_count(void) const
776 //////////////////////////////////////////////////////////////////////////////
777 // access the output device for whatever reason (for example, to ensure that
778 // text output goes wherever the messages go)
780 std::ostream
& device(void);
782 //////////////////////////////////////////////////////////////////////////////
783 // Message reporting functions
784 // These are based on the error formatting functions in the baseclass
786 // information 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
);
793 bool information(const std::string
& id
)
794 throw(message_handler_id_error
,message_handler_format_error
);
796 bool information(const std::string
& id
,
797 const std::string
& arg1
)
798 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
817 bool information(const message_position
&,
818 const std::string
& id
)
819 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
842 bool warning(const std::string
& id
,
843 const std::vector
<std::string
>& args
)
844 throw(message_handler_id_error
,message_handler_format_error
);
846 bool warning(const std::string
& id
)
847 throw(message_handler_id_error
,message_handler_format_error
);
849 bool warning(const std::string
& id
,
850 const std::string
& arg1
)
851 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
870 bool warning(const message_position
&,
871 const std::string
& id
)
872 throw(message_handler_id_error
,message_handler_format_error
);
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
);
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
);
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
);
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
);
899 bool error(const std::string
& id
)
900 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
946 // These report the error and then always throw the fatal_error exception
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
);
953 bool fatal(const std::string
& id
)
954 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
);
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
1004 bool plaintext (const std::string
& text
);
1007 friend class message_handler_body
;
1008 smart_ptr_nocopy
<message_handler_body
> m_body
;
1011 ////////////////////////////////////////////////////////////////////////////////
1013 } // end namespace stlplus