swift
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends | List of all members
swift::misc::CContainerBase< Derived > Class Template Reference

Base class for CCollection and CSequence adding mutating operations and CValueObject facility on top of CRangeBase. More...

Inherits swift::misc::CRangeBase< Derived >, swift::misc::mixin::MetaType< Derived >, swift::misc::mixin::DBusOperators< Derived >, swift::misc::mixin::JsonOperators< Derived >, and swift::misc::mixin::String< Derived >.

Inherited by swift::misc::CCollection< CVPilotModelRule >, swift::misc::CCollection< CCallsign >, swift::misc::CCollection< CPlatform >, swift::misc::CSequence< CUrlLog >, swift::misc::CSequence< CAircraftSituation >, swift::misc::CSequence< CAircraftModel >, swift::misc::CSequence< CClient >, swift::misc::CSequence< CPropertyIndex >, swift::misc::CSequence< CNavDataReference >, swift::misc::CSequence< CDistributor >, swift::misc::CSequence< CLogCategory >, swift::misc::CSequence< CDatabaseReaderConfig >, swift::misc::CSequence< CSimulatedAircraft >, swift::misc::CSequence< CMatchingStatisticsEntry >, swift::misc::CSequence< CTextMessage >, swift::misc::CSequence< CRole >, swift::misc::CSequence< CAirlineIcaoCode >, swift::misc::CSequence< CAircraftCategory >, swift::misc::CSequence< CIdentifier >, swift::misc::CSequence< CDbInfo >, swift::misc::CSequence< CSimulatorInfo >, swift::misc::CSequence< CCoordinateGeodetic >, swift::misc::CSequence< QJsonObject >, swift::misc::CSequence< CCloudLayer >, swift::misc::CSequence< CUser >, swift::misc::CSequence< CAircraftSituationChange >, swift::misc::CSequence< CAircraftEngine >, swift::misc::CSequence< CNameVariantPair >, swift::misc::CSequence< CWindLayer >, swift::misc::CSequence< CLivery >, swift::misc::CSequence< CApplicationInfo >, swift::misc::CSequence< CAircraftCfgEntries >, swift::misc::CSequence< CRawFsdMessage >, swift::misc::CSequence< CEcosystem >, swift::misc::CSequence< CAtcStation >, swift::misc::CSequence< CCountry >, swift::misc::CSequence< CKeyboardKey >, swift::misc::CSequence< CArtifact >, swift::misc::CSequence< CServer >, swift::misc::CSequence< CAudioDeviceInfo >, swift::misc::CSequence< CStatusMessage >, swift::misc::CSequence< CMetar >, swift::misc::CSequence< CRemoteFile >, swift::misc::CSequence< CDistribution >, swift::misc::CSequence< CAirport >, swift::misc::CSequence< CVariant >, swift::misc::CSequence< CSimulatorPluginInfo >, swift::misc::CSequence< CAircraftIcaoCode >, swift::misc::CSequence< CPresentWeather >, swift::misc::CSequence< CJoystickButton >, swift::misc::CSequence< CActionHotkey >, swift::misc::CSequence< CFlightPlan >, swift::misc::CSequence< CAircraftParts >, swift::misc::CSequence< Ts >, and swift::misc::CSequence< CIcon >.

Public Member Functions

template<template< class > class Other>
auto to () const
 Return a new container of a different type, containing the same elements as this one. More...
 
template<template< class > class Other, class T >
Other< T > to (Other< T > other) const
 Return a new container of a different type, containing the same elements as this one. More...
 
template<class K0 , class V0 , class... KeysValues>
int removeIf (K0 k0, V0 v0, KeysValues... keysValues)
 Remove elements matching some particular key/value pair(s). More...
 
QJsonObject toJson () const
 Cast to JSON object. More...
 
QString toJsonString (QJsonDocument::JsonFormat format=QJsonDocument::Indented) const
 Convenience function JSON as string.
 
void convertFromJson (const QJsonObject &json)
 Assign from JSON object. More...
 
void convertFromJson (const QString &jsonString, bool acceptCacheFormat=false)
 Assign from JSON object string.
 
CStatusMessage convertFromJsonNoThrow (const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromJson, catch any CJsonException that is thrown and return it as CStatusMessage.
 
CStatusMessage convertFromJsonNoThrow (const QString &jsonString, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromJson, catch any CJsonException that is thrown and return it as CStatusMessage.
 
QString convertToQString (bool i18n=false) const
 Cast as QString. More...
 
QStringList toStringList (bool i18n=false) const
 To string list.
 
void marshallToDbus (QDBusArgument &argument) const
 Marshall without begin/endStructure, for when composed within another object. More...
 
void unmarshallFromDbus (const QDBusArgument &argument)
 Unmarshall without begin/endStructure, for when composed within another object. More...
 
- Public Member Functions inherited from swift::misc::CRangeBase< Derived >
template<class F >
auto transform (F function) const
 Return a new container generated by applying some transformation function to all elements of this one.
 
template<class Predicate >
auto findBy (Predicate p) const
 Return a copy containing only those elements for which a given predicate returns true.
 
template<class K0 , class V0 , class... KeysValues>
auto findBy (K0 k0, V0 v0, KeysValues... keysValues) const
 Return a copy containing only those elements matching some particular key/value pair(s). More...
 
template<class Predicate >
const auto & findFirstBy (Predicate p) const
 Return a reference to the first element for which a given predicate returns true. Undefined if there is none.
 
template<class K , class V >
const auto & findFirstBy (K key, V value) const
 Return a reference to the first element matching some particular key/value pair(s). Undefined if there is none.
 
template<class Predicate , class Value >
auto findFirstByOrDefault (Predicate p, const Value &def) const
 Return a copy of the first element for which a given predicate returns true, or a default value if there is none.
 
template<class Predicate >
auto findFirstByOrDefault (Predicate p) const
 Return a copy of the first element for which a given predicate returns true, or a default value if there is none.
 
template<class K , class V , class Value >
auto findFirstByOrDefault (K key, V value, const Value &def) const
 Return a copy of the first element matching some particular key/value pair(s), or a default value if there is none.
 
template<class T , class K , class V >
auto findFirstByOrDefault (K T::*key, V value) const
 Return a copy of the first element matching some particular key/value pair(s), or a default value if there is none.
 
template<class Predicate >
bool containsBy (Predicate p) const
 Return true if there is an element for which a given predicate returns true.
 
template<class T >
bool contains (const T &object) const
 Return true if there is an element equal to given object. Uses the most efficient implementation available in the derived container.
 
template<class K0 , class V0 , class... KeysValues>
bool contains (K0 k0, V0 v0, KeysValues... keysValues) const
 Return a copy containing only those elements matching some particular key/value pair(s). More...
 
template<class T , class Predicate >
bool equalsBy (const T &other, Predicate c) const
 Return true if this container equals another container according to the given element equality predicate.
 
template<class T , class Key0 , class... Keys>
bool equalsByKeys (const T &other, Key0 k0, Keys... keys) const
 Return true if this container equals another container, considering only the given element members.
 
template<class T >
randomElement () const
 Pick one random element.
 
Derived randomElements (int n) const
 Copy n elements from the container at random.
 
Derived sampleElements (int n) const
 Copy n elements from the container, randomly selected but evenly distributed.
 
- Public Member Functions inherited from swift::misc::mixin::MetaType< Derived >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object. More...
 
QString getClassName () const
 Class name.
 
bool isA (int metaTypeId) const
 Returns true if this object is an instance of the class with the given meta type ID, or one of its subclasses.
 
- Public Member Functions inherited from swift::misc::mixin::String< Derived >
QString toQString (bool i18n=false) const
 Cast as QString.
 
std::string toStdString (bool i18n=false) const
 To std string.
 
QString stringForStreaming () const
 String for streaming operators.
 

Static Public Member Functions

static Derived fromJson (const QJsonObject &json)
 Static version of convertFromJson.
 
static Derived fromJson (const QString &jsonString, bool acceptCacheJson=false)
 Static version of convertFromJson.
 
static Derived fromJsonNoThrow (const QString &jsonString, bool acceptCacheJson, bool &success, QString &errMsg)
 Static version of convertFromJson.
 
- Static Public Member Functions inherited from swift::misc::mixin::MetaType< Derived >
static void registerMetadata ()
 Register metadata.
 

Protected Member Functions

int getMetaTypeId () const
 Returns the Qt meta type ID of this object. More...
 

Friends

int compare (const Derived &a, const Derived &b)
 Return negative, zero, or positive if a is less than, equal to, or greater than b. More...
 
size_t qHash (const Derived &)
 Simplifies composition, returns 0 for performance.
 

Additional Inherited Members

- Static Protected Member Functions inherited from swift::misc::CRangeBase< Derived >
template<typename T , typename U >
static bool equalPointers (const T *a, const U *b)
 Efficiently compare addresses of two objects. Return false if types are not compatible.
 

Detailed Description

template<class Derived>
class swift::misc::CContainerBase< Derived >

Base class for CCollection and CSequence adding mutating operations and CValueObject facility on top of CRangeBase.

Definition at line 59 of file containerbase.h.

Member Function Documentation

◆ convertFromJson()

template<class Derived >
void swift::misc::CContainerBase< Derived >::convertFromJson ( const QJsonObject &  json)
inline

Assign from JSON object.

Exceptions
CJsonException

Definition at line 132 of file containerbase.h.

◆ convertToQString()

template<class Derived >
QString swift::misc::CContainerBase< Derived >::convertToQString ( bool  i18n = false) const
inline

Cast as QString.

Definition at line 206 of file containerbase.h.

◆ getMetaTypeId()

template<class Derived >
int swift::misc::CContainerBase< Derived >::getMetaTypeId ( ) const
inlineprotected

Returns the Qt meta type ID of this object.

Remarks
for CVariant this returns the id of CVariant, not of the encapsulated object. valueVariant.userType()` returns metatype of the contained object

Definition at line 227 of file containerbase.h.

◆ marshallToDbus()

template<class Derived >
void swift::misc::CContainerBase< Derived >::marshallToDbus ( QDBusArgument &  argument) const
inline

Marshall without begin/endStructure, for when composed within another object.

Definition at line 231 of file containerbase.h.

◆ removeIf()

template<class Derived >
template<class K0 , class V0 , class... KeysValues>
int swift::misc::CContainerBase< Derived >::removeIf ( K0  k0,
V0  v0,
KeysValues...  keysValues 
)
inline

Remove elements matching some particular key/value pair(s).

Parameters
k0A pointer to a member function of T.
v0A value to compare against the value returned by k0.
keysValuesZero or more additional pairs of { pointer to member function of T, value to compare it against }.
Returns
The number of elements removed.

Definition at line 105 of file containerbase.h.

◆ to() [1/2]

template<class Derived >
template<template< class > class Other>
auto swift::misc::CContainerBase< Derived >::to ( ) const
inline

Return a new container of a different type, containing the same elements as this one.

Template Parameters
Otherthe type of the new container.

Definition at line 83 of file containerbase.h.

◆ to() [2/2]

template<class Derived >
template<template< class > class Other, class T >
Other<T> swift::misc::CContainerBase< Derived >::to ( Other< T >  other) const
inline

Return a new container of a different type, containing the same elements as this one.

Template Parameters
Otherthe type of the new container.
Telement type of the new container.
Parameters
otheran initial value for the new container; will be copied.

Definition at line 93 of file containerbase.h.

◆ toJson()

template<class Derived >
QJsonObject swift::misc::CContainerBase< Derived >::toJson ( ) const
inline

Cast to JSON object.

Definition at line 114 of file containerbase.h.

◆ unmarshallFromDbus()

template<class Derived >
void swift::misc::CContainerBase< Derived >::unmarshallFromDbus ( const QDBusArgument &  argument)
inline

Unmarshall without begin/endStructure, for when composed within another object.

Definition at line 239 of file containerbase.h.

Friends And Related Function Documentation

◆ compare

template<class Derived >
int compare ( const Derived &  a,
const Derived &  b 
)
friend

Return negative, zero, or positive if a is less than, equal to, or greater than b.

Definition at line 68 of file containerbase.h.


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