swift
Loading...
Searching...
No Matches
swift::misc::CVariantMap Class Reference

Map of { QString, CVariant } pairs. More...

#include <variantmap.h>

Inheritance diagram for swift::misc::CVariantMap:
[legend]

Public Member Functions

 CVariantMap ()=default
 Default constructor.
 CVariantMap (const CVariantMap &)=default
 Copy constructor.
 CVariantMap (CVariantMap &&other) noexcept
 Move constructor.
CVariantMap & operator= (const CVariantMap &other)
 Copy assignment operator.
CVariantMap & operator= (CVariantMap &&other) noexcept
 Move assignment operator.
 ~CVariantMap ()=default
 Destructor.
QJsonObject & mergeToJson (QJsonObject &json) const
 Insert values from this map into an existing JSON object.
QJsonObject toJson () const
 Cast to JSON object.
void convertFromJson (const QJsonObject &json)
 Assign from JSON object.
void convertFromJson (const QJsonObject &json, const QStringList &keys)
 Assign from JSON object.
CStatusMessageList convertFromJsonNoThrow (const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromJson, catch any CJsonException that are thrown and return them as CStatusMessage.
CStatusMessageList convertFromJsonNoThrow (const QJsonObject &json, const QStringList &keys, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromJson, catch any CJsonException that are thrown and return them as CStatusMessage.
QJsonObject & mergeToMemoizedJson (QJsonObject &json) const
 Insert values from this map into an existing compact JSON object.
QJsonObject toMemoizedJson () const
 To compact JSON format.
void convertFromMemoizedJson (const QJsonObject &json)
 From compact JSON format.
void convertFromMemoizedJson (const QJsonObject &json, const QStringList &keys)
 From compact JSON format. Convert only keys present in list argument.
CStatusMessageList convertFromMemoizedJsonNoThrow (const QJsonObject &json, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromMemoizedJson, catch any CJsonException that are thrown and return them as CStatusMessage.
CStatusMessageList convertFromMemoizedJsonNoThrow (const QJsonObject &json, const QStringList &keys, const CLogCategoryList &categories, const QString &prefix)
 Call convertFromMemoizedJson, catch any CJsonException that are thrown and return them as CStatusMessage.
 CDictionary ()=default
 Default constructor.
 CDictionary (std::initializer_list< std::pair< Key, Value > > il)
 Initializer list constructor.
 CDictionary (const CDictionary &)=default
 Copy constructor.
 CDictionary (CDictionary &&other) noexcept
 Move constructor.
Public Member Functions inherited from swift::misc::CDictionary< QString, CVariant, QMap >
CDictionary findKeyBy (Predicate p) const
 Return a copy containing only those elements for which the dictionary keys return true for a given predicate.
CDictionary findValueBy (Predicate p) const
 Return a copy containing only those elements for which a given predicate returns true.
bool containsByKey (Predicate p) const
 Return true if there is an element for which a given predicate returns true.
bool containsByValue (Predicate p) const
 Return true if there is an element for which a given predicate returns true.
void removeByKeyIf (Predicate p)
 Remove elements for which a given predicate for value returns true.
void removeByValueIf (Predicate p)
 Remove elements for which a given predicate for key returns true.
void removeDuplicates (const CDictionary &other)
 Remove elements for which the same key/value pair is present in an other dictionary.
QJsonObject toJson () const
 Cast to JSON object.
void convertFromJson (const QJsonObject &json)
 Assign from JSON object.
 CDictionary ()=default
 Default constructor.
 ~CDictionary ()=default
 Destructor.
iterator begin ()
 Returns iterator at the beginning of the dictionary.
const_iterator cbegin () const
 Returns const iterator at the beginning of the dictionary.
iterator end ()
 Returns iterator at the end of the dictionary.
const_iterator cend () const
 Returns const iterator at the end of the dictionary.
auto keyBegin () const
 Returns const iterator for iterating over keys.
auto keyEnd () const
 Returns const iterator for iterating over keys.
auto keyValueBegin ()
 Returns iterator for iterating over keys and values together.
auto keyValueEnd ()
 Returns iterator for iterating over keys and values together.
auto constKeyValueBegin () const
 Returns const iterator for iterating over keys and values together.
auto constKeyValueEnd () const
 Returns const iterator for iterating over keys and values together.
void clear ()
 Removes all items from the dictionary.
const_iterator constBegin () const
 Returns const iterator at the beginning of the dictionary.
const_iterator constEnd () const
 Returns const iterator at the end of the dictionary.
const_iterator constFind (const QString &key) const
 Returns an const iterator pointing to the item with the key.
const_iterator find (const QString &key) const
 Returns an const iterator pointing to the item with the key.
bool contains (const QString &key) const
 Returns true if dictionary contains an item with key, otherwise false.
int count (const QString &key) const
 Returns the number of items with key.
bool empty () const
 Returns true if the.
iterator erase (iterator pos)
 Removes the key/value pair iterator is currently pointing to and returns an iterator to the next item.
iterator insert (const QString &key, const CVariant &value)
 Insert new item with key and value.
bool isEmpty () const
 Returns true if dictionary is empty.
const QString key (const CVariant &value) const
 Return key assigned to value.
auto keys () const
 Return a range of all keys (does not allocate a temporary container).
int remove (const QString &key)
 Remove all items with key from the dictionary.
int size () const
 Returns the number of items in the hash.
void swap (CDictionary &other) noexcept
 Swaps hash other with this hash. This operation is very fast and never fails.
const CVariant value (const QString &key) const
 Returns the value associated with the key.
CRange< const_iterator > values () const
 Return a range of all values (does not allocate a temporary container).
CDictionary & operator= (const CDictionary &other)
 Copy assignment.
CVariant & operator[] (const QString &key)
 Access an element by its key.
QString convertToQString (bool i18n=false) const
 Cast as QString.
void marshallToDbus (QDBusArgument &argument) const
 Marshall without begin/endStructure, for when composed within another object.
void unmarshallFromDbus (const QDBusArgument &argument)
 Unmarshall without begin/endStructure, for when composed within another object.
void marshalToDataStream (QDataStream &stream) const
 Marshal a value to a QDataStream.
void unmarshalFromDataStream (QDataStream &stream)
 Unmarshal a value from a QDataStream.
Public Member Functions inherited from swift::misc::mixin::String< CDictionary< QString, CVariant, QMap > >
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.
Public Member Functions inherited from swift::misc::mixin::MetaType< CVariantMap >
int getMetaTypeId () const
 Returns the Qt meta type ID of this object.
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.

Additional Inherited Members

Public Types inherited from swift::misc::CDictionary< QString, CVariant, QMap >
using impl_type
 The implementation container.
using key_type
 STL compatibility.
using value_type
 STL compatibility.
using reference
 STL compatibility.
using const_reference
 STL compatibility.
using size_type
 STL compatibility.
using iterator
 STL compatibility.
using const_iterator
 STL compatibility.
Static Public Member Functions inherited from swift::misc::mixin::MetaType< CVariantMap >
static void registerMetadata ()
 Register metadata.

Detailed Description

Map of { QString, CVariant } pairs.

Using QMap as implementation type so keys are sorted.

Definition at line 32 of file variantmap.h.

Constructor & Destructor Documentation

◆ CVariantMap()

swift::misc::CVariantMap::CVariantMap ( CVariantMap && other)
inlinenoexcept

Move constructor.

Definition at line 47 of file variantmap.h.

Member Function Documentation

◆ CDictionary() [1/2]

swift::misc::CDictionary< Key, Value, Impl >::CDictionary ( CDictionary && other)
inlinenoexcept

Move constructor.

Definition at line 330 of file dictionary.h.

◆ CDictionary() [2/2]

swift::misc::CDictionary< Key, Value, Impl >::CDictionary ( std::initializer_list< std::pair< Key, Value > > il)
inline

Initializer list constructor.

Definition at line 324 of file dictionary.h.

◆ convertFromJson() [1/2]

void swift::misc::CVariantMap::convertFromJson ( const QJsonObject & json)

Assign from JSON object.

Definition at line 30 of file variantmap.cpp.

◆ convertFromJson() [2/2]

void swift::misc::CVariantMap::convertFromJson ( const QJsonObject & json,
const QStringList & keys )

Assign from JSON object.

Convert only keys present in list argument.

Definition at line 44 of file variantmap.cpp.

◆ convertFromJsonNoThrow() [1/2]

CStatusMessageList swift::misc::CVariantMap::convertFromJsonNoThrow ( const QJsonObject & json,
const CLogCategoryList & categories,
const QString & prefix )

Call convertFromJson, catch any CJsonException that are thrown and return them as CStatusMessage.

Definition at line 110 of file variantmap.cpp.

◆ convertFromJsonNoThrow() [2/2]

CStatusMessageList swift::misc::CVariantMap::convertFromJsonNoThrow ( const QJsonObject & json,
const QStringList & keys,
const CLogCategoryList & categories,
const QString & prefix )

Call convertFromJson, catch any CJsonException that are thrown and return them as CStatusMessage.

Definition at line 134 of file variantmap.cpp.

◆ convertFromMemoizedJson() [1/2]

void swift::misc::CVariantMap::convertFromMemoizedJson ( const QJsonObject & json)

From compact JSON format.

Definition at line 78 of file variantmap.cpp.

◆ convertFromMemoizedJson() [2/2]

void swift::misc::CVariantMap::convertFromMemoizedJson ( const QJsonObject & json,
const QStringList & keys )

From compact JSON format. Convert only keys present in list argument.

Definition at line 92 of file variantmap.cpp.

◆ convertFromMemoizedJsonNoThrow() [1/2]

CStatusMessageList swift::misc::CVariantMap::convertFromMemoizedJsonNoThrow ( const QJsonObject & json,
const CLogCategoryList & categories,
const QString & prefix )

Call convertFromMemoizedJson, catch any CJsonException that are thrown and return them as CStatusMessage.

Definition at line 162 of file variantmap.cpp.

◆ convertFromMemoizedJsonNoThrow() [2/2]

CStatusMessageList swift::misc::CVariantMap::convertFromMemoizedJsonNoThrow ( const QJsonObject & json,
const QStringList & keys,
const CLogCategoryList & categories,
const QString & prefix )

Call convertFromMemoizedJson, catch any CJsonException that are thrown and return them as CStatusMessage.

Definition at line 187 of file variantmap.cpp.

◆ mergeToJson()

QJsonObject & swift::misc::CVariantMap::mergeToJson ( QJsonObject & json) const

Insert values from this map into an existing JSON object.

Definition at line 14 of file variantmap.cpp.

◆ mergeToMemoizedJson()

QJsonObject & swift::misc::CVariantMap::mergeToMemoizedJson ( QJsonObject & json) const

Insert values from this map into an existing compact JSON object.

Definition at line 62 of file variantmap.cpp.

◆ operator=() [1/2]

CVariantMap & swift::misc::CVariantMap::operator= ( const CVariantMap & other)
inline

Copy assignment operator.

Definition at line 50 of file variantmap.h.

◆ operator=() [2/2]

CVariantMap & swift::misc::CVariantMap::operator= ( CVariantMap && other)
inlinenoexcept

Move assignment operator.

Definition at line 57 of file variantmap.h.

◆ toJson()

QJsonObject swift::misc::CVariantMap::toJson ( ) const

Cast to JSON object.

Definition at line 23 of file variantmap.cpp.

◆ toMemoizedJson()

QJsonObject swift::misc::CVariantMap::toMemoizedJson ( ) const

To compact JSON format.

Definition at line 71 of file variantmap.cpp.


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