// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCDeleteItemNoUI // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCDeleteItemNoUI::COp_KCDeleteItemNoUI() { AddParam(mItemIndex); }
void CLevelParser::Load() { CInputStream file; file.open(m_filename); if (!file.is_open()) throw CLevelParserException("Failed to open file: " + m_filename); char lang = CApplication::GetInstancePointer()->GetLanguageChar(); std::string line; int lineNumber = 0; std::set<std::string> translatableLines; while (getline(file, line)) { lineNumber++; boost::replace_all(line, "\t", " "); // replace tab by space // ignore comments std::size_t comment = line.find("//"); if (comment != std::string::npos) line = line.substr(0, comment); boost::algorithm::trim(line); std::size_t pos = line.find_first_of(" \t\n"); std::string command = line.substr(0, pos); if (pos != std::string::npos) { line = line.substr(pos + 1); boost::algorithm::trim(line); } else { line = ""; } if (command.empty()) continue; auto parserLine = MakeUnique<CLevelParserLine>(lineNumber, command); parserLine->SetLevel(this); if (command.length() > 2 && command[command.length() - 2] == '.') { std::string baseCommand = command.substr(0, command.length() - 2); parserLine->SetCommand(baseCommand); char languageChar = command[command.length() - 1]; if (languageChar == 'E' && translatableLines.count(baseCommand) == 0) { translatableLines.insert(baseCommand); } else if (languageChar == lang) { if (translatableLines.count(baseCommand) > 0) { auto it = std::remove_if( m_lines.begin(), m_lines.end(), [&baseCommand](const CLevelParserLineUPtr& line) { return line->GetCommand() == baseCommand; }); m_lines.erase(it, m_lines.end()); } translatableLines.insert(baseCommand); } else { continue; } } while (!line.empty()) { pos = line.find_first_of("="); std::string paramName = line.substr(0, pos); boost::algorithm::trim(paramName); line = line.substr(pos + 1); boost::algorithm::trim(line); if (line[0] == '\"') { pos = line.find_first_of("\"", 1); if (pos == std::string::npos) throw CLevelParserException("Unclosed \" in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber)); } else if (line[0] == '\'') { pos = line.find_first_of("'", 1); if (pos == std::string::npos) throw CLevelParserException("Unclosed ' in " + m_filename + ":" + boost::lexical_cast<std::string>(lineNumber)); } else { pos = line.find_first_of("="); if (pos != std::string::npos) { std::size_t pos2 = line.find_last_of(" \t\n", line.find_last_not_of(" \t\n", pos-1)); if (pos2 != std::string::npos) pos = pos2; } else { pos = line.length()-1; } } std::string paramValue = line.substr(0, pos + 1); boost::algorithm::trim(paramValue); parserLine->AddParam(paramName, MakeUnique<CLevelParserParam>(paramName, paramValue)); if (pos == std::string::npos) break; line = line.substr(pos + 1); boost::algorithm::trim(line); } if (parserLine->GetCommand().length() > 1 && parserLine->GetCommand()[0] == '#') { std::string cmd = parserLine->GetCommand().substr(1, std::string::npos); if(cmd == "Include") { std::unique_ptr<CLevelParser> includeParser = MakeUnique<CLevelParser>(parserLine->GetParam("file")->AsPath("")); includeParser->Load(); for(CLevelParserLineUPtr& line : includeParser->m_lines) { AddLine(std::move(line)); } } else { throw CLevelParserException("Unknown preprocessor command '#" + cmd + "' (in " + m_filename + ":" + StrUtils::ToString<int>(lineNumber) + ")"); } } else { AddLine(std::move(parserLine)); } } file.close(); }
enumError cmd_compr() { const bool have_param = n_param > 0; if (!n_param) { int i; for ( i = 0; i < WD_COMPR__N; i++ ) AddParam(wd_get_compression_name(i,0),false); if (long_count) { AddParam(" DEFAULT",false); AddParam(" FAST",false); AddParam(" GOOD",false); AddParam(" BEST",false); AddParam(" MEM",false); char buf[2] = {0,0}; for ( i = '0'; i <= '9'; i++ ) { buf[0] = i; AddParam(buf,true); } } } int err_count = 0; if (print_sections) { if (!have_param) { printf( "\n[compression-modes]\n" "n-methods=%u\n", WD_COMPR__N ); print_default_compr("default"); print_default_compr("fast"); print_default_compr("good"); print_default_compr("best"); print_default_compr("mem"); } int index = 0; ParamList_t * param; for ( param = first_param; param; param = param->next, index++ ) { int level; u32 csize; wd_compression_t compr = ScanCompression(param->arg,true,&level,&csize); printf( "\n[compression-mode-%u]\n" "input=%s\n" "num=%d\n" "name=%s\n", index, param->arg, compr, wd_get_compression_name(compr,"-") ); if ( compr == (wd_compression_t)-1 ) err_count++; else { CalcDefaultSettingsWIA(&compr,&level,&csize); if ( level > 0 ) printf("level=%u\n",level); if ( csize > 0 ) printf("chunk-factor=%u\nchunk-size=%u\n", csize/WIA_BASE_CHUNK_SIZE, csize ); #ifdef NO_BZIP2 if ( compr == WD_COMPR_BZIP2 ) fputs("not-supported=1\n",stdout); #endif } } putchar('\n'); } else if (long_count) { const bool print_header = !OptionUsed[OPT_NO_HEADER]; if (print_header) printf( "\n" " mode memory usage\n" " %s reading writing input mode\n" "---------------------------------------------\n", OptionUsed[OPT_NUMERIC] ? "num " : "name" ); const int mode = OptionUsed[OPT_NUMERIC] ? 1 : 2; ParamList_t * param; for ( param = first_param; param; param = param->next ) { int level; u32 csize; wd_compression_t compr = ScanCompression(param->arg,true,&level,&csize); if ( verbose > 0 ) { wd_compression_t compr2 = compr; CalcDefaultSettingsWIA(&compr2,&level,&csize); } if ( compr == (wd_compression_t)-1 ) { err_count++; printf(" - - - %s\n",param->arg); } else { u32 read_size = CalcMemoryUsageWIA(compr,level,csize,false); u32 write_size = CalcMemoryUsageWIA(compr,level,csize,true); printf(" %-11s %s %s %.30s\n", wd_print_compression(0,0,compr,level,csize,mode), wd_print_size_1024(0,0,read_size,true), wd_print_size_1024(0,0,write_size,true), param->arg ); } } if (print_header) putchar('\n'); } else { const int mode = OptionUsed[OPT_NUMERIC] ? 1 : 2; ParamList_t * param; for ( param = first_param; param; param = param->next ) { int level; u32 csize; wd_compression_t compr = ScanCompression(param->arg,true,&level,&csize); if ( verbose > 0 ) { wd_compression_t compr2 = compr; CalcDefaultSettingsWIA(&compr2,&level,&csize); } #ifdef NO_BZIP2 if ( !have_param && compr == WD_COMPR_BZIP2 ) continue; // ignore it #endif if ( compr == (wd_compression_t)-1 ) err_count++; printf("%s\n",wd_print_compression(0,0,compr,level,csize,mode)); } } return err_count ? ERR_WARNING : ERR_OK; }
void CHooks::AddPathParam(CString& sCmd, const CTGitPathList& pathList) { CTGitPath temppath = CTempFiles::Instance().GetTempFilePath(true); pathList.WriteToFile(temppath.GetWinPathString(), true); AddParam(sCmd, temppath.GetWinPathString()); }
void CHooks::AddDepthParam(CString& sCmd, git_depth_t depth) { CString sTemp; sTemp.Format(_T("%d"), depth); AddParam(sCmd, sTemp); }
HX_RESULT CHXFMTPParser::Parse(const char* pFMTPStr, IHXValues* pHeaders) { HX_RESULT res = HXR_UNEXPECTED; // e.g. a=fmtp:101 emphasis=50/15;foo=bar;flag if (m_pCCF) { const char* pCur = pFMTPStr; // Skip payload type //for (;*pCur && (*pCur != ' '); pCur++) //; res = HXR_OK; IHXBuffer* pFieldName = 0; IHXBuffer* pFieldValue = 0; UINT32 ulState = 0; const char* pDelims = 0; while ((HXR_OK == res) && *pCur) { // Skip whitespace for (;*pCur && (*pCur == ' '); pCur++) ; HXBOOL bCollectValue = FALSE; HXBOOL bAddValue = FALSE; IHXBuffer** ppTokDest = 0; switch (ulState) { case 0: pDelims = " ;="; if (strchr(pDelims, *pCur)) { pCur++; // Skip delimiter } else { ulState = 1; bCollectValue = TRUE; ppTokDest = &pFieldName; } break; case 1: if (*pCur == '=') { pCur++; // Skip delimiter pDelims = " ;"; ulState = 2; } else { bAddValue = TRUE; if (strchr(pDelims, *pCur)) pCur++; // Skip delimiter } break; case 2: ppTokDest = &pFieldValue; bCollectValue = TRUE; ulState = 3; break; case 3: if (*pCur && strchr(pDelims, *pCur)) pCur++; // Skip delimiter bAddValue = TRUE; break; } if (bCollectValue) { res = CollectToken(pCur, pDelims, ppTokDest, bAddValue); } if (bAddValue) { res = AddParam(pFieldName, pFieldValue, pHeaders); HX_RELEASE(pFieldName); HX_RELEASE(pFieldValue); ulState = 0; } } if (HXR_OK == res) { // Add last parameter res = AddParam(pFieldName, pFieldValue, pHeaders); } HX_RELEASE(pFieldName); HX_RELEASE(pFieldValue); } return res; }
void MsdFile::ReadBuf( const char *buf, int len, bool bUnescape ) { values.reserve( 64 ); bool ReadingValue=false; int i = 0; char *cProcessed = new char[len]; int iProcessedLen = -1; while( i < len ) { if( i+1 < len && buf[i] == '/' && buf[i+1] == '/' ) { /* Skip a comment entirely; don't copy the comment to the value/parameter */ do { i++; } while( i < len && buf[i] != '\n' ); continue; } if( ReadingValue && buf[i] == '#' ) { /* Unfortunately, many of these files are missing ;'s. * If we get a # when we thought we were inside a value, assume we * missed the ;. Back up and end the value. */ // Make sure this # is the first non-whitespace character on the line. bool FirstChar = true; int j = iProcessedLen; while( j > 0 && cProcessed[j - 1] != '\r' && cProcessed[j - 1] != '\n' ) { if( cProcessed[j - 1] == ' ' || cProcessed[j - 1] == '\t' ) { --j; continue; } FirstChar = false; break; } if( !FirstChar ) { /* We're not the first char on a line. Treat it as if it were a normal character. */ cProcessed[iProcessedLen++] = buf[i++]; continue; } /* Skip newlines and whitespace before adding the value. */ iProcessedLen = j; while( iProcessedLen > 0 && ( cProcessed[iProcessedLen - 1] == '\r' || cProcessed[iProcessedLen - 1] == '\n' || cProcessed[iProcessedLen - 1] == ' ' || cProcessed[iProcessedLen - 1] == '\t' ) ) --iProcessedLen; AddParam( cProcessed, iProcessedLen ); iProcessedLen = 0; ReadingValue=false; } /* # starts a new value. */ if( !ReadingValue && buf[i] == '#' ) { AddValue(); ReadingValue=true; } if( !ReadingValue ) { if( bUnescape && buf[i] == '\\' ) i += 2; else ++i; continue; /* nothing else is meaningful outside of a value */ } /* : and ; end the current param, if any. */ if( iProcessedLen != -1 && (buf[i] == ':' || buf[i] == ';') ) AddParam( cProcessed, iProcessedLen ); /* # and : begin new params. */ if( buf[i] == '#' || buf[i] == ':' ) { ++i; iProcessedLen = 0; continue; } /* ; ends the current value. */ if( buf[i] == ';' ) { ReadingValue=false; ++i; continue; } /* We've gone through all the control characters. All that is left is either an escaped character, * ie \#, \\, \:, etc., or a regular character. */ if( bUnescape && i < len && buf[i] == '\\' ) ++i; if( i < len ) { cProcessed[iProcessedLen++] = buf[i++]; } } /* Add any unterminated value at the very end. */ if( ReadingValue ) AddParam( cProcessed, iProcessedLen ); delete [] cProcessed; }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCSetAttribute // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCSetAttribute::COp_KCSetAttribute() :mAttribute("Attribute") { AddParam(mItemIndex); AddParam(mAttribute); }
void LoadConfigurationFile(char *s, int err) { FILE *in; char file[128]; arg_node *node, *node2; char line[256]; int n; memset(file, 0, 128); strncpy(file, s, 121); strcat(file, ".cfg"); in = fopen(file, "rt"); if(in == 0) { if(err) fprintf(stderr, "Could not find configuration file %s.\n", file); return; } if(!first) { node = arg_node_root; arg_node_root = arg_node_root->next; free(node); } first = 1; node = arg_node_root; node2 = arg_node_tail; arg_node_root = 0; arg_node_tail = 0; while(fgets(line, 256, in) != 0) { if(line[0] == ';') continue; n = strlen(line)-1; if(n < 0) continue; if(line[n] == '\n') { if(n == 0) continue; line[n] = 0; } AddParam(line); } arg_node_tail->next = node; if(node2 != 0) arg_node_tail = node2; fclose(in); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCFindNextItem // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCFindNextItem::COp_KCFindNextItem() { AddParam(mSearchIndex); AddResult(mItemIndex); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCReleaseSearch // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCReleaseSearch::COp_KCReleaseSearch() { AddParam(mSearchIndex); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCCopyItem // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCCopyItem::COp_KCCopyItem() { AddParam(mKeychainIndex); AddParam(mItemIndex); AddResult(mItemIndex); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCReleaseItem // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCReleaseItem::COp_KCReleaseItem() { AddParam(mItemIndex); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCUpdateItem // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCUpdateItem::COp_KCUpdateItem() { AddParam(mItemIndex); }
//----------------------------------------------------------------------------- int mglParser::FlowExec(mglGraph *, const std::wstring &com, long m, mglArg *a) { int n=-1; if(!ifskip() && !com.compare(L"once")) { if(a[0].type==2) { n = 0; if(a[0].v) Skip = !Once; else Skip = Once = false; } else n = 1; } else if(!Skip && !com.compare(L"if")) { int cond; if(a[0].type==2) { n = 0; cond = (a[0].v!=0)?3:0; } else if(a[0].type==0) { n = 0; a[1].s.assign(a[1].w.begin(),a[1].w.end()); cond = a[0].d->FindAny((m>1 && a[1].type==1) ? a[1].s.c_str():"u")?3:0; } else n = 1; if(n==0) { if_stack[if_pos] = cond; if_pos = if_pos<39 ? if_pos+1 : 39; } } else if(!Skip && !com.compare(L"endif")) { if_pos = if_pos>0 ? if_pos-1 : 0; n = 0; } else if(!Skip && !com.compare(L"else")) { if(if_pos>0) { n=0; if_stack[if_pos-1] = (if_stack[if_pos-1]&2)?2:3; } else n = 1; } else if(!Skip && !com.compare(L"elseif")) { int cond; if(if_pos<1 || m<1) n = 1; else if(if_stack[if_pos-1]&2) { n = 0; cond = 2; } else if(a[0].type==2) { n = 0; cond = (a[0].v!=0)?3:0; } else if(a[0].type==0) { n = 0; a[1].s.assign(a[1].w.begin(),a[1].w.end()); cond = a[0].d->FindAny((m>1 && a[1].type==1) ? a[1].s.c_str():"u")?3:0; } else n = 1; if(n==0) if_stack[if_pos-1] = cond; } else if(!ifskip() && !Skip && !com.compare(L"break")) { if(if_pos==if_for[0]) if_pos = if_pos>0 ? if_pos-1 : 0; } else if(!skip() && !com.compare(L"return")) { if(fn_stack.size()<1) return 2; const mglFnStack &fn=fn_stack.back(); for(int i=0;i<10;i++) par[i]=fn.par[i]; n = -fn.pos-1; fn_stack.pop_back(); } else if(!ifskip() && !Skip && !com.compare(L"next")) { if(if_pos==if_for[0]) if_pos = if_pos>0 ? if_pos-1 : 0; int r = for_stack[0]-1; n = for_stack[0] ? 0:1; if(for_stack[0]) { if(fval[r].ny<fval[r].nx && !for_br) { wchar_t buf[32]; mglprintf(buf,32,L"%g",fval[r].a[fval[r].ny]); AddParam(r, buf); fval[r].ny += 1; n = -fval[r].nz-1; } else { for(int i=0;i<39;i++) { for_stack[i]=for_stack[i+1]; if_for[i]=if_for[i+1]; } for_stack[39] = 0; for_br=false; } } } else if(!ifskip() && !Skip && !com.compare(L"continue")) { if(if_pos==if_for[0]) if_pos = if_pos>0 ? if_pos-1 : 0; int r = for_stack[0]-1; n = for_stack[0] ? 0:1; if(for_stack[0]) { if(fval[r].ny<fval[r].nx) { wchar_t buf[32]; mglprintf(buf,32,L"%g",fval[r].a[fval[r].ny]); AddParam(r, buf); fval[r].ny += 1; n = -fval[r].nz-1; } else for_br = true; } } return n+1; }
void ISerializeble::AddParam( const Hash hash, bool& value ) { AddParam( hash, new Value( value ) ); }
void CHooks::AddDepthParam(CString& sCmd, svn_depth_t depth) { CString sTemp; sTemp.Format(L"%d", depth); AddParam(sCmd, sTemp); }
bool TKPlayerPage::PopulateMenuPage(player_t *player_ptr) { bool is_bot; char *name; this->params.GetParam("is_bot", &is_bot); this->params.GetParam("name", &name); this->SetEscLink("%s", Translate(player_ptr, 620)); this->SetTitle("%s", Translate(player_ptr, 631,"%s", name)); // Some people don't want the forgive option if (IsMenuOptionAllowed(MANI_TK_FORGIVE, is_bot)) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 632, AddParam("punish", MANI_TK_FORGIVE)); } // Some people don't want the slay option if (IsMenuOptionAllowed(MANI_TK_SLAY, is_bot)) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 633, AddParam("punish", MANI_TK_SLAY)); } // Some people don't want the slap option if (IsMenuOptionAllowed(MANI_TK_SLAP, is_bot) && gpManiGameType->IsSlapAllowed()) { MenuItem *ptr = new TKPlayerItem; ptr->SetDisplayText("%s", Translate(player_ptr, 634, "%i", mani_tk_slap_to_damage.GetInt())); ptr->params.AddParam("punish", MANI_TK_SLAP); this->AddItem(ptr); } // Some people don't want the beacon option if (IsMenuOptionAllowed(MANI_TK_BEACON, is_bot) && gpManiGameType->GetAdvancedEffectsAllowed()) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 643, AddParam("punish", MANI_TK_BEACON)); } // Some people don't want the time bomb option if (IsMenuOptionAllowed(MANI_TK_TIME_BOMB, is_bot)) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 640, AddParam("punish", MANI_TK_TIME_BOMB)); } // Some people don't want the fire bomb option if (IsMenuOptionAllowed(MANI_TK_FIRE_BOMB, is_bot) && gpManiGameType->IsFireAllowed()) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 641, AddParam("punish", MANI_TK_FIRE_BOMB)); } // Some people don't want the freeze bomb option if (IsMenuOptionAllowed(MANI_TK_FREEZE_BOMB, is_bot)) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 642, AddParam("punish", MANI_TK_FREEZE_BOMB)); } // Some people don't want the freeze option if (IsMenuOptionAllowed(MANI_TK_FREEZE, is_bot)) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 636, AddParam("punish", MANI_TK_FREEZE)); } // Some people don't want the burn option if (IsMenuOptionAllowed(MANI_TK_BURN, is_bot) && gpManiGameType->IsFireAllowed()) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 639, AddParam("punish", MANI_TK_BURN)); } // Some people don't want the cash option if (IsMenuOptionAllowed(MANI_TK_CASH, is_bot) && gpManiGameType->CanUseProp(MANI_PROP_ACCOUNT)) { MenuItem *ptr = new TKPlayerItem; ptr->SetDisplayText("%s", Translate(player_ptr, 637, "%i", mani_tk_cash_percent.GetInt())); ptr->params.AddParam("punish", MANI_TK_CASH); this->AddItem(ptr); } // Some people don't want the drug option if (IsMenuOptionAllowed(MANI_TK_DRUG, is_bot) && gpManiGameType->IsDrugAllowed()) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 638, AddParam("punish", MANI_TK_DRUG)); } // Some people don't want the blind option if (IsMenuOptionAllowed(MANI_TK_BLIND, is_bot)) { MENUOPTION_CREATE_PARAM(TKPlayerItem, 635, AddParam("punish", MANI_TK_BLIND)); } return true; }
CvFGDetectorBase(int type, void* param) { m_pFG = NULL; m_FGType = type; m_pFGParam = param; if( m_FGType == CV_BG_MODEL_FGD || m_FGType == CV_BG_MODEL_FGD_SIMPLE ) { if(m_pFGParam) { m_ParamFGD = *(CvFGDStatModelParams*)m_pFGParam; } else { m_ParamFGD.Lc = CV_BGFG_FGD_LC; m_ParamFGD.N1c = CV_BGFG_FGD_N1C; m_ParamFGD.N2c = CV_BGFG_FGD_N2C; m_ParamFGD.Lcc = CV_BGFG_FGD_LCC; m_ParamFGD.N1cc = CV_BGFG_FGD_N1CC; m_ParamFGD.N2cc = CV_BGFG_FGD_N2CC; m_ParamFGD.delta = CV_BGFG_FGD_DELTA; m_ParamFGD.alpha1 = CV_BGFG_FGD_ALPHA_1; m_ParamFGD.alpha2 = CV_BGFG_FGD_ALPHA_2; m_ParamFGD.alpha3 = CV_BGFG_FGD_ALPHA_3; m_ParamFGD.T = CV_BGFG_FGD_T; m_ParamFGD.minArea = CV_BGFG_FGD_MINAREA; m_ParamFGD.is_obj_without_holes = 1; m_ParamFGD.perform_morphing = 1; } AddParam("LC",&m_ParamFGD.Lc); AddParam("alpha1",&m_ParamFGD.alpha1); AddParam("alpha2",&m_ParamFGD.alpha2); AddParam("alpha3",&m_ParamFGD.alpha3); AddParam("N1c",&m_ParamFGD.N1c); AddParam("N2c",&m_ParamFGD.N2c); AddParam("N1cc",&m_ParamFGD.N1cc); AddParam("N2cc",&m_ParamFGD.N2cc); m_SaveName = 0; m_LoadName = 0; AddParam("SaveName",&m_SaveName); AddParam("LoadName",&m_LoadName); AddParam("ObjWithoutHoles",&m_ParamFGD.is_obj_without_holes); AddParam("Morphology",&m_ParamFGD.perform_morphing); } else if( m_FGType == CV_BG_MODEL_MOG ) // "MOG" == "Mixture Of Gaussians" { if(m_pFGParam) { m_ParamMOG = *(CvGaussBGStatModelParams*)m_pFGParam; } else { // These constants are all from cvaux/include/cvaux.h m_ParamMOG.win_size = CV_BGFG_MOG_WINDOW_SIZE; m_ParamMOG.bg_threshold = CV_BGFG_MOG_BACKGROUND_THRESHOLD; m_ParamMOG.std_threshold = CV_BGFG_MOG_STD_THRESHOLD; m_ParamMOG.weight_init = CV_BGFG_MOG_WEIGHT_INIT; m_ParamMOG.variance_init = CV_BGFG_MOG_SIGMA_INIT*CV_BGFG_MOG_SIGMA_INIT; m_ParamMOG.minArea = CV_BGFG_MOG_MINAREA; m_ParamMOG.n_gauss = CV_BGFG_MOG_NGAUSSIANS; } AddParam("NG",&m_ParamMOG.n_gauss); } };
//--------------------------------------------------------------------------------- // Purpose: Handle a player death event //--------------------------------------------------------------------------------- bool ProcessTKDeath ( player_t *attacker_ptr, player_t *victim_ptr ) { if (mani_tk_protection.GetInt() == 0) return false; // Check TK happened outside spawn protection time if (gpGlobals->curtime < end_spawn_protection_time) return false; // Killed by world ? if (attacker_ptr->user_id <= 0) return false; // Are players on same team ? if (!gpManiTeam->IsOnSameTeam (victim_ptr, attacker_ptr)) return false; if (mani_tk_forgive.GetInt() == 0) { ProcessTKNoForgiveMode(attacker_ptr, victim_ptr); return false; } int tk_player_index = -1; // Find tkplayer list and create tracking data if (!victim_ptr->is_bot && !attacker_ptr->is_bot) { for (int i = 0; i < tk_player_list_size; i++) { if (IsLAN()) { if (attacker_ptr->user_id == tk_player_list[i].user_id) { tk_player_index = i; break; } } else if (FStrEq(attacker_ptr->steam_id, tk_player_list[i].steam_id)) { tk_player_index = i; break; } } // TK/TW occured (both on same team) // Handle tracking of this player if (tk_player_index != -1) { // If a new round then bump the violations tk_player_list[tk_player_index].last_round_violation = round_number; if (!attacker_ptr->is_bot) { if (mani_tk_add_violation_without_forgive.GetInt() == 1) { tk_player_list[tk_player_index].violations_committed++; Q_strcpy(tk_player_list[tk_player_index].name, attacker_ptr->name); // Check if ban required if (TKBanPlayer (attacker_ptr, tk_player_index)) { return false; } } } } else { // Add this player to list CreateNewTKPlayer(attacker_ptr->name, attacker_ptr->steam_id, attacker_ptr->user_id, 0, 0); // Check if ban required if (!attacker_ptr->is_bot && mani_tk_add_violation_without_forgive.GetInt() == 1) { tk_player_list[tk_player_list_size - 1].violations_committed = 1; if(TKBanPlayer (attacker_ptr, tk_player_list_size -1)) { return false; } } else { tk_player_list[tk_player_list_size - 1].violations_committed = 0; } } } // No point showing to menu to player if (victim_ptr->entity == NULL) return false; if (victim_ptr->is_bot && mani_tk_allow_bots_to_punish.GetInt() == 0) { // Dont't let bots punish players return false; } int bot_choice; // Handle a bot dishing out punishments if (victim_ptr->is_bot) { if (attacker_ptr->is_dead) return false; if (attacker_ptr->is_bot) { bot_choice = GetRandomTKPunishmentAgainstBot(); } else { bot_choice = GetRandomTKPunishmentAgainstHuman(); } char log_string[512]; char output_string[512]; GetTKPunishSayString(bot_choice, attacker_ptr, victim_ptr, output_string, log_string, false); ProcessTKPunishment(bot_choice, attacker_ptr, victim_ptr, output_string, log_string, false); return false; } // Force client to call command to show menu g_menu_mgr.Kill(victim_ptr); MENUPAGE_CREATE_PARAM4(TKPlayerPage, victim_ptr, AddParam("is_bot", attacker_ptr->is_bot), AddParam("user_id", attacker_ptr->user_id), AddParam("steam_id", attacker_ptr->steam_id), AddParam("name", attacker_ptr->name), 2, -1); return true; }
/** define allowed parameters */ Parameter::Parameter() { AddParam("beam-threshold", "b", "threshold for threshold pruning"); AddParam("config", "f", "location of the configuration file"); AddParam("continue-partial-translation", "cpt", "start from nonempty hypothesis"); AddParam("decoding-graph-backoff", "dpb", "only use subsequent decoding paths for unknown spans of given length"); AddParam("drop-unknown", "du", "drop unknown words instead of copying them"); AddParam("disable-discarding", "dd", "disable hypothesis discarding"); AddParam("factor-delimiter", "fd", "specify a different factor delimiter than the default"); AddParam("generation-file", "location and properties of the generation table"); AddParam("global-lexical-file", "gl", "discriminatively trained global lexical translation model file"); AddParam("input-factors", "list of factors in the input"); AddParam("input-file", "i", "location of the input file to be translated"); AddParam("inputtype", "text (0), confusion network (1), word lattice (2) (default = 0)"); AddParam("labeled-n-best-list", "print out labels for each weight type in n-best list. default is true"); AddParam("include-alignment-in-n-best", "include word alignment in the n-best list. default is false"); AddParam("lmodel-file", "location and properties of the language models"); AddParam("lmodel-dub", "dictionary upper bounds of language models"); AddParam("lmodel-oov-feature", "add language model oov feature, one per model"); AddParam("mapping", "description of decoding steps"); AddParam("max-partial-trans-opt", "maximum number of partial translation options per input span (during mapping steps)"); AddParam("max-trans-opt-per-coverage", "maximum number of translation options per input span (after applying mapping steps)"); AddParam("max-phrase-length", "maximum phrase length (default 20)"); AddParam("n-best-list", "file and size of n-best-list to be generated; specify - as the file in order to write to STDOUT"); AddParam("lattice-samples", "generate samples from lattice, in same format as nbest list. Uses the file and size arguments, as in n-best-list"); AddParam("n-best-factor", "factor to compute the maximum number of contenders (=factor*nbest-size). value 0 means infinity, i.e. no threshold. default is 0"); AddParam("print-all-derivations", "to print all derivations in search graph"); AddParam("output-factors", "list of factors in the output"); AddParam("phrase-drop-allowed", "da", "if present, allow dropping of source words"); //da = drop any (word); see -du for comparison AddParam("report-all-factors", "report all factors in output, not just first"); AddParam("report-all-factors-in-n-best", "Report all factors in n-best-lists. Default is false"); AddParam("report-segmentation", "t", "report phrase segmentation in the output"); #ifdef HAVE_SYNLM AddParam("slmodel-file", "location of the syntactic language model file(s)"); AddParam("weight-slm", "slm", "weight(s) for syntactic language model"); AddParam("slmodel-factor", "factor to use with syntactic language model"); AddParam("slmodel-beam", "beam width to use with syntactic language model's parser"); #endif AddParam("stack", "s", "maximum stack size for histogram pruning"); AddParam("stack-diversity", "sd", "minimum number of hypothesis of each coverage in stack (default 0)"); AddParam("threads","th", "number of threads to use in decoding (defaults to single-threaded)"); AddParam("translation-details", "T", "for each best hypothesis, report translation details to the given file"); AddParam("ttable-file", "location and properties of the translation tables"); AddParam("ttable-limit", "ttl", "maximum number of translation table entries per input phrase"); AddParam("translation-option-threshold", "tot", "threshold for translation options relative to best for input phrase"); AddParam("early-discarding-threshold", "edt", "threshold for constructing hypotheses based on estimate cost"); AddParam("verbose", "v", "verbosity level of the logging"); AddParam("weight-d", "d", "weight(s) for distortion (reordering components)"); AddParam("weight-lr", "lr", "weight(s) for lexicalized reordering, if not included in weight-d"); AddParam("weight-generation", "g", "weight(s) for generation components"); AddParam("weight-i", "I", "weight(s) for word insertion - used for parameters from confusion network and lattice input links"); AddParam("weight-l", "lm", "weight(s) for language models"); AddParam("weight-lex", "lex", "weight for global lexical model"); AddParam("weight-t", "tm", "weights for translation model components"); AddParam("weight-w", "w", "weight for word penalty"); AddParam("weight-u", "u", "weight for unknown word penalty"); AddParam("weight-e", "e", "weight for word deletion"); AddParam("output-factors", "list if factors in the output"); AddParam("cache-path", "?"); AddParam("distortion-limit", "dl", "distortion (reordering) limit in maximum number of words (0 = monotone, -1 = unlimited)"); AddParam("monotone-at-punctuation", "mp", "do not reorder over punctuation"); AddParam("distortion-file", "source factors (0 if table independent of source), target factors, location of the factorized/lexicalized reordering tables"); AddParam("distortion", "configurations for each factorized/lexicalized reordering model."); AddParam("xml-input", "xi", "allows markup of input with desired translations and probabilities. values can be 'pass-through' (default), 'inclusive', 'exclusive', 'ignore'"); AddParam("xml-brackets", "xb", "specify strings to be used as xml tags opening and closing, e.g. \"{{ }}\" (default \"< >\"). Avoid square brackets because of configuration file format. Valid only with text input mode" ); AddParam("minimum-bayes-risk", "mbr", "use miminum Bayes risk to determine best translation"); AddParam("lminimum-bayes-risk", "lmbr", "use lattice miminum Bayes risk to determine best translation"); AddParam("consensus-decoding", "con", "use consensus decoding (De Nero et. al. 2009)"); AddParam("mbr-size", "number of translation candidates considered in MBR decoding (default 200)"); AddParam("mbr-scale", "scaling factor to convert log linear score probability in MBR decoding (default 1.0)"); AddParam("lmbr-thetas", "theta(s) for lattice mbr calculation"); AddParam("lmbr-pruning-factor", "average number of nodes/word wanted in pruned lattice"); AddParam("lmbr-p", "unigram precision value for lattice mbr"); AddParam("lmbr-r", "ngram precision decay value for lattice mbr"); AddParam("lmbr-map-weight", "weight given to map solution when doing lattice MBR (default 0)"); AddParam("lattice-hypo-set", "to use lattice as hypo set during lattice MBR"); AddParam("clean-lm-cache", "clean language model caches after N translations (default N=1)"); AddParam("use-persistent-cache", "cache translation options across sentences (default true)"); AddParam("persistent-cache-size", "maximum size of cache for translation options (default 10,000 input phrases)"); AddParam("recover-input-path", "r", "(conf net/word lattice only) - recover input path corresponding to the best translation"); AddParam("output-word-graph", "owg", "Output stack info as word graph. Takes filename, 0=only hypos in stack, 1=stack + nbest hypos"); AddParam("time-out", "seconds after which is interrupted (-1=no time-out, default is -1)"); AddParam("output-search-graph", "osg", "Output connected hypotheses of search into specified filename"); AddParam("output-search-graph-extended", "osgx", "Output connected hypotheses of search into specified filename, in extended format"); AddParam("unpruned-search-graph", "usg", "When outputting chart search graph, do not exclude dead ends. Note: stack pruning may have eliminated some hypotheses"); #ifdef HAVE_PROTOBUF AddParam("output-search-graph-pb", "pb", "Write phrase lattice to protocol buffer objects in the specified path."); #endif AddParam("cube-pruning-pop-limit", "cbp", "How many hypotheses should be popped for each stack. (default = 1000)"); AddParam("cube-pruning-diversity", "cbd", "How many hypotheses should be created for each coverage. (default = 0)"); AddParam("cube-pruning-lazy-scoring", "cbls", "Don't fully score a hypothesis until it is popped"); AddParam("parsing-algorithm", "Which parsing algorithm to use. 0=CYK+, 1=scope-3. (default = 0)"); AddParam("search-algorithm", "Which search algorithm to use. 0=normal stack, 1=cube pruning, 2=cube growing. (default = 0)"); AddParam("constraint", "Location of the file with target sentences to produce constraining the search"); AddParam("use-alignment-info", "Use word-to-word alignment: actually it is only used to output the word-to-word alignment. Word-to-word alignments are taken from the phrase table if any. Default is false."); AddParam("print-alignment-info", "Output word-to-word alignment into the log file. Word-to-word alignments are takne from the phrase table if any. Default is false"); AddParam("print-alignment-info-in-n-best", "Include word-to-word alignment in the n-best list. Word-to-word alignments are takne from the phrase table if any. Default is false"); AddParam("link-param-count", "Number of parameters on word links when using confusion networks or lattices (default = 1)"); AddParam("description", "Source language, target language, description"); AddParam("max-chart-span", "maximum num. of source word chart rules can consume (default 10)"); AddParam("non-terminals", "list of non-term symbols, space separated"); AddParam("rule-limit", "a little like table limit. But for chart decoding rules. Default is DEFAULT_MAX_TRANS_OPT_SIZE"); AddParam("source-label-overlap", "What happens if a span already has a label. 0=add more. 1=replace. 2=discard. Default is 0"); AddParam("output-hypo-score", "Output the hypo score to stdout with the output string. For search error analysis. Default is false"); AddParam("unknown-lhs", "file containing target lhs of unknown words. 1 per line: LHS prob"); AddParam("translation-systems", "specify multiple translation systems, each consisting of an id, followed by a set of models ids, eg '0 T1 R1 L0'"); AddParam("show-weights", "print feature weights and exit"); AddParam("alignment-output-file", "print output word alignments into given file"); AddParam("sort-word-alignment", "Sort word alignments for more consistent display. 0=no sort (default), 1=target order"); AddParam("start-translation-id", "Id of 1st input. Default = 0"); }
void CHooks::AddCWDParam(CString& sCmd, const CString& workingTree) { AddParam(sCmd, workingTree); }
void CHooks::AddCWDParam(CString& sCmd, const CTGitPathList& pathList) { AddParam(sCmd, pathList.GetCommonRoot().GetDirectory().GetWinPathString()); }
//----------------------------------------------------------------------------- void mglParser::AddParam(int n, const char *str) { MGL_TO_WCS(str,AddParam(n,wcs)); }
void Group::Generate(IdList<Entity,hEntity> *entity, IdList<Param,hParam> *param) { Vector gn = (SS.GW.projRight).Cross(SS.GW.projUp); Vector gp = SS.GW.projRight.Plus(SS.GW.projUp); Vector gc = (SS.GW.offset).ScaledBy(-1); gn = gn.WithMagnitude(200/SS.GW.scale); gp = gp.WithMagnitude(200/SS.GW.scale); int a, i; switch(type) { case DRAWING_3D: break; case DRAWING_WORKPLANE: { Quaternion q; if(subtype == WORKPLANE_BY_LINE_SEGMENTS) { Vector u = SK.GetEntity(predef.entityB)->VectorGetNum(); Vector v = SK.GetEntity(predef.entityC)->VectorGetNum(); u = u.WithMagnitude(1); Vector n = u.Cross(v); v = (n.Cross(u)).WithMagnitude(1); if(predef.swapUV) SWAP(Vector, u, v); if(predef.negateU) u = u.ScaledBy(-1); if(predef.negateV) v = v.ScaledBy(-1); q = Quaternion::From(u, v); } else if(subtype == WORKPLANE_BY_POINT_ORTHO) { // Already given, numerically. q = predef.q; } else oops(); Entity normal; memset(&normal, 0, sizeof(normal)); normal.type = Entity::NORMAL_N_COPY; normal.numNormal = q; normal.point[0] = h.entity(2); normal.group = h; normal.h = h.entity(1); entity->Add(&normal); Entity point; memset(&point, 0, sizeof(point)); point.type = Entity::POINT_N_COPY; point.numPoint = SK.GetEntity(predef.origin)->PointGetNum(); point.group = h; point.h = h.entity(2); entity->Add(&point); Entity wp; memset(&wp, 0, sizeof(wp)); wp.type = Entity::WORKPLANE; wp.normal = normal.h; wp.point[0] = point.h; wp.group = h; wp.h = h.entity(0); entity->Add(&wp); break; } case EXTRUDE: { AddParam(param, h.param(0), gn.x); AddParam(param, h.param(1), gn.y); AddParam(param, h.param(2), gn.z); int ai, af; if(subtype == ONE_SIDED) { ai = 0; af = 2; } else if(subtype == TWO_SIDED) { ai = -1; af = 1; } else oops(); // Get some arbitrary point in the sketch, that will be used // as a reference when defining top and bottom faces. hEntity pt = { 0 }; for(i = 0; i < entity->n; i++) { Entity *e = &(entity->elem[i]); if(e->group.v != opA.v) continue; if(e->IsPoint()) pt = e->h; e->CalculateNumerical(false); hEntity he = e->h; e = NULL; // As soon as I call CopyEntity, e may become invalid! That // adds entities, which may cause a realloc. CopyEntity(entity, SK.GetEntity(he), ai, REMAP_BOTTOM, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, true, false); CopyEntity(entity, SK.GetEntity(he), af, REMAP_TOP, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, true, false); MakeExtrusionLines(entity, he); } // Remapped versions of that arbitrary point will be used to // provide points on the plane faces. MakeExtrusionTopBottomFaces(entity, pt); break; } case LATHE: { break; } case TRANSLATE: { // The translation vector AddParam(param, h.param(0), gp.x); AddParam(param, h.param(1), gp.y); AddParam(param, h.param(2), gp.z); int n = (int)valA, a0 = 0; if(subtype == ONE_SIDED && skipFirst) { a0++; n++; } for(a = a0; a < n; a++) { for(i = 0; i < entity->n; i++) { Entity *e = &(entity->elem[i]); if(e->group.v != opA.v) continue; e->CalculateNumerical(false); CopyEntity(entity, e, a*2 - (subtype == ONE_SIDED ? 0 : (n-1)), (a == (n - 1)) ? REMAP_LAST : a, h.param(0), h.param(1), h.param(2), NO_PARAM, NO_PARAM, NO_PARAM, NO_PARAM, true, false); } } break; } case ROTATE: { // The center of rotation AddParam(param, h.param(0), gc.x); AddParam(param, h.param(1), gc.y); AddParam(param, h.param(2), gc.z); // The rotation quaternion AddParam(param, h.param(3), 30*PI/180); AddParam(param, h.param(4), gn.x); AddParam(param, h.param(5), gn.y); AddParam(param, h.param(6), gn.z); int n = (int)valA, a0 = 0; if(subtype == ONE_SIDED && skipFirst) { a0++; n++; } for(a = a0; a < n; a++) { for(i = 0; i < entity->n; i++) { Entity *e = &(entity->elem[i]); if(e->group.v != opA.v) continue; e->CalculateNumerical(false); CopyEntity(entity, e, a*2 - (subtype == ONE_SIDED ? 0 : (n-1)), (a == (n - 1)) ? REMAP_LAST : a, h.param(0), h.param(1), h.param(2), h.param(3), h.param(4), h.param(5), h.param(6), false, true); } } break; } case IMPORTED: // The translation vector AddParam(param, h.param(0), gp.x); AddParam(param, h.param(1), gp.y); AddParam(param, h.param(2), gp.z); // The rotation quaternion AddParam(param, h.param(3), 1); AddParam(param, h.param(4), 0); AddParam(param, h.param(5), 0); AddParam(param, h.param(6), 0); for(i = 0; i < impEntity.n; i++) { Entity *ie = &(impEntity.elem[i]); CopyEntity(entity, ie, 0, 0, h.param(0), h.param(1), h.param(2), h.param(3), h.param(4), h.param(5), h.param(6), false, false); } break; default: oops(); } }
//----------------------------------------------------------------------------- int mglParser::ParseDef(std::wstring &str) { if(!skip() && !str.compare(0,3,L"def") && (str[6]==' ' || str[6]=='\t')) { int res = 1; mreal d; PutArg(str,true); const std::wstring s = mgl_trim_ws(str.substr(7)); if(!str.compare(3,3,L"ine")) { int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) { AddParam(nn, mgl_trim_ws(s.substr(2)).c_str()); return 1; } } if(!str.compare(3,3,L"num")) { int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) { res = 0; HMDT dd = mglFormulaCalc(mgl_trim_ws(s.substr(2)), this, DataList); d = dd->a[0]; delete dd; char buf[32]; snprintf(buf,32,"%g",d); buf[31] = 0; AddParam(nn, buf); } return res+1; } if(!str.compare(3,3,L"chr")) { int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) { res = 0; HMDT dd = mglFormulaCalc(mgl_trim_ws(s.substr(2)), this, DataList); d=dd->a[0]; delete dd; wchar_t buf[2]={0,0}; buf[0] = wchar_t(d); AddParam(nn, buf); } return res+1; } } if(!skip() && !str.compare(0,3,L"ask") && (str[3]==' ' || str[3]=='\t')) { PutArg(str,true); std::wstring s = mgl_trim_ws(str.substr(4)); int nn = s[1]<='9' ? s[1]-'0' : (s[1]>='a' ? s[1]-'a'+10:-1); if(s[0]=='$' && nn>=0 && nn<='z'-'a'+10) { s = mgl_trim_ws(s.substr(2)); if(s[0]=='\'') s=s.substr(1,s.length()-2); if(mgl_ask_func) { static wchar_t res[1024]; mgl_ask_func(s.c_str(),res); if(*res) AddParam(nn, res); } return mgl_ask_func?1:2; } else return 2; } if(!skip() && !str.compare(0,3,L"for") && (str[3]==' ' || str[3]=='\t')) { size_t i; for(i=4;str[i]<=' ';i++); // if command have format 'for $N ...' then change it to 'for N ...' if(str[i]=='$' && str[i+1]>='0' && str[i+1]<='9') str[i] = ' '; if(str[i]=='$' && str[i+1]>='a' && str[i+1]<='z') str[i] = ' '; } return 0; }
void CWOBackendReq::AddParam(const char* name, int val) { char buf[1024]; sprintf(buf, "%d", val); AddParam(name, buf); }
//----------------------------------------------------------------------------- // return values: 0 - OK, 1 - wrong arguments, 2 - wrong command, 3 - string too long, 4 -- unclosed string int mglParser::Parse(mglGraph *gr, std::wstring str, long pos) { if(Stop || gr->NeedStop()) return 0; curGr = gr->Self(); std::wstring arg[1024]; str=mgl_trim_ws(str); long n,k=0,m=0,mm=0,res; // try parse ':' -- several commands in line for(n=0;n<long(str.length());n++) { if(str[n]=='\'' && (n==0 || str[n-1]!='\\')) k++; if(k%2) continue; if(str[n]=='(') m++; if(str[n]==')') m--; if(str[n]=='{') mm++; if(str[n]=='}') mm--; if(str[n]=='#') break; if((str[n]==':' || str[n]=='\n') && k%2==0 && m==0 && mm==0) { res=Parse(gr,str.substr(0,n),pos); if(!res) res=Parse(gr,str.substr(n+1),pos); return res; } } if(k%2 || m || mm) return 4; // strings is not closed // define parameters or start cycle res = ParseDef(str); if(res) return res-1; // parse arguments (parameters $1, ..., $9) PutArg(str,false); str=mgl_trim_ws(str); std::wstring opt; for(k=0;k<1024;k++) // parse string to substrings (by spaces) { n = mglFindArg(str); if(n<1) // this is option { if(str[-n]==';') opt = str.substr(-n+1); if(n<0) str = str.substr(0,-n); break; } arg[k] = str.substr(0,n); str = mgl_trim_ws(str.substr(n+1)); } // try to find last argument if(str[0]!=0 && str[0]!='#' && str[0]!=';') { arg[k] = str; k++; } if(k<1) n =0; else { // fill arguments by its values mglArg *a = new mglArg[k]; FillArg(gr, k, arg, a); // execute first special (program-flow-control) commands if(!skip() && !arg[0].compare(L"stop")) { Stop = true; delete []a; return 0; } if(!arg[0].compare(L"func")) { Stop = true; delete []a; return 0; } n = FlowExec(gr, arg[0].c_str(),k-1,a); if(n) { delete []a; return n-1; } if(skip()) { delete []a; return 0; } if(!arg[0].compare(L"load")) { int n = a[0].type==1?0:1; a[0].s.assign(a[0].w.begin(),a[0].w.end()); if(!n) mgl_parser_load(this,a[0].s.c_str()); delete []a; return n; } if(!arg[0].compare(L"define")) { if(k==3) { DeleteVar(arg[1].c_str()); // force to delete variable with the same name mglNum *v=AddNum(arg[1].c_str()); if(arg[2][0]=='!') // complex number is added { HADT dd = mglFormulaCalcC(arg[2].substr(1),this, DataList); v->d=NAN; v->c = dd->a[0]; delete dd; } else { HMDT dd = mglFormulaCalc(arg[2],this, DataList); v->c = v->d = dd->a[0]; delete dd; } } delete []a; return k==3?0:1; } if(!arg[0].compare(L"rkstep")) { int res=1; if(k>2 && a[0].type==1 && a[1].type==1) { std::wstring a1 = arg[1], a2=arg[2]; res = 0; if(a1[0]=='\'') a1 = a1.substr(1,a1.length()-2); if(a2[0]=='\'') a2 = a2.substr(1,a2.length()-2); mgl_rk_step_w(this, a1.c_str(), a2.c_str(), (k>=3 && a[2].type==2)?a[2].v:1); } delete []a; return res; } if(!arg[0].compare(L"call")) { n = 1; if(a[0].type==1) { int na=0; a[0].s.assign(a[0].w.begin(),a[0].w.end()); n=-IsFunc(a[0].w.c_str(),&na); if(n && k!=na+2) { char buf[64]; snprintf(buf,64,"Bad arguments for %ls: %ld instead of %d\n", a[0].w.c_str(),k-2,na); buf[63]=0; gr->SetWarn(-1,buf); n = 1; } else if(n) { mglFnStack fn; fn.pos = pos; for(int i=0;i<10;i++) { fn.par[i] = par[i]; par[i]=L""; } for(int i=1;i<k-1;i++) AddParam(i,arg[i+1].c_str()); fn_stack.push_back(fn); n--; } else if(AllowFileIO) // disable external scripts if AllowFileIO=false { FILE *fp = fopen(a[0].s.c_str(),"rt"); if(fp) { register int i; mglParser *prs = new mglParser(AllowSetSize); prs->DataList.swap(DataList); prs->NumList.swap(NumList); prs->Cmd=Cmd; for(i=10;i<30;i++) prs->AddParam(i,par[i].c_str()); prs->Execute(gr,fp); for(i=10;i<30;i++) AddParam(i,prs->par[i].c_str()); DataList.swap(prs->DataList); NumList.swap(prs->NumList); prs->Cmd=0; delete prs; fclose(fp); } else n=1; } } delete []a; return n; } if(!arg[0].compare(L"for")) { n = 1; char ch = arg[1][0]; int r = ch-'0'; if(ch>='a' && ch<='z') r = 10+ch-'a'; // int r = int(a[0].v); if(arg[1][1]==0 && (r>=0 && r<40)) { if(a[1].type==0) { n=0; fval[r] = *(a[1].d); fval[r].nx *= fval[r].ny*fval[r].nz; } else if(a[1].type==2 && a[2].type==2 && a[2].v>a[1].v) { mreal step = a[3].type==2?a[3].v:1; mm = int(step>0 ? (a[2].v-a[1].v)/step : 0); if(mm>0) { n=0; fval[r].Create(mm+1); for(int ii=0;ii<mm+1;ii++) fval[r].a[ii] = a[1].v + step*ii; } } if(n==0) { for(int i=39;i>0;i--) { for_stack[i]=for_stack[i-1]; if_for[i]=if_for[i-1]; } for_stack[0] = r+1; fval[r].nz = pos; if_for[0]=if_pos; wchar_t buf[32]; mglprintf(buf,32,L"%g",fval[r].a[0]); AddParam(r, buf); fval[r].ny = 1; } } delete []a; return n; } // alocate new arrays and execute the command itself n = PreExec(gr, k, arg, a); if(n>0) n--; else if(!arg[0].compare(L"setsize") && !AllowSetSize) n = 2; else n = Exec(gr, arg[0].c_str(),k-1,a, arg[1].c_str(), opt.c_str()); delete []a; } // delete temporary data arrays for(size_t i=0;i<DataList.size();i++) if(DataList[i] && DataList[i]->temp) { mglDataA *u=DataList[i]; DataList[i]=0; delete u; } return n; }
void VJSFunction::AddParam( const VJSONValue& inVal) { VJSValue val( fContext); val.SetJSONValue( inVal); AddParam( val); }
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ // ¥ COp_KCDeleteItem // ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ COp_KCDeleteItem::COp_KCDeleteItem() { AddParam(mItemIndex); }