//============================================================================= bool CPdpManager::SaveToFile(const string &toFile ) { string xml = toFile; int fileEnd = toFile.rfind('.'); if (fileEnd != -1) xml = xml.substr(0, fileEnd); xml += ".hap"; return SaveToXml(xml); /* const string separator = ";-------------------------------------------------------------------------------"; fstream file( toFile.c_str(), ios::out ); if( file.good() ) { StorePathFile(toFile); file << separator << endl << "; " << toFile << endl << separator << endl << endl << separator << endl << "; Required first command - indicates a valid .pdp file" << endl << "!PAGE_DEBUGGER_PROJECT_FILE" << endl << endl << separator << endl << "; File format version" << endl << "!VERSION" << endl << "=" << Version() << endl << endl << separator << endl << "; Project name" << endl << "!PROJECT" << endl << "=" << m_strProjectName << endl << endl << separator << endl << "; Working Directory" << endl << "!WORKING_DIR" << endl << "=" << m_strWorkingDir << endl << endl << separator << endl << "; Remote Path" << endl << "!REMOTE_PATH" << endl << "=" << m_strRemotePath << endl << endl; file << separator << endl << "; Project files" << endl << "!FILES" << endl; for( FileList::iterator it = m_FileList.begin(); it != m_FileList.end(); ++it ) { file << "=" << (it->filename) << endl; } file << endl; for( FileList::iterator it = m_FileList.begin(); it != m_FileList.end(); ++it ) { if (it->nGroupInx > -1) { file << separator << endl << "; File grouping" << endl << "!GROUPING" << endl << "=" << (it->filename) << "->" << m_GroupList[it->nGroupInx] << endl << endl; } } file << separator << endl << "; Project boot file" << endl << "!BOOT_FILE" << endl << "=" << m_strBootFile << endl << endl << separator << endl << "; Commandline run options" << endl << "!RUN_OPTS" << endl << "=" << m_strRunOptions << endl << endl; file.close(); StoreFileModTime(toFile); } else { return false; } return true; */ }
void FuzzyDetector::LoadFromXml(QString settingsFileName) { QFile data_input(settingsFileName); if(! data_input.open(QFile::ReadOnly | QFile::Text)) { qDebug() << "Could not load settings, creating new one!"; SaveToXml(settingsFileName); return; } QXmlStreamReader xml; xml.setDevice(&data_input); fp_onAir.clear(); fp_onGrnd.clear(); pa_onAir.clear(); pa_onGrnd.clear(); ia_onAir.clear(); ia_onGrnd.clear(); if(xml.readNextStartElement()) { if(xml.name() != "FuzzyDetectorSettings") { qDebug() << "not a fuzzy detector log file"; return; } } do { while( xml.readNextStartElement()) { if(xml.name() == "FP_OnAir") { do { while(xml.readNextStartElement()) { if(xml.name() == "relation") { fp_onAir.push_back(Relation( xml.attributes().value("inVal").toString().toDouble(), xml.attributes().value("outVal").toString().toDouble() )); } else { xml.skipCurrentElement(); } } } while(xml.name() != "FP_OnAir"); } else if(xml.name() == "FP_OnGrnd") { do { while(xml.readNextStartElement()) { if(xml.name() == "relation") { fp_onGrnd.push_back(Relation( xml.attributes().value("inVal").toString().toDouble(), xml.attributes().value("outVal").toString().toDouble() )); } else { xml.skipCurrentElement(); } } } while(xml.name() != "FP_OnGrnd"); } else if(xml.name() == "PA_OnAir") { do { while(xml.readNextStartElement()) { if(xml.name() == "relation") { pa_onAir.push_back(Relation( xml.attributes().value("inVal").toString().toDouble(), xml.attributes().value("outVal").toString().toDouble() )); } else { xml.skipCurrentElement(); } } } while(xml.name() != "PA_OnAir"); } else if(xml.name() == "PA_OnGrnd") { do { while(xml.readNextStartElement()) { if(xml.name() == "relation") { pa_onGrnd.push_back(Relation( xml.attributes().value("inVal").toString().toDouble(), xml.attributes().value("outVal").toString().toDouble() )); } else { xml.skipCurrentElement(); } } } while(xml.name() != "PA_OnGrnd"); } else if(xml.name() == "IA_OnAir") { do { while(xml.readNextStartElement()) { if(xml.name() == "relation") { ia_onAir.push_back(Relation( xml.attributes().value("inVal").toString().toDouble(), xml.attributes().value("outVal").toString().toDouble() )); } else { xml.skipCurrentElement(); } } } while(xml.name() != "IA_OnAir"); } else if(xml.name() == "IA_OnGrnd") { do { while(xml.readNextStartElement()) { if(xml.name() == "relation") { ia_onGrnd.push_back(Relation( xml.attributes().value("inVal").toString().toDouble(), xml.attributes().value("outVal").toString().toDouble() )); } else { xml.skipCurrentElement(); } } } while(xml.name() != "IA_OnGrnd"); } else { xml.skipCurrentElement(); } } }while(xml.name() != "FuzzyDetectorSettings"); }