#include "GameBase.hpp" #include "PGNGameBase.hpp" std::shared_ptr OpenDatabase(const std::string &dbpath, bool createIfNotExist){ wxFileName file(dbpath); wxString ext = file.GetExt().Lower(); bool create=(createIfNotExist && !file.Exists()); if (ext == "pgn") { if(create) PGNGameBase::CreateDatabaseFile(dbpath); return std::shared_ptr(new PGNGameBase(dbpath)); } return nullptr; } std::shared_ptr OpenGameX(const std::string &dbpath, long id){ std::shared_ptr base=OpenDatabase(dbpath); return base->GetGame(id); } void SaveGame(const std::string &dbpath, std::shared_ptr g){ wxFileName file(dbpath); wxString ext = file.GetExt().Lower(); // Create data structure std::vector> new_games; new_games.push_back(g); std::vector dummy_empty_bases; std::vector dummy_empty_ignores; // Save the game if (ext == "pgn") { PGNGameBase::CreateDatabaseFile(dbpath); // Erase if exist GameBase *b=new PGNGameBase(dbpath); b->Save(dummy_empty_ignores,dummy_empty_bases, new_games); } }