mirror of
https://gitlab.com/manzerbredes/ochess.git
synced 2025-04-07 02:26:29 +02:00
Update db code
This commit is contained in:
parent
e5ba738f72
commit
f40fd3e7a4
2 changed files with 22 additions and 1 deletions
13
src/base_tab/gamebase/GameBase.cpp
Normal file
13
src/base_tab/gamebase/GameBase.cpp
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
#include "GameBase.hpp"
|
||||||
|
#include "PGNGameBase.hpp"
|
||||||
|
|
||||||
|
std::shared_ptr<GameBase> OpenDatabase(const std::string &dbpath, bool createIfNotExist){
|
||||||
|
wxFileName file(dbpath);
|
||||||
|
wxString ext = file.GetExt().Lower();
|
||||||
|
if (ext == "pgn") {
|
||||||
|
if(createIfNotExist && !file.Exists())
|
||||||
|
PGNGameBase::CreateDatabaseFile(dbpath);
|
||||||
|
return std::shared_ptr<GameBase>(new PGNGameBase(dbpath));
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
|
@ -27,4 +27,12 @@ public:
|
||||||
* @brief An additionnal static method is expected with the following signature:
|
* @brief An additionnal static method is expected with the following signature:
|
||||||
* static void CreateDatabaseFile(std::string path);
|
* static void CreateDatabaseFile(std::string path);
|
||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Open a data
|
||||||
|
*
|
||||||
|
* @param dbpath
|
||||||
|
* @return std::shared_ptr<GameBase>
|
||||||
|
*/
|
||||||
|
std::shared_ptr<GameBase> OpenDatabase(const std::string &dbpath, bool createIfNotExist=true);
|
Loading…
Add table
Reference in a new issue