swift
Loading...
Searching...
No Matches
swift::misc::db::IDatastoreObjectWithStringKey Class Reference

Class from which a derived class can inherit datastore-related functions. More...

#include <datastore.h>

Inheritance diagram for swift::misc::db::IDatastoreObjectWithStringKey:
[legend]

Public Types

enum  ColumnIndex {
  IndexDbStringKey = CPropertyIndexRef::GlobalIndexIDatastoreString , IndexDbKeyAsString , IndexIsLoadedFromDb , IndexDatabaseIcon ,
  IndexVersion , IndexEndMarker
}
 Property index. More...
Public Types inherited from swift::misc::ITimestampBased
enum  ColumnIndex {
  IndexUtcTimestamp = CPropertyIndexRef::GlobalIndexITimestampBased , IndexUtcTimestampFormattedYmdhms , IndexUtcTimestampFormattedYmdhmsz , IndexUtcTimestampFormattedMdhms ,
  IndexUtcTimestampFormattedMdhmsz , IndexUtcTimestampFormattedDhms , IndexUtcTimestampFormattedHms , IndexUtcTimestampFormattedHm ,
  IndexMSecsSinceEpoch
}
 Properties by index. More...

Public Member Functions

const QString & getDbKey () const
 Get DB key.
QString getDbKeyAsString () const
 DB key as string.
QJsonValue getDbKeyAsJsonValue () const
 Key as JSON value, or null.
QString getDbKeyAsStringInParentheses (const QString &prefix={}) const
 Db key in parentheses, e.g. "(3)".
void setDbKey (const QString &key)
 Set the DB key.
bool hasValidDbKey () const
 Has valid DB key.
bool isDbEqual (const IDatastoreObjectWithStringKey &other) const
 Same DB key and hence equal.
bool isLoadedFromDb () const
 Loaded from DB.
void setLoadedFromDb (bool loaded)
 Mark as loaded from DB.
bool matchesDbKeyState (db::DbKeyStateFilter filter) const
 Matches filter?
const CIcon & toDatabaseIcon () const
 Database icon if this has valid key, otherwise empty.
Public Member Functions inherited from swift::misc::db::IDatastoreObject
const QString & getVersion () const
 Version info.
QVersionNumber getQVersion () const
 Version as QVersion.
bool hasVersion () const
 Having a version?s.
void setVersion (const QString &version)
 Version info.
Public Member Functions inherited from swift::misc::ITimestampBased
QDateTime getUtcTimestamp () const
 Get timestamp.
qint64 getMSecsSinceEpoch () const
 Timestamp as ms value.
qint64 getTimeDifferenceMs (qint64 compareTime) const
 Time difference in ms.
qint64 getTimeDifferenceAbsMs (qint64 compareTime) const
 Time difference in ms.
qint64 getTimeDifferenceToNowMs () const
 Time difference to now.
qint64 getTimeDifferenceMs (const ITimestampBased &compare) const
 Time difference in ms.
qint64 getAbsTimeDifferenceMs (qint64 compareTime) const
 Time difference in ms.
qint64 getAbsTimeDifferenceMs (const ITimestampBased &compare) const
 Time difference in ms.
void setTimestampToNull ()
 Set to null.
void setMSecsSinceEpoch (qint64 mSecsSinceEpoch)
 Timestamp as ms value.
void setByYearMonthDayHourMinute (const QString &yyyyMMddhhmmss)
 Set by value such as "20141003231045".
void setUtcTimestamp (const QDateTime &timestamp)
 Set timestamp.
bool isNewerThan (const ITimestampBased &otherTimestampObj) const
 Is this newer than other?
bool isNewerThan (qint64 mSecsSinceEpoch) const
 Is newer than epoch value?
bool isOlderThan (const ITimestampBased &otherTimestampObj) const
 Is this older than other?
bool isOlderThan (qint64 mSecsSinceEpoch) const
 Is this older than other?
bool isOlderThanNowMinusOffset (int offsetMs) const
 Older than now-offset.
bool isSame (const ITimestampBased &otherTimestampObj) const
 Same timestamp.
qint64 msecsTo (const ITimestampBased &otherTimestampObj) const
 Time difference.
qint64 absMsecsTo (const ITimestampBased &otherTimestampObj) const
 Time difference.
qint64 msecsToNow () const
 Milliseconds to now.
void setCurrentUtcTime ()
 Set the current time as timestamp.
void addMsecs (qint64 ms)
 Add the given number of milliseconds to the timestamp.
QString getFormattedUtcTimestampHms () const
 As hh:mm:ss.
QString getFormattedUtcTimestampHmsz () const
 As hh:mm:ss.zzz.
QString getFormattedUtcTimestampHm () const
 As hh:mm.
QString getFormattedUtcTimestampDhms () const
 As dd HH mm ss.
QString getFormattedUtcTimestampMdhms () const
 As MM dd HH mm ss.
QString getFormattedUtcTimestampMdhmsz () const
 As MM dd HH mm ss.zzz.
QString getFormattedUtcTimestampYmdhms () const
 As yyyy MM dd HH mm ss.
QString getFormattedUtcTimestampYmdhmsz () const
 As yyyy MM dd HH mm ss.zzz.
bool hasValidTimestamp () const
 Valid timestamp?

Static Public Member Functions

static QString invalidDbKey ()
 Invalid key.
static const CPropertyIndex & keyIndex ()
 The key index.
Static Public Member Functions inherited from swift::misc::ITimestampBased
static bool isAnyTimestampIndex (int index)
 Any of the timestamp indexes.
static bool canHandleIndex (CPropertyIndexRef index)
 Can given index be handled.

Protected Member Functions

 IDatastoreObjectWithStringKey ()
 Constructor.
 IDatastoreObjectWithStringKey (const QString &key)
 Constructor.
void setKeyVersionTimestampFromDatabaseJson (const QJsonObject &json, const QString &prefix=QString())
 Set key and timestamp values.
QVariant propertyByIndex (swift::misc::CPropertyIndexRef index) const
 Property by index.
void setPropertyByIndex (swift::misc::CPropertyIndexRef index, const QVariant &variant)
 Set property by index.
int comparePropertyByIndex (swift::misc::CPropertyIndexRef index, const IDatastoreObjectWithStringKey &compareValue) const
 Compare for index.
Protected Member Functions inherited from swift::misc::db::IDatastoreObject
void setTimestampVersionFromDatabaseJson (const QJsonObject &json, const QString &prefix=QString())
 Set versionn and timestamp values.
Protected Member Functions inherited from swift::misc::ITimestampBased
 ITimestampBased ()=default
 Constructor.
 ITimestampBased (qint64 msSincePoch)
 Constructor.
 ITimestampBased (const QDateTime &timestamp)
 Constructor.
QVariant propertyByIndex (CPropertyIndexRef index) const
 Property by index.
void setPropertyByIndex (CPropertyIndexRef index, const QVariant &variant)
 Set property by index.
int comparePropertyByIndex (CPropertyIndexRef index, const ITimestampBased &compareValue) const
 Compare for index.
void updateMissingParts (const ITimestampBased &other)
 Update missing parts.

Static Protected Member Functions

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.

Protected Attributes

QString m_dbKey
 key
bool m_loadedFromDb
 as we have no artificial key, it can happen key is set, but not loaded from DB
Protected Attributes inherited from swift::misc::db::IDatastoreObject
QString m_version
 version info
Protected Attributes inherited from swift::misc::ITimestampBased
qint64 m_timestampMSecsSinceEpoch = -1
 timestamp value

Detailed Description

Class from which a derived class can inherit datastore-related functions.

Definition at line 165 of file datastore.h.

Member Enumeration Documentation

◆ ColumnIndex

Property index.

Enumerator
IndexEndMarker 

keep as last element

Definition at line 169 of file datastore.h.

Constructor & Destructor Documentation

◆ IDatastoreObjectWithStringKey() [1/2]

swift::misc::db::IDatastoreObjectWithStringKey::IDatastoreObjectWithStringKey ( )
inlineprotected

Constructor.

Definition at line 227 of file datastore.h.

◆ IDatastoreObjectWithStringKey() [2/2]

swift::misc::db::IDatastoreObjectWithStringKey::IDatastoreObjectWithStringKey ( const QString & key)
inlineprotected

Constructor.

Definition at line 230 of file datastore.h.

Member Function Documentation

◆ canHandleIndex()

bool swift::misc::db::IDatastoreObjectWithStringKey::canHandleIndex ( swift::misc::CPropertyIndexRef index)
staticprotected

Can given index be handled.

Definition at line 290 of file datastore.cpp.

◆ comparePropertyByIndex()

int swift::misc::db::IDatastoreObjectWithStringKey::comparePropertyByIndex ( swift::misc::CPropertyIndexRef index,
const IDatastoreObjectWithStringKey & compareValue ) const
protected

Compare for index.

Definition at line 270 of file datastore.cpp.

◆ existsKey()

bool swift::misc::db::IDatastoreObjectWithStringKey::existsKey ( const QJsonObject & json,
const QString & prefix = QString() )
staticprotected

Is a key available?

Definition at line 227 of file datastore.cpp.

◆ getDbKey()

const QString & swift::misc::db::IDatastoreObjectWithStringKey::getDbKey ( ) const
inline

Get DB key.

Definition at line 180 of file datastore.h.

◆ getDbKeyAsJsonValue()

QJsonValue swift::misc::db::IDatastoreObjectWithStringKey::getDbKeyAsJsonValue ( ) const

Key as JSON value, or null.

Definition at line 181 of file datastore.cpp.

◆ getDbKeyAsString()

QString swift::misc::db::IDatastoreObjectWithStringKey::getDbKeyAsString ( ) const
inline

DB key as string.

Definition at line 183 of file datastore.h.

◆ getDbKeyAsStringInParentheses()

QString swift::misc::db::IDatastoreObjectWithStringKey::getDbKeyAsStringInParentheses ( const QString & prefix = {}) const

Db key in parentheses, e.g. "(3)".

Definition at line 191 of file datastore.cpp.

◆ hasValidDbKey()

bool swift::misc::db::IDatastoreObjectWithStringKey::hasValidDbKey ( ) const
inline

Has valid DB key.

Definition at line 195 of file datastore.h.

◆ invalidDbKey()

QString swift::misc::db::IDatastoreObjectWithStringKey::invalidDbKey ( )
inlinestatic

Invalid key.

Definition at line 216 of file datastore.h.

◆ isDbEqual()

bool swift::misc::db::IDatastoreObjectWithStringKey::isDbEqual ( const IDatastoreObjectWithStringKey & other) const
inline

Same DB key and hence equal.

Definition at line 198 of file datastore.h.

◆ isLoadedFromDb()

bool swift::misc::db::IDatastoreObjectWithStringKey::isLoadedFromDb ( ) const
inline

Loaded from DB.

Definition at line 204 of file datastore.h.

◆ keyIndex()

const CPropertyIndex & swift::misc::db::IDatastoreObjectWithStringKey::keyIndex ( )
inlinestatic

The key index.

Definition at line 219 of file datastore.h.

◆ matchesDbKeyState()

bool swift::misc::db::IDatastoreObjectWithStringKey::matchesDbKeyState ( db::DbKeyStateFilter filter) const

Matches filter?

Definition at line 200 of file datastore.cpp.

◆ propertyByIndex()

QVariant swift::misc::db::IDatastoreObjectWithStringKey::propertyByIndex ( swift::misc::CPropertyIndexRef index) const
protected

Property by index.

Definition at line 233 of file datastore.cpp.

◆ setDbKey()

void swift::misc::db::IDatastoreObjectWithStringKey::setDbKey ( const QString & key)
inline

Set the DB key.

Definition at line 192 of file datastore.h.

◆ setKeyVersionTimestampFromDatabaseJson()

void swift::misc::db::IDatastoreObjectWithStringKey::setKeyVersionTimestampFromDatabaseJson ( const QJsonObject & json,
const QString & prefix = QString() )
protected

Set key and timestamp values.

Definition at line 219 of file datastore.cpp.

◆ setLoadedFromDb()

void swift::misc::db::IDatastoreObjectWithStringKey::setLoadedFromDb ( bool loaded)
inline

Mark as loaded from DB.

Definition at line 207 of file datastore.h.

◆ setPropertyByIndex()

void swift::misc::db::IDatastoreObjectWithStringKey::setPropertyByIndex ( swift::misc::CPropertyIndexRef index,
const QVariant & variant )
protected

Set property by index.

Definition at line 252 of file datastore.cpp.

◆ toDatabaseIcon()

const CIcon & swift::misc::db::IDatastoreObjectWithStringKey::toDatabaseIcon ( ) const

Database icon if this has valid key, otherwise empty.

Definition at line 209 of file datastore.cpp.

Member Data Documentation

◆ m_dbKey

QString swift::misc::db::IDatastoreObjectWithStringKey::m_dbKey
protected

key

Definition at line 251 of file datastore.h.

◆ m_loadedFromDb

bool swift::misc::db::IDatastoreObjectWithStringKey::m_loadedFromDb
protected
Initial value:
=
false

as we have no artificial key, it can happen key is set, but not loaded from DB

Definition at line 252 of file datastore.h.


The documentation for this class was generated from the following files: