//----------------------------------------------------------------------------- // 描述: 处理标准命令行参数 // 参数: // isInitializing - 应用程序 (IseApplication) 是否处于初始化期间 // 返回: // true - 当前命令行参数是标准参数 // false - 与上相反 //----------------------------------------------------------------------------- bool IseApplication::processStandardArgs(bool isInitializing) { if (!isInitializing) { if (getArgCount() == 1) { string arg = getArgString(0); if (arg == "--version") { string version = iseBusiness_->getAppVersion(); printf("%s\n", version.c_str()); return true; } if (arg == "--help") { string help = iseBusiness_->getAppHelp(); printf("%s\n", help.c_str()); return true; } } } else { if (argList_.exists("--nodaemon")) { iseOptions_.setIsDaemon(false); return true; } } return false; }
//virtual bool setOperatingMode(uint32_t opMode) = 0; int config_setOperatingMode(lua_State* L) { if( getArgCount(L) != 1) return 0; uint32_t opMode = 0; // check for int first! a int can easyly be converted to a string (lua_isstring() returned true even for numbers) if(lua_isnumber(L, 1)) { const int opModeI = luaL_checkinteger(L, 1); //std::cout << "[Lua] config_setOperatingMode got int: " << opModeI << std::endl; switch (opModeI) { case 1: opMode = RS_OPMODE_FULL; break; case 2: opMode = RS_OPMODE_NOTURTLE; break; case 3: opMode = RS_OPMODE_GAMING; break; case 4: opMode = RS_OPMODE_MINIMAL; break; default: // opMode = 0 break; } } else { const std::string opModeS = luaL_checkstring(L, 1); //std::cout << "[Lua] config_setOperatingMode got string: " << opModeS << std::endl; if(opModeS == "full") opMode = RS_OPMODE_FULL; else if (opModeS == "noturtle") opMode = RS_OPMODE_NOTURTLE; else if (opModeS == "minimal") opMode = RS_OPMODE_MINIMAL; else if (opModeS == "gaming") opMode = RS_OPMODE_GAMING; // else opMode = 0 } //std::cout << "[Lua] config_setOperatingMode opMode: " << opMode << std::endl; if(opMode == 0) // somthing went wrong return 0; rsConfig->setOperatingMode(opMode); return 0; }
int DmetEngine::parseArgv( const char * const * const argv, int start ){ vector<string> argvStrings; for (const char* const * arg=argv;*arg!=NULL;arg++) { argvStrings.push_back(*arg); } int argc = argvStrings.size(); // Parse DmetEngine Options int argvPos = Options::parseArgv(argv, start); vector<string> celFiles; for(vector<const char *>::size_type i = 0; i < getArgCount(); i++) celFiles.push_back(getArg(i)); setOpt("cels",celFiles); // Allow user to override APS defaults if(argc > argvPos) { ProbesetSummarizeEngine pse; int newArgvPos = pse.parseArgv(argv, argvPos+1); Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetSummarizeEngine!"); m_ArgvPosAPS = argvPos + 1; argvPos = newArgvPos; } else { m_ArgvPosAPS = -1; } // Allow user to override CN defaults if(argc > argvPos) { DmetCopyNumberEngine cde; int newArgvPos = cde.parseArgv(argv,argvPos+1); Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for DmetCopyNumberEngine!"); m_ArgvPosCN = argvPos + 1; argvPos = newArgvPos; } else { m_ArgvPosCN = -1; } // Allow user to override APG defaults if(argc > argvPos) { ProbesetGenotypeEngine pge; int newArgvPos = pge.parseArgv(argv,argvPos+1); Verbose::out(1,"Parsed " + ToStr(newArgvPos - argvPos - 1) + " extra options for ProbesetGenotypeEngine!"); m_ArgvPosAPG = argvPos + 1; argvPos = newArgvPos; } else { m_ArgvPosAPG = -1; } m_argv = argv; return argvPos; }
// download / upload speed //virtual int SetMaxDataRates( int downKb, int upKb ) = 0; int config_setMaxDataRates(lua_State* L) { if( getArgCount(L) != 2) return 0; luaL_checktype(L, 1, LUA_TNUMBER); luaL_checktype(L, 2, LUA_TNUMBER); int kbDown = luaL_checkinteger(L, 1); int kbUp = luaL_checkinteger(L, 2); rsConfig->SetMaxDataRates(kbDown, kbUp); return 0; }
virtual double operator()(int argc, const double *argv) { if (argc != getArgCount()) throw std::runtime_error("Argument count mismatch, function should have 0 arguments"); return (*m_function)(); }
virtual double operator()(int argc, const double *argv) { // KHP: Maybe only check in debug? if (argc != getArgCount()) throw std::runtime_error("Argument count mismatch, function should have 4 arguments"); return (*m_function)(argv[0], argv[1], argv[2], argv[3]); }