6#include <QStringBuilder>
10using namespace swift::misc::network;
14namespace swift::misc::db
63 return QStringLiteral(
"Table %1 with entries %1").arg(m_tableName).arg(m_entries);
97 case IndexEntity: this->
setEntity(
static_cast<CEntityFlags::Entity
>(variant.
toInt()));
break;
127 default: Q_ASSERT_X(
false, Q_FUNC_INFO,
"No comparison possible");
139 const int id(json.value(prefix % u
"id").toInt());
140 const int entries(json.value(prefix % u
"entries").toInt());
141 const QString tableName(json.value(prefix % u
"tablename").toString());
142 CDbInfo dbInfo(
id, tableName, entries);
149 static const QStringList names({
"aircrafticao.json",
"airlineicao.json",
"airports.json",
"countries.json",
150 "distributors.json",
"liveries.json",
"models.json",
151 "aircraftcategories.json" });
157 static const QString f(
"dbinfo.json");
163 static const QStringList names({
"jsonaircrafticao.php",
"jsonairlineicao.php",
"jsonairport.php",
164 "jsoncountry.php",
"jsondistributor.php",
"jsonlivery.php",
165 "jsonaircraftmodel.php",
"jsonaircraftcategory.php" });
Non-owning reference to a CPropertyIndex with a subset of its features.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
bool isMyself() const
Myself index, used with nesting.
CDbInfo()=default
Constructor.
int comparePropertyByIndex(CPropertyIndexRef index, const CDbInfo &compareValue) const
Compare by index.
const QString & getSharedFileName() const
The shared file name such as "airports.json".
static const QString & sharedInfoFileName()
Get shared info file name.
void setEntries(int entries)
Set entries.
const QString & getServiceName() const
Service name such as "jsonairport.php".
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
static const QStringList & sharedFileNames()
The shared file names.
ColumnIndex
Properties by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
bool isValid() const
Valid?
static const QStringList & serviceNames()
Service names.
static const QString & entityToSharedName(network::CEntityFlags::Entity entity)
Get shared file name.
bool matchesEntity(network::CEntityFlags::Entity entity) const
Matches given entity.
int getEntries() const
Entry count.
QString convertToQString(bool i18n=false) const
Cast as QString.
static CDbInfo fromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
From our database JSON format.
void setEntity(network::CEntityFlags::Entity entity)
Set entity, should be in sync with a corresponding table name.
void setTableName(const QString &tableName)
Set table name.
static const QString & entityToServiceName(network::CEntityFlags::Entity entity)
Get service file name.
network::CEntityFlags::Entity getEntity() const
Get entity (based on table name.
const QString & getTableName() const
Table name.
IDatastoreObjectWithIntegerKey()
Constructor.
QVariant propertyByIndex(swift::misc::CPropertyIndexRef index) const
Property by index.
static bool existsKey(const QJsonObject &json, const QString &prefix=QString())
Is a key available?
static bool canHandleIndex(swift::misc::CPropertyIndexRef index)
Can given index be handled?
int comparePropertyByIndex(CPropertyIndexRef index, const IDatastoreObjectWithIntegerKey &compareValue) const
Compare for index.
void setKeyVersionTimestampFromDatabaseJson(const QJsonObject &json, const QString &prefix=QString())
Set key and timestamp values.
void setPropertyByIndex(swift::misc::CPropertyIndexRef index, const QVariant &variant)
Set property by index.
void setPropertyByIndex(CPropertyIndexRef index, const QVariant &variant)
Set property by index.
QVariant propertyByIndex(CPropertyIndexRef index) const
Property by index.
static EntityFlag entityToEntityFlag(Entity entity)
To flag (when explicit conversion is needed).
static Entity singleEntityByName(const QString &name)
Get by name.
@ AircraftCategoryEntity
aircraft category entities
@ CountryEntity
country codes
@ AirlineIcaoEntity
ICAO codes for airlines.
@ AircraftIcaoEntity
ICAO codes for aircraft.
@ DistributorEntity
distributors
int compare(T a, T b)
Compare arithmetic values.
QList< T >::const_reference at(qsizetype i) const const
int compare(QLatin1StringView s1, const QString &s2, Qt::CaseSensitivity cs)
bool isEmpty() const const
QString toLower() const const
QString trimmed() const const
QVariant fromValue(T &&value)
int toInt(bool *ok) const const
QString toString() const const
#define SWIFT_DEFINE_VALUEOBJECT_MIXINS(Namespace, Class)
Explicit template definition of mixins for a CValueObject subclass.