Revision ac5cbdcf
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
EntityManager.pro | ||
---|---|---|
INSTALLS += target
|
||
}
|
||
CONFIG += c++14
|
||
QMAKE_CXXFLAGS += -Wall -Wextra -Wuninitialized -Wmaybe-uninitialized -Wsuggest-final-types -Wstrict-overflow -Wsuggest-final-methods -Wsuggest-override -Wunsafe-loop-optimizations -Waddress
|
src/entity.cpp | ||
---|---|---|
} else if (value.canConvert<QList<QVariant>>()) {
|
||
auto list = value.toList();
|
||
val.append("[");
|
||
for (int var = 0; var < list.size(); ++var) {
|
||
val = list.at(var).toString();
|
||
for (int i = 0; i < list.size(); ++i) {
|
||
val = list.at(i).toString();
|
||
}
|
||
val.append("]");
|
||
} else {
|
src/entitymanager.h | ||
---|---|---|
*/
|
||
public:
|
||
template<class T> qint8 count(QHash<QString, QString> condition =
|
||
QHash<QString, QString>()) {
|
||
QHash<QString, QVariant>()) {
|
||
Entity *e = EntityInstanceFactory::createInstance<T>();
|
||
qint8 rc = 0;
|
||
if (e) {
|
||
... | ... | |
(EntityInstanceFactory::createInstance<T>());
|
||
if (ptr) {
|
||
auto maps = this->findAll(ptr);
|
||
const char *className = ptr.data()->getClassname();
|
||
return this->convert(maps, className);
|
||
return this->convert(maps, ptr->getClassname());
|
||
}
|
||
return QList<QSharedPointer<Entity>>();
|
||
}
|
||
... | ... | |
}
|
||
|
||
template<class T> QSharedPointer<Entity> findEntityByAttributes(
|
||
const QHash<QString, QString>
|
||
const QHash<QString, QVariant>
|
||
&attributes) {
|
||
auto list = this->findAllEntitiesByAttributes<T>(attributes, 1, 0);
|
||
if (list.isEmpty()) {
|
||
... | ... | |
}
|
||
|
||
template<class T> QList<QSharedPointer<Entity>> findAllEntitiesByAttributes(
|
||
const QHash<QString, QString> &attributes =
|
||
const QHash<QString, QVariant> &attributes =
|
||
QHash<QString, QString>(), quint32 limit = 0, quint32 offset = 0) {
|
||
auto list = this->findAllEntitiesByAttributes<T>(attributes);
|
||
return list;
|
||
QSharedPointer<Entity> e = QSharedPointer<Entity>
|
||
(EntityInstanceFactory::createInstance<T>());
|
||
if (e) {
|
||
auto results = this->findAllByAttributes(attributes, e->getTablename());
|
||
auto list = this->convert(results, e->getClassname());
|
||
return list;
|
||
}
|
||
return QList<QSharedPointer<Entity>>();
|
||
}
|
||
|
||
template<class T> QList<QSharedPointer<Entity>> findEntitiesBySql(
|
src/schema/sqlitequerybuilder.h | ||
---|---|---|
QSharedPointer<Database> database);
|
||
~SqliteQueryBuilder();
|
||
|
||
virtual QString truncateTable(QString tableName) const;
|
||
virtual QString dropIndex(QString name, QString tableName) const;
|
||
virtual QString dropColumn(QString tableName, QString columnName)const;
|
||
virtual QString truncateTable(QString tableName) const override;
|
||
virtual QString dropIndex(QString name, QString tableName) const override;
|
||
virtual QString dropColumn(QString tableName, QString columnName)const override;
|
||
virtual QString renameColumn(QString tableName, QString oldName,
|
||
QString newName) const;
|
||
virtual QString addForeignKey(QString name, QString tableName, QStringList columns,
|
||
QString newName) const override;
|
||
virtual QString addForeignKey(QString name, QString tableName,
|
||
QStringList columns,
|
||
QString refTableName,
|
||
QStringList refColumns, QString deleteConstraint,
|
||
QString updateConstraint) const;
|
||
virtual QString dropForeignKey(QString name, QString tableName) const;
|
||
QString updateConstraint) const override;
|
||
virtual QString dropForeignKey(QString name, QString tableName) const override;
|
||
virtual QString alterColumn(QString tableName, QString columnName,
|
||
QString newType) const;
|
||
QString newType) const override;
|
||
virtual QString addPrimaryKey(QString name, QString tableName,
|
||
QStringList columns) const;
|
||
virtual QString dropPrimaryKey(QString name, QString tableName) const;
|
||
virtual bool supportsForeignKeys() const;
|
||
QStringList columns) const override;
|
||
virtual QString dropPrimaryKey(QString name, QString tableName) const override;
|
||
virtual bool supportsForeignKeys() const override;
|
||
};
|
||
|
||
}
|
src/schema/sqliteschema.h | ||
---|---|---|
public:
|
||
SqliteSchema(QSharedPointer<Database> database);
|
||
~SqliteSchema();
|
||
QSharedPointer<QHash<QString, QString> > getTypeMap();
|
||
QSharedPointer<QHash<QString, QString> > getTypeMap() override;
|
||
protected:
|
||
|
||
virtual QStringList findTableNames(QString schema = "");
|
||
virtual QHash<QString, QStringList> findUniqueIndexes(const QSharedPointer<TableSchema>
|
||
&table);
|
||
virtual void findConstraints(const QSharedPointer<TableSchema> &ts);
|
||
virtual bool findColumns(const QSharedPointer<TableSchema> &ts);
|
||
virtual QSharedPointer<TableSchema> loadTableSchema(QString name);
|
||
virtual QStringList findTableNames(QString schema = "") override;
|
||
virtual QHash<QString, QStringList> findUniqueIndexes(const
|
||
QSharedPointer<TableSchema>
|
||
&table) override;
|
||
virtual void findConstraints(const QSharedPointer<TableSchema> &ts) override;
|
||
virtual bool findColumns(const QSharedPointer<TableSchema> &ts) override;
|
||
virtual QSharedPointer<TableSchema> loadTableSchema(QString name) override;
|
||
};
|
||
}
|
||
#endif // SQLITESCHEMA_H
|
Auch abrufbar als: Unified diff
stackoverflow fix in em