Herunterladen als
root/src/enums/databasetype.h @ 14f9beed
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>
|
|
14f9beed | Christian Ehringfeld | #include <QSharedPointer>
|
|
b0b8dac3 | Christian Ehringfeld | #include "../schema/sqliteschema.h"
|
|
a604a5a2 | Christian Ehringfeld | ||
6899f814 | Christian Ehringfeld | namespace CuteEntityManager {
|
|
14f9beed | Christian Ehringfeld | class Schema;
|
|
class Database;
|
|||
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;
|
|
}
|
|||
}
|
|||
14f9beed | Christian Ehringfeld | static const QSharedPointer<Schema> getSchema(int db, QSharedPointer<Database> database) {
|
|
b0b8dac3 | Christian Ehringfeld | switch (db) {
|
|
case SQLITE:
|
|||
14f9beed | Christian Ehringfeld | return QSharedPointer<Schema>(new SqliteSchema(database));;
|
|
a604a5a2 | Christian Ehringfeld | break;
|
|
14f9beed | Christian Ehringfeld | // case PGSQL:
|
|
// return QSharedPointer<Schema>(new PgSqlSchema());
|
|||
// break;
|
|||
// case MYSQL:
|
|||
// return QSharedPointer<Schema>(new MysqlSchema());
|
|||
// break;
|
|||
b0b8dac3 | Christian Ehringfeld | default:
|
|
14f9beed | Christian Ehringfeld | return QSharedPointer<Schema>(new SqliteSchema(database));
|
|
b0b8dac3 | Christian Ehringfeld | break;
|
|
}
|
|||
}
|
|||
81c23b56 | Christian Ehringfeld | }
|
|
#endif // DATABASETYPE_H
|