swift
Public Types | Public Member Functions | Friends | List of all members
swift::misc::CDictionary< Key, Value, Impl > Class Template Reference

Associative container with value semantics, chooses a sensible default implementation container type. More...

Inheritance diagram for swift::misc::CDictionary< Key, Value, Impl >:
[legend]

Public Types

using impl_type = Impl< Key, Value >
 The implementation container.
 
typedef Key key_type
 STL compatibility.
 
typedef Value value_type
 STL compatibility.
 
typedef Value & reference
 STL compatibility.
 
typedef const Value & const_reference
 STL compatibility.
 
typedef Impl< Key, Value >::size_type size_type
 STL compatibility.
 
typedef Impl< Key, Value >::iterator iterator
 STL compatibility.
 
typedef Impl< Key, Value >::const_iterator const_iterator
 STL compatibility.
 

Public Member Functions

template<class Predicate >
CDictionary findKeyBy (Predicate p) const
 Return a copy containing only those elements for which the dictionary keys return true for a given predicate.
 
template<class... Pairs>
CDictionary findKeyBy (Pairs... pairs) const
 Return a copy containing only those elements which key matches a particular pair. More...
 
template<class Predicate >
CDictionary findValueBy (Predicate p) const
 Return a copy containing only those elements for which a given predicate returns true.
 
template<class... Pairs>
CDictionary findValueBy (Pairs... pairs) const
 Return a copy containing only those elements which value matches a particular pair. More...
 
template<class Predicate >
bool containsByKey (Predicate p) const
 Return true if there is an element for which a given predicate returns true.
 
template<class MembFunc , class ReturnValue >
bool containsByKey (MembFunc membFunc, ReturnValue returnValue) const
 Return true if there is an element which key matches a given pair.
 
template<class Predicate >
bool containsByValue (Predicate p) const
 Return true if there is an element for which a given predicate returns true.
 
template<class MembFunc , class ReturnValue >
bool containsByValue (MembFunc membFunc, ReturnValue returnValue) const
 Return true if there is an element which value matches a given pair.
 
template<class Predicate >
void removeByKeyIf (Predicate p)
 Remove elements for which a given predicate for value returns true.
 
template<class Predicate >
void removeByValueIf (Predicate p)
 Remove elements for which a given predicate for key returns true.
 
template<class MembFunc , class ReturnValue >
void removeByKeyIf (MembFunc membFunc, ReturnValue returnValue)
 Remove elements for which key matches a particular pair.
 
template<class MembFunc , class ReturnValue >
void removeByValueIf (MembFunc membFunc, ReturnValue returnValue)
 Remove elements for which value matches a particular pair.
 
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. More...
 
void convertFromJson (const QJsonObject &json)
 Assign from JSON object. More...
 
 CDictionary ()
 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.
 
 ~CDictionary ()=default
 Destructor.
 
iterator begin ()
 Returns iterator at the beginning of the dictionary.
 
const_iterator begin () const
 Returns const 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 end () const
 Returns const 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 keyValueBegin () const
 Returns const iterator for iterating over keys and values together.
 
auto constKeyValueBegin () const
 Returns const iterator for iterating over keys and values together.
 
auto keyValueEnd () 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 Key &key) const
 Returns an const iterator pointing to the item with the key. More...
 
const_iterator find (const Key &key) const
 Returns an const iterator pointing to the item with the key. More...
 
iterator find (const Key &key)
 Returns an iterator pointing to the item with the key. More...
 
bool contains (const Key &key) const
 Returns true if dictionary contains an item with key, otherwise false.
 
int count (const Key &key) const
 Returns the number of items with key.
 
int count () const
 Returns the size of the dictionary.
 
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 Key &key, const Value &value)
 Insert new item with key and value.
 
void insert (const CDictionary &other)
 Insert all items of other dictionary into this dictionary.
 
bool isEmpty () const
 Returns true if dictionary is empty.
 
const Key key (const Value &value) const
 Return key assigned to value.
 
const Key key (const Value &value, const Key &defaultKey) const
 Return key assigned to value or if key is not found defaultKey.
 
auto keys () const
 Return a range of all keys (does not allocate a temporary container)
 
int remove (const Key &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 Value value (const Key &key) const
 Returns the value associated with the key.
 
const Value value (const Key &key, const Value &defaultValue) const
 Returns the value associated with the key or if key is not found defaultValue.
 
CRange< const_iteratorvalues () const
 Return a range of all values (does not allocate a temporary container)
 
CDictionaryoperator= (const CDictionary &other)
 Copy assignment.
 
CDictionaryoperator= (CDictionary &&other) noexcept
 Move assignment.
 
Value & operator[] (const Key &key)
 Access an element by its key. More...
 
const Value operator[] (const Key &key) const
 Access an element by its key.
 
QString convertToQString (bool i18n=false) const
 Cast as QString. More...
 
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...
 
void marshalToDataStream (QDataStream &stream) const
 Marshal a value to a QDataStream. More...
 
void unmarshalFromDataStream (QDataStream &stream)
 Unmarshal a value from a QDataStream. More...
 
- Public Member Functions inherited from swift::misc::mixin::String< CDictionary< Key, Value, TDefaultAssociativeType > >
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.
 

Friends

int compare (const CDictionary &a, const CDictionary &b)
 Return negative, zero, or positive if a is less than, equal to, or greater than b. More...
 
impl_typeimplementationOf (CDictionary &dict)
 Return reference to the internal implementation object.
 
const impl_typeimplementationOf (const CDictionary &dict)
 Return reference to the internal implementation object.
 
bool operator== (const CDictionary &a, const CDictionary &b)
 Test for equality.
 
bool operator!= (const CDictionary &a, const CDictionary &b)
 Test for inequality.
 

Detailed Description

template<class Key, class Value, template< class... > class Impl = TDefaultAssociativeType>
class swift::misc::CDictionary< Key, Value, Impl >

Associative container with value semantics, chooses a sensible default implementation container type.

Definition at line 77 of file dictionary.h.

Member Function Documentation

◆ constFind()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
const_iterator swift::misc::CDictionary< Key, Value, Impl >::constFind ( const Key &  key) const
inline

Returns an const iterator pointing to the item with the key.

Returns
If key is not found, the function returns constEnd()

Definition at line 348 of file dictionary.h.

◆ convertFromJson()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
void swift::misc::CDictionary< Key, Value, Impl >::convertFromJson ( const QJsonObject &  json)
inline

Assign from JSON object.

Definition at line 248 of file dictionary.h.

◆ convertToQString()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
QString swift::misc::CDictionary< Key, Value, Impl >::convertToQString ( bool  i18n = false) const
inline

Cast as QString.

Definition at line 446 of file dictionary.h.

◆ find() [1/2]

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
iterator swift::misc::CDictionary< Key, Value, Impl >::find ( const Key &  key)
inline

Returns an iterator pointing to the item with the key.

Returns
If key is not found, the function returns end()

Definition at line 356 of file dictionary.h.

◆ find() [2/2]

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
const_iterator swift::misc::CDictionary< Key, Value, Impl >::find ( const Key &  key) const
inline

Returns an const iterator pointing to the item with the key.

Returns
If key is not found, the function returns end()

Definition at line 352 of file dictionary.h.

◆ findKeyBy()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
template<class... Pairs>
CDictionary swift::misc::CDictionary< Key, Value, Impl >::findKeyBy ( Pairs...  pairs) const
inline

Return a copy containing only those elements which key matches a particular pair.

Parameters
pairsPairs of { pointer to member function of Value, return value to compare it against }.

Definition at line 134 of file dictionary.h.

◆ findValueBy()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
template<class... Pairs>
CDictionary swift::misc::CDictionary< Key, Value, Impl >::findValueBy ( Pairs...  pairs) const
inline

Return a copy containing only those elements which value matches a particular pair.

Parameters
pairsPairs of { pointer to member function of Value, return value to compare it against }.

Definition at line 155 of file dictionary.h.

◆ marshallToDbus()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
void swift::misc::CDictionary< Key, Value, Impl >::marshallToDbus ( QDBusArgument &  argument) const
inline

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

Definition at line 461 of file dictionary.h.

◆ marshalToDataStream()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
void swift::misc::CDictionary< Key, Value, Impl >::marshalToDataStream ( QDataStream &  stream) const
inline

Marshal a value to a QDataStream.

Definition at line 467 of file dictionary.h.

◆ operator[]()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
Value& swift::misc::CDictionary< Key, Value, Impl >::operator[] ( const Key &  key)
inline

Access an element by its key.

Note
If dictionary does not contain any item with key, a default constructed value will be inserted.

Definition at line 434 of file dictionary.h.

◆ toJson()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
QJsonObject swift::misc::CDictionary< Key, Value, Impl >::toJson ( ) const
inline

Cast to JSON object.

Definition at line 237 of file dictionary.h.

◆ unmarshalFromDataStream()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
void swift::misc::CDictionary< Key, Value, Impl >::unmarshalFromDataStream ( QDataStream &  stream)
inline

Unmarshal a value from a QDataStream.

Definition at line 470 of file dictionary.h.

◆ unmarshallFromDbus()

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
void swift::misc::CDictionary< Key, Value, Impl >::unmarshallFromDbus ( const QDBusArgument &  argument)
inline

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

Definition at line 464 of file dictionary.h.

Friends And Related Function Documentation

◆ compare

template<class Key , class Value , template< class... > class Impl = TDefaultAssociativeType>
int compare ( const CDictionary< Key, Value, Impl > &  a,
const CDictionary< Key, Value, Impl > &  b 
)
friend

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

Definition at line 85 of file dictionary.h.


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