void Ex3SuifPass::initialize() { PipelinablePass::initialize(); OptionList *l; // Create grammar for parsing the command line. This must occur // after the parent class's initialize routine has been executed. _command_line->set_description("cookbook example #3"); // Collect optional flags. OptionSelection *flags = new OptionSelection(false); // -reserve_reg l = new OptionList; l->add(new OptionLiteral("-reserve_reg")); l->add(new OptionString("reg", &reserved_reg_name)); l->set_description("specifies name of register to reserve"); flags->add(l); // Accept tagged options in any order. _command_line->add(new OptionLoop(flags)); // zero or more file names file_names = new OptionString("file name"); OptionLoop *files = new OptionLoop(file_names, "names of optional input and/or output files"); _command_line->add(files); }
JavaAssertions::OptionList* JavaAssertions::match_package(const char* classname) { // Search the package list for any items that apply to classname. Each // sub-package in classname is checked, from most-specific to least, until one // is found. if (_packages == 0) return 0; // Find the length of the "most-specific" package in classname. If classname // does not include a package, length will be 0 which will match items for the // default package (from options "-ea:..." or "-da:..."). size_t len = strlen(classname); for (/* empty */; len > 0 && classname[len] != '/'; --len) /* empty */; do { assert(len == 0 || classname[len] == '/', "not a package name"); for (OptionList* p = _packages; p != 0; p = p->next()) { if (strncmp(p->name(), classname, len) == 0 && p->name()[len] == '\0') { return p; } } // Find the length of the next package, taking care to avoid decrementing // past 0 (len is unsigned). while (len > 0 && classname[--len] != '/') /* empty */; } while (len > 0); return 0; }
int real_main(int argc, char* argv[]) { OptionList options; options.parse(argc, argv, "f:L:l:c:t:s"); if(options.args.size() == 0) { usage("testngppst-runner"); } //showOptions(options); StringList listeners; getListeners(listeners, options); StringList searchingPathsOfListeners; getSearchingPathsOfListeners(searchingPathsOfListeners, options); StringList fixtures; getSpecifiedFixtures(fixtures, options); bool usesSandbox = useSandbox(options); unsigned int maxConcurrent = 0; if(usesSandbox) { maxConcurrent = getMaxConcurrent(options); } std::string tagsFilterOption = getSingleOption("t", options, "*"); return TestRunner().runTests(useSandbox(options), maxConcurrent, options.args, listeners , searchingPathsOfListeners, fixtures, tagsFilterOption); }
// Sets an option void Installer::setOption(const std::string& name, const std::string& value) { BOOST_ASSERT(name.empty() == false); BOOST_ASSERT(value.empty() == false); // before set any new config file option // reread config file m_factory->getConfig()->load(); // look for the option OptionList options = m_factory->getConfig()->getOptions(); OptionList::iterator i = std::find_if( options.begin(), options.end(), boost::bind( std::equal_to<std::string>(), name, boost::bind(&IOption::getName, _1))); if (i == options.end()) { throw Exception(__FILE__, __LINE__, "Cannot find option with name: " + name); } (*i)->setValue(value); // save result m_factory->getConfig()->save(); }
MeterRandom::MeterRandom(std::list<Option> options) : Protocol("random") { OptionList optlist; _min = 0; _max = 40; _last = (_max + _min) / 2; /* start in the middle */ try { _min = optlist.lookup_double(options, "min"); } catch( vz::OptionNotFoundException &e ) { _min = 0; } catch( vz::VZException &e ) { print(log_error, "Min value has to be a floating point number (e.g. '40.0')", name().c_str()); throw; } try { _max = optlist.lookup_double(options, "max"); } catch( vz::OptionNotFoundException &e ) { _max = 0; } catch( vz::VZException &e ) { print(log_error, "Max value has to be a floating point number (e.g. '40.0')", name().c_str()); throw; } }
void M2aSuifPass::initialize() { OptionList *l; OptionLiteral *f; PipelinablePass::initialize(); // Create parse tree for parsing the command line. This must occur // after the parent class's initialize routine has been executed. _command_line->set_description( "translate Machine-SUIF file to assembly language"); // Collect optional flags. OptionSelection *flags = new OptionSelection(false); // -debug level l = new OptionList; l->add(new OptionLiteral("-debug")); l->add(new OptionInt("level", &debuglvl)); l->set_description("set verbosity level for debugging messages"); flags->add(l); // -all_notes -- print all instruction notes f = new OptionLiteral("-all_notes", &m2a.print_all_notes, true); f->set_description("force all instruction notes to appear in output"); flags->add(f); // -noprint note -- do not print this note l = new OptionList; l->add(new OptionLiteral("-noprint")); nonprinting_notes_option = new OptionString("annotation key"); l->add(nonprinting_notes_option); l->set_description("suppress annotations with given key"); flags->add(l); // -G max -- max byte size of datum in $gp area l = new OptionList; l->add(new OptionLiteral("-G")); l->add(new OptionInt("max", &m2a.Gnum)); l->set_description("set max byte size of a datum in the $gp area"); flags->add(l); // -stabs -- print with stabs information f = new OptionLiteral("-stabs", &m2a.want_stabs, true); f->set_description("add stabs debugging information to output"); flags->add(f); // accept flags in any order _command_line->add(new OptionLoop(flags)); // zero or more file names file_names_option = new OptionString("file name"); OptionLoop *files = new OptionLoop(file_names_option, "names of optional input and/or output files"); _command_line->add(files); }
inline JavaAssertions::OptionList* JavaAssertions::match_class(const char* classname) { for (OptionList* p = _classes; p != 0; p = p->next()) { if (strcmp(p->name(), classname) == 0) { return p; } } return 0; }
void SolveFeedbackVariablesPass3::initialize() { PipelinablePass::initialize() ; _command_line->set_description("Solves feedback variables") ; OptionInt* optionIsSystolic = new OptionInt("IsSystolic", &isSystolic) ; OptionList* feedbackArguments = new OptionList() ; feedbackArguments->add(optionIsSystolic) ; _command_line->add(feedbackArguments) ; }
void ExportPass::initialize() { PipelinablePass::initialize() ; _command_line->set_description("Add either a system or a module to the repository from the current suif file") ; OptionString* directory = new OptionString("Local Dir", &localDirectory) ; OptionList* args = new OptionList() ; args->add(directory) ; _command_line->add(args) ; }
vz::api::Volkszaehler::Volkszaehler( Channel::Ptr ch, std::list<Option> pOptions ) : ApiIF(ch) , _last_timestamp(0) { OptionList optlist; char url[255], agent[255]; unsigned short curlTimeout = 30; // 30 seconds /* parse options */ try { _middleware = optlist.lookup_string(pOptions, "middleware"); } catch (vz::OptionNotFoundException &e) { throw; } catch (vz::VZException &e) { throw; } try { curlTimeout = optlist.lookup_int(pOptions, "timeout"); } catch (vz::OptionNotFoundException &e) { // use default value instead curlTimeout = 30; // 30 seconds } catch (vz::VZException &e) { throw; } /* prepare header, uuid & url */ sprintf(agent, "User-Agent: %s/%s (%s)", PACKAGE, VERSION, curl_version()); /* build user agent */ sprintf(url, "%s/data/%s.json", middleware().c_str(), channel()->uuid()); /* build url */ _api.headers = NULL; _api.headers = curl_slist_append(_api.headers, "Content-type: application/json"); _api.headers = curl_slist_append(_api.headers, "Accept: application/json"); _api.headers = curl_slist_append(_api.headers, agent); _api.curl = curl_easy_init(); if (!_api.curl) { throw vz::VZException("CURL: cannot create handle."); } curl_easy_setopt(_api.curl, CURLOPT_URL, url); curl_easy_setopt(_api.curl, CURLOPT_HTTPHEADER, _api.headers); curl_easy_setopt(_api.curl, CURLOPT_VERBOSE, options.verbosity()); curl_easy_setopt(_api.curl, CURLOPT_DEBUGFUNCTION, curl_custom_debug_callback); curl_easy_setopt(_api.curl, CURLOPT_DEBUGDATA, channel().get()); // signal-handling in libcurl is NOT thread-safe. so force to deactivated them! curl_easy_setopt(_api.curl, CURLOPT_NOSIGNAL, 1); // set timeout to 5 sec. required if next router has an ip-change. curl_easy_setopt(_api.curl, CURLOPT_TIMEOUT, curlTimeout); }
QVariant TableModelVariablesOptions::data(const QModelIndex &index, int role) const { if (_boundTo == NULL) return QVariant(); if (index.column() == 0) { if (role == Qt::DisplayRole) { OptionField *option = static_cast<OptionField *>(_boundTo->at(index.row())->get(0)); string value = option->value()[0]; return QString::fromUtf8(value.c_str(), value.length()); } else { return QVariant(); } } else { if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant(); Option* option = _boundTo->at(index.row())->get(index.column()); OptionList *list = dynamic_cast<OptionList *>(option); if (list == NULL) return QVariant("WTF"); string selected = list->value(); QString qsSelected = QString::fromUtf8(selected.c_str(), selected.length()); if (role == Qt::DisplayRole) return qsSelected; vector<string> items = list->options(); QStringList qsItems; for (int i = 0; i < items.size(); i++) { string item = items.at(i); QString qs = QString::fromUtf8(item.c_str(), item.size()); qsItems.append(qs); } QVariant qvSelected = QVariant(qsSelected); QVariant qvItems = QVariant(qsItems); QList<QVariant> qvValue; qvValue.append(qvSelected); qvValue.append(qvItems); return qvValue; } }
MeterS0::HWIF_UART::HWIF_UART(const std::list<Option> &options) : _fd(-1) { OptionList optlist; try { _device = optlist.lookup_string(options, "device"); } catch (vz::VZException &e) { print(log_error, "Missing device or invalid type", ""); throw; } }
void MarkRedundantPass::initialize() { PipelinablePass::initialize() ; _command_line->set_description("Marks labels as redundant") ; OptionString* optionRedundantLabel = new OptionString("Redundant Label", &redundantLabel) ; OptionInt* doubleOption = new OptionInt("DoubleOrTriple", &doubleOrTriple) ; OptionList* arguments = new OptionList() ; arguments->add(optionRedundantLabel) ; arguments->add(doubleOption) ; _command_line->add(arguments) ; }
//------------------------------------------------------------------------ void OptimiseTool::doInvoke(const OptionList& toolOptions, const Ogre::StringVector& inFileNames, const Ogre::StringVector& outFileNamesArg) { // Name count has to match, else we have no way to figure out how to apply output // names to input files. if (!(outFileNamesArg.empty() || inFileNames.size() == outFileNamesArg.size())) { fail("number of output files must match number of input files."); } mPosTolerance = mNormTolerance = mUVTolerance = 1e-06f; mKeepIdentityTracks = OptionsUtil::isOptionSet(toolOptions, "keep-identity-tracks"); for (OptionList::const_iterator it = toolOptions.begin(); it != toolOptions.end(); ++it) { if (it->first == "tolerance") { mPosTolerance = mNormTolerance = mUVTolerance = static_cast<float>(any_cast<Real>(it->second)); } else if (it->first == "pos_tolerance") { mPosTolerance = static_cast<float>(any_cast<Real>(it->second)); } else if (it->first == "norm_tolerance") { mNormTolerance = static_cast<float>(any_cast<Real>(it->second)); } else if (it->first == "uv_tolerance") { mUVTolerance = static_cast<float>(any_cast<Real>(it->second)); } } StringVector outFileNames = outFileNamesArg.empty() ? inFileNames : outFileNamesArg; // Process the meshes for (size_t i = 0, end = inFileNames.size(); i < end; ++i) { if (StringUtil::endsWith(inFileNames[i], ".mesh", true)) { processMeshFile(inFileNames[i], outFileNames[i]); } else if (StringUtil::endsWith(inFileNames[i], ".skeleton", true)) { processSkeletonFile(inFileNames[i], outFileNames[i]); } else { warn("unrecognised name ending for file " + inFileNames[i]); warn("file skipped."); } } }
void RemoveModulePass::initialize() { PipelinablePass::initialize() ; _command_line->set_description("Remove a module from the repository") ; OptionString* name = new OptionString("Module Name", &moduleName) ; OptionString* directory = new OptionString("Local Directory", &localDirectory) ; OptionList* args = new OptionList() ; args->add(name) ; args->add(directory) ; _command_line->add(args) ; }
Playlist Generator::generate(OptionList optionList) { //Recupération d'une pool de morceaux TrackPool pool = db.select(optionList,optionList.getSize()*POOL_SIZE_FACTOR); selectionFeedback.notifyAll(pool.size(), pool); Playlist playlist; if(pool.size() == 0) return playlist; //On lance la génération generationLoop(&playlist, pool, optionList.getSize()); return playlist; }
MeterSML::MeterSML(std::list<Option> options) : Protocol("sml") , _host("") , _device("") , BUFFER_LEN(SML_BUFFER_LEN) { OptionList optlist; /* connection */ try { _host = optlist.lookup_string(options, "host"); } catch ( vz::OptionNotFoundException &e ) { try { _device = optlist.lookup_string(options, "device"); } catch ( vz::VZException &e ){ print(log_error, "Missing device or host", name().c_str()); throw ; } } catch( vz::VZException &e ) { print(log_error, "Missing device or host", name().c_str()); throw; } /* baudrate */ int baudrate = 9600; /* default to avoid compiler warning */ try { baudrate = optlist.lookup_int(options, "baudrate"); /* find constant for termios structure */ switch (baudrate) { case 1200: _baudrate = B1200; break; case 1800: _baudrate = B1800; break; case 2400: _baudrate = B2400; break; case 4800: _baudrate = B4800; break; case 9600: _baudrate = B9600; break; case 19200: _baudrate = B19200; break; case 38400: _baudrate = B38400; break; case 57600: _baudrate = B57600; break; case 115200: _baudrate = B115200; break; case 230400: _baudrate = B230400; break; default: print(log_error, "Invalid baudrate: %i", name().c_str(), baudrate); throw vz::VZException("Invalid baudrate"); } } catch( vz::OptionNotFoundException &e ) { /* using default value if not specified */ _baudrate = 9600; } catch( vz::VZException &e ) { print(log_error, "Failed to parse the baudrate", name().c_str()); throw; } }
Playlist Generator::regenerate(OptionList optionList, Playlist playlist) { //Recupération d'une pool de morceaux TrackPool pool = db.select(optionList,optionList.getSize()*POOL_SIZE_FACTOR); selectionFeedback.notifyAll(pool.size(), pool); if(pool.size() == 0) return playlist; //On remplit la pool avec les morceaux de la playlist précédente for(auto it = playlist.begin(); it != playlist.end(); ++it) pool.insert(*it); Playlist newPlaylist; //On lance la génération generationLoop(&newPlaylist, pool, optionList.getSize()); return newPlaylist; }
virtual void initialize() { Pass::initialize(); _def_flag_argument = new OptionLiteral("-D", &def, true); _def_opts_argument = new OptionMultiString("definition", &_d_opts); _def_list_argument = new OptionList(); _def_list_argument->add(_def_flag_argument); _def_list_argument->add(_def_opts_argument); _def_loop_argument = new OptionLoop(_def_list_argument, true); _def_selector = new OptionSelection(true); _def_selector->add(_def_loop_argument); _command_line->add(_def_selector); _incl_flag_argument = new OptionLiteral("-I", &incl, true); _incl_opts_argument = new OptionMultiString("include", &_i_opts); _incl_list_argument = new OptionList(); _incl_list_argument->add(_incl_flag_argument); _incl_list_argument->add(_incl_opts_argument); _incl_loop_argument = new OptionLoop(_incl_list_argument, true); _incl_selector = new OptionSelection(true); _incl_selector->add(_incl_loop_argument); _command_line->add(_incl_selector); _debug_argument = new OptionLiteral("-d", &debug_it, true); _debug_selector = new OptionSelection(true); _debug_selector-> add( _debug_argument ); _command_line-> add(_debug_selector); #ifndef MSVC _macro_file_name = get_default_file_name("suif/suif2b/basesuif/s2c/c_text.mac"); #else _macro_file_name = get_default_file_name("suif\\suif2b\\basesuif\\s2c\\c_text.mac"); #endif _output_file_name_argument = new OptionString( "output-file" ); _command_line-> add( _output_file_name_argument ); _macro_file_name_argument = new OptionString( "macro-file",&_macro_file_name ); _option_selector = new OptionSelection(true); _option_selector-> add( _macro_file_name_argument ); _command_line-> add(_option_selector); _command_line-> set_description("Outputs C form of a SUIF tree." ); // SuifEnv *s = get_suif_env(); }
static void print_allowed_options(const OptionList &allowed_options) { for (OptionList::const_iterator i = allowed_options.begin(); i != allowed_options.end(); ++i) { std::ostringstream os1(std::ios::binary); os1 << " --" << i->first; if (i->second.type != VALUETYPE_FLAG) os1 << _(" <value>"); dstream << padStringRight(os1.str(), 24); if (i->second.help != NULL) dstream << i->second.help; dstream << std::endl; } }
bool JavaAssertions::enabled(const char* classname, bool systemClass) { assert(classname != 0, "must have a classname"); // This will be slow if the number of assertion options on the command line is // large--it traverses two lists, one of them multiple times. Could use a // single n-ary tree instead of lists if someone ever notices. // First check options that apply to classes. If we find a match we're done. OptionList* p; if (p = match_class(classname)) { trace(classname, "class", p->name(), p->enabled()); return p->enabled(); } // Now check packages, from most specific to least. if (p = match_package(classname)) { trace(classname, "package", p->name(), p->enabled()); return p->enabled(); } // No match. Return the default status. bool result = systemClass ? systemClassDefault() : userClassDefault(); trace(classname, systemClass ? "system" : "user", "default", result); return result; }
void set_option_to_list( const std::string & name, const typename OPTION_TYPE::value_type & value, OptionList & options ) { if( !options.check(name) ) options.add_option< OPTION_TYPE >(name, value); else options[name].change_value( value ); }
bool TableModelVariablesOptions::setData(const QModelIndex &index, const QVariant &value, int role) { if (_boundTo == NULL) return false; Options *options = _boundTo->at(index.row()); Option *option = options->get(index.column()); OptionList *list = dynamic_cast<OptionList *>(option); QString qsValue = value.toString(); QByteArray bytes = qsValue.toUtf8(); list->setValue(string(bytes.constData(), bytes.length())); emit dataChanged(index, index); return true; }
MeterS0::HWIF_GPIO::HWIF_GPIO(int gpiopin, const std::list<Option> &options) : _fd(-1), _gpiopin(gpiopin), _configureGPIO(true) { OptionList optlist; if (_gpiopin <0) throw vz::VZException("invalid (<0) gpio(pin) set"); try { _configureGPIO = optlist.lookup_bool(options, "configureGPIO"); } catch (vz::VZException &e) { print(log_info, "Missing bool configureGPIO using default true", "S0"); _configureGPIO = true; } _device.append("/sys/class/gpio/gpio"); _device.append(std::to_string(_gpiopin)); _device.append("/value"); }
QVariant TableModelVariablesOptions::data(const QModelIndex &index, int role) const { if (_boundTo == NULL) return QVariant(); if (index.column() == 0) { if (role == Qt::DisplayRole) { OptionTerms *option = static_cast<OptionTerms *>(_rows.at(index.row())->get(0)); return Term(option->value().front()).asQString(); } else { return QVariant(); } } else { if (role != Qt::DisplayRole && role != Qt::EditRole) return QVariant(); Option* option = _rows.at(index.row())->get(index.column()); OptionList *list = dynamic_cast<OptionList *>(option); if (list == NULL) return QVariant("WTF"); QString selected = tq(list->value()); if (role == Qt::DisplayRole) return selected; QStringList items = tql(list->options()); QList<QVariant> value; value.append(selected); value.append(items); return value; } }
MeterExec::MeterExec(std::list<Option> options) : Protocol("exec") { OptionList optlist; try { _command = optlist.lookup_string(options, "command"); } catch (vz::VZException &e) { print(log_error, "Missing command or invalid type", ""); throw; } try { _format = optlist.lookup_string(options, "format"); } catch (vz::OptionNotFoundException &e) { _format = NULL; /* use default format */ } catch (vz::VZException &e) { print(log_error, "Failed to parse format", ""); throw; } }
// Available colours - if you change these update the tests :-) ParameterTable BrushStyle::newDefaultColorTable(const std::string& nameOfDefaultTable) { typedef std::vector<std::string> OptionList; ParameterTable t; OptionList listOfColours; listOfColours.push_back("black"); listOfColours.push_back("white"); listOfColours.push_back("red"); listOfColours.push_back("blue"); listOfColours.push_back("green"); listOfColours.push_back("cyan"); listOfColours.push_back("magenta"); listOfColours.push_back("yellow"); listOfColours.push_back("orange"); listOfColours.push_back("brown"); t.addParameter("color", listOfColours, "black"); return t; }
void Parser::clear() { if (not pAllOptions.empty()) { OptionList::iterator end = pAllOptions.end(); for (OptionList::iterator i = pAllOptions.begin(); i != end; ++i) delete *i; // clear-and-minimize idiom OptionsOrderedByShortName emptyShort; OptionsOrderedByLongName emptyLong; OptionList emptyOptions; emptyShort.swap(pShortNames); emptyLong.swap(pLongNames); emptyOptions.swap(pAllOptions); // the whole content of these 3 containers will be destroyed here } delete pRemains; pRemains = nullptr; }
inline Type ns_cert_type(const OptionList& opt) { const Option* o = opt.get_ptr("ns-cert-type"); if (o) { const std::string& ct = o->get_optional(1, 16); if (ct == "server") return SERVER; else if (ct == "client") return CLIENT; else throw option_error("ns-cert-type must be 'client' or 'server'"); } return NONE; }
// Processes interactive option void Installer::processInteractive() { // process all options IConfig* config = m_factory->getConfig(); // before set any new config file option // reread config file config->load(); // look for the option OptionList options = config->getOptions(); for (OptionList::iterator i = options.begin(); i != options.end(); i++) { const std::string name = (*i)->getName(); const std::string oldval = (*i)->getValue(); std::cout << "Option '" << name << "' has the following value: " << oldval << std::endl; if (ask("Do you want to change it [N/y]: ")) { std::string value = get("New value: "); setOption((*i)->getName(), value); } } if (ask("Do you want to recreate DB [N/y]: ")) { recreateDB(); } // resources detection if (ask("Do you want to detect resources [N/y]: ")) { detectResources(); } }