bool CutTool::mouseReleaseEvent(QMouseEvent* event, MapCoordF map_coord, MapWidget* widget) { if (path_tool) return path_tool->mouseReleaseEvent(event, map_coord, widget); if (event->button() != Qt::LeftButton) return false; if (dragging) { updateDragging(map_coord, widget); if (dragging_on_line) { Q_ASSERT(edit_object->getType() == Object::Path); splitLine(edit_object, drag_part_index, drag_start_len, drag_end_len); } deletePreviewPath(); dragging = false; } else { PathCoord split_pos; if (findEditPoint(split_pos, edit_object, map_coord, (int)Symbol::Line, 0, widget)) { Q_ASSERT(edit_object->getType() == Object::Path); splitLine(edit_object, split_pos); } } setEditingInProgress(false); return true; }
Image::Image(const char * path) { std::ifstream imageIs(path); if (!imageIs) { fprintf(stderr, "Loading image fail.\n"); return; } std::string line; getNextLine(imageIs, line); auto vs = splitLine(line); width = std::stoi(vs[1]); getNextLine(imageIs, line); vs = splitLine(line); height = std::stoi(vs[1]); image = new uint32_t[width*height]; for (int i = 0; i != height; ++i) { getNextLine(imageIs, line); //vs = splitLine(line); std::istringstream iss(line); for (int j = 0; j != width; ++j) { uint32_t value; iss >> value; image[i*width + j] = value; } } }
void fillCode (FILE *file) { char line[8] ={0}; int i = 0; char *terms[3]={0}; while (fgets(line, sizeof(line), file) ) { // printLine(line); IR inst; //split input line using space a delim splitLine(line, terms); //generate instruction object using values in terms[] generateInst(&inst, terms, i); //set current code index to new inst obj code[i] = inst; //clear line in memory memset(&line[0], 0, sizeof(line)); i++; } CURRENT_CODE_LENGTH = i; stack[0] = (int) &code; }
double Core::extract_time(QString line){ QStringList list =splitLine(line); return (list.at(1)).toDouble(); }
int main(int argc, char* argv[]) { if (argc != 2) { std::cout << "ERROR! The program requires 1 argument, but " << argc - 1 << " were provided." << std::endl; std::cout << "Usage: " << argv[0] << " path_to_phrase_table." << std::endl; } //Read the file util::FilePiece filein(argv[1]); unsigned long uniq_lines = 0; line_text prev_line; while (true){ line_text new_line; try { //Process line read new_line = splitLine(filein.ReadLine()); } catch (util::EndOfFileException e){ std::cout << "End of file" << std::endl; break; } if (new_line.source_phrase == prev_line.source_phrase){ continue; } else { uniq_lines++; prev_line = new_line; } } std::cout << "Number of unique lines is: " << uniq_lines << std::endl; return 1; }
void CommandInterpretor::buildTree(std::string file){ std::vector<Command*> res; std::ifstream flux(file.c_str()); if (flux){ std::string line; std::string commandName; std::vector<std::string> commands; while (getline(flux,line)){ std::vector<std::string> splitted=splitLine(line); if (splitted[0]=="<command"){ commandName=splitted[1].substr(0,splitted[1].size()-1); }else if(splitted[0]=="</command>"){ std::vector<std::string> copy; for(unsigned i(0);i<commands.size();++i){ copy.push_back(commands[i]); } commands=std::vector<std::string>(); Command* toAdd=new Command(commandName,copy); res.push_back(toAdd); }else if(line.size()>=1){ commands.push_back(line); } } }else{ throw("[Erreur] Didn't succeed in opening .xml file"); } this->commands_=res; }
QString KicadSchematic2Svg::convertRect(const QString & line) { QStringList s = splitLine(line); if (s.count() < 8) { DebugDialog::debug(QString("bad rectangle %1").arg(line)); return ""; } if (s.count() < 9) { s.append("N"); // assume it's unfilled } int x = s[1].toInt(); int y = -s[2].toInt(); // KiCad flips y-axis w.r.t. svg int x2 = s[3].toInt(); int y2 = -s[4].toInt(); // KiCad flips y-axis w.r.t. svg checkXLimit(x); checkXLimit(x2); checkYLimit(y); checkYLimit(y2); QString rect = QString("<rect x='%1' y='%2' width='%3' height='%4' ") .arg(qMin(x, x2)) .arg(qMin(y, y2)) .arg(qAbs(x2 - x)) .arg(qAbs(y2 - y)); rect += addFill(line, s[8], s[7]); rect += " />\n"; return rect; }
// Process SSH Service Lines void processSOSSSH(char *line, struct nipperConfig *nipper) { // Variables struct ciscoCommand command; // Debug Output if (nipper->debugMode == true) printf("SSH Line: %s\n", line); // Init command = splitLine(line); // Version? if (strcasecmp(command.part[2], "version") == 0) { if (strcasecmp(command.part[3], "v1") == 0) nipper->sos->sshVersion = 1; else if (strcasecmp(command.part[3], "v2") == 0) nipper->sos->sshVersion = 2; } // Enabled? else if (strcasecmp(command.part[2], "enable") == 0) nipper->sos->sshEnabled = true; // SSH v1 Key Gen Time else if (strcasecmp(command.part[2], "key-gen-time") == 0) nipper->sos->sshKeyGenTime = atoi(command.part[3]); // SSH v2 Public Key else if (strcasecmp(command.part[2], "pub-key") == 0) strncpy(nipper->sos->sshPublicKey, command.part[3], sizeof(nipper->sos->sshPublicKey) - 1); }
QString KicadSchematic2Svg::convertCircle(const QString & line) { QStringList s = splitLine(line); if (s.count() < 8) { DebugDialog::debug(QString("bad circle %1").arg(line)); return ""; } int x = s[1].toInt(); int y = -s[2].toInt(); // KiCad flips y-axis w.r.t. svg int r = s[3].toInt(); checkXLimit(x + r); checkXLimit(x - r); checkYLimit(y + r); checkYLimit(y - r); QString circle = QString("<circle cx='%1' cy='%2' r='%3' ") .arg(x) .arg(y) .arg(r); circle += addFill(line, s[7], s[6]); circle += " />\n"; return circle; }
/* Receives a message from the server. */ int twitClient::receiveFromServer(char* buf,std::vector<std::string>& clientsNames) { std::string msg; std::vector<std::string> tokens; msg.assign(buf); splitLine(msg,tokens); std::set<std::string> receiveOptions; _session.messageToReceive(receiveOptions); if (receiveOptions.find(tokens.at(0)) == receiveOptions.end()) { std::cout << SERVER_ERROR_PRINT << std::endl; return FAILURE_EXIT; } messageToPrint(tokens,clientsNames); if (tokens.at(0) == WHO) { clientsNames.push_back(tokens.at(1)); } _session.setPreviousReceiveMessage(tokens.at(0)); if (tokens.at(0) == NAME_USED) { return FAILURE_EXIT; } if (tokens.at(0) == EXIT) { return SUCCESS_EXIT; } return NOT_EXIT; }
QString KicadSchematic2Svg::convertText(const QString & line) { QStringList fs = splitLine(line); if (fs.count() < 8) { DebugDialog::debug("bad text " + line); return ""; } return convertField(fs[2], fs[3], fs[4], fs[1], "C", "C", fs[8]); }
void InsertMacro(CMacro* Macro, std::wstring& Args) { tTextData Text; ArgumentList Arguments; splitArguments(Arguments,Args); if ((int)Arguments.size() != Macro->getArgumentCount()) { Logger::printError(Logger::Error,L"%s macro arguments (%d vs %d)", (int)Arguments.size() > Macro->getArgumentCount() ? L"Too many" : L"Not enough", Arguments.size(),Macro->getArgumentCount()); return; } Global.MacroNestingLevel++; if (Global.MacroNestingLevel == ASSEMBLER_MACRO_NESTING_LEVEL) { Logger::printError(Logger::Error,L"Maximum macro nesting level reached"); return; } int MacroCounter = Macro->getIncreaseCounter(); for (int i = 0; i < Macro->getLineCount(); i++) { Text.buffer = Macro->getLine(i,Arguments,MacroCounter); Text.buffer = Global.symbolTable.insertEquations(Text.buffer,Global.FileInfo.FileNum,Global.Section); if (CheckEquLabel(Text.buffer) == false) { Text.buffer = checkLabel(Text.buffer,false); splitLine(Text.buffer,Text.name,Text.params); if (Text.name.size() == 0) continue; bool macro = false; for (size_t i = 0; i < Global.Macros.size(); i++) { if (Text.name.compare(Global.Macros[i]->getName()) == 0) { InsertMacro(Global.Macros[i],Text.params); macro = true; } } if (macro == true) continue; if (Arch->AssembleDirective(Text.name,Text.params) == false) { Arch->AssembleOpcode(Text.name,Text.params); } } } Global.MacroNestingLevel--; }
/* *Cette fonction vient lire chaque ligne et extrait time *et DeltaTCP pour chaque trame. Elle stocke cette info dans une QStringList. *Elle s'occupe aussi d'enregistrer les logs dans le fichier report.csv */ void Core::process_line(QString line){ QStringList list =splitLine(line); double deltaTCP = extractDeltaTCP(list); _DeltaTcpList.append(deltaTCP); double time = extract_time(line); report(time,deltaTCP); }
bool ExternalFileDataParser::getLineVariableValue(const std::string & line, std::string & value) { boost::char_separator<char> separator("="); boost::tokenizer<boost::char_separator<char>> tokens(line, separator); std::vector<std::string> splitLine(std::begin(tokens), std::end(tokens)); if (2 != splitLine.size()) { return false; } value = splitLine.back(); return true; }
QString KicadSchematic2Svg::convertPoly(const QString & line) { QStringList s = splitLine(line); if (s.count() < 6) { DebugDialog::debug(QString("bad poly %1").arg(line)); return ""; } int np = s[1].toInt(); if (np < 2) { DebugDialog::debug(QString("degenerate poly %1").arg(line)); return ""; } if (s.count() < (np * 2) + 5) { DebugDialog::debug(QString("bad poly (2) %1").arg(line)); return ""; } if (s.count() < (np * 2) + 6) { s.append("N"); // assume unfilled } int ix = 5; if (np == 2) { int x1 = s[ix++].toInt(); int y1 = -s[ix++].toInt(); // KiCad flips y-axis w.r.t. svg int x2 = s[ix++].toInt(); int y2 = -s[ix++].toInt(); // KiCad flips y-axis w.r.t. svg checkXLimit(x1); checkYLimit(y1); checkXLimit(x2); checkYLimit(y2); QString line = QString("<line x1='%1' y1='%2' x2='%3' y2='%4' ").arg(x1).arg(y1).arg(x2).arg(y2); line += addFill(line, s[ix], s[4]); line += " />\n"; return line; } QString poly = "<polyline points='"; for (int i = 0; i < np; i++) { int x = s[ix++].toInt(); int y = -s[ix++].toInt(); // KiCad flips y-axis w.r.t. svg checkXLimit(x); checkYLimit(y); poly += QString("%1,%2,").arg(x).arg(y); } poly.chop(1); poly += "' "; poly += addFill(line, s[ix], s[4]); poly += " />\n"; return poly; }
void LoadAssemblyFile(const std::wstring& fileName, TextFile::Encoding encoding) { tTextData Text; int num = 0; AddFileName((char*)convertWStringToUtf8(fileName).c_str()); Global.IncludeNestingLevel++; if (Global.IncludeNestingLevel == ASSEMBLER_INCLUDE_NESTING_LEVEL) { Logger::printError(Logger::Error,L"Maximum include nesting level reached"); return; } TextFile input; if (input.open(fileName,TextFile::Read,encoding) == false) { Logger::printError(Logger::Error,L"Could not open file"); return; } while (!input.atEnd()) { Global.FileInfo.LineNumber++; Global.FileInfo.TotalLineCount++; if (GetLine(input,Text.buffer) == false) continue; if (Text.buffer.size() == 0) continue; Text.buffer = Global.symbolTable.insertEquations(Text.buffer,Global.FileInfo.FileNum,Global.Section); if (CheckEquLabel(Text.buffer) == false) { Text.buffer = checkLabel(Text.buffer,false); splitLine(Text.buffer,Text.name,Text.params); if (Text.name.empty()) continue; if (ParseMacro(input,Text.name,Text.params) == true) continue; if (Arch->AssembleDirective(Text.name,Text.params) == false) { Arch->AssembleOpcode(Text.name,Text.params); } } if (Logger::hasFatalError()) return; } Logger::printQueue(); Global.IncludeNestingLevel--; input.close(); }
/** * Displays a command line and processes the commands entered. * * \retval 0 stdin was closed. * \retval 2 The user typed exit or quit. */ int Boomerang::cmdLine() { char line[1024]; printf("boomerang: "); fflush(stdout); while (fgets(line, sizeof(line), stdin)) { char **argv; int argc = splitLine(line, &argv); if (parseCmd(argc, (const char **)argv) == 2) return 2; printf("boomerang: "); fflush(stdout); } return 0; }
FinancialAsset buildFinancialAsset(char *line) { char **split = splitLine(line, ";"); FinancialAsset fa; fa.fundType = *split[0]; fa.assetType = getAssetType(split[2]); fa.amount = stringToDouble(split[3]); fa.rate = stringToDouble(split[4]); fa.price = stringToDouble(split[5]); fa.daysUntilValid = stringToInt(split[6]); free(split); return fa; }
bool WatchersDialog::parseWatchers(CvsService_stub* cvsService, const QStringList& files) { setCaption(i18n("CVS Watchers")); DCOPRef job = cvsService->watchers(files); if( !cvsService->ok() ) return false; ProgressDialog dlg(this, "Watchers", job, "watchers", i18n("CVS Watchers")); if( !dlg.execute() ) return false; QString line; int numRows = 0; while( dlg.getLine(line) ) { // parse the output line QStringList list = splitLine(line); // ignore empty lines and unknown files if( list.isEmpty() || list[0] == "?" ) continue; // add a new row to the table table->setNumRows(numRows + 1); table->setText(numRows, 0, list[0]); table->setText(numRows, 1, list[1]); QCheckTableItem* item = new QCheckTableItem(table, ""); item->setChecked(list.contains("edit")); table->setItem(numRows, 2, item); item = new QCheckTableItem(table, ""); item->setChecked(list.contains("unedit")); table->setItem(numRows, 3, item); item = new QCheckTableItem(table, ""); item->setChecked(list.contains("commit")); table->setItem(numRows, 4, item); ++numRows; } return true; }
int shell_exe(char* cmd, int input, int first, int last) { int i; splitLine(cmd); if (args[0] != NULL) { for (i = 0; i < builtins_Size(); i++) { if (strcmp(args[0], builtin_str[i]) == 0) { return (*builtin_func[i])(args); } } timesCommandWasCalled += 1; return sys_exe(input, first, last); } return 0; }
void processPASInput(struct nipperConfig *nipper, char *line) { // Variables... struct ciscoCommand command; // Split the command line up command = splitLine(line); // Software Version if ((strcmp(command.part[0], "#") == 0) && (strcmp(command.part[1], "software") == 0) && (strcmp(command.part[2], "version") == 0) && (strcmp(command.part[3], ":") == 0)) processSoftwarePAS(line, nipper); // Box Type else if ((strcmp(command.part[0], "#") == 0) && (strcmp(command.part[1], "box") == 0) && (strcmp(command.part[2], "type") == 0) && (strcmp(command.part[3], ":") == 0)) processBoxTypePAS(line, nipper); // Monitor Version else if ((strcmp(command.part[0], "#") == 0) && (strcmp(command.part[1], "monitor") == 0) && (strcmp(command.part[2], "version") == 0) && (strcmp(command.part[3], ":") == 0)) processMonitorPAS(line, nipper); // IP Commands... else if (strcmp(command.part[0], "ip") == 0) { // Traffic Filter Commands... if (strcmp(command.part[1], "traffic-filter") == 0) { // Create ... if (strcmp(command.part[2], "create") == 0) processCreateFilterPAS(line, nipper); // Filter ... else if (strcmp(command.part[2], "filter") == 0) processFilterPAS(line, nipper); // Filter Set... else if ((strcmp(command.part[2], "set") == 0) || (strcmp(command.part[2], "global-set") == 0)) processFilterSetPAS(line, nipper); } } // Debug (lines not processed) else if (nipper->linesnotprocessed == true) printf("%s\n", line); }
/* Gets commands from the user. */ bool twitClient::getCommands() { std::string line = EMPTY; std::stringstream stringStream; std::vector<std::string> tokens; std::getline(std::cin,line); splitLine(line,tokens); int finishVal = performCommand(tokens); stringStream.clear(); tokens.clear(); if (finishVal == FINISH) { return true; } return false; }
QString KicadSchematic2Svg::convertField(const QString & line) { QStringList fs = splitLine(line); if (fs.count() < 7) { DebugDialog::debug("bad field " + line); return ""; } if (fs[6] == "I") { // invisible return ""; } while (fs.count() < 9) { fs.append(""); } return convertField(fs[2], fs[3], fs[4], fs[5], fs[7], fs[8], fs[1]); }
char* processCommand(char* request){ char** commands = splitLine(request, " "); if (*commands != NULL && strcmp("create", commands[0]) == 0){ int res = createTask(commands[1], commands[2]); if (res == 1) return "Task created successfully"; return "Task creation failed"; } /*else if (*commands != NULL && commands[1] != NULL && strcmp("get", commands[0]) == 0){ printf("Getting\n"); char* task = getTask(commands[1]); if (task != NULL) return task; return "Failed to get task"; }*/ else return "Unknown command"; }
void SludgeFloorMaker::button1Release(int local_pointx, int local_pointy) { int xx, yy; awaitButton1Release = FALSE; selx2 = xx = (local_pointx+x)*zmul; sely2 = yy = (local_pointy-y)*zmul; lit = snapToClosest(&xx, &yy, getFloor()); litX = xx; litY = yy; if (lit && (xx != selx1 || yy != sely1)) { selx2 = xx; sely2 = yy; } selection = 0; switch (mode) { case 1: // Move vertices if (moveVertices(selx1, sely1, selx2, sely2, getFloor())) { setFileChanged(); } else { errorBox("Can't move vertex", "Sorry - that vertex is already contained in one or more of the polygons you're changing."); return; } break; case 4: // Split lines splitLine(selx1, sely1, selx2, sely2, getFloor()); setFileChanged(); break; case 5: // Split segments struct polyList * firstPoly = getFloor(); splitPoly(selx1, sely1, selx2, sely2, &firstPoly); setFloor(firstPoly); setFileChanged(); break; } }
// File Methods bool IniReader::readFromFile(const std::string &filename) { std::string line; std::ifstream file(filename); std::regex brackets("\\[.*\\]"); std::string currentSection; if(file) { while(std::getline(file, line)) { if(std::regex_match(line, brackets)) { currentSection = line.substr(1, line.size()-2); } else if(!currentSection.empty()) { std::vector<std::string> result = splitLine(line, '='); if(result.size() == 2) { iniContainer[currentSection][result[0]] = result[1]; } else { // invalid entry } } else { // ini doesn't start with a section } } file.close(); return true; } else { // file doesn't exist return false; } }
vector<Token> TokenizerEn::processSentence(const wstring& i_sentence, vector<wstring>& o_content, vector<size_t>& o_positions) const { o_content.clear(); o_positions.clear(); splitLine(i_sentence, o_content, o_positions); vector<Token> tokens = fillSourceTokens(i_sentence, o_content, o_positions); for(size_t index = 0; index < o_content.size(); index++) { o_content[index] = replaceBracketsAndSpecialCharacters(o_content[index]); } replaceQuotations(i_sentence, o_positions, o_content ); for(size_t index = 0; index < tokens.size(); index++) { tokens[index].content = o_content[index]; } return tokens; }
const void *nextRow() { RtlDynamicRowBuilder row(allocator); loop { if (eoi || activity.abortSoon) return NULL; unsigned lineLength = splitLine(); if (!lineLength) return NULL; size32_t res = activity.helper->transform(row, csvSplitter.queryLengths(), (const char * *)csvSplitter.queryData()); inputStream->skip(lineLength); if (res != 0) { localOffset += lineLength; ++activity.diskProgress; return row.finalizeRowClear(res); } } }
void WatchersModel::parseData(const QStringList& data) { foreach( const QString &line, data ) { // parse the output line QStringList list = splitLine(line); // ignore empty lines and unknown files if( list.isEmpty() || list[0] == "?" ) continue; WatchersEntry entry; entry.file = list[0]; entry.watcher = list[1]; entry.edit = list.contains("edit"); entry.unedit = list.contains("unedit"); entry.commit = list.contains("commit"); m_list.append(entry); }
void CvrpFileReader::processNextLine() { QString l_line = m_file->readLine(); if (l_line.isNull()) { // qDebug() << "END OF FILE reached."; return; } QStringList l_wordList = splitLine(l_line); removeWhiteSpaces(l_wordList); if (l_wordList.isEmpty()) { // qDebug() << "Skipped empty line"; return; } processLine(l_wordList, l_line); }