Revision 6c58eb3f
Von Christian Ehringfeld vor mehr als 9 Jahren hinzugefügt
samples/example/main.cpp | ||
---|---|---|
* ---------------------------------
|
||
*/
|
||
QSharedPointer<Entity> groupFindPtr = e->findById<Group *>(1);
|
||
qDebug() << "GroupID:" << groupFindPtr->getId();
|
||
QSharedPointer<Group> grp = groupFindPtr.objectCast<Group>();
|
||
qDebug()<< "Group:" << groupFindPtr->toString();
|
||
qDebug() << "PersonSize:" << grp->getPersons().size();
|
||
qDebug() << "MainTeacher:" << grp->getMainTeacher()->toString();
|
||
qDebug() << "Duration:" << t.elapsed();
|
src/entity.cpp | ||
---|---|---|
r.append(": {");
|
||
auto properties = this->getMetaProperties();
|
||
for (auto var = properties.constBegin(); var != properties.constEnd(); ++var) {
|
||
r.append(var.key() + ": " + var.value().read(this).toString() + ", ");
|
||
QString val = "";
|
||
auto value = var.value().read(this);
|
||
if (var.value().isEnumType()) {
|
||
val = var.value().enumerator().valueToKey(var.value().read(this).toInt());
|
||
} 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();
|
||
}
|
||
val.append("]");
|
||
} else {
|
||
val = value.toString();
|
||
}
|
||
r.append(var.key() + ": " + val + ", ");
|
||
}
|
||
r.append("}");
|
||
return r;
|
||
}
|
||
|
||
QString Entity::slimToString() const {
|
||
QString r = "";
|
||
r.append(this->getClassname());
|
||
r.append(": {");
|
||
r.append("id: ") + this->getId() + "}";
|
||
return r;
|
||
}
|
||
|
||
Entity::~Entity() {
|
||
|
||
}
|
src/entity.h | ||
---|---|---|
void setId(const qint64 &value);
|
||
|
||
protected:
|
||
virtual QString slimToString() const;
|
||
qint64 id;
|
||
};
|
||
}
|
Auch abrufbar als: Unified diff
toString for entity not completed