QString BtTextFilter::processText(const QString &text) { if (text.isEmpty()) return text; QString localText = fixNonRichText(text); splitText(localText); fixDoubleBR(); if (m_showReferences) { int i = 0; int count = m_parts.count(); do { QString part = m_parts.at(i); if (part.startsWith("<") && part.contains("class=\"footnote\"")) { i= i + rewriteFootnoteAsLink(i, part); } else if (part.startsWith("<") && (part.contains("href=\"") ) ) { i = i + rewriteHref(i, part); } else if (part.startsWith("<") && ( part.contains("lemma=\"") ||part.contains("morph=\"") ) ) { i= i+ rewriteLemmaOrMorphAsLink(i, part); } else { i++; } } while (i < count); } return m_parts.join(""); }
void EquipMgr::initEquipMap(const char **aStrArray, int aArrayLen) { stEquipData tmp; int index=0; tmp.equipKey=atoi(aStrArray[index++]); strncpy(tmp.equipName, aStrArray[index++], MAX_NAME_STRING); tmp.equipScope=static_cast<EquipScope>(atoi(aStrArray[index++])); tmp.equipType=static_cast<EquipType>(atoi(aStrArray[index++])); tmp.isPlane=atoi(aStrArray[index++])?true:false; tmp.firePower=atoi(aStrArray[index++]); tmp.AviTorpedo=atoi(aStrArray[index++]); tmp.AviBomb=atoi(aStrArray[index++]); tmp.antiAir=atoi(aStrArray[index++]); tmp.antiSubmarine=atoi(aStrArray[index++]); tmp.searchEnemy=atoi(aStrArray[index++]); tmp.hitRate=atoi(aStrArray[index++]); tmp.dodge=atoi(aStrArray[index++]); tmp.range=static_cast<Shooting_Range>(atoi(aStrArray[index++])); tmp.armor=atoi(aStrArray[index++]); auto tempVec=splitText(aStrArray[index++],"#"); for (int i=0; i<tempVec.size(); ++i) { tmp.supKantaiType[i]=(static_cast<KantaiType>(atoi(tempVec[i].c_str()))); } equipMap[tmp.equipKey]=tmp; }
int main(int argc, char* argv[]) { if( argc != 3 ) return 3; std::string inp{argv[1]}, out{argv[2]}; std::map <std::string, int> Words; std::ifstream T{inp}; // բացում ենք ֆայլ, որտեղից պետք է կարդանք տեքստը std::ofstream F{out}; // բացում ենք ֆայլ բառարանի համար std::string Text; // string փոփոխականի մեջ պետք է կարդանք տեքստը if (!T) return 1; if (!F) return 2; while (! T.eof()) { std::getline(T, Text); splitText (Text, Words); } for (auto &w : Words) F << w.first << " " << w.second << "\n"; T.close(); F.close(); return 0; }
static void dumb_pager(const char *name, const char *data, size_t datalen) { const int MAX_PAGE_LINES = 21; char *fmt = xstrdup(_("(%0-%1 of %2 lines, see more?)")); int i = 0; int w = 0; int linecount = 0; boolean getout = false; char **lines = splitText(data, 80, &linecount, &w); assert(linecount >= 0); printf("%s\n", name); if (lines == NULL) // failed to parse?! printf("%s\n", data); // just dump it all. Oh well. else { int printed = 0; do { for (i = 0; (i < MAX_PAGE_LINES) && (printed < linecount); i++) printf("%s", lines[printed++]); if (printed >= linecount) getout = true; else { char *msg = NULL; printf("\n"); msg = format(fmt, numstr((printed-i)+1), numstr(printed), numstr(linecount)); getout = !MojoGui_stdio_promptyn("", msg, true); free(msg); printf("\n"); } // else } while (!getout); for (i = 0; i < linecount; i++) free(lines[i]); free(lines); } // while free(fmt); } // dumb_pager
// ------------------------------------------------------------------------- string SgeGridMonitor::submitJob(const string & sgePath, const string & jobFilename, const string & params, const string & gridType) { string command(sgePath); if (!command.empty()) { command += "/"; } command += "qsub "; command += params; command += " "; command += jobFilename; command += " > qstat.tmp"; DEBUG_VAR(command); system(command.c_str()); ifstream ifs("qstat.tmp", ios::binary); char buf[256]; int linecount = 0; if (ifs.good() && !ifs.eof()) { ifs.getline(buf, 256); DEBUG_VAR(buf); string jobId; if (gridType == "pbs") { jobId = buf; if (jobId.empty()) { ERROR_MSG("Unable to parse qsub output."); ERROR_MSG("qstat.tmp is empty?."); return ""; } DEBUG_VAR(jobId); return jobId; } else if (gridType == "sge") { list<string> listString; splitText(buf, listString, " \t"); list<string>::iterator itr = listString.begin(); list<string>::iterator itr_end = listString.end(); //DEBUG_VAR(listString.size()); if (listString.size() < 5) { ERROR_MSG("Unable to parse qsub output."); ERROR_MSG("Not enough [" << listString.size() << "] entries in file."); return ""; } for (int count = 0; itr != itr_end; itr++,count++) { if (count == 2) { jobId = *itr; return jobId; } } } else { ERROR_MSG("Unknown grid type"); return ""; } } // if (ifs.good() && !ifs.eof()) return ""; }
// ------------------------------------------------------------------------- bool SgeGridMonitor::refreshInfo(const string & sgePath) { //DEBUG_TRACE; jobs.clear(); string command(sgePath); if (!command.empty()) { command += "/"; } command += "qstat > qstat.tmp"; DEBUG_VAR(command); system(command.c_str()); ifstream ifs("qstat.tmp", ios::binary); char buf[256]; int linecount = 0; while (ifs.good() && !ifs.eof()) { ifs.getline(buf, 256); // Skip the first two lines.. they are headed info linecount++; if (linecount < 3) { continue; } if (strlen(buf) == 0) { continue; } DEBUG_VAR(buf); list<string> listString; splitText(buf, listString, " \t"); //DEBUG_VAR(listString.size()); if (listString.size() < 5) { ERROR_MSG("Unable to parse qstat output"); return false; } list<string>::iterator itr = listString.begin(); list<string>::iterator itr_end = listString.end(); string jobId; string status; for (int count = 0; itr != itr_end; itr++,count++) { if (count == 0) { jobId = *itr; //DEBUG_VAR(jobId); } if (count == 4) { status = *itr; //DEBUG_VAR(status); } } SgeGridMonitor::JobStatus js = JS_UNKNOWN; if (status == "d") { js = JS_DELETION; } else if (status == "E") { js = JS_ERROR; } else if (status == "h") { js = JS_HOLD; } else if (status == "r" || status == "R" || status == "t" ) { js = JS_RUNNING; } else if (status == "R") { js = JS_RESTARTED; } else if (status == "s" || status == "S"|| status == "T") { js = JS_SUSPENDED; } else if (status == "w" || status == "qw") { js = JS_WAITING; } jobs[jobId] = js; } return false; }
int SpecCheckInterface::processOptions(int argc, char **argv) { //-------------------------------------------------------------------------------------------- // Initialize directories used //-------------------------------------------------------------------------------------------- //-------------------------------------------------------------------------------------------- // Parse the command line parameters //-------------------------------------------------------------------------------------------- vector<CommandLineParser::Option> listOptions; // c++ instruction cmd line option parameter name takes value? listOptions.push_back(CommandLineParser::Option("-help", "help", false)); listOptions.push_back(CommandLineParser::Option("-version", "VERSION", false)); listOptions.push_back(CommandLineParser::Option("-input-list", "INPUT_LIST", true)); listOptions.push_back(CommandLineParser::Option("-inputspectra", "INPUT_SPECS_MS", true)); // parameter file listOptions.push_back(CommandLineParser::Option("-p", "PARAMETER_FILE", true)); //////////////////////////////////////////////////////////////////////////////// // Execute the command line parser CommandLineParser clp(argc, argv, 0, listOptions); //////////////////////////////////////////////////////////////////////////////// // Checking for errors string parser_error; if (!clp.validate(parser_error)) { ERROR_MSG(parser_error); return -1; } //////////////////////////////////////////////////////////////////////////////// // The parameters' values ParameterList commandLineParams; clp.getOptionsAsParameterList(commandLineParams); //////////////////////////////////////////////////////////////////////////////// // Parameter file //////////////////////////////////////////////////////////////////////////////// if (commandLineParams.exists("PARAMETER_FILE")) { string parameterFilename = commandLineParams.getValue("PARAMETER_FILE"); ParameterList ip; ip.readFromFile(parameterFilename); // Combine the command line parameters to the file ones // Command line parameters take precedence (hence the overwrite flag not set) commandLineParams.addList(ip, false); } //////////////////////////////////////////////////////////////////////////////// // "help" prints help and exits if (commandLineParams.exists("VERSION")) return version(cout); //////////////////////////////////////////////////////////////////////////////// // the same for "version" if (commandLineParams.exists("help")) return help(cout); //////////////////////////////////////////////////////////////////////////////// // File load section // input spectra file to load if (commandLineParams.exists("INPUT_LIST")) { inputFilesNames = commandLineParams.getValue("INPUT_LIST").c_str(); // load input files names if(!loadStringVector(inputFilesNames, inputFiles)) { cerr << "Unable to load file: " << inputFilesNames << endl; exit(0); } } if (commandLineParams.exists("INPUT_SPECS_MS")) { string aux = commandLineParams.getValue("INPUT_SPECS_MS").c_str(); splitText(aux.c_str(), inputFiles, ";|"); } // Keep record of loaded files int filesLoaded = 0; cout << "Loading " << inputFiles.size() << " files." << endl; for(int i = 0 ; i < inputFiles.size() ; i++) { SpecSet spec; if(loadSpecset(inputFiles[i], spec)) { inputData.push_back(spec); filesLoaded++; } } cout << filesLoaded << " files loaded." << endl; // exit if no file was loaded if(!filesLoaded) { cerr << "No file loaded." << endl; return 0; } //////////////////////////////////////////////////////////////////////////////// // Processing section // check for zero PM cout << "Checking " << inputData.size() << " specsets." << endl; for(int i = 0 ; i < inputData.size() ; i++) { cout << " #" << i << " Checking " << inputData[i].size() << " spectra." << endl; vector<int> aux; for(int j = 0 ; j < inputData[i].size() ; j++) { if(inputData[i][j].parentMass < 2.0) { aux.push_back(j); cout << "found: " << i << " ; " << j << " -> " << inputData[i][j].parentMass << endl; } //else // cout << "value: " << i << " ; " << j << " -> " << inputData[i][j].parentMass << " - " << inputData[i][j].parentMZ << endl; } if(aux.size()) invalid.insert(pair<int, vector<int> >(i, aux)); } //////////////////////////////////////////////////////////////////////////////// // output section map<int, vector<int> >::iterator it; for(it = invalid.begin() ; it != invalid.end() ; it++) { int fileIdx = it->first; string fn = inputFiles[fileIdx]; cout << "------- " << fn << " -------" << endl; for(int i = 0 ; i > it->second.size() ; i++) { if(!i) cout << " ; "; cout << it->second[i]; } cout << endl; } // return status ok return 0; }