//Function to input and initiate initial selection of action void Information::compSciOrLinkChoice() { char number; cin >> number; cout << endl; switch (number) { case'1':{ instructions(); choices(number); break;} case '2':{ instructions(); choices(number); //scientis break;} case '3':{ linkChoice(); break;} case '4':{ //serv.disconnect(); displayClosing(); exit(0); break;} default:{ cout << "This is invalid choice!! " << endl; compSciOrLink(); break;} } }
void Choice::publish_traits() { TraitsRef exemplar; if ( choices.isValid() && choices().link().current_meta_info().get() ) exemplar = choices().link().current_meta_info(); if ( exemplar.get() ) my_traits.reset( new MetaInfo(*exemplar) ); else my_traits.reset( new MetaInfo() ); for ( iterator i = choices.begin(); i != choices.end(); ++i ) { if ( i->link().current_meta_info() != exemplar && i->link().current_meta_info().get() ) my_traits->forward_connections( *i->link().current_meta_info() ); } update_current_meta_info( my_traits ); }
result_type operator()(A0& yi, A1& inputs) const { yi.resize(inputs.extent()); const child0 & x = boost::proto::child_c<0>(inputs); if (numel(x) <= 1) BOOST_ASSERT_MSG(numel(x) > 1, "Interpolation requires at least two sample points in each dimension."); else { BOOST_ASSERT_MSG(issorted(x, 'a'), "for 'nearest' interpolation x values must be sorted in ascending order"); const child1 & y = boost::proto::child_c<1>(inputs); BOOST_ASSERT_MSG(numel(x) == numel(y), "The grid vectors do not define a grid of points that match the given values."); const child2 & xi = boost::proto::child_c<2>(inputs); bool extrap = false; value_type extrapval = Nan<value_type>(); choices(inputs, extrap, extrapval, N1()); table<index_type> index = bsearch (x, xi); table<value_type> dx = xi-x(index); table<index_type> indexp1 = oneplus(index); yi = y(nt2::if_else(lt(nt2::abs(xi-x(index)), nt2::abs(xi-x(indexp1))), index, indexp1)); value_type b = value_type(x(begin_)); value_type e = value_type(x(end_)); if (!extrap) yi = nt2::if_else(nt2::logical_or(boost::simd::is_nge(xi, b), boost::simd::is_nle(xi, e)), extrapval, yi); } return yi; }
NewToolDlg::NewToolDlg(wxWindow* parent, IManager* mgr, ExternalToolData* data) : NewToolBase(parent) , m_mgr(mgr) { // Don't use wxFB to load translated versions of these strings: the translations wouldn't be very sensible, and it // might break things const wxString IdChoices[] = { wxT("external_tool_0"), wxT("external_tool_1"), wxT("external_tool_2"), wxT("external_tool_3"), wxT("external_tool_4"), wxT("external_tool_5"), wxT("external_tool_6"), wxT("external_tool_7"), wxT("external_tool_8"), wxT("external_tool_9") }; wxArrayString choices(10, IdChoices); m_choiceId->Clear(); m_choiceId->Append(choices); m_choiceId->SetFocus(); if(data) { m_textCtrlArguments->SetValue(data->m_args); m_choiceId->SetStringSelection(data->m_id); m_textCtrlPath->SetValue(data->m_path); m_textCtrlWd->SetValue(data->m_workingDirectory); m_textCtrlIcon16->SetValue(data->m_icon16); m_textCtrlIcon24->SetValue(data->m_icon24); m_textCtrlName->SetValue(data->m_name); m_checkBoxCaptureProcessOutput->SetValue(data->m_captureOutput); m_checkBoxSaveAllFilesBefore->SetValue(data->m_saveAllFiles); m_choiceId->Enable(false); } SetName("NewToolDlg"); WindowAttrManager::Load(this); }
void TruncSilenceDialog::PopulateOrExchange(ShuttleGui & S) { S.AddSpace(0, 5); S.StartHorizontalLay(); { // Action choices wxArrayString processChoices; processChoices.Add(_("Truncate Detected Silence")); processChoices.Add(_("Compress Excess Silence")); S.Id(ID_PROCESS_CHOICE).TieChoice(wxT(""), mEffect->mProcessIndex, &processChoices); S.SetSizeHints(-1, -1); } S.EndHorizontalLay(); S.StartStatic(_("Detect Silence")); { S.StartMultiColumn(3, wxALIGN_CENTER_HORIZONTAL); { // Threshold wxArrayString choices(Enums::NumDbChoices, Enums::GetDbChoices()); S.TieChoice(_("Level:"), mEffect->mTruncDbChoiceIndex, &choices); S.SetSizeHints(-1, -1); S.AddSpace(0); // 'choices' aleady includes units. // Ignored silence S.Id(ID_DETECT_SILENCE).TieNumericTextBox(_("Duration:"), mEffect->mInitialAllowedSilence, 12); S.AddUnits(wxT("seconds")); } S.EndMultiColumn(); } S.EndStatic(); S.StartMultiColumn(3, wxALIGN_CENTER_HORIZONTAL); { // Truncation / Compression factor S.Id( ID_TRUNCATION_DURATION ).TieNumericTextBox(_("Truncate to:"), mEffect->mTruncLongestAllowedSilence, 12); S.AddUnits(wxT("seconds")); S.Id( ID_COMPRESS_FACTOR ).TieNumericTextBox(_("Compress to:"), mEffect->mSilenceCompressPercent, 12); S.AddUnits(wxT("percent")); } S.EndMultiColumn(); // Warnings pWarning = S.AddVariableText( wxT("") ); UpdateUI(); }
void MPILock::reserve(Resource resource) { MPIResource *res = get_resource(resource); res->lock(); if (DEBUG) printf("#%u: reserve(%s)\n", index, RESOURCE(resource)); if (DEBUG) res->print_state(sides); if (res->has_any_tokens(SIDE_INDEX_SELF)) { res->change_state(HAS_TOKEN); } else { res->push_request(SIDE_INDEX_SELF); vector<unsigned> choices(1, SIDE_INDEX_PARENT); for (unsigned side_index = SIDE_INDEX_FIRST_CHILD, len = sides.size(); side_index < len; side_index += 1) { choices.push_back(side_index); } try_request_token(res, choices); if (DEBUG) res->print_state(sides); if (DEBUG) printf("#%u: wait(%s)\n", index, RESOURCE(resource)); res->wait(); if (DEBUG) printf("#%u: woken up(%s)\n", index, RESOURCE(resource)); } if (DEBUG) printf("#%u: reserved successfully(%s)\n", index, RESOURCE(resource)); if (DEBUG) res->print_state(sides); res->unlock(); }
std::vector<int> get_choices(const std::vector<std::vector<int>> &M, int N, int i, int j) { std::vector<int> choices(N); for (int r = 1; r <= N; r++) { choices[r - 1] = r; } int sq_size = int(sqrt(N)); for (int m = 0; m < N; m++) { if (M[i][m] != 0) { choices[M[i][m] - 1] = 0; } } for (int n = 0; n < N; n++) { if (M[n][j] != 0) { choices[M[n][j] - 1] = 0; } } int m = i / sq_size; int n = j / sq_size; for (int x = sq_size * m; x < sq_size * (m + 1); x++) { for (int y = sq_size * n; y < sq_size * (n + 1); y++) { if (M[x][y] != 0) { choices[M[x][y] - 1] = 0; } } } //random_shuffle(choices.begin(),choices.end()); return choices; }
void TruncSilenceDialog::PopulateOrExchange(ShuttleGui & S) { S.StartHorizontalLay(wxCENTER, false); { S.AddTitle(_("by Lynn Allan")); } S.EndHorizontalLay(); S.StartHorizontalLay(wxCENTER, false); { // Add a little space } S.EndHorizontalLay(); S.StartThreeColumn(); { wxArrayString choices(Enums::NumDbChoices, Enums::GetDbChoices()); S.Id( ID_LONGEST_SILENCE_TEXT ).TieTextBox(_("Max silence duration:"), mEffect->mTruncLongestAllowedSilentMs, 10); S.AddUnits( _("milliseconds") ); //S.AddUnits(_("(9999999 or greater is off)")); S.TieChoice(_("Threshold for silence:"), mEffect->mTruncDbChoiceIndex, &choices); } S.EndTwoColumn(); pWarning = S.AddVariableText( wxT("") ); }
OSArgument makeChoiceArgumentOfWorkspaceObjects(const std::string& name, const std::string& referenceName, const Workspace& workspace, bool required) { std::vector< std::pair<std::string, std::string> > intermediate; std::vector<WorkspaceObject> objects = workspace.getObjectsByReference(referenceName); for (const WorkspaceObject& object : objects){ intermediate.push_back(std::pair<std::string,std::string>(toString(object.handle()), object.name().get())); } std::sort(intermediate.begin(), intermediate.end(), SecondOfPairLess< std::pair<std::string,std::string> >()); int n = intermediate.size(); StringVector choices(n), displayNames(n); for (int i = 0; i < n; ++i) { choices[i] = intermediate[i].first; displayNames[i] = intermediate[i].second; } return OSArgument::makeChoiceArgument(name, choices, displayNames, required); }
// let the user pick the choices and calls the next function void Information::choices(char num) // 1 == computer { //vector<Scientist> vec; char number; cin >> number; cout << endl; switch (number) { case'1':{ if (num == '1') choiceChangeComp(); else if (num == '2') choiceChangeSci(); break;} case'2':{ if (num == '1') choiceSort(num); else if (num == '2') choiceSort(num); break;} case'3':{ if (num == '1') choiceSearch(num); else if (num == '2') choiceSearch(num); break;} default:{ cout << "This is invalid choice!! " << endl; choices(num); break;} } }
int main() { system("TITLE, TIC TAC TOE"); choices(); getch(); return 0; }
void resolver(int computer, int user) { std::cout << "Computer chooses " << choices(computer) << std::endl; int value = (3 + computer - user) % 3; switch(value) { case 0: std::cout << "Its a tie \n" << std::endl; break; case 1: std::cout << choices(computer) << " beats " << choices(user) << "\n"; std::cout << "The computer wins" << std::endl; break; case 2: std::cout << choices(user) << " beats " << choices(computer) << "\n"; std::cout << "You win" << std::endl; break; } }
Gura_ImplementMethod(wx_ListBox, Set) { Signal &sig = env.GetSignal(); Object_wx_ListBox *pThis = Object_wx_ListBox::GetObjectThis(arg); if (pThis->IsInvalid(sig)) return Value::Nil; std::unique_ptr<wxArrayString> choices(CreateArrayString(arg.GetList(0))); void **clientData = nullptr; //if (arg.IsValid(1)) **clientData = arg.GetInt(1); pThis->GetEntity()->Set(*choices, clientData); return Value::Nil; }
// If the user wants to sort the list he tells the program in what kind of way here. void Information::orderSci() { Service serv; vector<Scientist> vec; char number; cin >> number; cout << endl; switch (number) { case'1':{ cout << "List sorted in alphabetical order:" << endl << endl; vec = serv.sortSci(number); displayAll(vec); compSciOrLink(); break;} case'2':{ cout << "List sorted in reverse alphabetical order:" << endl << endl; vec = serv.sortSci(number); displayAll(vec); compSciOrLink(); break;} case'3':{ cout << "List sorted ascendingly by year of birth:" << endl << endl; vec = serv.sortSci(number); displayAll(vec); compSciOrLink(); break;} case'4':{ cout << "List sorted descendingly by year of birth:" << endl << endl; vec = serv.sortSci(number); displayAll(vec); compSciOrLink(); break;} case'5':{ cout << "List sorted by gender (Female first):" << endl << endl; command = "SELECT * FROM Scientists ORDER BY gender, name"; serv.sortSci(number); displayAll(vec); compSciOrLink(); break;} case'6':{ instructions(); choices('2'); break;} default:{ cout << "This is invalid choice " << endl; orderSci(); break;} } }
wxPGProperty* ParamsDialog::make_property(const Param& param) { const wxString name = param.get_name(); const wxString type = param.get_type(); const wxString value = param.get_value(); const wxArrayString values = param.get_values(); wxPGProperty* ret = NULL; // category if (type == "CAT") ret = new wxPropertyCategory(name); // directory else if (type == "DIR") { ret = new DirProperty(name, wxPG_LABEL, value); if (name == "Input Directory" && !task_->is_root()) { ret->ChangeFlag(wxPG_PROP_READONLY, true); //wxColour color("LIGHT GREY"); //ret->SetBackgroundColour(color); } if (name == "Output Directory") ret->ChangeFlag(wxPG_PROP_READONLY, true); } // file else if (type == "FILE") { ret = new FileProperty(name, wxPG_LABEL, value); if (name == "Program") { ret->SetAttribute(wxPG_FILE_WILDCARD, wxT("R files (*.R)|*.R")); } } // drop-down-list else if (type == "ENUM") { wxPGChoices choices(values); ret = new wxEditEnumProperty(name, wxPG_LABEL, choices, value); } // custom property with custom variables editor else if (type == "LIST") ret = new ArrayVariableProperty(name, wxPG_LABEL, values); // simple text-entry else ret = new wxStringProperty(name, wxPG_LABEL, value); if (readonly_) ret->ChangeFlag(wxPG_PROP_READONLY, true); return ret; }
//Function to select different sorting of computers in output void Information::orderComp() { Service serv; vector<Computer> vec; char number; cin >> number; cout << endl; switch (number) { case'1':{ cout << "List sorted in alphabetical order:" << endl << endl; vec = serv.sortCom(number); displayAll(vec); compSciOrLink(); break;} case'2':{ cout << "List sorted in reverse alphabetical order:" << endl << endl; vec = serv.sortCom(number); displayAll(vec); compSciOrLink(); break;} case'3':{ cout << "List sorted ascendingly by build year:" << endl << endl; vec = serv.sortCom(number); displayAll(vec); compSciOrLink(); break;} case'4':{ cout << "List sorted descendingly by year of birth:" << endl << endl; vec = serv.sortCom(number); displayAll(vec); compSciOrLink(); break;} case'5':{ instructions(); choices('1'); break;} default:{ cout << "This is invalid choice " << endl; orderComp(); break;} } }
NewIneritanceDlg::NewIneritanceDlg(wxWindow* parent, IManager* mgr, const wxString& parentName, const wxString& access) : NewIneritanceBaseDlg(parent, wxID_ANY, _("New Inheritance")) , m_mgr(mgr) { // Do this the hard way, rather than letting wxFB localise these particular strings :p const wxString AccessChoices[] = { wxT("public"), wxT("private"), wxT("protected") }; wxArrayString choices(3, AccessChoices); m_choiceAccess->Clear(); m_choiceAccess->Append(choices); // by default select 0 m_choiceAccess->Select(0); if(access.IsEmpty() == false) { m_choiceAccess->SetStringSelection(access); } m_textCtrlInhertiance->SetValue(parentName); CentreOnParent(); SetName("NewIneritanceDlg"); WindowAttrManager::Load(this); }
Gura_ImplementMethod(wx_OwnerDrawnComboBox, Create) { Signal &sig = env.GetSignal(); Object_wx_OwnerDrawnComboBox *pThis = Object_wx_OwnerDrawnComboBox::GetObjectThis(arg); if (pThis->IsInvalid(sig)) return Value::Nil; wxWindow *parent = Object_wx_Window::GetObject(arg, 0)->GetEntity(); wxWindowID id = static_cast<wxWindowID>(arg.GetInt(1)); wxString value = wxString::FromUTF8(arg.GetString(2)); wxPoint *pos = Object_wx_Point::GetObject(arg, 3)->GetEntity(); wxSize *size = Object_wx_Size::GetObject(arg, 4)->GetEntity(); std::unique_ptr<wxArrayString> choices(CreateArrayString(arg.GetList(5))); long style = 0; if (arg.IsValid(6)) style = arg.GetLong(6); wxValidator *validator = (wxValidator *)(&wxDefaultValidator); if (arg.IsValid(7)) validator = Object_wx_Validator::GetObject(arg, 7)->GetEntity(); wxString name = wxT("comboBox"); if (arg.IsValid(8)) name = wxString::FromUTF8(arg.GetString(8)); bool rtn = pThis->GetEntity()->Create(parent, id, value, *pos, *size, *choices, style, *validator, name); return ReturnValue(env, arg, Value(rtn)); }
NewQtProjDlg::NewQtProjDlg( wxWindow* parent, QmakeConf *conf, IManager *mgr ) : NewQtProjBaseDlg( parent ) , m_conf(conf) , m_mgr (mgr) { const wxString ProjKinds[] = { wxT("Console"), wxT("GUI"), wxT("Static Library"), wxT("Dynamic Library") }; wxArrayString choices(4, ProjKinds); m_choiceProjKind->Clear(); m_choiceProjKind->Append(choices); m_choiceProjKind->SetSelection(1); m_choiceQmake->Append(m_conf->GetAllConfigurations()); if (m_choiceQmake->IsEmpty() == false) { m_choiceQmake->SetSelection(0); } if( m_mgr->IsWorkspaceOpen() ) { m_dirPicker4->SetPath( m_mgr->GetWorkspace()->GetWorkspaceFileName().GetPath() ); } WindowAttrManager::Load(this, wxT("NewQtProjDlg"), m_mgr->GetConfigTool()); }
void Choice::traits_changed( TraitsRef t, Link* from ) { bool provides_something = ( t.get() != NULL && ! t->provides_nothing() ); if ( auto_select && choices.isValid() && &choices().link() == from && ! provides_something ) { DEBUG("Auto-deselecting value other than the current"); /* Choice can deliver no traits, i.e. is invalid. Find valid one. */ bool found = false; for ( iterator i = choices.begin(); i != choices.end(); ++i ) { if ( i->link().current_meta_info().get() != NULL && ! i->link().current_meta_info()->provides_nothing() ) { choices.value = i->getName(); found = true; } } if ( ! found ) choices.value = ""; } if ( auto_select && ! choices.isValid() && provides_something ) { for ( iterator i = choices.begin(); i != choices.end(); ++i ) if ( &i->link() == from ) choices.value = i->getName(); } if ( ! will_publish_traits ) publish_traits(); }
BaseSource* Choice::makeSource() { if ( ! choices.isValid() ) throw std::runtime_error("No choice selected for '" + description() + "'"); return choices().link().make_source().release(); }
QStringList InputMatcher::allChoices() const { struct WordWraps { const char *prefix; const char *postfix; }; // TODO should get from config file. WordWraps wraps[] = { { 0, "'s"}, { "\"", "'s\""}, { "\"", "\""}, { "\"", "'s"}, { "\"", 0}, { 0, 0}, }; QStringList result; bool added_number = FALSE; if ( count() > 0 ) { result = choices(TRUE, FALSE, QString(), QString()); if (count() == 1) { QStringList all = findAll(); QStringList::Iterator it; for (it = all.begin(); it != all.end(); ++it) if (!result.contains(*it)) result.append(*it); } WordWraps *w = wraps; // test if should add with gramar prefixes and post fixes. while(result.count() < 1 && (w->prefix != 0 || w->postfix != 0)) { result = choices(TRUE, FALSE, w->prefix, w->postfix); w += 1; } // test if should add with gramar prefixes and post fixes for number w = wraps; while(result.count() < 1 && (w->prefix != 0 || w->postfix != 0)) { QString nword = numberWord(w->prefix, w->postfix); if (!nword.isEmpty()) { added_number = TRUE; result += nword; } w += 1; } // test if anyting that may fit in prefix/postfix w = wraps; while(result.count() < 1 && (w->prefix != 0 || w->postfix != 0)) { // only returns a word if sets have error values... QString wword = writtenWord(w->prefix, w->postfix); if (!wword.isEmpty()) result += wword; w += 1; } // always append the number word as a choice. if (!added_number) { QString nword = numberWord(QString(), QString()); if (!nword.isEmpty()) { added_number = TRUE; result += nword; } } } return result; }
QStringList InputMatcher::choices(bool allowpartial, bool allowpredicted) const { return choices(allowpartial, allowpredicted, QString(), QString()); }
void doref(char *line1) { char buff[QLEN], dbuff[3*QLEN]; char answer[ANSLEN], temp[TLEN], line[BUFSIZ]; char *p, **sr, *flds[NFLD], *r; int nf, nr, query = 0, alph, digs; again: buff[0] = dbuff[0] = 0; if (biblio && Iline == 1 && line1[0] == '%') n_strcat(dbuff, line1, sizeof(dbuff)); while (input(line, sizeof(line))) { /* get query */ Iline++; if (prefix(line, ".]")) break; if (biblio && line[0] == '\n') break; if (biblio && line[0] == '%' && line[1] == *convert) break; if (control(line[0])) query = 1; n_strcat(query ? dbuff : buff, line, query ? sizeof(dbuff) : sizeof(buff)); if (strlen(buff) > QLEN) err("query too long (%d)", strlen(buff)); if (strlen(dbuff) > 3 * QLEN) err("record at line %d too long", Iline-1); } if (biblio && line[0] == '\n' && feof(in)) return; if (strcmp(buff, "$LIST$\n")==0) { assert (dbuff[0] == 0); dumpold(); return; } answer[0] = 0; for (p = buff; *p; p++) { if (isupper((int)*p)) *p |= 040; } alph = digs = 0; for (p = buff; *p; p++) { if (isalpha((int)*p)) alph++; else if (isdigit((int)*p)) digs++; else { *p = 0; if ((alph+digs < 3) || common(p-alph)) { r = p-alph; while (r < p) *r++ = ' '; } if (alph == 0 && digs > 0) { r = p-digs; if (digs != 4 || atoi(r)/100 != 19) { while (r < p) *r++ = ' '; } } *p = ' '; alph = digs = 0; } } one[0] = 0; if (buff[0]) { /* do not search if no query */ for (sr = rdata; sr < search; sr++) { temp[0] = 0; corout(buff, temp, "hunt", *sr, TLEN); assert(strlen(temp) < TLEN); if (strlen(temp)+strlen(answer) > BUFSIZ) err("Accumulated answers too large",0); n_strcat(answer, temp, sizeof(answer)); if (strlen(answer)>BUFSIZ) err("answer too long (%d)", strlen(answer)); if (newline(answer) > 0) break; } } assert(strlen(one) < ANSLEN); assert(strlen(answer) < ANSLEN); if (buff[0]) switch (newline(answer)) { case 0: fprintf(stderr, "No such paper: %s\n", buff); return; default: fprintf(stderr, "Too many hits: %s\n", trimnl(buff)); choices(answer); p = buff; while (*p != '\n') p++; *++p = 0; case 1: if (endpush) if ((nr = chkdup(answer))) { if (bare < 2) { nf = tabs(flds, one); nf += tabs(flds+nf, dbuff); assert(nf < NFLD); putsig(nf,flds,nr,line1,line,0); } return; } if (one[0] == 0) corout(answer, one, "deliv", dr, QLEN); break; } assert(strlen(buff) < QLEN); assert(strlen(one) < ANSLEN); nf = tabs(flds, one); nf += tabs(flds+nf, dbuff); assert(nf < NFLD); refnum++; if (sort) putkey(nf, flds, refnum, keystr); if (bare < 2) putsig(nf, flds, refnum, line1, line, 1); else flout(); putref(nf, flds); if (biblio && line[0] == '\n') goto again; if (biblio && line[0] == '%' && line[1] == *convert) fprintf(fo, "%s%c%s", convert+1, sep, line+3); }
TypeSpec ASTfunction_call::typecheck (TypeSpec expected) { typecheck_children (); bool match = false; // Look for an exact match, including expected return type m_typespec = typecheck_all_poly (expected, false); if (m_typespec != TypeSpec()) match = true; // Now look for an exact match on args, but any assignable return type if (! match && expected != TypeSpec()) { m_typespec = typecheck_all_poly (TypeSpec(), false); if (m_typespec != TypeSpec()) match = true; } // Now look for a coercible match of args, exact march on return type if (! match) { m_typespec = typecheck_all_poly (expected, true); if (m_typespec != TypeSpec()) match = true; } // All that failed, try for a coercible match on everything if (! match && expected != TypeSpec()) { m_typespec = typecheck_all_poly (TypeSpec(), true); if (m_typespec != TypeSpec()) match = true; } if (match) { if (! is_user_function ()) typecheck_builtin_specialcase (); return m_typespec; } // Couldn't find any way to match any polymorphic version of the // function that we know about. OK, at least try for helpful error // message. std::string choices (""); for (FunctionSymbol *poly = func(); poly; poly = poly->nextpoly()) { const char *code = poly->argcodes().c_str(); int advance; TypeSpec returntype = m_compiler->type_from_code (code, &advance); code += advance; if (choices.length()) choices += "\n"; choices += Strutil::format ("\t%s %s (%s)", type_c_str(returntype), m_name.c_str(), m_compiler->typelist_from_code(code).c_str()); } std::string actualargs; for (ASTNode::ref arg = args(); arg; arg = arg->next()) { if (actualargs.length()) actualargs += ", "; actualargs += arg->typespec().string(); } error ("No matching function call to '%s (%s)'\n Candidates are:\n%s", m_name.c_str(), actualargs.c_str(), choices.c_str()); return TypeSpec(); }
const MSStringVector& MSTableColumn::cellChoices(unsigned) { return choices(); }
MSBoolean MSTableColumn::hasOptions(void) { return choices().length()>0 ? MSTrue : MSFalse; }
MSAttrValueList& MSTableColumn::get(MSAttrValueList& avList_) { MSStringVector aBoolVector("MSFalse\nMSTrue"); avList_<<MSAttrValue("tag",tag().symbolName(),MSAttrValue::Control|MSAttrValue::String); avList_<<MSAttrValue("heading",MSAttrValue::stringVectorToString(heading()),MSAttrValue::String); avList_<<MSAttrValue("headingForeground",server()->colorName(headingForeground()),MSAttrValue::Color); avList_<<MSAttrValue("headingFont",server()->fontName(headingFont()),MSAttrValue::Font); MSStringVector alignmentVector("MSNone\nMSCenter\nMSTop\nMSBottom\nMSLeft\nMSRight"); avList_<<MSAttrValue("headingAlignment",MSAttrValue::alignmentToString(headingAlignment()), alignmentVector, MSAttrValue::List); avList_<<MSAttrValue("cycleColors",MSAttrValue::colorVectorToString(cycleColors(),server()), MSAttrValue::Color|MSAttrValue::List|MSAttrValue::StringVector); const char *value; switch (cycleColorMode()) { case MSBackground: value="MSBackground"; break; case MSReverseVideo: value="MSReverseVideo"; break; case MSForeground: default: value="MSForeground"; break; } avList_<<MSAttrValue("cycleColorMode",value, MSStringVector("MSBackground\nMSForeground\nMSReverseVideo")); switch (columnAlignment()) { case MSCenter: value="MSCenter"; break; case MSLeft: value="MSLeft"; break; case MSRight: default: value="MSRight"; break; } avList_<<MSAttrValue("columnAlignment",value,MSStringVector("MSLeft\nMSRight\nMSCenter")); MSStringVector clipModeVector("MSNoClipping\nMSClipStars"); if(clipMode()==MSClipStars) value="MSClipStars"; else value="MSNoClipping"; avList_<<MSAttrValue("clipMode",value,clipModeVector); avList_<<MSAttrValue("columnWidth",MSString(columnWidth())); avList_<<MSAttrValue("editWidth",MSString(editWidth())); avList_<<MSAttrValue("resizable",resizable()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("format",format().asString(),format().formats(),MSAttrValue::String); avList_<<MSAttrValue("breakOn",breakOn()==MSTrue?"MSTrue":"MSFalse",aBoolVector); MSStringVector modes="MSP::Total\nMSP::Minimum\nMSP::Maximum\nMSP::Average"; MSUnsignedLongVector modeValues; modeValues.append(MSP::Total); modeValues.append(MSP::Minimum); modeValues.append(MSP::Maximum); modeValues.append(MSP::Average); MSString result=MSAttrValue::enumToString(breakProcessMode(),modes,modeValues,modes(0),MSTrue); avList_<<MSAttrValue("breakProcessMode",result,modes); avList_<<MSAttrValue("breakProcessOn",breakProcessOn()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("breakBg",server()->colorName(breakBgPixel()),MSAttrValue::Color); avList_<<MSAttrValue("breakFg",server()->colorName(breakFgPixel()),MSAttrValue::Color); // avList_<<MSAttrValue("breakFont",server()->fontName(breakFont()),MSAttrValue::Font); avList_<<MSAttrValue("suppressDuplicate",suppressDuplicate()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("columnresize","",MSAttrValue::Callback); avList_<<MSAttrValue("valueQuoted",valueQuoted()==MSTrue?"MSTrue":"MSFalse",aBoolVector); avList_<<MSAttrValue("choices",MSAttrValue::stringVectorToString(choices()),MSAttrValue::StringVector); return MSWidget::get(avList_); }
void MSTableColumn::set(MSAttrValueList& avList_) { MSWidget::set(avList_); MSIndexVector index; for (unsigned i=0;i<avList_.length();i++) { if (avList_[i].attribute()=="breakOn") { breakOn(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="suppressDuplicate") { suppressDuplicate(avList_[i].value().asBoolean()); index<<i; } /* else if (avList_[i].attribute()=="breakFont") { breakFont(avList_[i].value()); index<<i; } */ else if (avList_[i].attribute()=="breakFg") { if(avList_[i].value().length()!=0) breakFg(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="breakBg") { if(avList_[i].value().length()!=0) breakBg(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="breakProcessOn") { breakProcessOn(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="breakProcessMode") { MSStringVector modes="MSP::Total\nMSP::Minimum\nMSP::Maximum\nMSP::Average"; MSUnsignedLongVector modeValues; modeValues.append(MSP::Total); modeValues.append(MSP::Minimum); modeValues.append(MSP::Maximum); modeValues.append(MSP::Average); unsigned long mode=MSAttrValue::stringToEnum(avList_[i].value(),modes,modeValues,MSP::Total,MSTrue); breakProcessMode((MSP::BreakProcessMode)mode); index<<i; } else if (avList_[i].attribute()=="heading") { heading(MSAttrValue::stringToStringVector(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="headingForeground") { headingForeground(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="headingFont") { headingFont(avList_[i].value()); index<<i; } else if (avList_[i].attribute()=="headingAlignment") { headingAlignment(MSAttrValue::stringToAlignment(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="cycleColors") { cycleColors(MSAttrValue::stringToStringVector(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="cycleColorMode") { if (avList_[i].value()=="MSBackground") cycleColorMode(MSBackground); else if (avList_[i].value()=="MSReverseVideo") cycleColorMode(MSReverseVideo); else cycleColorMode(MSForeground); index<<i; } else if (avList_[i].attribute()=="clipMode") { if (avList_[i].value()=="MSClipStars") clipMode(MSClipStars); else clipMode(MSNoClipping); index<<i; } else if (avList_[i].attribute()=="columnAlignment") { if (avList_[i].value()=="MSRight") columnAlignment(MSRight); else if (avList_[i].value()=="MSLeft") columnAlignment(MSLeft); else columnAlignment(MSCenter); index<<i; } else if (avList_[i].attribute()=="columnWidth") { columnWidth(avList_[i].value().asInt()); index<<i; } else if (avList_[i].attribute()=="editWidth") { editWidth(avList_[i].value().asInt()); index<<i; } else if (avList_[i].attribute()=="resizable") { resizable(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="format") { format(MSFormat(avList_[i].value())); index<<i; } else if(avList_[i].attribute()=="tag") { if(avList_[i].value().length()==0) tag(MSSymbol::nullSymbol()); else tag(MSSymbol(avList_[i].value())); index<<i; } else if (avList_[i].attribute()=="valueQuoted") { valueQuoted(avList_[i].value().asBoolean()); index<<i; } else if (avList_[i].attribute()=="choices") { choices(MSAttrValue::stringToStringVector(avList_[i].value())); index<<i; } } avList_.remove(index); }
int main(int argc, char** argv) { mq::MapSite::StrVec args(argv + 1, argv + argc); // "+ 1" to skip first arg. It's the name of the program if(args.size() < 1) { std::cout << "[ERROR]: Not enough arguments. Type at least something to search for after the exe name.\n"; return 3; } std::string searchStr = args[0]; for(auto i = 1u; i < args.size(); i++) searchStr.append(" " + args[i]); mq::BattlezoneOneCom bz1server; if(!bz1server.isServerGood()) { std::cout << "[ERROR]: Cannot contact server. Exiting.\n"; return 1; } mq::MapSite::StrMap results = bz1server.getMaps(searchStr); if(results.empty()) { std::cout << "No results found for \"" << searchStr << "\"!\n"; return 0; } for(auto it = results.begin(); it != results.end(); it++) { std::cout << std::distance(results.begin(), it) << ") " << it->first << " : " << it->second << '\n'; } bool badInput = true; std::string input; std::vector<unsigned int> choices(1); while(badInput) { std::cout << "\nEnter the number(s) of the map to download (\"-1\" to cancel): "; std::getline(std::cin, input); if(input == "-1") return 0; std::stringstream ss(input); badInput = false; try { while(ss >> choices.back()) choices.emplace_back(); choices.erase(--choices.end()); // get rid of extra item for(auto& c : choices) if(c >= results.size()) throw 0; } catch(...) { badInput = true; choices.resize(1); std::cout << "[ERROR]: Bad input. Try again!\n"; } } std::string installLocation = getBZinstallDir(); if(installLocation.empty()) installLocation = getExePath(); installLocation += "addon/"; for(auto& c : choices) { auto choiceIter = std::next(results.begin(), c); std::string resFileName = bz1server.downloadMap(choiceIter->second, installLocation); if(resFileName.empty()) { std::cout << "[ERROR]: Download failed for \"" << choiceIter->first << "\". Exiting.\n"; return 2; } extractMap(resFileName); } return 0; }