1 ////////////////////////////////////////////////////////////////////////////////
3 // Author: Andy Rushton
4 // Copyright: (c) Southampton University 1999-2004
5 // (c) Andy Rushton 2004-2009
6 // License: BSD License, see ../docs/license.html
8 ////////////////////////////////////////////////////////////////////////////////
9 #include "message_handler.hpp"
10 #include "dprintf.hpp"
15 ////////////////////////////////////////////////////////////////////////////////
20 ////////////////////////////////////////////////////////////////////////////////
23 static std::ostream
& operator<< (std::ostream
& device
, const std::vector
<std::string
>& data
)
25 for (unsigned i
= 0; i
< data
.size(); i
++)
26 device
<< data
[i
] << std::endl
;
31 ////////////////////////////////////////////////////////////////////////////////
33 static const char* information_id
= "INFORMATION";
34 static const char* context_id
= "CONTEXT";
35 static const char* supplement_id
= "SUPPLEMENT";
36 static const char* warning_id
= "WARNING";
37 static const char* error_id
= "ERROR";
38 static const char* fatal_id
= "FATAL";
39 static const char* position_id
= "POSITION";
41 static const char* default_information_format
= "@0";
42 static const char* default_context_format
= "context: @0";
43 static const char* default_supplement_format
= "supplement: @0";
44 static const char* default_warning_format
= "warning: @0";
45 static const char* default_error_format
= "error: @0";
46 static const char* default_fatal_format
= "FATAL: @0";
47 static const char* default_position_format
= "\"@1\" (@2,@3) : @0";
49 ////////////////////////////////////////////////////////////////////////////////
52 message_position::message_position(void) :
53 m_filename(std::string()), m_line(0), m_column(0)
57 message_position::message_position(const std::string
& filename
, unsigned line
, unsigned column
) :
58 m_filename(filename
), m_line(line
), m_column(column
)
62 message_position::~message_position(void)
66 const std::string
& message_position::filename(void) const
71 unsigned message_position::line(void) const
76 unsigned message_position::column(void) const
81 message_position
message_position::operator + (unsigned offset
) const
83 message_position
result(*this);
88 message_position
& message_position::operator += (unsigned offset
)
94 bool message_position::empty(void) const
96 return m_filename
.empty();
99 bool message_position::valid(void) const
104 std::vector
<std::string
> message_position::show(void) const
106 std::vector
<std::string
> result
;
109 // skip row-1 lines of the file and print out the resultant line
110 std::ifstream
source(filename().c_str());
111 std::string current_line
;
112 for (unsigned i
= 0; i
< line(); i
++)
116 std::getline(source
,current_line
);
118 result
.push_back(current_line
);
119 // now put an up-arrow at the appropriate column
120 // preserve any tabs in the original line
121 result
.push_back(std::string());
122 for (unsigned j
= 0; j
< column(); j
++)
124 if (j
< current_line
.size() && current_line
[j
] == '\t')
125 result
.back() += '\t';
127 result
.back() += ' ';
129 result
.back() += '^';
134 std::string
to_string(const message_position
& where
)
136 return dformat("{%s:%u:%u}", where
.filename().c_str(), where
.line(), where
.column());
139 ////////////////////////////////////////////////////////////////////////////////
142 class message_context_body
146 message_handler_base
* m_base
;
149 message_context_body(message_handler_base
& handler
) :
150 m_depth(0), m_base(0)
155 ~message_context_body(void)
160 void set(message_handler_base
& handler
)
163 m_depth
= m_base
->context_depth();
169 m_base
->pop_context(m_depth
);
172 message_context_body(const message_context_body
&);
173 message_context_body
& operator=(const message_context_body
&);
176 // exported context class
178 message_context::message_context(message_handler_base
& handler
) : m_body(new message_context_body(handler
))
182 void message_context::set(message_handler_base
& handler
)
184 m_body
->set(handler
);
187 void message_context::pop(void)
192 ////////////////////////////////////////////////////////////////////////////////
197 message_handler_read_error::message_handler_read_error(const message_position
& position
, const std::string
& reason
) :
198 std::runtime_error(to_string(position
) + std::string(": Message handler read error - ") + reason
),
203 message_handler_read_error::~message_handler_read_error(void) throw()
207 const message_position
& message_handler_read_error::where(void) const
214 message_handler_format_error::message_handler_format_error(const std::string
& format
, unsigned offset
) :
215 std::runtime_error(std::string("Message handler formatting error in \"") + format
+ std::string("\"")),
216 m_position("",0,0), m_format(format
), m_offset(offset
)
220 message_handler_format_error::message_handler_format_error(const message_position
& pos
, const std::string
& format
, unsigned offset
) :
221 std::runtime_error(to_string(pos
) + std::string(": Message handler formatting error in \"") + format
+ std::string("\"")),
222 m_position(pos
), m_format(format
), m_offset(offset
)
226 message_handler_format_error::~message_handler_format_error(void) throw()
230 const message_position
& message_handler_format_error::where(void) const
235 const std::string
& message_handler_format_error::format(void) const
240 unsigned message_handler_format_error::offset(void) const
247 message_handler_id_error::message_handler_id_error(const std::string
& id
) :
248 std::runtime_error(std::string("Message handler message ID not found: ") + id
), m_id(id
)
252 message_handler_id_error::~message_handler_id_error(void) throw()
256 const std::string
& message_handler_id_error::id(void) const
263 message_handler_limit_error::message_handler_limit_error(unsigned limit
) :
264 std::runtime_error(std::string("Message handler limit error: ") + dformat("%u",limit
) + std::string(" reached")),
269 message_handler_limit_error::~message_handler_limit_error(void) throw()
273 unsigned message_handler_limit_error::limit(void) const
280 message_handler_fatal_error::message_handler_fatal_error(const std::string
& id
) :
281 std::runtime_error(std::string("Message Handler Fatal error: ") + id
),
286 message_handler_fatal_error::~message_handler_fatal_error(void) throw()
290 const std::string
& message_handler_fatal_error::id(void) const
295 ////////////////////////////////////////////////////////////////////////////////
300 unsigned m_index
; // index into message files
301 unsigned m_line
; // line
302 unsigned m_column
; // column
303 std::string m_text
; // text
306 message(unsigned index
= (unsigned)-1,
309 const std::string
& text
= "") :
310 m_index(index
),m_line(line
),m_column(column
),m_text(text
)
313 message(const std::string
& text
) :
314 m_index((unsigned)-1),m_line(0),m_column(0),m_text(text
)
322 unsigned index(void) const
327 unsigned line(void) const
332 unsigned column(void) const
337 const std::string
& text(void) const
343 ////////////////////////////////////////////////////////////////////////////////
345 class pending_message
348 message_position m_position
;
350 std::vector
<std::string
> m_args
;
352 pending_message(const message_position
& position
, const std::string
& id
, const std::vector
<std::string
>& args
) :
353 m_position(position
), m_id(id
), m_args(args
) {}
354 pending_message(const std::string
& id
, const std::vector
<std::string
>& args
) :
355 m_position(message_position()), m_id(id
), m_args(args
) {}
356 ~pending_message(void) {}
358 const message_position
& position(void) const {return m_position
;}
359 const std::string
& id(void) const {return m_id
;}
360 const std::vector
<std::string
>& args(void) const {return m_args
;}
363 ////////////////////////////////////////////////////////////////////////////////
365 class message_handler_base_body
368 std::vector
<std::string
> m_files
; // message files in the order they were added
369 std::map
<std::string
,message
> m_messages
; // messages stored as id:message pairs
370 bool m_show
; // show source
371 std::list
<pending_message
> m_context
; // context message stack
372 std::list
<pending_message
> m_supplement
; // supplementary message stack
375 message_handler_base_body(void) :
378 // preload with default formats
379 add_message(information_id
,default_information_format
);
380 add_message(warning_id
,default_warning_format
);
381 add_message(error_id
,default_error_format
);
382 add_message(fatal_id
,default_fatal_format
);
383 add_message(position_id
,default_position_format
);
384 add_message(context_id
,default_context_format
);
385 add_message(supplement_id
,default_supplement_format
);
388 ~message_handler_base_body(void)
392 void set_show(bool show
)
397 void add_message_file(const std::string
& file
)
398 throw(message_handler_read_error
)
400 m_files
.push_back(file
);
401 std::ifstream
input(file
.c_str());
403 throw message_handler_read_error(message_position(file
,0,0), std::string("file not found: ") + file
);
408 std::getline(input
,line
);
410 if (line
.size() > 0 && isalpha(line
[0]))
412 // Get the id field which starts with an alphabetic and contains alphanumerics and underscore
415 for (; i
< line
.size(); i
++)
417 if (isalnum(line
[i
]) || line
[i
] == '_')
422 // check this ID is unique within the files - however it is legal to override a hard-coded message
423 std::map
<std::string
,message
>::iterator found
= m_messages
.find(id
);
424 if (found
!= m_messages
.end() && found
->second
.index() != (unsigned)-1)
425 throw message_handler_read_error(message_position(file
,l
,i
), std::string("repeated ID ") + id
);
427 for (; i
< line
.size(); i
++)
429 if (!isspace(line
[i
]))
432 // now get the text part and add the message to the message map
433 std::string text
= line
.substr(i
, line
.size()-i
);
434 m_messages
[id
] = message(m_files
.size()-1, l
, i
, text
);
439 void add_message(const std::string
& id
, const std::string
& text
)
442 m_messages
[id
] = message((unsigned)-1, 0, 0, text
);
445 bool message_present(const std::string
& id
) const
448 return m_messages
.find(id
) != m_messages
.end();
451 void push_supplement(const message_position
& position
,
452 const std::string
& message_id
,
453 const std::vector
<std::string
>& args
)
455 m_supplement
.push_back(pending_message(position
,message_id
,args
));
458 void push_context(const message_position
& position
,
459 const std::string
& message_id
,
460 const std::vector
<std::string
>& args
)
462 m_context
.push_back(pending_message(position
,message_id
,args
));
465 void pop_context(unsigned depth
)
467 while (depth
< m_context
.size())
468 m_context
.pop_back();
471 unsigned context_depth(void) const
473 return m_context
.size();
476 std::vector
<std::string
> format_report(const message_position
& position
,
477 const std::string
& message_id
,
478 const std::string
& status_id
,
479 const std::vector
<std::string
>& args
)
480 throw(message_handler_id_error
,message_handler_format_error
)
482 // gathers everything together into a full multi-line report
483 std::vector
<std::string
> result
;
484 // the first part of the report is the status message (info/warning/error/fatal)
485 result
.push_back(format_id(position
, message_id
, status_id
, args
));
486 // now append any supplemental messages that have been stacked
487 // these are printed in FIFO order i.e. the order that they were added to the handler
488 for (std::list
<pending_message
>::iterator j
= m_supplement
.begin(); j
!= m_supplement
.end(); j
++)
489 result
.push_back(format_id(j
->position(),j
->id(),supplement_id
,j
->args()));
490 // now discard any supplementary messages because they only persist until they are printed once
491 m_supplement
.clear();
492 // now append any context messages that have been stacked
493 // these are printed in LIFO order i.e. closest context first
494 for (std::list
<pending_message
>::reverse_iterator i
= m_context
.rbegin(); i
!= m_context
.rend(); i
++)
495 result
.push_back(format_id(i
->position(),i
->id(),context_id
,i
->args()));
499 std::string
format_id(const message_position
& position
,
500 const std::string
& message_id
,
501 const std::string
& status_id
,
502 const std::vector
<std::string
>& args
)
503 throw(message_handler_id_error
,message_handler_format_error
)
505 // This function creates a fully-formatted single-line message from a
506 // combination of the position format and the status format plus the message
507 // ID and its arguments. There are up to three levels of substitution
508 // required to do this.
510 // get the status format from the status_id
511 std::map
<std::string
,message
>::iterator status_found
= m_messages
.find(status_id
);
512 if (status_found
== m_messages
.end()) throw message_handler_id_error(status_id
);
514 // similarly get the message format
515 std::map
<std::string
,message
>::iterator message_found
= m_messages
.find(message_id
);
516 if (message_found
== m_messages
.end()) throw message_handler_id_error(message_id
);
518 // format the message contents
519 std::string message_text
= format_message(message_found
->second
, args
);
521 // now format the message in the status string (informational, warning etc).
522 std::vector
<std::string
> status_args
;
523 status_args
.push_back(message_text
);
524 std::string result
= format_message(status_found
->second
, status_args
);
526 // finally, if the message is positional, format the status message in the positional string
527 if (position
.valid())
529 // get the position format from the message set
530 std::map
<std::string
,message
>::iterator position_found
= m_messages
.find(position_id
);
531 if (position_found
== m_messages
.end()) throw message_handler_id_error(position_id
);
533 // now format the message
534 std::vector
<std::string
> position_args
;
535 position_args
.push_back(result
);
536 position_args
.push_back(position
.filename());
537 position_args
.push_back(dformat("%u",position
.line()));
538 position_args
.push_back(dformat("%u",position
.column()));
539 result
= format_message(position_found
->second
, position_args
);
540 // add the source file text and position if that option is on
544 std::vector
<std::string
> show
= position
.show();
545 for (unsigned i
= 0; i
< show
.size(); i
++)
547 result
+= std::string("\n");
555 std::string
format_message(const message
& mess
,
556 const std::vector
<std::string
>& args
)
557 throw(message_handler_format_error
)
559 // this function creates a formatted string from the stored message text and
560 // the arguments. Most of the work is done in format_string. However, if a
561 // formatting error is found, this function uses extra information stored in
562 // the message data structure to improve the reporting of the error
565 // This is the basic string formatter which performs parameter substitution
566 // into a message. Parameter placeholders are in the form @0, @1 etc, where
567 // the number is the index of the argument in the args vector. At present,
568 // no field codes are supported as in printf formats Algorithm: scan the
569 // input string and transfer it into the result. When an @nnn appears,
570 // substitute the relevant argument from the args vector. Throw an exception
571 // if its out of range. Also convert C-style escaped characters of the form
573 std::string format
= mess
.text();
575 for (unsigned i
= 0; i
< format
.size(); )
577 if (format
[i
] == '@')
579 // an argument substitution has been found - now find the argument number
580 if (i
+1 == format
.size()) throw message_handler_format_error(format
, i
);
582 // check for @@ which is an escaped form of '@'
583 if (format
[i
] == '@')
590 // there must be at least one digit in the substitution number
591 if (!isdigit(format
[i
])) throw message_handler_format_error(format
,i
);
593 for (; i
< format
.size() && isdigit(format
[i
]); i
++)
596 a
+= (format
[i
] - '0');
598 // check for an argument request out of the range of the set of arguments
599 if (a
>= args
.size()) throw message_handler_format_error(format
,i
-1);
603 else if (format
[i
] == '\\')
605 // an escaped character has been found
606 if (i
+1 == format
.size()) throw message_handler_format_error(format
, i
);
608 // do the special ones first, then all the others just strip off the \ and leave the following characters
634 // plain text found - just append to the result
635 result
+= format
[i
++];
640 catch(message_handler_format_error
& exception
)
642 // if the message came from a message file, improve the error reporting by adding file positional information
643 // Also adjust the position from the start of the text (stored in the message field) to the column of the error
644 if (mess
.index() != (unsigned)-1)
645 throw message_handler_format_error(
646 message_position(m_files
[mess
.index()], mess
.line(), mess
.column()+exception
.offset()),
655 message_handler_base_body(message_handler_base_body
&);
656 message_handler_base_body
& operator=(message_handler_base_body
&);
659 ////////////////////////////////////////////////////////////////////////////////
661 message_handler_base::message_handler_base(bool show
)
663 m_base_body(new message_handler_base_body
)
665 m_base_body
->set_show(show
);
668 message_handler_base::message_handler_base(const std::string
& file
, bool show
)
669 throw(message_handler_read_error
) :
670 m_base_body(new message_handler_base_body
)
672 m_base_body
->set_show(show
);
673 add_message_file(file
);
676 message_handler_base::message_handler_base(const std::vector
<std::string
>& files
, bool show
)
677 throw(message_handler_read_error
) :
678 m_base_body(new message_handler_base_body
)
680 m_base_body
->set_show(show
);
681 add_message_files(files
);
684 message_handler_base::~message_handler_base(void)
689 ////////////////////////////////////////////////////////////////////////////////
691 void message_handler_base::add_message_file(const std::string
& file
)
692 throw(message_handler_read_error
)
694 m_base_body
->add_message_file(file
);
697 void message_handler_base::add_message_files(const std::vector
<std::string
>& files
)
698 throw(message_handler_read_error
)
700 for (unsigned i
= 0; i
< files
.size(); i
++)
701 add_message_file(files
[i
]);
704 void message_handler_base::add_message(const std::string
& id
, const std::string
& text
)
707 m_base_body
->add_message(id
,text
);
710 bool message_handler_base::message_present(const std::string
& id
) const
713 return m_base_body
->message_present(id
);
716 ////////////////////////////////////////////////////////////////////////////////
718 void message_handler_base::set_information_format(const std::string
& format
) throw()
720 add_message(information_id
, format
);
723 void message_handler_base::set_warning_format(const std::string
& format
) throw()
725 add_message(warning_id
, format
);
728 void message_handler_base::set_error_format(const std::string
& format
) throw()
730 add_message(error_id
, format
);
733 void message_handler_base::set_fatal_format(const std::string
& format
) throw()
735 add_message(fatal_id
, format
);
738 void message_handler_base::set_position_format(const std::string
& format
) throw()
740 add_message(position_id
, format
);
743 void message_handler_base::set_context_format(const std::string
& format
) throw()
745 add_message(context_id
, format
);
748 void message_handler_base::set_supplement_format(const std::string
& format
) throw()
750 add_message(supplement_id
, format
);
753 ////////////////////////////////////////////////////////////////////////////////
755 void message_handler_base::show_position(void)
758 m_base_body
->set_show(true);
761 void message_handler_base::hide_position(void)
764 m_base_body
->set_show(false);
767 ////////////////////////////////////////////////////////////////////////////////
768 // information messages
770 std::vector
<std::string
> message_handler_base::information_message(const std::string
& id
,
771 const std::vector
<std::string
>& args
)
772 throw(message_handler_id_error
,message_handler_format_error
)
774 return information_message(message_position(), id
, args
);
777 std::vector
<std::string
> message_handler_base::information_message(const std::string
& id
)
778 throw(message_handler_id_error
,message_handler_format_error
)
780 std::vector
<std::string
> args
;
781 return information_message(id
, args
);
784 std::vector
<std::string
> message_handler_base::information_message(const std::string
& id
,
785 const std::string
& arg1
)
786 throw(message_handler_id_error
,message_handler_format_error
)
788 std::vector
<std::string
> args
;
789 args
.push_back(arg1
);
790 return information_message(id
, args
);
793 std::vector
<std::string
> message_handler_base::information_message(const std::string
& id
,
794 const std::string
& arg1
,
795 const std::string
& arg2
)
796 throw(message_handler_id_error
,message_handler_format_error
)
798 std::vector
<std::string
> args
;
799 args
.push_back(arg1
);
800 args
.push_back(arg2
);
801 return information_message(id
, args
);
804 std::vector
<std::string
> message_handler_base::information_message(const std::string
& id
,
805 const std::string
& arg1
,
806 const std::string
& arg2
,
807 const std::string
& arg3
)
808 throw(message_handler_id_error
,message_handler_format_error
)
810 std::vector
<std::string
> args
;
811 args
.push_back(arg1
);
812 args
.push_back(arg2
);
813 args
.push_back(arg3
);
814 return information_message(id
, args
);
817 std::vector
<std::string
> message_handler_base::information_message(const message_position
& position
,
818 const std::string
& id
,
819 const std::vector
<std::string
>& args
)
820 throw(message_handler_id_error
,message_handler_format_error
)
822 return m_base_body
->format_report(position
, id
, information_id
, args
);
825 std::vector
<std::string
> message_handler_base::information_message(const message_position
& position
,
826 const std::string
& id
)
827 throw(message_handler_id_error
,message_handler_format_error
)
829 std::vector
<std::string
> args
;
830 return information_message(position
, id
, args
);
833 std::vector
<std::string
> message_handler_base::information_message(const message_position
& position
,
834 const std::string
& id
,
835 const std::string
& arg1
)
836 throw(message_handler_id_error
,message_handler_format_error
)
838 std::vector
<std::string
> args
;
839 args
.push_back(arg1
);
840 return information_message(position
, id
, args
);
843 std::vector
<std::string
> message_handler_base::information_message(const message_position
& position
,
844 const std::string
& id
,
845 const std::string
& arg1
,
846 const std::string
& arg2
)
847 throw(message_handler_id_error
,message_handler_format_error
)
849 std::vector
<std::string
> args
;
850 args
.push_back(arg1
);
851 args
.push_back(arg2
);
852 return information_message(position
, id
, args
);
855 std::vector
<std::string
> message_handler_base::information_message(const message_position
& position
,
856 const std::string
& id
,
857 const std::string
& arg1
,
858 const std::string
& arg2
,
859 const std::string
& arg3
)
860 throw(message_handler_id_error
,message_handler_format_error
)
862 std::vector
<std::string
> args
;
863 args
.push_back(arg1
);
864 args
.push_back(arg2
);
865 args
.push_back(arg3
);
866 return information_message(position
, id
, args
);
869 ////////////////////////////////////////////////////////////////////////////////
872 std::vector
<std::string
> message_handler_base::warning_message(const std::string
& id
,
873 const std::vector
<std::string
>& args
)
874 throw(message_handler_id_error
,message_handler_format_error
)
876 return warning_message(message_position(), id
, args
);
879 std::vector
<std::string
> message_handler_base::warning_message(const std::string
& id
)
880 throw(message_handler_id_error
,message_handler_format_error
)
882 std::vector
<std::string
> args
;
883 return warning_message(id
, args
);
886 std::vector
<std::string
> message_handler_base::warning_message(const std::string
& id
,
887 const std::string
& arg1
)
888 throw(message_handler_id_error
,message_handler_format_error
)
890 std::vector
<std::string
> args
;
891 args
.push_back(arg1
);
892 return warning_message(id
, args
);
895 std::vector
<std::string
> message_handler_base::warning_message(const std::string
& id
,
896 const std::string
& arg1
,
897 const std::string
& arg2
)
898 throw(message_handler_id_error
,message_handler_format_error
)
900 std::vector
<std::string
> args
;
901 args
.push_back(arg1
);
902 args
.push_back(arg2
);
903 return warning_message(id
, args
);
906 std::vector
<std::string
> message_handler_base::warning_message(const std::string
& id
,
907 const std::string
& arg1
,
908 const std::string
& arg2
,
909 const std::string
& arg3
)
910 throw(message_handler_id_error
,message_handler_format_error
)
912 std::vector
<std::string
> args
;
913 args
.push_back(arg1
);
914 args
.push_back(arg2
);
915 args
.push_back(arg3
);
916 return warning_message(id
, args
);
919 std::vector
<std::string
> message_handler_base::warning_message(const message_position
& position
,
920 const std::string
& id
,
921 const std::vector
<std::string
>& args
)
922 throw(message_handler_id_error
,message_handler_format_error
)
924 return m_base_body
->format_report(position
, id
, warning_id
, args
);
927 std::vector
<std::string
> message_handler_base::warning_message(const message_position
& position
,
928 const std::string
& id
)
929 throw(message_handler_id_error
,message_handler_format_error
)
931 std::vector
<std::string
> args
;
932 return warning_message(position
, id
, args
);
935 std::vector
<std::string
> message_handler_base::warning_message(const message_position
& position
,
936 const std::string
& id
,
937 const std::string
& arg1
)
938 throw(message_handler_id_error
,message_handler_format_error
)
940 std::vector
<std::string
> args
;
941 args
.push_back(arg1
);
942 return warning_message(position
, id
, args
);
945 std::vector
<std::string
> message_handler_base::warning_message(const message_position
& position
,
946 const std::string
& id
,
947 const std::string
& arg1
,
948 const std::string
& arg2
)
949 throw(message_handler_id_error
,message_handler_format_error
)
951 std::vector
<std::string
> args
;
952 args
.push_back(arg1
);
953 args
.push_back(arg2
);
954 return warning_message(position
, id
, args
);
957 std::vector
<std::string
> message_handler_base::warning_message(const message_position
& position
,
958 const std::string
& id
,
959 const std::string
& arg1
,
960 const std::string
& arg2
,
961 const std::string
& arg3
)
962 throw(message_handler_id_error
,message_handler_format_error
)
964 std::vector
<std::string
> args
;
965 args
.push_back(arg1
);
966 args
.push_back(arg2
);
967 args
.push_back(arg3
);
968 return warning_message(position
, id
, args
);
971 ////////////////////////////////////////////////////////////////////////////////
974 std::vector
<std::string
> message_handler_base::error_message(const std::string
& id
,
975 const std::vector
<std::string
>& args
)
976 throw(message_handler_id_error
,message_handler_format_error
)
978 return error_message(message_position(), id
, args
);
981 std::vector
<std::string
> message_handler_base::error_message(const std::string
& id
)
982 throw(message_handler_id_error
,message_handler_format_error
)
984 std::vector
<std::string
> args
;
985 return error_message(id
, args
);
988 std::vector
<std::string
> message_handler_base::error_message(const std::string
& id
,
989 const std::string
& arg1
)
990 throw(message_handler_id_error
,message_handler_format_error
)
992 std::vector
<std::string
> args
;
993 args
.push_back(arg1
);
994 return error_message(id
, args
);
997 std::vector
<std::string
> message_handler_base::error_message(const std::string
& id
,
998 const std::string
& arg1
,
999 const std::string
& arg2
)
1000 throw(message_handler_id_error
,message_handler_format_error
)
1002 std::vector
<std::string
> args
;
1003 args
.push_back(arg1
);
1004 args
.push_back(arg2
);
1005 return error_message(id
, args
);
1008 std::vector
<std::string
> message_handler_base::error_message(const std::string
& id
,
1009 const std::string
& arg1
,
1010 const std::string
& arg2
,
1011 const std::string
& arg3
)
1012 throw(message_handler_id_error
,message_handler_format_error
)
1014 std::vector
<std::string
> args
;
1015 args
.push_back(arg1
);
1016 args
.push_back(arg2
);
1017 args
.push_back(arg3
);
1018 return error_message(id
, args
);
1021 std::vector
<std::string
> message_handler_base::error_message(const message_position
& position
,
1022 const std::string
& id
,
1023 const std::vector
<std::string
>& args
)
1024 throw(message_handler_id_error
,message_handler_format_error
)
1026 return m_base_body
->format_report(position
, id
, error_id
, args
);
1029 std::vector
<std::string
> message_handler_base::error_message(const message_position
& position
,
1030 const std::string
& id
)
1031 throw(message_handler_id_error
,message_handler_format_error
)
1033 std::vector
<std::string
> args
;
1034 return error_message(position
, id
, args
);
1037 std::vector
<std::string
> message_handler_base::error_message(const message_position
& position
,
1038 const std::string
& id
,
1039 const std::string
& arg1
)
1040 throw(message_handler_id_error
,message_handler_format_error
)
1042 std::vector
<std::string
> args
;
1043 args
.push_back(arg1
);
1044 return error_message(position
, id
, args
);
1047 std::vector
<std::string
> message_handler_base::error_message(const message_position
& position
,
1048 const std::string
& id
,
1049 const std::string
& arg1
,
1050 const std::string
& arg2
)
1051 throw(message_handler_id_error
,message_handler_format_error
)
1053 std::vector
<std::string
> args
;
1054 args
.push_back(arg1
);
1055 args
.push_back(arg2
);
1056 return error_message(position
, id
, args
);
1059 std::vector
<std::string
> message_handler_base::error_message(const message_position
& position
,
1060 const std::string
& id
,
1061 const std::string
& arg1
,
1062 const std::string
& arg2
,
1063 const std::string
& arg3
)
1064 throw(message_handler_id_error
,message_handler_format_error
)
1066 std::vector
<std::string
> args
;
1067 args
.push_back(arg1
);
1068 args
.push_back(arg2
);
1069 args
.push_back(arg3
);
1070 return error_message(position
, id
, args
);
1073 ////////////////////////////////////////////////////////////////////////////////
1076 std::vector
<std::string
> message_handler_base::fatal_message(const std::string
& id
,
1077 const std::vector
<std::string
>& args
)
1078 throw(message_handler_id_error
,message_handler_format_error
)
1080 return fatal_message(message_position(), id
, args
);
1083 std::vector
<std::string
> message_handler_base::fatal_message(const std::string
& id
)
1084 throw(message_handler_id_error
,message_handler_format_error
)
1086 std::vector
<std::string
> args
;
1087 return fatal_message(id
, args
);
1090 std::vector
<std::string
> message_handler_base::fatal_message(const std::string
& id
,
1091 const std::string
& arg1
)
1092 throw(message_handler_id_error
,message_handler_format_error
)
1094 std::vector
<std::string
> args
;
1095 args
.push_back(arg1
);
1096 return fatal_message(id
, args
);
1099 std::vector
<std::string
> message_handler_base::fatal_message(const std::string
& id
,
1100 const std::string
& arg1
,
1101 const std::string
& arg2
)
1102 throw(message_handler_id_error
,message_handler_format_error
)
1104 std::vector
<std::string
> args
;
1105 args
.push_back(arg1
);
1106 args
.push_back(arg2
);
1107 return fatal_message(id
, args
);
1110 std::vector
<std::string
> message_handler_base::fatal_message(const std::string
& id
,
1111 const std::string
& arg1
,
1112 const std::string
& arg2
,
1113 const std::string
& arg3
)
1114 throw(message_handler_id_error
,message_handler_format_error
)
1116 std::vector
<std::string
> args
;
1117 args
.push_back(arg1
);
1118 args
.push_back(arg2
);
1119 args
.push_back(arg3
);
1120 return fatal_message(id
, args
);
1123 std::vector
<std::string
> message_handler_base::fatal_message(const message_position
& position
,
1124 const std::string
& id
,
1125 const std::vector
<std::string
>& args
)
1126 throw(message_handler_id_error
,message_handler_format_error
)
1128 return m_base_body
->format_report(position
, id
, fatal_id
, args
);
1131 std::vector
<std::string
> message_handler_base::fatal_message(const message_position
& position
,
1132 const std::string
& id
)
1133 throw(message_handler_id_error
,message_handler_format_error
)
1135 std::vector
<std::string
> args
;
1136 return fatal_message(position
, id
, args
);
1139 std::vector
<std::string
> message_handler_base::fatal_message(const message_position
& position
,
1140 const std::string
& id
,
1141 const std::string
& arg1
)
1142 throw(message_handler_id_error
,message_handler_format_error
)
1144 std::vector
<std::string
> args
;
1145 args
.push_back(arg1
);
1146 return fatal_message(position
, id
, args
);
1149 std::vector
<std::string
> message_handler_base::fatal_message(const message_position
& position
,
1150 const std::string
& id
,
1151 const std::string
& arg1
,
1152 const std::string
& arg2
)
1153 throw(message_handler_id_error
,message_handler_format_error
)
1155 std::vector
<std::string
> args
;
1156 args
.push_back(arg1
);
1157 args
.push_back(arg2
);
1158 return fatal_message(position
, id
, args
);
1161 std::vector
<std::string
> message_handler_base::fatal_message(const message_position
& position
,
1162 const std::string
& id
,
1163 const std::string
& arg1
,
1164 const std::string
& arg2
,
1165 const std::string
& arg3
)
1166 throw(message_handler_id_error
,message_handler_format_error
)
1168 std::vector
<std::string
> args
;
1169 args
.push_back(arg1
);
1170 args
.push_back(arg2
);
1171 args
.push_back(arg3
);
1172 return fatal_message(position
, id
, args
);
1175 ////////////////////////////////////////////////////////////////////////////////
1176 // supplemental messages
1178 void message_handler_base::push_supplement(const std::string
& id
,
1179 const std::vector
<std::string
>& args
)
1180 throw(message_handler_id_error
,message_handler_format_error
)
1182 push_supplement(message_position(), id
, args
);
1185 void message_handler_base::push_supplement(const std::string
& id
)
1186 throw(message_handler_id_error
,message_handler_format_error
)
1188 std::vector
<std::string
> args
;
1189 push_supplement(id
, args
);
1192 void message_handler_base::push_supplement(const std::string
& id
,
1193 const std::string
& arg1
)
1194 throw(message_handler_id_error
,message_handler_format_error
)
1196 std::vector
<std::string
> args
;
1197 args
.push_back(arg1
);
1198 push_supplement(id
, args
);
1201 void message_handler_base::push_supplement(const std::string
& id
,
1202 const std::string
& arg1
,
1203 const std::string
& arg2
)
1204 throw(message_handler_id_error
,message_handler_format_error
)
1206 std::vector
<std::string
> args
;
1207 args
.push_back(arg1
);
1208 args
.push_back(arg2
);
1209 push_supplement(id
, args
);
1212 void message_handler_base::push_supplement(const std::string
& id
,
1213 const std::string
& arg1
,
1214 const std::string
& arg2
,
1215 const std::string
& arg3
)
1216 throw(message_handler_id_error
,message_handler_format_error
)
1218 std::vector
<std::string
> args
;
1219 args
.push_back(arg1
);
1220 args
.push_back(arg2
);
1221 args
.push_back(arg3
);
1222 push_supplement(id
, args
);
1225 void message_handler_base::push_supplement(const message_position
& position
,
1226 const std::string
& id
,
1227 const std::vector
<std::string
>& args
)
1228 throw(message_handler_id_error
,message_handler_format_error
)
1230 m_base_body
->push_supplement(position
, id
, args
);
1233 void message_handler_base::push_supplement(const message_position
& position
,
1234 const std::string
& id
)
1235 throw(message_handler_id_error
,message_handler_format_error
)
1237 std::vector
<std::string
> args
;
1238 push_supplement(position
, id
, args
);
1241 void message_handler_base::push_supplement(const message_position
& position
,
1242 const std::string
& id
,
1243 const std::string
& arg1
)
1244 throw(message_handler_id_error
,message_handler_format_error
)
1246 std::vector
<std::string
> args
;
1247 args
.push_back(arg1
);
1248 push_supplement(position
, id
, args
);
1251 void message_handler_base::push_supplement(const message_position
& position
,
1252 const std::string
& id
,
1253 const std::string
& arg1
,
1254 const std::string
& arg2
)
1255 throw(message_handler_id_error
,message_handler_format_error
)
1257 std::vector
<std::string
> args
;
1258 args
.push_back(arg1
);
1259 args
.push_back(arg2
);
1260 push_supplement(position
, id
, args
);
1263 void message_handler_base::push_supplement(const message_position
& position
,
1264 const std::string
& id
,
1265 const std::string
& arg1
,
1266 const std::string
& arg2
,
1267 const std::string
& arg3
)
1268 throw(message_handler_id_error
,message_handler_format_error
)
1270 std::vector
<std::string
> args
;
1271 args
.push_back(arg1
);
1272 args
.push_back(arg2
);
1273 args
.push_back(arg3
);
1274 push_supplement(position
, id
, args
);
1277 ////////////////////////////////////////////////////////////////////////////////
1280 void message_handler_base::push_context (const std::string
& id
,
1281 const std::vector
<std::string
>& args
)
1282 throw(message_handler_id_error
,message_handler_format_error
)
1284 push_context(message_position(), id
, args
);
1287 void message_handler_base::push_context (const std::string
& id
)
1288 throw(message_handler_id_error
,message_handler_format_error
)
1290 std::vector
<std::string
> args
;
1291 push_context(id
, args
);
1294 void message_handler_base::push_context (const std::string
& id
,
1295 const std::string
& arg1
)
1296 throw(message_handler_id_error
,message_handler_format_error
)
1298 std::vector
<std::string
> args
;
1299 args
.push_back(arg1
);
1300 push_context(id
, args
);
1303 void message_handler_base::push_context (const std::string
& id
,
1304 const std::string
& arg1
,
1305 const std::string
& arg2
)
1306 throw(message_handler_id_error
,message_handler_format_error
)
1308 std::vector
<std::string
> args
;
1309 args
.push_back(arg1
);
1310 args
.push_back(arg2
);
1311 push_context(id
, args
);
1314 void message_handler_base::push_context (const std::string
& id
,
1315 const std::string
& arg1
,
1316 const std::string
& arg2
,
1317 const std::string
& arg3
)
1318 throw(message_handler_id_error
,message_handler_format_error
)
1320 std::vector
<std::string
> args
;
1321 args
.push_back(arg1
);
1322 args
.push_back(arg2
);
1323 args
.push_back(arg3
);
1324 push_context(id
, args
);
1327 void message_handler_base::push_context (const message_position
& position
,
1328 const std::string
& id
,
1329 const std::vector
<std::string
>& args
)
1330 throw(message_handler_id_error
,message_handler_format_error
)
1332 m_base_body
->push_context(position
, id
, args
);
1335 void message_handler_base::push_context (const message_position
& position
,
1336 const std::string
& id
)
1337 throw(message_handler_id_error
,message_handler_format_error
)
1339 std::vector
<std::string
> args
;
1340 push_context(position
, id
, args
);
1343 void message_handler_base::push_context (const message_position
& position
,
1344 const std::string
& id
,
1345 const std::string
& arg1
)
1346 throw(message_handler_id_error
,message_handler_format_error
)
1348 std::vector
<std::string
> args
;
1349 args
.push_back(arg1
);
1350 push_context(position
, id
, args
);
1353 void message_handler_base::push_context (const message_position
& position
,
1354 const std::string
& id
,
1355 const std::string
& arg1
,
1356 const std::string
& arg2
)
1357 throw(message_handler_id_error
,message_handler_format_error
)
1359 std::vector
<std::string
> args
;
1360 args
.push_back(arg1
);
1361 args
.push_back(arg2
);
1362 push_context(position
, id
, args
);
1365 void message_handler_base::push_context (const message_position
& position
,
1366 const std::string
& id
,
1367 const std::string
& arg1
,
1368 const std::string
& arg2
,
1369 const std::string
& arg3
)
1370 throw(message_handler_id_error
,message_handler_format_error
)
1372 std::vector
<std::string
> args
;
1373 args
.push_back(arg1
);
1374 args
.push_back(arg2
);
1375 args
.push_back(arg3
);
1376 push_context(position
, id
, args
);
1379 void message_handler_base::pop_context(void) throw()
1381 m_base_body
->pop_context(m_base_body
->context_depth()-1);
1384 void message_handler_base::pop_context(unsigned depth
) throw()
1386 m_base_body
->pop_context(depth
);
1389 unsigned message_handler_base::context_depth(void) const
1392 return m_base_body
->context_depth();
1395 message_context
message_handler_base::auto_push_context(const std::string
& id
, const std::vector
<std::string
>& args
)
1396 throw(message_handler_id_error
,message_handler_format_error
)
1398 return auto_push_context(message_position(), id
, args
);
1401 message_context
message_handler_base::auto_push_context(const std::string
& id
)
1402 throw(message_handler_id_error
,message_handler_format_error
)
1404 std::vector
<std::string
> args
;
1405 return auto_push_context(id
, args
);
1408 message_context
message_handler_base::auto_push_context(const std::string
& id
,
1409 const std::string
& arg1
)
1410 throw(message_handler_id_error
,message_handler_format_error
)
1412 std::vector
<std::string
> args
;
1413 args
.push_back(arg1
);
1414 return auto_push_context(id
, args
);
1417 message_context
message_handler_base::auto_push_context (const std::string
& id
,
1418 const std::string
& arg1
,
1419 const std::string
& arg2
)
1420 throw(message_handler_id_error
,message_handler_format_error
)
1422 std::vector
<std::string
> args
;
1423 args
.push_back(arg1
);
1424 args
.push_back(arg2
);
1425 return auto_push_context(id
, args
);
1428 message_context
message_handler_base::auto_push_context(const std::string
& id
,
1429 const std::string
& arg1
,
1430 const std::string
& arg2
,
1431 const std::string
& arg3
)
1432 throw(message_handler_id_error
,message_handler_format_error
)
1434 std::vector
<std::string
> args
;
1435 args
.push_back(arg1
);
1436 args
.push_back(arg2
);
1437 args
.push_back(arg3
);
1438 return auto_push_context(id
, args
);
1441 message_context
message_handler_base::auto_push_context(const message_position
& position
,
1442 const std::string
& id
,
1443 const std::vector
<std::string
>& args
)
1444 throw(message_handler_id_error
,message_handler_format_error
)
1446 message_context
result(*this);
1447 m_base_body
->push_context(position
, id
, args
);
1451 message_context
message_handler_base::auto_push_context(const message_position
& position
,
1452 const std::string
& id
)
1453 throw(message_handler_id_error
,message_handler_format_error
)
1455 std::vector
<std::string
> args
;
1456 return auto_push_context(position
, id
, args
);
1459 message_context
message_handler_base::auto_push_context(const message_position
& position
,
1460 const std::string
& id
,
1461 const std::string
& arg1
)
1462 throw(message_handler_id_error
,message_handler_format_error
)
1464 std::vector
<std::string
> args
;
1465 args
.push_back(arg1
);
1466 return auto_push_context(position
, id
, args
);
1469 message_context
message_handler_base::auto_push_context(const message_position
& position
,
1470 const std::string
& id
,
1471 const std::string
& arg1
,
1472 const std::string
& arg2
)
1473 throw(message_handler_id_error
,message_handler_format_error
)
1475 std::vector
<std::string
> args
;
1476 args
.push_back(arg1
);
1477 args
.push_back(arg2
);
1478 return auto_push_context(position
, id
, args
);
1481 message_context
message_handler_base::auto_push_context(const message_position
& position
,
1482 const std::string
& id
,
1483 const std::string
& arg1
,
1484 const std::string
& arg2
,
1485 const std::string
& arg3
)
1486 throw(message_handler_id_error
,message_handler_format_error
)
1488 std::vector
<std::string
> args
;
1489 args
.push_back(arg1
);
1490 args
.push_back(arg2
);
1491 args
.push_back(arg3
);
1492 return auto_push_context(position
, id
, args
);
1495 ////////////////////////////////////////////////////////////////////////////////
1496 // iostream-based derivative uses the above base class to generate messages then uses iostream to print them
1497 ////////////////////////////////////////////////////////////////////////////////
1499 class message_handler_body
1502 std::ostream
* m_device
; // TextIO output device
1503 unsigned m_limit
; // error limit
1504 unsigned m_errors
; // error count
1507 message_handler_body(std::ostream
& device
, unsigned limit
) :
1508 m_device(&device
), m_limit(limit
), m_errors(0)
1512 ~message_handler_body(void)
1517 std::ostream
& device(void)
1522 unsigned limit(void) const
1527 void set_limit(unsigned limit
)
1532 unsigned count(void) const
1537 void set_count(unsigned count
)
1542 void error_increment(void)
1547 bool limit_reached(void) const
1549 return m_limit
> 0 && m_errors
>= m_limit
;
1553 message_handler_body(const message_handler_body
&);
1554 message_handler_body
& operator=(const message_handler_body
&);
1557 ////////////////////////////////////////////////////////////////////////////////
1559 message_handler::message_handler(std::ostream
& device
, unsigned limit
, bool show
)
1561 message_handler_base(show
), m_body(new message_handler_body(device
, limit
))
1565 message_handler::message_handler(std::ostream
& device
,
1566 const std::string
& message_file
, unsigned limit
, bool show
)
1567 throw(message_handler_read_error
) :
1568 message_handler_base(message_file
,show
), m_body(new message_handler_body(device
, limit
))
1572 message_handler::message_handler(std::ostream
& device
, const std::vector
<std::string
>& message_files
, unsigned limit
, bool show
)
1573 throw(message_handler_read_error
) :
1574 message_handler_base(message_files
,show
), m_body(new message_handler_body(device
, limit
))
1578 message_handler::~message_handler(void)
1583 ////////////////////////////////////////////////////////////////////////////////
1586 void message_handler::set_error_limit(unsigned error_limit
)
1589 m_body
->set_limit(error_limit
);
1592 unsigned message_handler::error_limit(void) const
1595 return m_body
->limit();
1598 void message_handler::reset_error_count(void)
1601 m_body
->set_count(0);
1604 unsigned message_handler::error_count(void) const
1607 return m_body
->count();
1610 std::ostream
& message_handler::device(void)
1612 return m_body
->device();
1615 ////////////////////////////////////////////////////////////////////////////////
1616 // information messages
1618 bool message_handler::information(const std::string
& id
,
1619 const std::vector
<std::string
>& args
)
1620 throw(message_handler_id_error
,message_handler_format_error
)
1622 device() << information_message(id
, args
);
1626 bool message_handler::information(const std::string
& id
)
1627 throw(message_handler_id_error
,message_handler_format_error
)
1629 device() << information_message(id
);
1633 bool message_handler::information(const std::string
& id
,
1634 const std::string
& arg1
)
1635 throw(message_handler_id_error
,message_handler_format_error
)
1637 device() << information_message(id
, arg1
);
1641 bool message_handler::information(const std::string
& id
,
1642 const std::string
& arg1
,
1643 const std::string
& arg2
)
1644 throw(message_handler_id_error
,message_handler_format_error
)
1646 device() << information_message(id
, arg1
, arg2
);
1650 bool message_handler::information(const std::string
& id
,
1651 const std::string
& arg1
,
1652 const std::string
& arg2
,
1653 const std::string
& arg3
)
1654 throw(message_handler_id_error
,message_handler_format_error
)
1656 device() << information_message(id
, arg1
, arg2
, arg3
);
1660 bool message_handler::information(const message_position
& position
,
1661 const std::string
& id
,
1662 const std::vector
<std::string
>& args
)
1663 throw(message_handler_id_error
,message_handler_format_error
)
1665 device() << information_message(position
, id
, args
);
1669 bool message_handler::information(const message_position
& position
,
1670 const std::string
& id
)
1671 throw(message_handler_id_error
,message_handler_format_error
)
1673 device() << information_message(position
, id
);
1677 bool message_handler::information(const message_position
& position
,
1678 const std::string
& id
,
1679 const std::string
& arg1
)
1680 throw(message_handler_id_error
,message_handler_format_error
)
1682 device() << information_message(position
, id
, arg1
);
1686 bool message_handler::information(const message_position
& position
,
1687 const std::string
& id
,
1688 const std::string
& arg1
,
1689 const std::string
& arg2
)
1690 throw(message_handler_id_error
,message_handler_format_error
)
1692 device() << information_message(position
, id
, arg1
, arg2
);
1696 bool message_handler::information(const message_position
& position
,
1697 const std::string
& id
,
1698 const std::string
& arg1
,
1699 const std::string
& arg2
,
1700 const std::string
& arg3
)
1701 throw(message_handler_id_error
,message_handler_format_error
)
1703 device() << information_message(position
, id
, arg1
, arg2
, arg3
);
1707 ////////////////////////////////////////////////////////////////////////////////
1710 bool message_handler::warning(const std::string
& id
,
1711 const std::vector
<std::string
>& args
)
1712 throw(message_handler_id_error
,message_handler_format_error
)
1714 device() << warning_message(id
, args
);
1718 bool message_handler::warning(const std::string
& id
)
1719 throw(message_handler_id_error
,message_handler_format_error
)
1721 device() << warning_message(id
);
1725 bool message_handler::warning(const std::string
& id
,
1726 const std::string
& arg1
)
1727 throw(message_handler_id_error
,message_handler_format_error
)
1729 device() << warning_message(id
, arg1
);
1733 bool message_handler::warning(const std::string
& id
,
1734 const std::string
& arg1
,
1735 const std::string
& arg2
)
1736 throw(message_handler_id_error
,message_handler_format_error
)
1738 device() << warning_message(id
, arg1
, arg2
);
1742 bool message_handler::warning(const std::string
& id
,
1743 const std::string
& arg1
,
1744 const std::string
& arg2
,
1745 const std::string
& arg3
)
1746 throw(message_handler_id_error
,message_handler_format_error
)
1748 device() << warning_message(id
, arg1
, arg2
, arg3
);
1752 bool message_handler::warning(const message_position
& position
,
1753 const std::string
& id
,
1754 const std::vector
<std::string
>& args
)
1755 throw(message_handler_id_error
,message_handler_format_error
)
1757 device() << warning_message(position
, id
, args
);
1761 bool message_handler::warning(const message_position
& position
,
1762 const std::string
& id
)
1763 throw(message_handler_id_error
,message_handler_format_error
)
1765 device() << warning_message(position
, id
);
1769 bool message_handler::warning(const message_position
& position
,
1770 const std::string
& id
,
1771 const std::string
& arg1
)
1772 throw(message_handler_id_error
,message_handler_format_error
)
1774 device() << warning_message(position
, id
, arg1
);
1778 bool message_handler::warning(const message_position
& position
,
1779 const std::string
& id
,
1780 const std::string
& arg1
,
1781 const std::string
& arg2
)
1782 throw(message_handler_id_error
,message_handler_format_error
)
1784 device() << warning_message(position
, id
, arg1
, arg2
);
1788 bool message_handler::warning(const message_position
& position
,
1789 const std::string
& id
,
1790 const std::string
& arg1
,
1791 const std::string
& arg2
,
1792 const std::string
& arg3
)
1793 throw(message_handler_id_error
,message_handler_format_error
)
1795 device() << warning_message(position
, id
, arg1
, arg2
, arg3
);
1799 ////////////////////////////////////////////////////////////////////////////////
1802 bool message_handler::error(const std::string
& id
,
1803 const std::vector
<std::string
>& args
)
1804 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1806 device() << error_message(id
, args
);
1807 m_body
->error_increment();
1808 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1812 bool message_handler::error(const std::string
& id
)
1813 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1815 device() << error_message(id
);
1816 m_body
->error_increment();
1817 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1821 bool message_handler::error(const std::string
& id
,
1822 const std::string
& arg1
)
1823 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1825 device() << error_message(id
, arg1
);
1826 m_body
->error_increment();
1827 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1831 bool message_handler::error(const std::string
& id
,
1832 const std::string
& arg1
,
1833 const std::string
& arg2
)
1834 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1836 device() << error_message(id
, arg1
, arg2
);
1837 m_body
->error_increment();
1838 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1842 bool message_handler::error(const std::string
& id
,
1843 const std::string
& arg1
,
1844 const std::string
& arg2
,
1845 const std::string
& arg3
)
1846 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1848 device() << error_message(id
, arg1
, arg2
, arg3
);
1849 m_body
->error_increment();
1850 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1854 bool message_handler::error(const message_position
& position
,
1855 const std::string
& id
,
1856 const std::vector
<std::string
>& args
)
1857 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1859 device() << error_message(position
, id
, args
);
1860 m_body
->error_increment();
1861 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1865 bool message_handler::error(const message_position
& position
,
1866 const std::string
& id
)
1867 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1869 device() << error_message(position
, id
);
1870 m_body
->error_increment();
1871 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1875 bool message_handler::error(const message_position
& position
,
1876 const std::string
& id
,
1877 const std::string
& arg1
)
1878 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1880 device() << error_message(position
, id
, arg1
);
1881 m_body
->error_increment();
1882 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1886 bool message_handler::error(const message_position
& position
,
1887 const std::string
& id
,
1888 const std::string
& arg1
,
1889 const std::string
& arg2
)
1890 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1892 device() << error_message(position
, id
, arg1
, arg2
);
1893 m_body
->error_increment();
1894 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1898 bool message_handler::error(const message_position
& position
,
1899 const std::string
& id
,
1900 const std::string
& arg1
,
1901 const std::string
& arg2
,
1902 const std::string
& arg3
)
1903 throw(message_handler_id_error
,message_handler_format_error
,message_handler_limit_error
)
1905 device() << error_message(position
, id
, arg1
, arg2
, arg3
);
1906 m_body
->error_increment();
1907 if (m_body
->limit_reached()) throw message_handler_limit_error(m_body
->limit());
1911 ////////////////////////////////////////////////////////////////////////////////
1914 bool message_handler::fatal(const std::string
& id
,
1915 const std::vector
<std::string
>& args
)
1916 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1918 device() << fatal_message(id
, args
);
1919 throw message_handler_fatal_error(id
);
1922 bool message_handler::fatal(const std::string
& id
)
1923 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1925 device() << fatal_message(id
);
1926 throw message_handler_fatal_error(id
);
1929 bool message_handler::fatal(const std::string
& id
,
1930 const std::string
& arg1
)
1931 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1933 device() << fatal_message(id
, arg1
);
1934 throw message_handler_fatal_error(id
);
1937 bool message_handler::fatal(const std::string
& id
,
1938 const std::string
& arg1
,
1939 const std::string
& arg2
)
1940 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1942 device() << fatal_message(id
, arg1
, arg2
);
1943 throw message_handler_fatal_error(id
);
1946 bool message_handler::fatal(const std::string
& id
,
1947 const std::string
& arg1
,
1948 const std::string
& arg2
,
1949 const std::string
& arg3
)
1950 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1952 device() << fatal_message(id
, arg1
, arg2
, arg3
);
1953 throw message_handler_fatal_error(id
);
1956 bool message_handler::fatal(const message_position
& position
,
1957 const std::string
& id
,
1958 const std::vector
<std::string
>& args
)
1959 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1961 device() << fatal_message(position
, id
, args
);
1962 throw message_handler_fatal_error(id
);
1965 bool message_handler::fatal(const message_position
& position
,
1966 const std::string
& id
)
1967 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1969 device() << fatal_message(position
, id
);
1970 throw message_handler_fatal_error(id
);
1973 bool message_handler::fatal(const message_position
& position
,
1974 const std::string
& id
,
1975 const std::string
& arg1
)
1976 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1978 device() << fatal_message(position
, id
, arg1
);
1979 throw message_handler_fatal_error(id
);
1982 bool message_handler::fatal(const message_position
& position
,
1983 const std::string
& id
,
1984 const std::string
& arg1
,
1985 const std::string
& arg2
)
1986 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1988 device() << fatal_message(position
, id
, arg1
, arg2
);
1989 throw message_handler_fatal_error(id
);
1992 bool message_handler::fatal(const message_position
& position
,
1993 const std::string
& id
,
1994 const std::string
& arg1
,
1995 const std::string
& arg2
,
1996 const std::string
& arg3
)
1997 throw(message_handler_id_error
,message_handler_format_error
,message_handler_fatal_error
)
1999 device() << fatal_message(position
, id
, arg1
, arg2
, arg3
);
2000 throw message_handler_fatal_error(id
);
2003 ///////////////////////////////////////////////////////////////////////////////
2006 bool message_handler::plaintext(const std::string
& text
)
2008 device() << text
<< std::endl
;
2012 ////////////////////////////////////////////////////////////////////////////////
2014 } // end namespace stlplus