void TitleSubst::Load(const std::string &filename, const std::string §ion) { XNode xml; if( !XmlFileUtil::LoadFromFileShowErrors(xml,filename) ) { // LoadFromFile will show its own error //LOG->Trace("Error opening %s: %s", filename.c_str(), f.GetError().c_str() ); return; } XNode *pGroup = xml.GetChild( section ); if( pGroup == nullptr ) { return; } for (auto const *child: *pGroup) { if( child == nullptr || child->GetName() != "Translation" ) { continue; } TitleTrans tr; tr.LoadFromNode( child ); AddTrans(tr); } }
bool RouteAddress::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("RouteAddress")); pNode->AppendAttr(_T("Name"), m_sAddress); return true; }
XNode* TapNote::CreateNode() const { XNode *p = new XNode( "TapNote" ); p->AppendChild( result.CreateNode() ); p->AppendChild( HoldResult.CreateNode() ); return p; }
XNode* SongID::CreateNode() const { XNode* pNode = new XNode; pNode->name = "Song"; pNode->AppendAttr( "Dir", sDir ); return pNode; }
XNode* TrailID::CreateNode() const { XNode* pNode = new XNode( "Trail" ); pNode->AppendAttr( "StepsType", GAMEMAN->GetStepsTypeInfo(st).szName ); pNode->AppendAttr( "CourseDifficulty", DifficultyToString(cd) ); return pNode; }
XNode* TapNoteResult::CreateNode() const { XNode *p = new XNode( "TapNoteResult" ); p->AppendAttr( "TapNoteScore", TapNoteScoreToString(tns) ); p->AppendAttr( "TapNoteOffset", fTapNoteOffset ); return p; }
bool FetchAccountUID::XMLStore(XNode *pUIDsNode, int iOptions) { XNode *pUIDNode = pUIDsNode->AppendChild(_T("UID")); pUIDNode->AppendAttr(_T("UID"), uid_); pUIDNode->AppendAttr(_T("Date"), date_); return true; }
bool BlockedAttachment::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("BlockedAttachment")); pNode->AppendAttr(_T("Name"), m_sWildcard); pNode->AppendAttr(_T("Description"), m_sDescription); return true; }
bool TCPIPPort::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("TCPIPPort")); pNode->AppendAttr(_T("Name"), GetName()); pNode->AppendAttr(_T("PortProtocol"), StringParser::IntToString(m_iPortProtocol)); pNode->AppendAttr(_T("PortNumber"), StringParser::IntToString(m_iPortNumber)); //JDR: added the following code to set if we are using a StartTLS connection. if (m_bUseSSL == true){ pNode->AppendAttr(_T("UseSSL"), _T("1")); } else if (m_bUseSTARTTLS == true){ LOG_DEBUG("Set UseSTARTLS"); pNode->AppendAttr(_T("UseSSL"), _T("2")); } else { pNode->AppendAttr(_T("UseSSL"), _T("0")); } pNode->AppendAttr(_T("Address"), String(_address.ToString())); if (m_iSSLCertificateID > 0) { pNode->AppendAttr(_T("SSLCertificateName"), _GetSSLCertificateName(m_iSSLCertificateID)); } return true; }
bool SSLCertificate::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("SSLCertificate")); pNode->AppendAttr(_T("Name"), m_sName); pNode->AppendAttr(_T("CertificateFile"), m_sCertificateFile); pNode->AppendAttr(_T("PrivateKeyFile"), m_sPrivateKeyFile); return true; }
bool SSLCertificate::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("SSLCertificate")); pNode->AppendAttr(_T("Name"), name_); pNode->AppendAttr(_T("CertificateFile"), certificate_file_); pNode->AppendAttr(_T("PrivateKeyFile"), private_key_file_); return true; }
bool ACLPermission::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("Permission")); pNode->AppendAttr(_T("Type"), StringParser::IntToString(m_iPermissionType)); pNode->AppendAttr(_T("Rights"), StringParser::IntToString(m_iValue)); pNode->AppendAttr(_T("Holder"), _GetPermissionHolderName(this)); return true; }
XNode* CourseID::CreateNode() const { XNode* pNode = new XNode; pNode->name = "Course"; if( !sPath.empty() ) pNode->AppendAttr( "Path", sPath ); if( !sFullTitle.empty() ) pNode->AppendAttr( "FullTitle", sFullTitle ); return pNode; }
bool Profile::SaveAllToDir( CString sDir, bool bSignData ) const { m_sLastPlayedMachineGuid = PROFILEMAN->GetMachineProfile()->m_sGuid; m_LastPlayedDate = DateTime::GetNowDate(); // Save editable.xml SaveEditableDataToDir( sDir ); // Save stats.xml CString fn = sDir + STATS_XML; XNode xml; xml.name = "Stats"; xml.AppendChild( SaveGeneralDataCreateNode() ); xml.AppendChild( SaveSongScoresCreateNode() ); xml.AppendChild( SaveCourseScoresCreateNode() ); xml.AppendChild( SaveCategoryScoresCreateNode() ); xml.AppendChild( SaveScreenshotDataCreateNode() ); xml.AppendChild( SaveCalorieDataCreateNode() ); xml.AppendChild( SaveRecentSongScoresCreateNode() ); xml.AppendChild( SaveRecentCourseScoresCreateNode() ); if( IsMachine() ) xml.AppendChild( SaveCoinDataCreateNode() ); DISP_OPT opts = optDefault; opts.stylesheet = STATS_XSL; opts.write_tabs = false; bool bSaved = xml.SaveToFile(fn, &opts); // Update file cache, or else IsAFile in CryptManager won't see this new file. FILEMAN->FlushDirCache( sDir ); if( bSaved && bSignData ) { CString sStatsXmlSigFile = fn+SIGNATURE_APPEND; CryptManager::SignFileToFile(fn, sStatsXmlSigFile); // Update file cache, or else IsAFile in CryptManager won't see sStatsXmlSigFile. FILEMAN->FlushDirCache( sDir ); // Save the "don't share" file CString sDontShareFile = sDir + DONT_SHARE_SIG; CryptManager::SignFileToFile(sStatsXmlSigFile, sDontShareFile); } SaveStatsWebPageToDir( sDir ); // Empty directories if none exist. FILEMAN->CreateDir( sDir + EDITS_SUBDIR ); FILEMAN->CreateDir( sDir + SCREENSHOTS_SUBDIR ); return bSaved; }
void BackupExecuter::_RestoreDataDirectory(shared_ptr<Backup> pBackup, XNode *pBackupNode) { XNode *pBackupInfoNode = pBackupNode->GetChild(_T("BackupInformation")); // Create the path to the zip file. String sBackupFile = pBackup->GetBackupFile(); String sPath = sBackupFile.Mid(0, sBackupFile.ReverseFind(_T("\\"))); String sDirContainingDataFiles; String sDataFileFormat = pBackupInfoNode->GetChildAttr(_T("DataFiles"), _T("Format"))->value; String sExtractedFilesDirectory; if (sDataFileFormat.CompareNoCase(_T("7Z")) == 0) { // Create the path to the directory that will contain the extracted files. // This directory is temporary and will be removed when we're done. sExtractedFilesDirectory = Utilities::GetUniqueTempDirectory(); // Extract the files to this directory. Compression oComp; oComp.Uncompress(sBackupFile, sExtractedFilesDirectory); // The data files in the zip file are stored in // a directory called DataBackup. sDirContainingDataFiles = sExtractedFilesDirectory + "\\DataBackup"; } else { // Fetch the path to the data files. String sFolderName = pBackupInfoNode->GetChildAttr(_T("DataFiles"), _T("FolderName"))->value; sDirContainingDataFiles = sPath + "\\" + sFolderName; } // Delete all directories from the data directory // so that we're sure that we're doing a clean restore String sDataDirectory = IniFileSettings::Instance()->GetDataDirectory(); std::set<String> vecExcludes; FileUtilities::DeleteFilesInDirectory(sDataDirectory); FileUtilities::DeleteDirectoriesInDirectory(sDataDirectory, vecExcludes); String errorMessage; FileUtilities::CopyDirectory(sDirContainingDataFiles, sDataDirectory, errorMessage); if (sDataFileFormat.CompareNoCase(_T("7z")) == 0) { // The temporary directory we created while // unzipping should be deleted now. FileUtilities::DeleteDirectory(sExtractedFilesDirectory); } }
XNode* StepsID::CreateNode() const { XNode* pNode = new XNode( "Steps" ); pNode->AppendAttr( "StepsType", GAMEMAN->GetStepsTypeInfo(st).szName ); pNode->AppendAttr( "Difficulty", DifficultyToString(dc) ); if( dc == Difficulty_Edit ) { pNode->AppendAttr( "Description", sDescription ); pNode->AppendAttr( "Hash", uHash ); } return pNode; }
bool ScreenArcadePatch::GetXMLData( RageFileDriverZip *fZip, CString &sGame, CString &sMessage, int &iRevision ) { int iError; RageFileBasic *fXML = fZip->Open( "patch.xml", RageFile::READ, iError ); if( fXML == NULL ) { STATE_TEXT( "Patch information check failed: could not open patch.xml." ); return false; } /* check the actual XML data now */ XNode *pNode = new XNode; pNode->m_sName = "Patch"; pNode->LoadFromFile( *fXML ); if( !pNode->GetChild("Game") || !pNode->GetChild("Revision") || !pNode->GetChild("Message") ) { STATE_TEXT( "Patch information check failed: patch.xml is corrupt." ); SAFE_DELETE( pNode ); SAFE_DELETE( fXML ); return false; } /* save the patch data */ pNode->GetChild("Revision")->GetValue(iRevision); sGame = pNode->GetChildValue("Game"); sMessage = pNode->GetChildValue("Message"); SAFE_DELETE( pNode ); SAFE_DELETE( fXML ); return true; }
bool WhiteListAddress::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("WhiteAddress")); pNode->AppendAttr(_T("Name"), GetName()); pNode->AppendAttr(_T("LowerIPAddress"), String(m_iWhiteLowerIPAddress.ToString())); pNode->AppendAttr(_T("UpperIPAddress"), String(m_iWhiteUpperIPAddress.ToString())); pNode->AppendAttr(_T("EMailAddress"), m_sWhiteEmailAddress); pNode->AppendAttr(_T("Description"), m_sWhiteDescription); return true; }
XNode* HighScoreList::CreateNode() const { XNode* pNode = new XNode( "HighScoreList" ); pNode->AppendChild( "NumTimesPlayed", iNumTimesPlayed ); pNode->AppendChild( "LastPlayed", dtLastPlayed.GetString() ); if( HighGrade != Grade_NoData ) pNode->AppendChild( "HighGrade", GradeToString(HighGrade) ); for( unsigned i=0; i<vHighScores.size(); i++ ) { const HighScore &hs = vHighScores[i]; pNode->AppendChild( hs.CreateNode() ); } return pNode; }
void PlayerAI::InitFromDisk() { IniFile ini; ini.ReadFile( AI_PATH ); for( int i=0; i<NUM_SKILL_LEVELS; i++ ) { CString sKey = ssprintf("Skill%d", i); XNode* pNode = ini.GetChild(sKey); if( pNode == NULL ) RageException::Throw( "AI.ini: '%s' doesn't exist.", sKey.c_str() ); TapScoreDistribution& dist = g_Distributions[i]; dist.fPercent[TNS_NONE] = 0; pNode->GetAttrValue( "MissWeight", dist.fPercent[TNS_MISS] ); pNode->GetAttrValue( "BooWeight", dist.fPercent[TNS_BOO] ); pNode->GetAttrValue( "GoodWeight", dist.fPercent[TNS_GOOD] ); pNode->GetAttrValue( "GreatWeight", dist.fPercent[TNS_GREAT] ); pNode->GetAttrValue( "PerfectWeight", dist.fPercent[TNS_PERFECT] ); pNode->GetAttrValue( "MarvelousWeight", dist.fPercent[TNS_MARVELOUS] ); float fSum = 0; for( int j=0; j<NUM_TAP_NOTE_SCORES; j++ ) fSum += dist.fPercent[j]; for( int j=0; j<NUM_TAP_NOTE_SCORES; j++ ) dist.fPercent[j] /= fSum; } }
OrderBy* GetFeatureRequest::ParserOrderBy(XElement* pxOrderBy) { OrderBy* pOrderBy = NULL; FilterFactory* pFilterFactory = augeGetFilterFactoryInstance(); if(!pxOrderBy->HasChildren()) { return NULL; } pOrderBy = pFilterFactory->CreateOrderBy(); char field_name[AUGE_NAME_MAX]; const char* property_name = NULL; XNode* pxNode = NULL; XNodeSet* pxNodeSet = pxOrderBy->GetChildren("PropertyName"); pxNodeSet->Reset(); while((pxNode=pxNodeSet->Next())!=NULL) { property_name = pxNode->GetContent(); if(strlen(property_name)>0) { ParseFieldName(property_name, field_name, AUGE_NAME_MAX); pOrderBy->AddField(field_name); } } pxNodeSet->Release(); XAttribute* pxAttr = pxOrderBy->GetAttribute("order"); if(pxAttr!=NULL) { const char* order = pxAttr->GetValue(); if(order!=NULL) { if(g_stricmp(order,"desc")==0) { pOrderBy->SetOrder(augeOrderDesc); } //pxAttr->Release(); } } return pOrderBy; }
int DiagnosticsUtil::GetNumMachineScores() { // Create the XML Handler and clear it, for practice XNode *xml = new XNode; xml->Clear(); // Check for the file existing if( !IsAFile(STATS_XML_PATH) ) { LOG->Warn( "There is no Stats.xml file!" ); SAFE_DELETE( xml ); return 0; } // Make sure you can read it if( !xml->LoadFromFile(STATS_XML_PATH) ) { LOG->Trace( "Stats.xml unloadable!" ); SAFE_DELETE( xml ); return 0; } const XNode *pData = xml->GetChild( "SongScores" ); if( pData == NULL ) { LOG->Warn( "Error loading scores: <SongScores> node missing" ); SAFE_DELETE( xml ); return 0; } unsigned int iScoreCount = 0; // Named here, for LoadFromFile() renames it to "Stats" xml->m_sName = "SongScores"; // For each pData Child, or the Child in SongScores... FOREACH_CONST_Child( pData , p ) iScoreCount++; SAFE_DELETE( xml ); return iScoreCount; }
void Transition::Load( CString sBGAniDir ) { if( IsADirectory(sBGAniDir) && sBGAniDir.Right(1) != "/" ) sBGAniDir += "/"; this->RemoveAllChildren(); m_sprTransition.Load( sBGAniDir ); m_sprTransition->PlayCommand( "On" ); this->AddChild( m_sprTransition ); m_fLengthSeconds = m_sprTransition->GetTweenTimeLeft(); m_State = waiting; // load sound from file specified by ini, or use the first sound in the directory if( IsADirectory(sBGAniDir) ) { IniFile ini; ini.ReadFile( sBGAniDir+"/BGAnimation.ini" ); CString sSoundFileName; if( ini.GetValue("BGAnimation","Sound", sSoundFileName) ) { FixSlashesInPlace( sSoundFileName ); CString sPath = sBGAniDir+sSoundFileName; CollapsePath( sPath ); m_sound.Load( sPath ); } else { m_sound.Load( sBGAniDir ); } } else if( GetExtension(sBGAniDir).CompareNoCase("xml") == 0 ) { CString sSoundFile; XNode xml; xml.LoadFromFile( sBGAniDir ); if( xml.GetAttrValue( "Sound", sSoundFile ) ) m_sound.Load( Dirname(sBGAniDir) + sSoundFile ); } }
bool PropertySet::XMLStore(XNode *pBackupNode) { XNode *pPropertiesNode = pBackupNode->AppendChild(_T("Properties")); std::map<String, std::shared_ptr<Property> >::iterator iterProperty = items_.begin(); while (iterProperty != items_.end()) { std::shared_ptr<Property> oProperty = (*iterProperty).second; XNode *pNode = pPropertiesNode->AppendChild(String(oProperty->GetName())); pNode->AppendAttr(_T("LongValue"), StringParser::IntToString(oProperty->GetLongValue())); pNode->AppendAttr(_T("StringValue"), oProperty->GetStringValue()); iterProperty++; } return true; }
bool Message::XMLStore(XNode *pParentNode, int iOptions) { XNode *pNode = pParentNode->AppendChild(_T("Message")); String sFilename = filename_; sFilename.Replace(IniFileSettings::Instance()->GetDataDirectory() + _T("\\"), _T("")); pNode->AppendAttr(_T("CreateTime"), String(create_time_)); pNode->AppendAttr(_T("Filename"), FileUtilities::GetFileNameFromFullPath(sFilename)); pNode->AppendAttr(_T("FromAddress"), String(from_address_)); pNode->AppendAttr(_T("State"), StringParser::IntToString(message_state_)); pNode->AppendAttr(_T("Size"), StringParser::IntToString(message_size_)); pNode->AppendAttr(_T("NoOfRetries"), StringParser::IntToString(no_of_retries_)); pNode->AppendAttr(_T("Flags"), StringParser::IntToString(flags_)); pNode->AppendAttr(_T("ID"), StringParser::IntToString(id_)); pNode->AppendAttr(_T("UID"), StringParser::IntToString(uid_)); return true; }
XNode* RadarValues::CreateNode( bool bIncludeSimpleValues, bool bIncludeComplexValues ) const { XNode* pNode = new XNode( "RadarValues" ); // TRICKY: Don't print a remainder for the integer values. FOREACH_ENUM( RadarCategory, rc ) { if( rc >= RadarCategory_TapsAndHolds ) { if( bIncludeSimpleValues ) pNode->AppendChild( RadarCategoryToString(rc), (int)m_Values.f[rc] ); } else { if( bIncludeComplexValues ) pNode->AppendChild( RadarCategoryToString(rc), m_Values.f[rc] ); } } return pNode; }
XElement::XElement(const XNode& xnode) : base(xnode.get_ptr().smart_dynamic_cast<Private::Element>()), XName(m_ptr->XName), Namespaces(m_ptr->Namespaces), Attributes(m_ptr->Attributes), Nodes(m_ptr->Nodes), Elements(m_ptr->Elements), Texts(m_ptr->Texts), Space(m_ptr->Space) { int c = 0; }
XNode* RadarValues::CreateNode() const { XNode* pNode = new XNode; pNode->m_sName = "RadarValues"; // TRICKY: Don't print a remainder for the integer values. FOREACH_RadarCategory( rc ) { if( rc >= RADAR_NUM_TAPS_AND_HOLDS ) { if( WRITE_SIMPLE_VALUES ) pNode->AppendChild( RadarCategoryToString(rc), (int)m_Values.f[rc] ); } else { if( WRITE_COMPLEX_VALUES ) pNode->AppendChild( RadarCategoryToString(rc), m_Values.f[rc] ); } } return pNode; }
XNode* MakeRecentScoreNode( const StageStats &ss, Trail *pTrail, const PlayerStageStats &pss, MultiPlayer mp ) { XNode* pNode = nullptr; if( GAMESTATE->IsCourseMode() ) { pNode = new XNode( "HighScoreForACourseAndTrail" ); CourseID courseID; courseID.FromCourse(GAMESTATE->m_pCurCourse ); pNode->AppendChild( courseID.CreateNode() ); TrailID trailID; trailID.FromTrail( pTrail ); pNode->AppendChild( trailID.CreateNode() ); } else { pNode = new XNode( "HighScoreForASongAndSteps" ); SongID songID; songID.FromSong( ss.m_vpPossibleSongs[0] ); pNode->AppendChild( songID.CreateNode() ); StepsID stepsID; stepsID.FromSteps( pss.m_vpPossibleSteps[0] ); pNode->AppendChild( stepsID.CreateNode() ); } XNode* pHighScore = pss.m_HighScore.CreateNode(); pHighScore->AppendChild("Pad", mp); pHighScore->AppendChild("StageGuid", GAMESTATE->m_sStageGUID); pHighScore->AppendChild("Guid", CryptManager::GenerateRandomUUID()); pNode->AppendChild( pHighScore ); return pNode; }
void ClassTester::_LoadSettings() { String sAppPath = Utilities::GetExecutableDirectory(); if (sAppPath.Right(1) != _T("\\")) sAppPath += _T("\\"); String sConfigFile = sAppPath + "test_config.xml"; String sTestSpec = FileUtilities::ReadCompleteTextFile(sConfigFile); if (sTestSpec.IsEmpty()) return; XDoc oDoc; oDoc.Load(sTestSpec); XNode *pBackupNode = oDoc.GetChild(_T("Config")); if (!pBackupNode) throw; m_sMimeDataPath = pBackupNode->GetChildValue(_T("MimeDataPath")); }