Herunterladen als
root/src/enums/databasetype.h @ 426974c6
81c23b56 | Christian Ehringfeld | /*
|
|
6899f814 | Christian Ehringfeld | * Copyright (C) 2015 Christian Ehringfeld <c.ehringfeld@t-online.de>
|
|
*
|
|||
* This program is free software; you can redistribute it and/or modify it
|
|||
* under the terms of the GNU Lesser General Public License as published by
|
|||
* the Free Software Foundation.
|
|||
*
|
|||
* This program is distributed in the hope that it will be useful, but
|
|||
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|||
* for more details.
|
|||
*
|
|||
* You should have received a copy of the GNU Lesser General Public License
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|||
*/
|
|||
81c23b56 | Christian Ehringfeld | ||
#ifndef DATABASETYPE_H
|
|||
#define DATABASETYPE_H
|
|||
b0b8dac3 | Christian Ehringfeld | #include <QString>
|
|
#include "../schema.h"
|
|||
#include "../schema/sqliteschema.h"
|
|||
a604a5a2 | Christian Ehringfeld | #include "../schema/pgsqlschema.h"
|
|
#include "../schema/mysqlschema.h"
|
|||
#include <memory>
|
|||
6899f814 | Christian Ehringfeld | namespace CuteEntityManager {
|
|
b0b8dac3 | Christian Ehringfeld | enum DatabaseType {
|
|
426974c6 | Christian Ehringfeld | SQLITE = 0,
|
|
PGSQL = 1,
|
|||
MYSQL = 2
|
|||
b0b8dac3 | Christian Ehringfeld | };
|
|
a604a5a2 | Christian Ehringfeld | static const DatabaseType getDatabaseType(QString s) {
|
|
426974c6 | Christian Ehringfeld | if (s == "qmysql") {
|
|
b0b8dac3 | Christian Ehringfeld | return CuteEntityManager::MYSQL;
|
|
426974c6 | Christian Ehringfeld | } else if (s == "qpgsql") {
|
|
b0b8dac3 | Christian Ehringfeld | return CuteEntityManager::PGSQL;
|
|
a604a5a2 | Christian Ehringfeld | } else {
|
|
b0b8dac3 | Christian Ehringfeld | return CuteEntityManager::SQLITE;
|
|
}
|
|||
}
|
|||
a604a5a2 | Christian Ehringfeld | static const std::shared_ptr<Schema> getSchema(int db) {
|
|
b0b8dac3 | Christian Ehringfeld | switch (db) {
|
|
case SQLITE:
|
|||
a604a5a2 | Christian Ehringfeld | return std::shared_ptr<Schema>(new SqliteSchema());
|
|
b0b8dac3 | Christian Ehringfeld | break;
|
|
case PGSQL:
|
|||
a604a5a2 | Christian Ehringfeld | return std::shared_ptr<Schema>(new PgSqlSchema());
|
|
break;
|
|||
b0b8dac3 | Christian Ehringfeld | case MYSQL:
|
|
a604a5a2 | Christian Ehringfeld | return std::shared_ptr<Schema>(new MysqlSchema());
|
|
break;
|
|||
b0b8dac3 | Christian Ehringfeld | default:
|
|
a604a5a2 | Christian Ehringfeld | return std::shared_ptr<Schema>(new SqliteSchema());
|
|
b0b8dac3 | Christian Ehringfeld | break;
|
|
}
|
|||
}
|
|||
81c23b56 | Christian Ehringfeld | }
|
|
#endif // DATABASETYPE_H
|