Projekt

Allgemein

Profil

Herunterladen als
Herunterladen (1,63 KB) Statistiken
| Zweig: | Revision:
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 Database;
b0b8dac3 Christian Ehringfeld
enum DatabaseType {
426974c6 Christian Ehringfeld
SQLITE = 0,
PGSQL = 1,
MYSQL = 2
b0b8dac3 Christian Ehringfeld
};

9d05e414 Christian Ehringfeld
static DatabaseType getDatabaseType(QString s) {
426974c6 Christian Ehringfeld
if (s == "qmysql") {
9d05e414 Christian Ehringfeld
return DatabaseType::MYSQL;
426974c6 Christian Ehringfeld
} else if (s == "qpgsql") {
9d05e414 Christian Ehringfeld
return DatabaseType::PGSQL;
a604a5a2 Christian Ehringfeld
} else {
9d05e414 Christian Ehringfeld
return DatabaseType::SQLITE;
b0b8dac3 Christian Ehringfeld
}
}

9d05e414 Christian Ehringfeld
static 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