raise ExitException instead of calling exit

This commit is contained in:
macbishop 2007-02-17 14:57:53 +00:00
parent ce79a6fa1c
commit 0953ea9976
4 changed files with 99 additions and 91 deletions

View File

@ -1,3 +1,4 @@
// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
/****************************************************************************** /******************************************************************************
* *
@ -192,7 +193,7 @@ inline void DocBookOutput::failure( CmdLineInterface& _cmd,
ArgException& e ) ArgException& e )
{ {
std::cout << e.what() << std::endl; std::cout << e.what() << std::endl;
exit(1); throw ExitException(1);
} }
inline void DocBookOutput::substituteSpecialChars( std::string& s, inline void DocBookOutput::substituteSpecialChars( std::string& s,

View File

@ -60,7 +60,7 @@ class HelpVisitor: public Visitor
* Calls the usage method of the CmdLineOutput for the * Calls the usage method of the CmdLineOutput for the
* specified CmdLine. * specified CmdLine.
*/ */
void visit() { (*_out)->usage(*_cmd); exit(0); } void visit() { (*_out)->usage(*_cmd); throw ExitException(0); }
}; };

View File

@ -1,3 +1,4 @@
// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
/****************************************************************************** /******************************************************************************
* *
@ -148,10 +149,11 @@ inline void StdOutput::failure( CmdLineInterface& _cmd,
else else
usage(_cmd); usage(_cmd);
exit(1); throw ExitException(1);
} }
inline void StdOutput::_shortUsage( CmdLineInterface& _cmd, inline void
StdOutput::_shortUsage( CmdLineInterface& _cmd,
std::ostream& os ) const std::ostream& os ) const
{ {
std::list<Arg*> argList = _cmd.getArgList(); std::list<Arg*> argList = _cmd.getArgList();
@ -182,10 +184,11 @@ inline void StdOutput::_shortUsage( CmdLineInterface& _cmd,
if ( secondLineOffset > 75/2 ) if ( secondLineOffset > 75/2 )
secondLineOffset = static_cast<int>(75/2); secondLineOffset = static_cast<int>(75/2);
spacePrint( std::cout, s, 75, 3, secondLineOffset ); spacePrint( os, s, 75, 3, secondLineOffset );
} }
inline void StdOutput::_longUsage( CmdLineInterface& _cmd, inline void
StdOutput::_longUsage( CmdLineInterface& _cmd,
std::ostream& os ) const std::ostream& os ) const
{ {
std::list<Arg*> argList = _cmd.getArgList(); std::list<Arg*> argList = _cmd.getArgList();

View File

@ -1,3 +1,4 @@
// -*- Mode: c++; c-basic-offset: 4; tab-width: 4; -*-
/****************************************************************************** /******************************************************************************
* *
@ -61,7 +62,10 @@ class VersionVisitor: public Visitor
* Calls the version method of the output object using the * Calls the version method of the output object using the
* specified CmdLine. * specified CmdLine.
*/ */
void visit() { (*_out)->version(*_cmd); exit(0); } void visit() {
(*_out)->version(*_cmd);
throw ExitException(0);
}
}; };