30 #include <boinc_api.h>
62 static std::vector< UtilityExitCallBack > * all_CB =
new std::vector< UtilityExitCallBack >;
85 virtual void show( std::ostream& )
const;
100 os <<
"\n\n[ERROR] EXCN_utility_exit has been thrown from: "
102 if ( !
msg_.empty() ) os <<
"ERROR: " <<
msg_ <<
"\n\n";
109 std::string
const & file,
111 std::string
const & message,
120 if ( isatty(fileno(stdout)) )
std::cerr <<
"\x1b[0m\x1b[1m\x1b[31m";
121 if ( ! message.empty() )
std::cerr << std::endl <<
"ERROR: " << message << std::endl;
122 std::cerr <<
"ERROR:: Exit from: " << file <<
" line: " << line << std::endl;
123 if ( isatty(fileno(stdout)) )
std::cerr <<
"\x1b[0m";
133 MPI_Abort( MPI_COMM_WORLD, 911 );
139 bool hasresults =
false;
145 std::cerr <<
"BOINC:: Error reading and gzipping output datafile: default.out" << std::endl;
std::cerr.
flush();
146 boinc_finish( status );
151 while(
getline(data,tmpline) ) {
152 if ( tmpline.substr(0,7) ==
"SCORE: " ) {
162 boinc_finish( status );
186 std::string
const & file,
188 std::string
const & message,
191 if ( condition )
return 1;
192 exit( file, line, message, status );
ocstream cerr(std::cerr)
Wrapper around std::cerr.
int cond_exit(bool condition, std::string const &file, int const line, std::string const &message, int const status)
Conditional Exit with file + line + message + optional status.
virtual std::string const msg() const
void exit(std::string const &file, int const line, std::string const &message, int const status)
Exit with file + line + message + optional status.
std::istream & getline(std::istream &stream, Fstring &s)
Get Line from Stream.
static void(* main_exit_callback)(void)=0
Place holder for 'end-action' of utility::exit(…)
long gzip(std::string const &uncompressedfile, bool overwrite)
gzip: file compression
Programmatic backtrace whenever you want it.
void close()
Close the ifstream and reset the state.
Program exit functions and macros.
std::vector< UtilityExitCallBack > & get_all_exit_callbacks()
Array to hold all additional exit-callbacks.
izstream: Input file stream wrapper for uncompressed and compressed files
Input file stream wrapper for uncompressed and compressed files.
void set_main_exit_callback(UtilityExitCallBack my_callback)
Set call back funtion that will be called on utility::exit. Use this function to overload default beh...
void(* UtilityExitCallBack)(void)
EXCN_utility_exit(std::string const &msg, std::string const &file, int const line)
base class for Exception system
void remove_exit_callback(UtilityExitCallBack cb)
Remove additional callback function that was previously added by using add_exit_callback.
utility::keys::lookup::begin< KeyType > const begin
ocstream & flush()
Flush the stream.
virtual void show(std::ostream &) const
void add_exit_callback(UtilityExitCallBack cb)
Add additional callback function that will be called before standard exit(…) is executed. [Note: do not confuse this function with 'set_main_exit_callback' which is replacing the end behavior of exit(…)].