// // init() // void QtEngineDriver::init(int argc, char ** argv) { if (_alreadyInitialized) { throw GenericException("QtEngineDriver::init() was called after being initialized. It should only be called once."); } _alreadyInitialized = true; CommandLineParser opts; std::vector< char * > leftOverArgs; opts.addOption( "-dumpframes", NULL, OPTION_DATA_TYPE_NO_DATA, 0, &_dumpFrames, true); opts.addOption( "-dumpFrames", NULL, OPTION_DATA_TYPE_NO_DATA, 0, &_dumpFrames, true); opts.parse(argc, argv, false, leftOverArgs); argc = leftOverArgs.size(); argv = (leftOverArgs.size() == 0) ? NULL : &(leftOverArgs[0]); _engine = new SimulationEngine(); _app = new QApplication(argc, argv); _mainWindow = new QMainWindow(); _controller = new QtEngineController(); // unclean, but this one should be initialized before others so that it can re-direct cout,cerr,clog as soon as possible. _consoleWidget = ConsoleWidget::getInstance(); // initialize the engine _engine->init(argc, argv, this); // initialize the GUI _initGUI(); // initialize the controller _controller->init(_engine, _glWidget); }
bool init(int nCmdShow) { TCHAR * const cmdlineStr = GetCommandLine();; CommandLineParser cmdline; cmdline.parse(cmdlineStr); if(HWND hwnd = AppWindow::findWindowByWindowName(cmdline.getWindowName())){ AppWindow::sendCommandLine(hwnd, getCurrentDirectory(), cmdlineStr);//カレントディレクトリも送らないとコマンドラインを正しく解釈できない。 return false; } window_.reset(new AppWindow(cmdline.getWindowName())); if(!window_->create()){ return false; } window_->setAlbum(cmdline.getAlbum()); if(!window_->restoreWindowPlacement()){ window_->showWindow(nCmdShow); } window_->updateWindow(); return true; }
int main(int argc, char* argv[]) { string opt_keys = "{ @path | |image path. }" "{ m method |canny |support canny, sobel, laplace, scharr}" "{ h help |false |print help. }"; CommandLineParser parser = CommandLineParser(argc, argv, opt_keys); if (parser.get<bool>("help")) { parser.printMessage(); exit(0); } string fn = parser.get<string>("@path"); string method = parser.get<string>("method"); Mat img = imread(fn.c_str()); if ("canny" == method){ Mat dst = do_canny(img); imwrite("do_canny.jpg", dst); } else if("sobel" == method){ } else if ("laplace" == method){ Mat dst = do_laplace(img); imwrite("do_laplace.jpg", dst); } else if ("scharr" == method){ } else{ printf("Please input right method\n"); } }
int getMode(CommandLineParser& parser) { if (parser.has("i")) return 0; if (parser.has("v")) return 1; if (parser.has("c")) return 3; }
Api::IClientFactoryPtr FabricTestClientsTracker::CreateCachedClientFactoryOnNode(CommandLineParser const & parser) { wstring clientName; parser.TryGetString(L"client", clientName, L""); wstring nodeName; parser.TryGetString(L"node", nodeName, L""); IClientFactoryPtr clientFactory; if (clientName.empty()) { if (nodeName.empty()) { TestSession::FailTest("Must provide 'node' for unnamed client"); } clientFactory = this->CreateClientFactoryOnNode(nodeName); } else { auto findIt = clientFactories_.find(clientName); if (findIt == clientFactories_.end()) { if (nodeName.empty()) { TestSession::FailTest("Must provide 'node' for new client: {0}", clientName); } clientFactory = this->CreateClientFactoryOnNode(nodeName); IClientSettingsPtr clientSettings; auto error = clientFactory->CreateSettingsClient(clientSettings); if (!error.IsSuccess()) { TestSession::FailTest("CreateSettingsClient: {0}", error); } auto settings = clientSettings->GetSettings(); settings.SetClientFriendlyName(clientName); error = clientSettings->SetSettings(move(settings)); if (!error.IsSuccess()) { TestSession::FailTest("SetSettings: {0}", error); } clientFactories_.insert(make_pair(clientName, clientFactory)); } else { clientFactory = findIt->second; } } return clientFactory; }
int main(int argc, char *argv[]) { CommandLineParser parser; setupCommandLineParser(parser); parser.parse(argc, argv); if (parser.hasParseError()) { std::cerr << parser.getErrorMessage() << std::endl; return 1; } if (parser.exists("-h") || parser.exists("-help")) { std::cout << parser.getHelpText() << std::endl; return 0; } if (parser.getPaths().empty()) { std::cerr << "error: no input file" << std::endl; return 1; } for (auto & path : parser.getPaths()) { refactorSourceCode(path); } return 0; }
int main(int argc, char *argv[]) { CommandLineParser parser; SetupCommandLineParser(parser); parser.parse(argc, argv); if (parser.hasParseError()) { std::cerr << parser.getErrorMessage() << std::endl; return 1; } if (parser.exists("-h") || parser.exists("-help")) { std::cout << parser.getHelpText() << std::endl; return 0; } if (parser.exists("-v")) { std::cout << "typo-poi version 0.1.0 (July 19, 2016)" << std::endl; return 0; } if (parser.getPaths().empty()) { std::cerr << "error: no input file" << std::endl; return 1; } somera::TypoMan typos; typos.setStrictWhiteSpace(false); typos.setStrictHyphen(false); typos.setStrictLetterCase(false); typos.setIgnoreBritishEnglish(true); typos.setMinimumWordSize(3); typos.setMaxCorrectWordCount(4); typos.setCacheEnabled(true); typos.setCacheSize(100); typos.setFoundCallback([](const somera::Typo& typo) -> void { showTypoInConsole(typo); }); for (auto & path : parser.getPaths()) { auto ext = std::get<1>(somera::FileSystem::splitExtension(path)); if (ext == ".png" || ext == ".jpg" || ext == "exe" || ext == ".DS_Store" || ext == ".o" || ext == ".a" || ext == ".d" || ext == ".lib" || ext == ".dll") { continue; } ReadTextFileWithoutPedanticMode(typos, path); } return 0; }
AbstractCommand::ReturnCodes Record::run() { CommandLineParser *args = CommandLineParser::instance(); m_all = m_config.isEmptyRepo() || (m_config.contains("all") && !args->contains("interactive")) || args->contains("all"); m_patchName = args->optionArgument("patch-name", m_config.optionArgument("patch-name")).toUtf8(); m_author = args->optionArgument("author", m_config.optionArgument("author")); return record(); }
vector<wstring> ConnectedShortcut::getLArgs() const { CommandLineParser cli; cli.allowAllKeys(); try { cli.parse(getArguments()); return cli.getLArgs(); } catch (CLIException&) { return {}; } }
int main(int argc,char ** argv) try{ /*设置本地编码*/ QTextCodec::setCodecForLocale(QTextCodec::codecForName(LOCAL_CODEC_)); /*初始化应用程序*/ QApplication app(argc,argv); { /*解析命令行*/ CommandLineParser parser; parser.process(app); /*全局配置文件*/ const QByteArray lua_file_name_=parser.value("lua").toLocal8Bit(); OpenCVApplicationConfigurationFile configure( app.applicationFilePath().toLocal8Bit(), BUILD_PATH_,lua_file_name_.constData()); } /*设置图片搜索目录*/ { QDir::addSearchPath("images",app.applicationDirPath()+"/Images"); QDir::addSearchPath("images",BUILD_PATH_); QDir::addSearchPath("images",QDir::cleanPath(BUILD_PATH_"/../Images")); } opencv_exception::set_error_function( [](const auto &,auto,auto,auto,auto,auto) { std::cout<<"opencv exception called"<<std::endl; } ); MainWindow * window=new MainWindow; window->setAttribute(Qt::WA_DeleteOnClose); window->show(); data_view::run(window->getOpenCVWindow() ); std::cout.flush(); return app.exec(); } catch (const cv::Exception & e) { opencv_exception::error(e,"get opencv exception",opencv_line(),opencv_file(),opencv_func()); } catch (const std::exception & e) { std::cout<<e.what()<<std::endl; return -10; } catch (...) { std::cout<<"unknow exception @ main"<<std::endl; return -99999; }
void MainWindow::handleCommandLineOptions(CommandLineParser parser) { if ( parser.isValidParameter() ) { if ( parser.isScanParameter() ) { doAutoScan(); } else if ( parser.isShredQuickParameter() ) { QStringList paths = parser.getPaths(); setShredFile(paths, 1); } else if ( parser.isShredSafeParameter() ) { QStringList paths = parser.getPaths(); setShredFile(paths, 2); } else if ( parser.isShredThroughParameter() ) { QStringList paths = parser.getPaths(); setShredFile(paths, 3); } else { //automaticCheckForUpdate(); } } else { // if wrong parameter , just show the application and ignore the parameters //automaticCheckForUpdate(); } }
AbstractCommand::ReturnCodes UnRecord::run() { CommandLineParser *args = CommandLineParser::instance(); m_all = args->contains("all"); if (args->contains("last")) { int count = args->optionArgument("last").toInt(); if (count <= 0) { Logger::error() << "need a positive number for `last'\n"; return InvalidOptions; } m_last = count; } return unRecord(); }
const string SuperComponent::checkForCommandLinePassedConfigurationFileOrDefaultConfigurationFile(const int &argc, char **argv) { string configurationFile = "configuration"; CommandLineParser cmdParser; cmdParser.addCommandLineArgument("configuration"); cmdParser.parse(argc, argv); CommandLineArgument cmdArgumentCONFIGURATION = cmdParser.getCommandLineArgument("configuration"); // Check the centrally maintained managed level. if (cmdArgumentCONFIGURATION.isSet()) { configurationFile = cmdArgumentCONFIGURATION.getValue<string>(); core::strings::StringToolbox::trim(configurationFile); } return configurationFile; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); CommandLineParser parser; Commands commands; parser.registerDataSink( &commands ); if ( !parser.parse( true ) ) { a.quit(); return -1; } Log::instance()->setMessageTypeEnabled( QtDebugMsg, commands.verbose ); PluginManager* pluginManager = PluginManager::instance(); pluginManager->loadPlugins(); if ( commands.listPlugins ) { printf( "%s\n\n", printStringTable( pluginManager->importerPlugins(), 1, "Importer Plugins" ).toUtf8().constData() ); printf( "%s\n\n", printStringTable( pluginManager->routerPlugins(), 1, "Router Plugins" ).toUtf8().constData() ); printf( "%s\n\n", printStringTable( pluginManager->gpsLookupPlugins(), 1, "GPS Lookup Plugins" ).toUtf8().constData() ); printf( "%s\n\n", printStringTable( pluginManager->rendererPlugins(), 1, "Renderer Plugins" ).toUtf8().constData() ); printf( "%s\n\n", printStringTable( pluginManager->addressLookupPlugins(), 1, "Address Lookup Plugins" ).toUtf8().constData() ); a.quit(); return 0; } if ( !commands.settings.isEmpty() ) { QSettings settings( commands.settings, QSettings::IniFormat ); pluginManager->loadSettings( &settings ); commands.importer = settings.value( "importer" ).toString(); commands.router = settings.value( "router" ).toString(); commands.gpsLookup = settings.value( "gpsLookup" ).toString(); commands.renderer = settings.value( "renderer" ).toString(); commands.addressLookup = settings.value( "addressLookup" ).toString(); } // parse a second time including all plugins // otherwise console settings would be overwritten by the settings file QVector< QObject* > plugins = pluginManager->plugins(); foreach( QObject* plugin, plugins ) { IConsoleSettings* settings = qobject_cast< IConsoleSettings* >( plugin ); if ( settings!= NULL ) { parser.registerDataSink( settings ); } }
extern "C" KPLATOWORK_EXPORT int kdemain( int argc, char **argv ) { QApplication app(argc, argv); KDBusService service(KDBusService::Unique); // we come here only once... // Migrate data from kde4 to kf5 locations Calligra2Migration m("calligraplanwork", "planwork"); m.setConfigFiles(QStringList() << QStringLiteral("planworkrc")); m.setUiFiles(QStringList() << QStringLiteral("planwork.rc") << QStringLiteral("planwork_readonly.rc") << QStringLiteral("planworkui.rc")); m.migrate(); CommandLineParser cmd; QObject::connect(&service, &KDBusService::activateRequested, &cmd, &CommandLineParser::handleActivateRequest); cmd.handleCommandLine(QDir::current()); return app.exec(); }
int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR lpCmdLine, int nCmdShow) { MSG msg; HACCEL hAccelTable; BOOL firstrun; InitCommonControls(); CoInitialize ( NULL ); firstrun = vdWindow.Start(hInstance, nCmdShow); if (!firstrun) { CommandLineParser parser; parser.ParseCommandLine(lpCmdLine); return -1; } // Load accelerators hAccelTable = LoadAccelerators(hInstance, (LPCTSTR)IDC_VIRTUALDIMENSION); // Main message loop: while (GetMessage(&msg, NULL, 0, 0)) { if (IsWindow(configBox) && IsDialogMessage(configBox, &msg)) { if (NULL == PropSheet_GetCurrentPageHwnd(configBox)) { DestroyWindow(configBox); configBox = NULL; } } else if (!TranslateAccelerator(msg.hwnd, hAccelTable, &msg)) { TranslateMessage(&msg); DispatchMessage(&msg); } } return (int) msg.wParam; }
int main(int ac, char *av[]) { // This line is absolutely mandatory for being able to have multiple // QOpenGLWidgets in different windows!!! QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); QSurfaceFormat _format; // _format.setVersion(3,3); _format.setProfile(QSurfaceFormat::CompatibilityProfile); #ifdef DEBUG _format.setOption(QSurfaceFormat::DebugContext); #endif QSurfaceFormat::setDefaultFormat(_format); omni::ui::Application _a(ac, av); /// Command line parser is only available in debug mode #ifdef DEBUG CommandLineParser parser; parser.parse(_a); if (!parser.value("stylesheet").isEmpty()) { qDebug() << parser.value("stylesheet"); _a.setStyleSheetFile(parser.value("stylesheet")); } #endif // ifdef DEBUG ui::MainWindow _w; _w.move(QApplication::primaryScreen()->geometry().topLeft()); // Load mapping session from given commandline argument when in release mode #ifndef DEBUG if (ac == 2) { _w.openProjection(av[1]); } #endif // ifndef DEBUG return _a.exec(); }
int main(int argc, char* argv[]) { cout << argc <<endl; string ar[] = { "*.cpp","../../", "/f","/fsunil" }; CommandLineParser clp; string path = clp.processCommandlinePath(argc, argv); cout << "Path is equel:" << path << endl; vector<string> option = clp.processCommandlineOption(argc, argv); for (auto op : option) cout << "option:" << op << endl; vector<string> pattern = clp.processCommandlinePattern(argc, argv); for (auto patt: pattern) cout << "pattern:" << patt << endl; string text1 = clp.processCommandlineText(argc, argv); cout << "Text is equel:" << text1 << endl; }
int main(int argc, char* argv[]) { std::cout << "usage : " << argv[0] << "{-x | -xml=file} {-t | --test=test_path} test_plugin_path" << std::endl << std::endl; if (argc < 2) return 1; bool result = false; try { CommandLineParser command; command.parseArgs(argc, argv); result = runPlugin(command); } catch (std::exception &e) { std::cerr << std::endl << "ERROR: " << e.what() << std::endl; } return result ? 0 : 1; }
int main(int argc, char * argv[]) { if( argc < 2 ){ errorLog << "Not enough input arguments!" << endl; printUsage(); return EXIT_FAILURE; } //Create an instance of the parser CommandLineParser parser; //Disable warning messages parser.setWarningLoggingEnabled( false ); //Add some options and identifiers that can be used to get the results parser.addOption( "-f", "dataset-filename" ); parser.addOption( "-m", "model-filename" ); parser.addOption( "-r", "results-filename" ); //Parse the command line parser.parse( argc, argv ); //Test the model if( test( parser ) ){ infoLog << "Model Tested!" << endl; return EXIT_SUCCESS; } infoLog << "Failed to test model!" << endl; return EXIT_FAILURE; }
int main(int argc, char *argv[]) { try { QCoreApplication app(argc, argv); CommandLineParser clParser; clParser.parse(); Benchmarker benchmarker(clParser.activies(), clParser.oldCommit(), clParser.newCommit(), clParser.testProjectFilePath(), clParser.qbsRepoDirPath()); benchmarker.benchmark(); printResults(clParser.activies(), benchmarker.results()); } catch (const Exception &e) { std::cerr << qPrintable(e.description()) << std::endl; return EXIT_FAILURE; } }
int main(int argc, char **argv) { QCoreApplication app(argc, argv); CommandLineParser clParser; try { clParser.parse(app.arguments()); if (clParser.helpRequested()) { printUsage(clParser.usageString()); return EXIT_SUCCESS; } Settings settings(clParser.settingsDir()); settings.setScopeForWriting(clParser.settingsScope()); if (clParser.autoDetectionMode()) { probe(&settings); return EXIT_SUCCESS; } createProfile(clParser.profileName(), clParser.toolchainType(), clParser.compilerPath(), &settings); } catch (const qbs::ErrorInfo &e) { std::cerr << qPrintable(e.toString()) << std::endl; return EXIT_FAILURE; } }
int main(int argc, char *argv[]) { CommandLineParser clp; gradConfig config = clp.getConfig(argc, argv); config.envName = "dam"; Dam mdp; PolynomialFunction *pf = new PolynomialFunction(); GaussianRbf* gf1 = new GaussianRbf(0, 50, true); GaussianRbf* gf2 = new GaussianRbf(50, 20, true); GaussianRbf* gf3 = new GaussianRbf(120, 40, true); GaussianRbf* gf4 = new GaussianRbf(160, 50, true); BasisFunctions basis; basis.push_back(pf); basis.push_back(gf1); basis.push_back(gf2); basis.push_back(gf3); basis.push_back(gf4); DenseFeatures phi(basis); MVNLogisticPolicy policy(phi, 50); vec p(6); p(0) = 50; p(1) = -50; p(2) = 0; p(3) = 0; p(4) = 50; p(5) = 0; policy.setParameters(p); PGTest<DenseAction, DenseState> pgTest(config, mdp, policy); pgTest.run(); return 0; }
// Create a JSON string based on the corresponding command line arguments // that can be used for a post/translation request. std::string create_post_data(const CommandLineParser &cmd_parser, const ConfigurationReader &config_reader) { Json::Value result; result["phrase"] = cmd_parser.phrase(); result["show_phrase"] = cmd_parser.has_show_phrase() || !config_reader.available() ? cmd_parser.show_phrase() : config_reader.show_phrase(); result["show_word_class"] = cmd_parser.has_show_word_class() || !config_reader.available() ? cmd_parser.show_word_class() : config_reader.show_word_class(); result["show_gender"] = cmd_parser.has_show_gender() || !config_reader.available() ? cmd_parser.show_gender() : config_reader.show_gender(); result["show_numerus"] = cmd_parser.has_show_numerus() || !config_reader.available() ? cmd_parser.show_numerus() : config_reader.show_numerus(); result["show_abbreviation"] = cmd_parser.has_show_abbreviation() || !config_reader.available() ? cmd_parser.show_abbreviation() : config_reader.show_abbreviation(); result["show_comment"] = cmd_parser.has_show_comment() || !config_reader.available() ? cmd_parser.show_comment() : config_reader.show_comment(); Json::StreamWriterBuilder json_writer; json_writer.settings_["indentation"] = ""; return Json::writeString(json_writer, result); }
int main(int argc, char * argv[]) { if( argc < 2 ){ errorLog << "Not enough input arguments!" << endl; printUsage(); return EXIT_FAILURE; } //Create an instance of the parser CommandLineParser parser; //Disable warning messages parser.setWarningLoggingEnabled( false ); //Add some options and identifiers that can be used to get the results parser.addOption( "-m", "mode" ); parser.addOption( "-f", "filename" ); parser.addOption( "--model", "model-filename" ); //Parse the command line parser.parse( argc, argv ); string mode = ""; string filename = ""; //Get the application mode if( !parser.get("mode",mode) ){ errorLog << "Failed to parse mode from command line! You can set the mode using the -m option." << endl; printUsage(); return EXIT_FAILURE; } //Train RF model if( mode == "train-model" ){ if( train( parser ) ){ infoLog << "Model Trained!" << endl; return EXIT_SUCCESS; } return EXIT_FAILURE; } errorLog << "Unknown application mode: " << mode << endl; printUsage(); return EXIT_FAILURE; }
int main(int argc, char* argv[]) { CommandLineParser clp; string fastaFileName, indexFileName; vector<string> fastaFileNames; vector<string> opts; clp.SetProgramName("bsdb"); clp.SetProgramSummary("Build an index database on a file of sequences.\n" " The index is used to map to reads given alignment positions.\n"); clp.RegisterStringOption("fasta", &fastaFileName, "A file with sequences to build an index."); clp.RegisterStringOption("index", &indexFileName, "The index file."); clp.RegisterPreviousFlagsAsHidden(); clp.ParseCommandLine(argc, argv, opts); ifstream fastaIn; ofstream indexOut; if (FileOfFileNames::IsFOFN(fastaFileName)) { FileOfFileNames::FOFNToList(fastaFileName, fastaFileNames); } else { fastaFileNames.push_back(fastaFileName); } CrucialOpen(indexFileName, indexOut, std::ios::out | std::ios::binary); SequenceIndexDatabase<FASTASequence> seqDB; int fileNameIndex; for (fileNameIndex = 0; fileNameIndex < fastaFileNames.size(); fileNameIndex++){ FASTAReader reader; FASTASequence seq; reader.Init(fastaFileNames[fileNameIndex]); int i = 0; while (reader.GetNext(seq)) { seqDB.AddSequence(seq); i++; } } seqDB.Finalize(); seqDB.WriteDatabase(indexOut); return 0; }
void Service::init(CommandLineParser& parser) { service_instance = this; base::util::setupSignals(); base::util::setupTermHandler(sigtermHandler); base::util::setupSignalHandler(SIGINT, sigtermHandler); sp_props_.reset(new Properties(parser.parse().values())); if (svc_type_.empty()) svc_type_ = sp_props_->get<string>("server.type"); if (!svc_num_) svc_num_ = sp_props_->getWithDef<uint64_t>("server.number", 0ULL); if (svc_domain_.empty()) svc_domain_ = sp_props_->getWithDef<string>("server.domain", "domain"); sp_worker_pools_.reset(new WorkersPoolsManager); sp_communicator_.reset(new Communicator); sp_modules_.reset(new ModulesManager); sp_statistics_.reset(new Statistics); }
int main(int argc, char* argv[]) { CommandLineParser clp; string indexDBName; bool printIndex = false; int searchIndex; // // Configure the command line. // clp.SetProgramName("testseqdb"); clp.SetProgramSummary("test the sequence db.\n"); clp.RegisterStringOption("indexdb", &indexDBName, "The index to test."); clp.RegisterPreviousFlagsAsHidden(); clp.RegisterFlagOption("p", &printIndex, "Print the start position of each read."); clp.RegisterIntOption("i", &searchIndex, "The index to search for", CommandLineParser::NonNegativeInteger, true); clp.ParseCommandLine(argc, argv); SequenceIndexDatabase<FASTASequence> seqDB; ifstream in; CrucialOpen(indexDBName, in, std::ios::in | std::ios::binary); seqDB.ReadDatabase(in); if (printIndex) { int i; for (i = 0; i < seqDB.nSeqPos - 1; i++) { cout << i << " " << seqDB.seqStartPos[i+1] << " " << seqDB.names[i] << endl; } } int dbPos = seqDB.SearchForIndex(searchIndex); if (dbPos >= 0) { cout << "searchIndex: " << searchIndex << " " << dbPos << " " << seqDB.seqStartPos[dbPos] << " " << seqDB.names[dbPos-1] << endl; } };
App::App(CommandLineParser& cmd) { cout << "\nControls:\n" << "\tESC - exit\n" << "\tm - change mode GPU <-> CPU\n" << "\tg - convert image to gray or not\n" << "\to - save output image once, or switch on/off video save\n" << "\t1/q - increase/decrease HOG scale\n" << "\t2/w - increase/decrease levels count\n" << "\t3/e - increase/decrease HOG group threshold\n" << "\t4/r - increase/decrease hit threshold\n" << endl; make_gray = cmd.has("gray"); resize_scale = cmd.get<double>("s"); vdo_source = cmd.get<string>("v"); img_source = cmd.get<string>("i"); output = cmd.get<string>("o"); camera_id = cmd.get<int>("c"); win_width = 48; win_stride_width = 8; win_stride_height = 8; gr_threshold = 8; nlevels = 13; hit_threshold = 1.4; scale = 1.05; gamma_corr = true; write_once = false; cout << "Group threshold: " << gr_threshold << endl; cout << "Levels number: " << nlevels << endl; cout << "Win width: " << win_width << endl; cout << "Win stride: (" << win_stride_width << ", " << win_stride_height << ")\n"; cout << "Hit threshold: " << hit_threshold << endl; cout << "Gamma correction: " << gamma_corr << endl; cout << endl; }
void ProgramOptions::Parse(CommandLineParser& parser) { // must contain at least one param ATLVERIFY(true == parser.GetNext(m_cszExecutable)); CString cszArg; while (parser.GetNext(cszArg)) { ATLASSERT(cszArg.GetLength() > 0); // check for first char TCHAR chArg = cszArg[0]; if (cszArg.GetLength() > 1 && (chArg == _T('/') || chArg == _T('-') )) { TCHAR chSearchOpt = 0; CString cszLongSearchOpt; // it's an option, either short or long one TCHAR chOptChar = cszArg[1]; if (chArg == _T('-') && chOptChar == _T('-')) { // we have a unix-style option, long name only cszLongSearchOpt = cszArg.Mid(2); cszLongSearchOpt.MakeLower(); } else { // we have either /X or -X or option, short name only chSearchOpt = chOptChar; } // now search for the proper option bool bFoundOption = false; for (size_t i=0, iMax=m_vecOptions.size(); i<iMax; i++) { OptionInfo& optInfo = m_vecOptions[i]; // check long name first, then short name if ((!cszLongSearchOpt.IsEmpty() && cszLongSearchOpt == optInfo.m_cszLongOption) || (chSearchOpt != 0 && CString(chSearchOpt).FindOneOf(optInfo.m_cszShortOptionChars) != -1)) { // found long or short option bFoundOption = true; // get arguments std::vector<CString> vecArgs; CString cszParamArgs; for (unsigned int uiArgs=0; uiArgs<optInfo.m_uiArgs; uiArgs++) { parser.GetNext(cszParamArgs); vecArgs.push_back(cszParamArgs); } if (vecArgs.size() < optInfo.m_uiArgs) { // too few arguments if (m_fnOptionOutputHandler) m_fnOptionOutputHandler(CString(_T("Too few parameters for option: ") + cszArg)); break; } ATLASSERT(optInfo.m_fnOptionHandler != NULL); bool bRet = optInfo.m_fnOptionHandler(vecArgs); if (!bRet) { if (m_fnOptionOutputHandler) m_fnOptionOutputHandler(CString(_T("Syntax error for option: ") + cszArg)); } break; } } // end for if (!bFoundOption) { // unknown option if (m_fnOptionOutputHandler) m_fnOptionOutputHandler(CString(_T("Unknown option: ") + cszArg)); } } else { // no arg; it's a file bool bHandled = false; if (m_fnParameterHandler) bHandled = m_fnParameterHandler(cszArg); if (!bHandled) { // output: unhandled option if (m_fnOptionOutputHandler) m_fnOptionOutputHandler(CString(_T("Unknown parameter: ") + cszArg)); } } } }