From 669934eb1a3f2e0b3aaeac03c054aebe7531e8b7 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Sat, 16 May 2020 20:24:25 +1000 Subject: [PATCH] GameList: Support exporting XML snippets for compatibility info --- src/core/game_list.cpp | 16 ++++++++++++++++ src/core/game_list.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/src/core/game_list.cpp b/src/core/game_list.cpp index 96004fa1c..3fd995459 100644 --- a/src/core/game_list.cpp +++ b/src/core/game_list.cpp @@ -1149,3 +1149,19 @@ bool GameList::SaveCompatibilityDatabaseForEntry(const GameListCompatibilityEntr Log_InfoPrintf("Updated compatibility list '%s'", m_compatibility_list_filename.c_str()); return true; } + +std::string GameList::ExportCompatibilityEntry(const GameListCompatibilityEntry* entry) +{ + tinyxml2::XMLDocument doc; + tinyxml2::XMLElement* root_elem = doc.NewElement("compatibility-list"); + doc.InsertEndChild(root_elem); + + tinyxml2::XMLElement* entry_elem = doc.NewElement("entry"); + root_elem->InsertEndChild(entry_elem); + InitElementForCompatibilityEntry(&doc, entry_elem, entry); + + tinyxml2::XMLPrinter printer; + //doc.Print(&printer); + entry_elem->Accept(&printer); + return std::string(printer.CStr(), printer.CStrSize()); +} diff --git a/src/core/game_list.h b/src/core/game_list.h index 9ac07f653..d98e9713d 100644 --- a/src/core/game_list.h +++ b/src/core/game_list.h @@ -110,6 +110,8 @@ public: void UpdateCompatibilityEntry(GameListCompatibilityEntry new_entry, bool save_to_list = true); + static std::string ExportCompatibilityEntry(const GameListCompatibilityEntry* entry); + private: enum : u32 {