int main(int argc, const char * argv[]) { argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present option::Stats stats(usage, argc, argv); option::Option* options = new option::Option[stats.options_max]; option::Option* buffer = new option::Option[stats.buffer_max]; option::Parser parse(usage, argc, argv, options, buffer); if (parse.error()) return 1; if (options[HELP]) { option::printUsage(std::cout, usage); return 0; } if (options[SOLVER] == NULL || options[SOLVER].arg == NULL) { std::cout << std::endl << "\tSolver type is required!" << std::endl << std::endl; option::printUsage(std::cout, usage); return 0; } for (option::Option* opt = options[UNKNOWN]; opt; opt = opt->next()){ std::cout << "Unknown option: " << opt->name << "\n"; } float time; size_t Nx, Ny, N; time = setValue<float>(options,TIME,0.2f); Nx = setValue<size_t>(options,X_SIZE,128); Ny = setValue<size_t>(options,Y_SIZE,128); N = setValue<size_t>(options,N_SIZE,150); AppManager* manager = NULL; try { manager = new AppManager(); manager->init(Nx,Ny,stringToEnum(options[SOLVER].arg),options[DEVICE].arg); manager->begin(N,time); } catch (std::exception& e) { std::cerr << e.what() << std::endl; } delete manager; delete [] options; delete [] buffer; return 0; }
int main(int argc, const char * argv[]) { argc-=(argc>0); argv+=(argc>0); // skip program name argv[0] if present option::Stats stats(usage, argc, argv); option::Option* options = new option::Option[stats.options_max]; option::Option* buffer = new option::Option[stats.buffer_max]; option::Parser parse(usage, argc, argv, options, buffer); if (parse.error()) return 1; if (options[HELP]) { option::printUsage(std::cout, usage); return 0; } for (option::Option* opt = options[UNKNOWN]; opt; opt = opt->next()){ std::cout << "Unknown option: " << opt->name << "\n"; } AppManager* manager = NULL; try { manager = new AppManager(); manager->init(); manager->begin(); } catch (std::exception& e) { std::cerr << e.what() << std::endl; } delete manager; delete [] options; delete [] buffer; return 0; }