You can use a single Error to collate the error messages from many different function calls. A sample usage is given below:
ofstream fp( "my_error_log" ); ... { Error temp_error( fp ); lib_func_call(...); lib_func_call(...); lib_func_call(...); by going out of scope, Error is destroyed. This defines a single message. } ... fp.close()
While not tremendously useful when used as in the example above, this becomes useful when you need to provide user feedback, via, say a broadcast or a dialog window.
Subclasses of Error provide more convinience.
Public Member Functions | |
Error (std::ostream *s) | |
Starts logging here on out to the stream passed in. | |
Error (std::ostream &s) | |
Starts logging here on out to the stream passed in. | |
~Error () | |
From the moment of construction to the point of destruction defines a single message. | |
Protected Attributes | |
std::ostream * | err_stream |
code::Error::Error | ( | std::ostream * | s | ) | [inline] |
Starts logging here on out to the stream passed in.
Usually, you would want to log to a strstream.
s | the stream to log into. |
code::Error::Error | ( | std::ostream & | s | ) | [inline] |
Starts logging here on out to the stream passed in.
Usually, you would want to log to a strstream.
s | the stream to log into. |
code::Error::~Error | ( | ) | [inline] |
From the moment of construction to the point of destruction defines a single message.
All errors by CODE components in the meantime are shoved in the stream passed in.
std::ostream* code::Error::err_stream [protected] |