int NppFTP::LoadSettings() { int result = 0; char xmlPath[MAX_PATH]; char * utf8Store = SU::TCharToCP(m_configStore, CP_ACP); strcpy(xmlPath, utf8Store); ::PathCombineA(xmlPath, utf8Store, "NppFTP.xml"); TiXmlDocument settingsDoc = TiXmlDocument(xmlPath); settingsDoc.LoadFile(); strcpy(xmlPath, utf8Store); ::PathCombineA(xmlPath, utf8Store, "Certificates.xml"); SU::FreeChar(utf8Store); TiXmlDocument certificatesDoc = TiXmlDocument(xmlPath); certificatesDoc.LoadFile(); TiXmlElement* ftpElem = settingsDoc.FirstChildElement("NppFTP"); if (!ftpElem) { result = 1; return result; } m_ftpSettings->LoadSettings(ftpElem); TiXmlElement * profilesElem = ftpElem->FirstChildElement(FTPProfile::ProfilesElement); if (!profilesElem) { m_profiles.clear(); result = 1; } else { m_profiles = FTPProfile::LoadProfiles(profilesElem); for(size_t i = 0; i < m_profiles.size(); i++) { m_profiles.at(i)->AddRef(); m_profiles.at(i)->SetCacheParent(m_ftpSettings->GetGlobalCache()); } } ftpElem = certificatesDoc.FirstChildElement("NppFTP"); if (!ftpElem) { m_certificates.clear(); result = 1; } else { TiXmlElement * dersElem = ftpElem->FirstChildElement(SSLCertificates::DERsElem); if (!dersElem) { m_certificates.clear(); result = 1; } else { vDER derVect = SSLCertificates::LoadDER(dersElem); m_certificates = SSLCertificates::ConvertDERVector(derVect); SSLCertificates::FreeDERVector(derVect); } } return result; }
NNXML::NNXML( std::string path ) : m_LoadSuccess(false) { m_Document = TiXmlDocument( path.c_str() ); //m_Document.LoadFile(TIXML_ENCODING_UTF8); m_LoadSuccess = m_Document.LoadFile(); }
Progress::Progress(void) { Logger::DiagnosticOut() << "Loading progress record\n"; //Load XML TiXmlDocument doc = TiXmlDocument("Progress.xml"); doc.LoadFile(); TiXmlElement* root = doc.FirstChildElement("Progress"); if(root) { TiXmlElement* record = root->FirstChildElement("Record"); int record_number = 0; while(record) { std::string filename = ""; bool completed = false; bool error = false; error |= (record->QueryValueAttribute("Filename", &filename) != TIXML_SUCCESS); error |= (record->QueryValueAttribute("Completed", &completed) != TIXML_SUCCESS); if(error) Logger::DiagnosticOut() << "Error parsing record number: " << record_number << ". Possible data: Filename:" << filename << ", completed: " << completed << "\n"; else { ProgressRecord pr; pr.completed = completed; progress_[filename] = pr; } record = record->NextSiblingElement("Record"); record_number++; } } }
//----------------------------------------------------------------------------- bool xml_c::read( std::string filename ) { // TODO: robust error checking TiXmlDocument doc; doc = TiXmlDocument( filename ); bool result; result = doc.LoadFile(); if( !result ) { return false; } TiXmlHandle tixml_hdoc( &doc ); TiXmlHandle tixml_root( 0 ); TiXmlElement* tixml_e; TiXmlHandle tixml_h( 0 ); tixml_e = tixml_hdoc.FirstChildElement().Element(); tixml_root = TiXmlHandle( tixml_e ); _root = xml_element_ptr( new xml_element_c() ); process_tixml_element( (void*)tixml_e, _root ); return true; }
void SettingsXML::Start(){ //Load the XML _File = TiXmlDocument(); TiXmlDeclaration* decl = new TiXmlDeclaration( "1.0", "", "" ); _File.LinkEndChild( decl ); TiXmlElement * root = new TiXmlElement( "Settings" ); _File.LinkEndChild( root ); }
WindowUser::WindowUser(QWidget *parent) : QMainWindow(parent), ui(new Ui::WindowUser) { ui->setupUi(this); doc= TiXmlDocument("Mis Vuelos.xml") ; mc= TiXmlDocument("Mis Conexiones.xml") ; //connect(this->draw,SIGNAL(MousePos()),this,SLOT(Mouse_Current_Pos())); this->setAirport(); this->ReadXML(); }
void ObjectLoader::setFile(string fileName) { // Set XML file and create the Tiny XML document object mFile = fileName; mXmlFile = TiXmlDocument(fileName.c_str()); // Important to load the file! mXmlFile.LoadFile(); }
void XML_Document::create_root(const String &field) { delete m_root; m_root = 0; m_xml_file = TiXmlDocument(); m_xml_file.LinkEndChild(new TiXmlDeclaration("1.0", "", "")); m_xml_file.LinkEndChild(new TiXmlElement(field.c_str())); TiXmlHandle root = &m_xml_file; m_root = new XML_Element(root); }
cliente::cliente(QWidget *parent) : QDialog(parent), ui(new Ui::cliente) { ui->setupUi(this); this->a = new miWidget(this); a->setGeometry(20,130,900,431); a->show(); doc=TiXmlDocument("Aeropuertos.xml"); doc2=TiXmlDocument("Conexiones.xml"); leerXml(); leerXml2(); cout<<this->miGrafo.p->ciudad.toStdString(); miGrafo.mostrar_grafo(); // miGrafo.llenarMatriz(); }
BOOL CSDXMLFile::LoadData(const CHAR* pszData, const UINT32 dwDataLen) { if(NULL == pszData) { return FALSE; } UnLoad(); m_pDocument = SDNew TiXmlDocument(); if(m_pDocument->LoadData(pszData, dwDataLen)) { return TRUE; } UnLoad(); return FALSE; }
BOOL CSDXMLFile::Load(const CHAR* pszXmlFile) { if(NULL == pszXmlFile) { return FALSE; } UnLoad(); m_pDocument = SDNew TiXmlDocument(); if(pszXmlFile!=NULL) { if(m_pDocument->LoadFile(pszXmlFile)) { return TRUE; } } UnLoad(); return FALSE; }
Progress::~Progress(void) { Logger::DiagnosticOut() << "Saving progress record\n"; //Save XML TiXmlDocument doc = TiXmlDocument("Progress.xml"); TiXmlDeclaration* decl = new TiXmlDeclaration(); TiXmlElement* root = new TiXmlElement("Progress"); doc.LinkEndChild(decl); doc.LinkEndChild(root); std::pair<std::string, ProgressRecord> item; BOOST_FOREACH(item, progress_) { TiXmlElement* record = new TiXmlElement("Record"); record->SetAttribute("Filename", item.first); record->SetAttribute("Completed", item.second.completed); root->LinkEndChild(record); }
void FindingElementDepthTest::setUp() { m_tag_father = Tag("portals"); m_tag_son = Tag("localDatabase"); m_tag_son_of_son = Tag("name"); m_invalid_tag_father = Tag("modalities"); m_invalid_tag_son = Tag("modality"); m_invalid_tag_son_of_son = Tag("password"); m_tag_son_value = "localDatabase"; m_tag_son_of_son_value = "name"; m_tag_son_of_son_text = "Dicomizer Local Database"; m_tag_son_with_attributes = Tag("portal"); m_tag_son_with_attributes.properties["id"] = "hu"; m_invalid_tag_son_with_attributes = Tag("portal"); m_invalid_tag_son_with_attributes.properties["id"] = "wrongid"; m_tag_son_of_son_with_attributes = Tag("databaseName"); m_tag_son_of_son_with_attributes_value = "databaseName"; m_tag_son_of_son_with_attributes_text = "telemedicina2"; m_first_tag_son_of_son_with_attributes_value = m_tag_son_of_son_with_attributes_value; m_first_tag_son_of_son_with_attributes_text = m_tag_son_of_son_with_attributes_text; m_tag_son_without_attributes = Tag("portal"); m_searcher = XmlSearcher(); m_doc = TiXmlDocument(); m_doc.LoadFile("test.xml"); }
HRESULT CRMxmlLoader::LoadMusicData(const std::string& folderName ) { std::string filePath; filePath.append("./Music/"); filePath.append( folderName ); filePath.append("/index.xml"); TiXmlDocument document = TiXmlDocument( filePath.c_str() ); // document.LoadFile(TIXML_ENCODING_UTF8); bool m_LoadSuccess = document.LoadFile(); std::string title; std::string artist; std::string level; std::string imageAlbum; std::string imageBackground; std::string imageShutter; std::string imageNote1; std::string imageNote2; std::string imageNoteEffect; std::string soundBackground; std::string soundNoteEffect1; std::string soundNoteEffect2; std::string note; if ( m_LoadSuccess ) { title = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Title/text()").c_str(); artist = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Artist/text()").c_str(); level = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Level/text()").c_str(); imageAlbum = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageAlbum/text()").c_str(); imageBackground = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageBackground/text()").c_str(); imageShutter = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageShutter/text()").c_str(); imageNote1 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageNote1/text()").c_str(); imageNote2 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageNote2/text()").c_str(); imageNoteEffect = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Image/imageNoteEffect/text()").c_str(); soundBackground = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Sound/soundBackground/text()").c_str(); soundNoteEffect1 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Sound/soundNoteEffect1/text()").c_str(); soundNoteEffect2 = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Sound/soundNoteEffect2/text()").c_str(); note = TinyXPath::S_xpath_string(document.RootElement(), "/Music/Note/text()").c_str(); printConsole("Loaded Music :%s \n", title.c_str()); } if ( title == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_TITLE, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( artist == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_ARTIST, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( level == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_LEVEL, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( imageAlbum == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_ALBUM, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( imageBackground == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_BACKGROUND, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( imageShutter == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_SHUTTER, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( imageNote1 == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_NOTE1, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( imageNote2 == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_NOTE2, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( imageNoteEffect == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_IMAGE_NOTE_EFFECT, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( soundBackground == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_SOUND_BACKGROUND, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( soundNoteEffect1 == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_SOUND_NOTE_EFFECT1, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( soundNoteEffect2 == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_SOUND_NOTE_EFFECT2, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } else if ( note == "" ) { MessageBox( NULL, ERROR_MESSAGE_LOAD_XML_NOTE_DATA, ERROR_TITLE_LOAD, MB_OK | MB_ICONSTOP ); return S_FALSE; } auto& toBeDelete = m_MusicDataMap[folderName]; SafeDelete( toBeDelete ); m_MusicDataMap[folderName] = new CRMmusicData(); m_MusicDataMap[folderName]->SetTitle( title ); m_MusicDataMap[folderName]->SetArtist( artist ); m_MusicDataMap[folderName]->SetLevel( level ); m_MusicDataMap[folderName]->SetImageAlbum( imageAlbum ); m_MusicDataMap[folderName]->SetImageBackground( imageBackground ); m_MusicDataMap[folderName]->SetImageShutter( imageShutter ); m_MusicDataMap[folderName]->SetImageNote1( imageNote1 ); m_MusicDataMap[folderName]->SetImageNote2( imageNote2 ); m_MusicDataMap[folderName]->SetImageNoteEffect( imageNoteEffect ); m_MusicDataMap[folderName]->SetSoundBackground( soundBackground ); m_MusicDataMap[folderName]->SetSoundNoteEffect1( soundNoteEffect1 ); m_MusicDataMap[folderName]->SetSoundNoteEffect2( soundNoteEffect2 ); m_MusicDataMap[folderName]->SetNote( note ); return S_OK; }
NNXML::NNXML() { m_Document = TiXmlDocument(); }
bool AutoCompletion::setLanguage(LangType language) { if (_curLang == language) return true; _curLang = language; TCHAR path[MAX_PATH]; //::GetModuleFileName(NULL, path, MAX_PATH); //PathRemoveFileSpec(path); CString strOwmPath = theApp.GetModulePath(); lstrcpy(path, strOwmPath); lstrcat(path, TEXT("\\APIs\\")); lstrcat(path, getApiFileName()); lstrcat(path, TEXT(".xml")); _XmlFile = TiXmlDocument(path); _funcCompletionActive = _XmlFile.LoadFile(); TiXmlNode * pAutoNode = NULL; if (_funcCompletionActive) { _funcCompletionActive = false; //safety TiXmlNode * pNode = _XmlFile.FirstChild(TEXT("OwmScite")); if (!pNode) return false; pAutoNode = pNode = pNode->FirstChildElement(TEXT("AutoComplete")); if (!pNode) return false; pNode = pNode->FirstChildElement(TEXT("KeyWord")); if (!pNode) return false; _pXmlKeyword = reinterpret_cast<TiXmlElement *>(pNode); if (!_pXmlKeyword) return false; _funcCompletionActive = true; } if(_funcCompletionActive) { //try setting up environment //setup defaults _ignoreCase = true; _funcCalltip._start = '('; _funcCalltip._stop = ')'; _funcCalltip._param = ','; _funcCalltip._terminal = ';'; _funcCalltip._ignoreCase = true; TiXmlElement * pElem = pAutoNode->FirstChildElement(TEXT("Environment")); if (pElem) { const TCHAR * val = 0; val = pElem->Attribute(TEXT("ignoreCase")); if (val && !lstrcmp(val, TEXT("no"))) { _ignoreCase = false; _funcCalltip._ignoreCase = false; } val = pElem->Attribute(TEXT("startFunc")); if (val && val[0]) _funcCalltip._start = val[0]; val = pElem->Attribute(TEXT("stopFunc")); if (val && val[0]) _funcCalltip._stop = val[0]; val = pElem->Attribute(TEXT("paramSeparator")); if (val && val[0]) _funcCalltip._param = val[0]; val = pElem->Attribute(TEXT("terminal")); if (val && val[0]) _funcCalltip._terminal = val[0]; } } if (_funcCompletionActive) { _funcCalltip.setLanguageXML(_pXmlKeyword); } else { _funcCalltip.setLanguageXML(NULL); } _keyWords = TEXT(""); if (_funcCompletionActive) { //Cache the keywords //Iterate through all keywords TiXmlElement *funcNode = _pXmlKeyword; const TCHAR * name = NULL; for (; funcNode; funcNode = funcNode->NextSiblingElement(TEXT("KeyWord")) ) { name = funcNode->Attribute(TEXT("name")); if (!name) //malformed node continue; _keyWords.append(name); _keyWords.append(TEXT("\n")); } } return _funcCompletionActive; }
/** * Constructor of the run class for toaster_vizualiser */ Run() { name_list = std::vector<std::string>(); id_cpt = 1; ros::NodeHandle reception_node; ros::NodeHandle emission_node; area_list = visualization_msgs::MarkerArray(); obj_list = visualization_msgs::MarkerArray(); human_list = visualization_msgs::MarkerArray(); robot_list = visualization_msgs::MarkerArray(); //definition of subscribers sub_objList = reception_node.subscribe("/pdg/objectList", 1000, &Run::chatterCallbackObjList, this); sub_areaList = reception_node.subscribe("/area_manager/areaList", 1000, &Run::chatterCallbackAreaList, this); sub_humanList = reception_node.subscribe("/pdg/humanList", 1000, &Run::chatterCallbackHumanList, this); sub_robotList = reception_node.subscribe("/pdg/robotList", 1000, &Run::chatterCallbackRobotList, this); //definition of publishers pub_obj = emission_node.advertise<visualization_msgs::MarkerArray>("/toaster_visualizer/marker_object", 1000); pub_area = emission_node.advertise<visualization_msgs::MarkerArray>("/toaster_visualizer/marker_area", 1000); pub_human = emission_node.advertise<visualization_msgs::MarkerArray>("/toaster_visualizer/marker_human", 1000); pub_robot = emission_node.advertise<visualization_msgs::MarkerArray>("/toaster_visualizer/marker_robot", 1000); //open xml files // Objects std::stringstream pathObj; pathObj << ros::package::getPath("toaster_visualizer") << "/src/list_obj.xml"; listObj = TiXmlDocument(pathObj.str()); if (!listObj.LoadFile()) { ROS_WARN_ONCE("Erreur lors du chargement du fichier xml"); ROS_WARN_ONCE("error # %d", listObj.ErrorId()); ROS_WARN_ONCE("%s", listObj.ErrorDesc()); } // Humans std::stringstream pathHuman; pathHuman << ros::package::getPath("toaster_visualizer") << "/src/list_human_morse_joints.xml"; listMemb = TiXmlDocument(pathHuman.str()); if (!listMemb.LoadFile()) { ROS_WARN_ONCE("Erreur lors du chargement du fichier xml"); ROS_WARN_ONCE("error # %d", listMemb.ErrorId()); ROS_WARN_ONCE("%s", listMemb.ErrorDesc()); } // Robots /*path.flush(); path << ros::package::getPath("toaster_visualizer") << "/src/list_robots.xml"; listRob = TiXmlDocument(path.str()); if (!listRob.LoadFile()) { ROS_WARN_ONCE("Erreur lors du chargement du fichier xml"); ROS_WARN_ONCE("error # %d", listRob.ErrorId()); ROS_WARN_ONCE("%s", listRob.ErrorDesc()); }*/ }
void Automata::loadFromXML(string archivo,string archivo_default) { TiXmlDocument doc_t(archivo.c_str()); bool loadOkay = doc_t.LoadFile(); if(!loadOkay) { doc_t=TiXmlDocument(archivo_default.c_str()); loadOkay=doc_t.LoadFile(); cout.flush(); } TiXmlDocument *doc; doc=&doc_t; for(TiXmlNode* nodo=doc->FirstChild("State"); nodo!=NULL; nodo=nodo->NextSibling("State")) { std::vector<Transicion*> transiciones; for(TiXmlElement *e_action=nodo->FirstChild("Action")->ToElement(); e_action!=NULL; e_action=e_action->NextSiblingElement("Action")) { Transicion *transicion; if(e_action->Attribute("rewardable")!=NULL) transicion=new Transicion(e_action->Attribute("input"),e_action->Attribute("destination"),strcmp(e_action->Attribute("rewardable"),"yes")==0); else transicion=new Transicion(e_action->Attribute("input"),e_action->Attribute("destination"),false); if(e_action->Attribute("reward")!=NULL) transicion->setRecompensa(atoi(e_action->Attribute("reward"))); if(e_action->Attribute("wait")!=NULL) transicion->setWait(atoi(e_action->Attribute("wait"))); if(e_action->FirstChild("condition")!=NULL) { for(TiXmlElement *elemento_condicion=e_action->FirstChild("condition")->ToElement(); elemento_condicion!=NULL; elemento_condicion=elemento_condicion->NextSiblingElement("condition")) { std::string exp_i(elemento_condicion->Attribute("left_exp")); std::string op(elemento_condicion->Attribute("relational_op")); std::string exp_d(elemento_condicion->Attribute("right_exp")); std::string str_contrario(elemento_condicion->Attribute("to_opponent")); bool contrario=(str_contrario=="yes"); transicion->agregarCondicion(Condicion2(exp_i,op,exp_d,contrario)); } } if(e_action->FirstChild("condition_integer")!=NULL) { for(TiXmlElement *elemento_condicion=e_action->FirstChild("condition_integer")->ToElement(); elemento_condicion!=NULL; elemento_condicion=elemento_condicion->NextSiblingElement("condition_integer")) { std::string exp_i(elemento_condicion->Attribute("left_exp")); std::string op(elemento_condicion->Attribute("relational_op")); int exp_d=atoi(elemento_condicion->Attribute("right_exp")); std::string str_contrario(elemento_condicion->Attribute("to_opponent")); bool contrario=(str_contrario=="yes"); transicion->agregarCondicion(Condicion2(exp_i,op,exp_d,contrario)); } } transiciones.push_back(transicion); } estados[std::string(nodo->ToElement()->Attribute("name"))]=new Estado(transiciones); } }
SystemParser::SystemParser(const char* filename, unsigned int verbosity, LeafType leaf_type) { // Open the document TiXmlDocument document = TiXmlDocument(filename); if (!document.LoadFile()) { throw ParseError("[ERROR] Could not load the input file."); } // Get the root node of the XML-document TiXmlNode* rootNode = document.RootElement(); if (rootNode == NULL) { throw ParseError("[ERROR] Could not access the root node of the XML-tree"); } // Find out the type of the transition system (lts, ctmc, imc) const std::string type_str = readStringAttribute(rootNode, "type"); if (type_str == "lts") system_type = lts_type; else if (type_str == "ctmc") system_type = ctmc_type; else if (type_str == "imc") system_type = imc_type; else system_type = lts_type; this->leaf_type = leaf_type; // Traverse the children of the root node and collect the pointers to the parts we need. TiXmlNode* varinfoNode = NULL; TiXmlNode* initialstateNode = NULL; TiXmlNode* transNode = NULL; TiXmlNode* markovtransNode = NULL; TiXmlNode* initialpartitionNode = NULL; TiXmlNode* tauNode = NULL; for (TiXmlNode* currentNode = rootNode->FirstChild(); currentNode != NULL; currentNode = currentNode->NextSibling()) { if (currentNode->ToElement() == NULL) continue; const char* const name = currentNode->ToElement()->Value(); if (strcmp(name, "variables") == 0) { varinfoNode = currentNode; } else if (strcmp(name, "dd") == 0) { std::string bdd_type = readStringAttribute(currentNode, "type"); if (bdd_type == "initial_state") { initialstateNode = currentNode; } else if (bdd_type == "trans") { transNode = currentNode; } else if (bdd_type == "markov_trans") { markovtransNode = currentNode; } else if (bdd_type == "tau") { tauNode = currentNode; } } else if (strcmp(name, "initial_partition") == 0) { initialpartitionNode = currentNode; } } // Check if we have found the variable information if (varinfoNode == NULL) { throw ParseError("[ERROR] No variable information found!"); } // Check if the correct information exists for the system type switch (system_type) { case lts_type: if (markovtransNode != NULL) { throw ParseError("[ERROR] LTS must not have any Markov transitions!"); } if (transNode == NULL) { throw ParseError("[ERROR] LTS must have an interactive transition relation!"); } break; case ctmc_type: if (transNode != NULL) { throw ParseError("[ERROR] CTMCs must not have any interactive transitions!"); } if (markovtransNode == NULL) { throw ParseError("[ERROR] CTMCs must have a Markov transition relation!"); } break; case imc_type: if (transNode == NULL) { throw ParseError("[ERROR] IMCs must have an interactive transition relation!"); } if (markovtransNode == NULL) { throw ParseError("[ERROR] IMCs must have a Markov transition relation!"); } break; } // Parse the variable information and create the BDD variables // together with an appropriate order for refinement if (verbosity > 0) std::cout << "[INFO] Creating BDD variables ... " << std::flush; createVariables(varinfoNode); if (verbosity > 0) std::cout << "finished." << std::endl; // Build the BDDs/ADDs for all parts if (verbosity > 0) std::cout << "[INFO] Building BDDs ... " << std::flush; std::vector<std::pair<Bdd, Bdd>> transitions; Bdd _transitions = Bdd::bddZero(); if (transNode != NULL) { _transitions = nodeToBdd(transNode); transitions.push_back(std::make_pair(_transitions, varS * varT)); } Mtbdd markov_transitions; if (markovtransNode != NULL) markov_transitions = nodeToMtbdd(markovtransNode); Bdd tau; if (tauNode != NULL) tau = nodeToBdd(tauNode); else { // Default value of tau: 0 int action_bits = sylvan_set_count(varA.GetBDD()); std::vector<uint8_t> tau_value; for (int i=0; i<action_bits; i++) tau_value.push_back(0); tau = Bdd::bddCube(varA, tau_value); } Bdd initial_state; if (initialstateNode != NULL) initial_state = nodeToBdd(initialstateNode); Bdd states = computeStateSpace(_transitions, markov_transitions); std::vector<Bdd> initial_partition; if (initialpartitionNode != NULL) { for (TiXmlNode* currentNode = initialpartitionNode->FirstChild(); currentNode != NULL; currentNode = currentNode->NextSibling()) { initial_partition.push_back(nodeToBdd(currentNode)); } } if (initial_partition.size() == 0) initial_partition.push_back(states); if (verbosity > 0) std::cout << "finished." << std::endl; // Fill the right system with information switch (system_type) { case lts_type: lts.transitions = transitions; lts.states = states; lts.tau = tau; lts.initialStates = initial_state; lts.initialPartition = initial_partition; lts.varS = varS; lts.varT = varT; lts.varA = varA; break; case imc_type: imc.transitions = transitions; imc.markov_transitions = markov_transitions; imc.states = states; imc.tau = tau; imc.initialStates = initial_state; imc.initialPartition = initial_partition; imc.varS = varS; imc.varT = varT; imc.varA = varA; break; case ctmc_type: ctmc.markov_transitions = markov_transitions; ctmc.states = states; ctmc.initialStates = initial_state; ctmc.initialPartition = initial_partition; ctmc.varS = varS; ctmc.varT = varT; break; default: break; } }
HRESULT CRMxmlLoader::LoadNoteData( const std::string& folderName ) { std::string filePath; filePath.append("./Music/"); filePath.append( folderName ); filePath.append("/"); filePath.append( m_MusicDataMap[folderName]->GetNote() ); TiXmlDocument document = TiXmlDocument( filePath.c_str() ); bool m_LoadSuccess = document.LoadFile(); if ( m_LoadSuccess ) { if ( m_NoteList.size() > 0 ) { for ( auto& toBeDelete : m_NoteList ) { SafeDelete( toBeDelete ); } } m_NoteList.clear(); TiXmlNode* node = document.FirstChild("Notes")->FirstChild("Note"); while ( node != NULL ) { int time = 0; int level = 0; node->ToElement()->Attribute("time", &time); node->ToElement()->Attribute("level", &level); std::string type = node->ToElement()->GetText(); CRMnoteData* noteData = new CRMnoteData (time, level, (type == "left") ? OBJECT_NOTE_NORMAL_1 : OBJECT_NOTE_NORMAL_2 ); m_NoteList.push_back( noteData ); node = node->NextSibling(); } /* TiXmlNode* node = document.FirstChild("Notes"); int bpm = 0; if ( node != NULL ) { node->ToElement()->Attribute("bpm", &bpm); } node = document.FirstChild("End"); int endTime = 0; if ( node != NULL ) { node->ToElement()->Attribute("time", &endTime); } node = document.FirstChild("Notes")->FirstChild("Note"); int level = 0; int beat1Time = 0; int nextTime = 0; int endJoint = 0; int jointCount = 0; std::string type; CRMnoteData* noteData = nullptr; while ( node != NULL && nextTime < endTime) { node->ToElement()->Attribute("start", &beat1Time); node->ToElement()->Attribute("end", &endJoint); type = node->ToElement()->GetText(); nextTime = beat1Time + ( 1000 * 60 / bpm ); jointCount = 0; if ( type == "on" ) { while ( beat1Time < endJoint ) { printConsole ( "%d밀리초에 노트 하나 추가요~! \n", (beat1Time + (jointCount * 60 / bpm) - 2152) ); noteData = new CRMnoteData( (beat1Time + (jointCount * 60 / bpm) - 2152) , (jointCount % 2) + 1 , (jointCount++ % 2 == 0) ? OBJECT_NOTE_NORMAL_1 : OBJECT_NOTE_NORMAL_2 ); // 2152 = 화면 최상단에서 판정판까지 내려오기까지 걸리는 시간 ms m_NoteList.push_back( noteData ); beat1Time += 1000 * 60 / bpm; } } node = node->NextSibling(); } */ } if ( m_NoteList.size() == 0 ) { return S_FALSE; } return S_OK; }
NNXML::NNXML( char *buf ) { m_Document = TiXmlDocument(); //m_Document.LoadFile(TIXML_ENCODING_UTF8); m_Document.Parse( buf ); }
void IPXMLParser::parseXML() { if ( fileName.empty() ) throw std::runtime_error( "Exception: fileName.empty()" ); doc = TiXmlDocument( fileName ); if ( !doc.LoadFile() ) throw std::runtime_error( "Exception: XML file cannot be loaded!" ); std::cout << fileName << " opened successfully!\n"; TiXmlHandle hDoc( &doc ); TiXmlHandle hRoot( NULL ); el = hDoc.FirstChildElement( "Properties" ).ToElement(); if ( !el ) throw std::runtime_error( "Exception: XML file empty or 'Properties' missing!" ); hRoot = TiXmlHandle( el ); TiXmlElement * properties = hRoot.FirstChild( "Property" ).ToElement(); if ( !properties ) throw std::runtime_error( "Exception: 'Properties' is empty!" ); for ( ; properties; properties = properties->NextSiblingElement( "Property" ) ) { const char * elName = properties->Attribute( "name" ); if ( !properties ) throw std::runtime_error( "Exception: no element named Property!" ); if ( strcmp( elName, "hsvMin" ) != 0 && std::strcmp( elName, "hsvMax" ) != 0 ) throw std::runtime_error( "Exception: hsvMin and hsvMax not available!" ); if ( strcmp( elName, "hsvMin" ) == 0 ) { double hMin, sMin, vMin; properties->QueryDoubleAttribute( "hMin", &hMin ); properties->QueryDoubleAttribute( "sMin", &sMin ); properties->QueryDoubleAttribute( "vMin", &vMin ); hsvMin = cv::Scalar( hMin, sMin, vMin ); std::cout << "hsvMin: " << hsvMin( 0 ) << " " << hsvMin( 1 ) << " " << hsvMin( 2 ) << " " << hsvMin( 3 ) << std::endl; } if ( strcmp( elName, "hsvMax" ) == 0 ) { double hMax, sMax, vMax; properties->QueryDoubleAttribute( "hMax", &hMax ); properties->QueryDoubleAttribute( "sMax", &sMax ); properties->QueryDoubleAttribute( "vMax", &vMax ); hsvMax = cv::Scalar( hMax, sMax, vMax ); std::cout << "hsvMax: " << hsvMax( 0 ) << " " << hsvMax( 1 ) << " " << hsvMax( 2 ) << " " << hsvMax( 3 ) << std::endl; } } }