/********************************************************************* * C++ Base Application Object * Written by Jonathan A. Foster #include #include #include #include #include "cli.h" /********************************************************************* * cBaseApp *********************************************************************/ cBaseApp *baseapp = 0; cBaseApp &cBaseApp::init(int argc, char **argv) { command_argc = argc; command_args = argv; } int cBaseApp::main() { int i, ct; char *p; bool switches = true; for(i=1; i=command_argc) throw std::runtime_error( "Last switch requires more arguments" ); do_switch_arg(p, command_args[i]); } } else // non-switch arguments do_arg(command_args[i]); } return ExitCode; } int cBaseApp::crash(const std::exception &e) { std::cerr << "Application crashed: " << e.what() << std::endl; return 216; // just a weird number hopefully not conflicting with anything else. }