void ToolsConfigWidget::readConfig() { readGroup("Tool Menu", &m_toolsmenuEntries); readGroup("File Context", &m_filecontextEntries); readGroup("Dir Context", &m_dircontextEntries); updateListBoxes(); }
static void activateCB_pushButton11( Widget wgt, XtPointer cd, XtPointer cb) { _UxCgroupNamesForm *UxSaveCtx, *UxContext; Widget UxWidget = wgt; XtPointer UxClientData = cd; XtPointer UxCallbackArg = cb; UxSaveCtx = UxGroupNamesFormContext; UxGroupNamesFormContext = UxContext = (_UxCgroupNamesForm *) UxGetContext(UxWidget); { DMAN_GROUPNAMES g; CONDITION cond; cond = readGroup(&g); if (cond != 1) { COND_DumpConditions(); return; } cond = DMAN_Delete(&dmanHandle, (DMAN_GENERICRECORD *) & g); if (cond != DMAN_NORMAL) COND_DumpConditions(); loadGroupGroupList(); loadGroupTitleList(g.GroupName); } UxGroupNamesFormContext = UxSaveCtx; }
/** * Add a new group definition to the ELSTABLE. Returns 0 if OK, -1 if parsing FORMULA * fails. Assumes the syntax of grpname is correct. */ QString KMolCalc::defineGroup (const QString& grpname, const QString& formula) { ElementList* els = new ElementList(grpname); QString error = readGroup(formula, els); if (error != "OK") return error; if (els->contains(grpname)) return QString("Can't define a group recursively!\n"); elstable->replace(grpname, els); return QString("OK"); }
int ListSeqsCommand::execute(){ try { if (abort) { if (calledHelp) { return 0; } return 2; } //read functions fill names vector if (fastafile != "") { inputFileName = fastafile; readFasta(); } else if (fastqfile != "") { inputFileName = fastqfile; readFastq(); } else if (namefile != "") { inputFileName = namefile; readName(); } else if (groupfile != "") { inputFileName = groupfile; readGroup(); } else if (alignfile != "") { inputFileName = alignfile; readAlign(); } else if (listfile != "") { inputFileName = listfile; readList(); } else if (taxfile != "") { inputFileName = taxfile; readTax(); } else if (countfile != "") { inputFileName = countfile; readCount(); } if (m->getControl_pressed()) { outputTypes.clear(); return 0; } //sort in alphabetical order sort(names.begin(), names.end()); if (outputDir == "") { outputDir += util.hasPath(inputFileName); } map<string, string> variables; variables["[filename]"] = outputDir + util.getRootName(util.getSimpleName(inputFileName)); string outputFileName = getOutputFileName("accnos", variables); util.printAccnos(outputFileName, names); outputNames.push_back(outputFileName); outputTypes["accnos"].push_back(outputFileName); if (m->getControl_pressed()) { outputTypes.clear(); util.mothurRemove(outputFileName); return 0; } current->setAccnosFile(outputFileName); m->mothurOut("\nOutput File Names: \n"); m->mothurOut(outputFileName); m->mothurOutEndLine(); m->mothurOutEndLine(); //set accnos file as new current accnosfile string currentName = ""; itTypes = outputTypes.find("accnos"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { currentName = (itTypes->second)[0]; current->setAccnosFile(currentName); } } return 0; } catch(exception& e) { m->errorOut(e, "ListSeqsCommand", "execute"); exit(1); } }
int main(int argc, const char * argv[]) { Tgroup contestants; int size = readGroup(&contestants); int winner_index = findLeast_time(contestants, size); calc_timeLag(&contestants, size, winner_index); printf("\nThe winner is:\n\n"); printWinners(contestants, size, winner_index); printf("\nThe result list:\n\n"); printLoosers(contestants, size, winner_index); printf("\n\n"); return 0; }
void SearchGroup::read(SearchXmlCachingReader& reader) { reset(); m_label->setGroupOperator(reader.groupOperator()); m_label->setDefaultFieldOperator(reader.defaultFieldOperator()); startReadingGroups(reader); while (!reader.atEnd()) { reader.readNext(); if (reader.isEndElement()) { break; } // subgroup if (reader.isGroupElement()) { readGroup(reader); } if (reader.isFieldElement()) { QString name = reader.fieldName(); SearchField* field = 0; SearchFieldGroup* fieldGroup = 0; foreach(fieldGroup, m_fieldGroups) { if ((field = fieldGroup->fieldForName(name))) { break; } } if (field) { field->read(reader); fieldGroup->markField(field); fieldGroup->setFieldsVisible(true); } else { qCWarning(DIGIKAM_GENERAL_LOG) << "Unhandled search field in XML with field name" << name; reader.readToEndOfElement(); } } }
void SVGReader::readSVG(void) { Q_ASSERT(mXml.isStartElement() && mXml.name() == "svg"); while (mXml.readNextStartElement()) { if (mXml.name() == "g") { readGroup(); } else if (mXml.name() == "desc" && mXml.attributes().value("version").toString().toDouble() > 0.4) { readDesc(); } else { mXml.skipCurrentElement(); } } }
bool JsonFileReader::read(const std::string &fileDir) { QFile loadFile(QString::fromUtf8(fileDir.c_str())); if (!loadFile.open(QIODevice::ReadOnly)) { return false; } QByteArray saveData = loadFile.readAll(); QJsonDocument loadDoc(QJsonDocument::fromJson(saveData)); QJsonObject jsonObj = loadDoc.object(); QJsonArray canvasShapes = jsonObj["CanvasShapes"].toArray(); readGroup(m_mainGroup, canvasShapes); return true; }
MeshData* LoadObj::readObjFile(std::string pObj) { bool first = true; fstream f(pObj.c_str()); string tmp; if(f) { while(f.eof() != true) { f >> tmp; if(tmp == "v") readVertices(f); if(tmp == "vt") readTexC(f); if(tmp == "vn") readNormal(f); if(tmp == "f") readFaces(f); if(tmp == "mtllib") readMtl(f); if(tmp == "g") readGroup(f); if(f.eof()) break; } } MeshData* data = new MeshData(); data->position = position; data->textureCoordinate = textureCoordinate; data->normal = normal; data->vertices = vertices; data->indices = indices; reset(); return data; }
void ContactsReader::readQNS(void) { Q_ASSERT(isStartElement() && name() == "qns"); while (!atEnd()) { readNext(); if (isEndElement()) break; if (isStartElement()) { if (name() == "Group") readGroup(0); else if (name() == "Contact") readContact(0); else if (name() == "BlockedContact") readBlocked(); else readUnknownElement(); } } }
int GetSeqsCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } //get names you want to keep names = m->readAccnos(accnosfile); if (m->control_pressed) { return 0; } if (countfile != "") { if ((fastafile != "") || (listfile != "") || (taxfile != "")) { m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n"); } } //read through the correct file and output lines you want to keep if (namefile != "") { readName(); } if (fastafile != "") { readFasta(); } if (fastqfile != "") { readFastq(); } if (groupfile != "") { readGroup(); } if (countfile != "") { readCount(); } if (alignfile != "") { readAlign(); } if (listfile != "") { readList(); } if (taxfile != "") { readTax(); } if (qualfile != "") { readQual(); } if (accnosfile2 != "") { compareAccnos(); } if (m->debug) { runSanityCheck(); } if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); //set fasta file as new current fastafile string current = ""; itTypes = outputTypes.find("fasta"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } } itTypes = outputTypes.find("name"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } } itTypes = outputTypes.find("group"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } } itTypes = outputTypes.find("list"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } } itTypes = outputTypes.find("taxonomy"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } } itTypes = outputTypes.find("qfile"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setQualFile(current); } } itTypes = outputTypes.find("count"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setCountTableFile(current); } } } return 0; } catch(exception& e) { m->errorOut(e, "GetSeqsCommand", "execute"); exit(1); } }
int RemoveGroupsCommand::execute(){ try { if (abort == true) { if (calledHelp) { return 0; } return 2; } //get groups you want to remove if (accnosfile != "") { m->readAccnos(accnosfile, Groups); m->setGroups(Groups); } if (groupfile != "") { groupMap = new GroupMap(groupfile); groupMap->readMap(); //make sure groups are valid //takes care of user setting groupNames that are invalid or setting groups=all vector<string> namesGroups = groupMap->getNamesOfGroups(); vector<string> checkedGroups; for (int i = 0; i < Groups.size(); i++) { if (m->inUsersGroups(Groups[i], namesGroups)) { checkedGroups.push_back(Groups[i]); } else { m->mothurOut("[WARNING]: " + Groups[i] + " is not a valid group in your groupfile, ignoring.\n"); } } if (checkedGroups.size() == 0) { m->mothurOut("[ERROR]: no valid groups, aborting.\n"); delete groupMap; return 0; } else { Groups = checkedGroups; m->setGroups(Groups); } //fill names with names of sequences that are from the groups we want to remove fillNames(); delete groupMap; }else if (countfile != ""){ if ((fastafile != "") || (listfile != "") || (taxfile != "")) { m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n"); } CountTable ct; ct.readTable(countfile, true, false); if (!ct.hasGroupInfo()) { m->mothurOut("[ERROR]: your count file does not contain group info, aborting.\n"); return 0; } vector<string> gNamesOfGroups = ct.getNamesOfGroups(); SharedUtil util; util.setGroups(Groups, gNamesOfGroups); vector<string> namesOfSeqs = ct.getNamesOfSeqs(); sort(Groups.begin(), Groups.end()); for (int i = 0; i < namesOfSeqs.size(); i++) { vector<string> thisSeqsGroups = ct.getGroups(namesOfSeqs[i]); if (m->isSubset(Groups, thisSeqsGroups)) { //you only have seqs from these groups so remove you names.insert(namesOfSeqs[i]); } } } if (m->control_pressed) { return 0; } //read through the correct file and output lines you want to keep if (namefile != "") { readName(); } if (fastafile != "") { readFasta(); } if (groupfile != "") { readGroup(); } if (countfile != "") { readCount(); } if (listfile != "") { readList(); } if (taxfile != "") { readTax(); } if (sharedfile != "") { readShared(); } if (designfile != "") { readDesign(); } if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); m->mothurOut("Output File names: "); m->mothurOutEndLine(); for (int i = 0; i < outputNames.size(); i++) { m->mothurOut(outputNames[i]); m->mothurOutEndLine(); } m->mothurOutEndLine(); //set fasta file as new current fastafile string current = ""; itTypes = outputTypes.find("fasta"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } } itTypes = outputTypes.find("name"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setNameFile(current); } } itTypes = outputTypes.find("group"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setGroupFile(current); } } itTypes = outputTypes.find("list"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setListFile(current); } } itTypes = outputTypes.find("taxonomy"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setTaxonomyFile(current); } } itTypes = outputTypes.find("shared"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setSharedFile(current); } } itTypes = outputTypes.find("design"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setDesignFile(current); } } itTypes = outputTypes.find("count"); if (itTypes != outputTypes.end()) { if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setCountTableFile(current); } } } return 0; } catch(exception& e) { m->errorOut(e, "RemoveGroupsCommand", "execute"); exit(1); } }
bool WRL1BASE::ReadNode( WRLPROC& proc, WRL1NODE* aParent, WRL1NODE** aNode ) { // This function reads a node and stores a pointer to it in aNode. // A value 'true' is returned if a node is successfully read or, // if the node is not supported, successfully discarded. Callers // must always check the value of aNode when the function returns // 'true' since it will be NULL if the node type is not supported. if( NULL != aNode ) *aNode = NULL; if( NULL == aParent ) { #ifdef DEBUG_VRML1 do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [BUG] invalid parent pointer (NULL)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } std::string glob; WRL1NODES ntype; if( !proc.ReadName( glob ) ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) if( !proc.eof() ) { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } #endif return false; } // Process node name: // the names encountered at this point should be one of the // built-in node names or one of: // DEF, USE if( !glob.compare( "USE" ) ) { if( !implementUse( proc, aParent, aNode ) ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } return true; } if( !glob.compare( "DEF" ) ) { if( !implementDef( proc, aParent, aNode ) ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << proc.GetError(); wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } return true; } ntype = getNodeTypeID( glob ); size_t line = 0; size_t column = 0; proc.GetFilePosData( line, column ); #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 2 ) do { std::ostringstream ostr; ostr << " * [INFO] Processing node '" << glob << "' ID: " << ntype; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif switch( ntype ) { case WRL1_GROUP: if( !readGroup( proc, aParent, aNode ) ) return false; break; case WRL1_SEPARATOR: if( !readSeparator( proc, aParent, aNode ) ) return false; break; case WRL1_SWITCH: if( !readSwitch( proc, aParent, aNode ) ) return false; break; case WRL1_MATERIAL: if( !readMaterial( proc, aParent, aNode ) ) return false; break; case WRL1_MATERIALBINDING: if( !readMatBinding( proc, aParent, aNode ) ) return false; break; case WRL1_COORDINATE3: if( !readCoords( proc, aParent, aNode ) ) return false; break; case WRL1_INDEXEDFACESET: if( !readFaceSet( proc, aParent, aNode ) ) return false; break; case WRL1_TRANSFORM: case WRL1_TRANSLATION: case WRL1_ROTATION: case WRL1_SCALE: if( !readTransform( proc, aParent, aNode ) ) return false; break; case WRL1_SHAPEHINTS: if( !readShapeHints( proc, aParent, aNode ) ) return false; break; // // items not implemented or for optional future implementation: // default: proc.GetFilePosData( line, column ); if( !proc.DiscardNode() ) { #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) do { std::ostringstream ostr; ostr << proc.GetError() << "\n"; ostr << __FILE__ << ": " << __FUNCTION__ << ": " << __LINE__ << "\n"; ostr << " * [INFO] could not discard node at line " << line; ostr << ", column " << column; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } while( 0 ); #endif return false; } #if defined( DEBUG_VRML1 ) && ( DEBUG_VRML1 > 1 ) else { std::ostringstream ostr; ostr << " * [INFO] discarded node '" << glob << "' at line "; ostr << line << ", col " << column << " (currently unsupported)"; wxLogTrace( MASK_VRML, "%s\n", ostr.str().c_str() ); } #endif break; } return true; }
void inline testID3() { ID3Group id3G; char inputFilePath[] = "./data/DecisionTree/buyComputer1.txt"; readGroup(id3G, inputFilePath); }