/* Copyright (C) 2015 * swift Project Community / Contributors * * This file is part of swift project. It is subject to the license terms in the LICENSE file found in the top-level * directory of this distribution and at http://www.swift-project.org/license.html. No part of swift project, * including this file, may be copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE file. */ #include "blackmisc/datastoreobjectlist.h" #include "blackmisc/predicates.h" #include "blackmisc/countrylist.h" #include "blackmisc/aviation/liverylist.h" #include "blackmisc/aviation/aircrafticaocodelist.h" #include "blackmisc/aviation/airlineicaocodelist.h" #include "blackmisc/simulation/aircraftmodellist.h" #include "blackmisc/simulation/distributorlist.h" #include #include namespace BlackMisc { template IDatastoreObjectListWithIntegerKey::IDatastoreObjectListWithIntegerKey() { } template IDatastoreObjectListWithStringKey::IDatastoreObjectListWithStringKey() { } template OBJ IDatastoreObjectListWithIntegerKey::findByKey(int key, const OBJ ¬Found) const { return this->container().findFirstByOrDefault(&OBJ::getDbKey, key, notFound); } template OBJ IDatastoreObjectListWithStringKey::findByKey(const QString &key, const OBJ ¬Found) const { return this->container().findFirstByOrDefault(&OBJ::getDbKey, key, notFound); } template void IDatastoreObjectListWithIntegerKey::sortByKey() { this->container().sort(BlackMisc::Predicates::MemberLess(&OBJ::getDbKey)); } template void IDatastoreObjectListWithStringKey::sortByKey() { this->container().sort(BlackMisc::Predicates::MemberLess(&OBJ::getDbKey)); } template QStringList IDatastoreObjectListWithStringKey::toDbKeyList() const { QStringList keys; for (const OBJ &obj : ITimestampObjectList::container()) { keys.append(obj.getDbKey()); } return keys; } template CONTAINER IDatastoreObjectListWithIntegerKey::fromDatabaseJson(const QJsonArray &array) { CONTAINER container; for (const QJsonValue &value : array) { container.push_back(OBJ::fromDatabaseJson(value.toObject())); } return container; } template CONTAINER IDatastoreObjectListWithStringKey::fromDatabaseJson(const QJsonArray &array) { CONTAINER container; for (const QJsonValue &value : array) { container.push_back(OBJ::fromDatabaseJson(value.toObject())); } return container; } // see here for the reason of thess forward instantiations // http://www.parashift.com/c++-faq/separate-template-class-defn-from-decl.html template class IDatastoreObjectListWithIntegerKey; template class IDatastoreObjectListWithIntegerKey; template class IDatastoreObjectListWithIntegerKey; template class IDatastoreObjectListWithIntegerKey; template class IDatastoreObjectListWithStringKey; template class IDatastoreObjectListWithStringKey; } // namespace