6 #ifndef SWIFT_MISC_PROPERTYINDEXVARIANTMAP_H
7 #define SWIFT_MISC_PROPERTYINDEXVARIANTMAP_H
11 #include <QDBusArgument>
68 bool isEmpty()
const {
return m_values.isEmpty(); }
83 QList<CVariant>
values()
const {
return m_values.values(); }
92 void clear() { m_values.clear(); }
107 template <
typename T,
typename = std::enable_if_t<!std::is_same_v<T, CVariant>>>
145 template <
class Derived>
147 bool skipEqualValues)
149 if (indexMap.
isEmpty())
return {};
152 const auto &map = indexMap.
map();
153 for (
auto it = map.begin(); it != map.end(); ++it)
159 const bool equal = derived()->equalsPropertyByIndex(value, index);
160 if (equal) {
continue; }
162 derived()->setPropertyByIndex(index, value);
Value object encapsulating a list of property indexes.
Specialized value object compliant map for variants, based on indexes.
void unmarshalFromDataStream(QDataStream &stream)
Unmarshal a value from a QDataStream.
void addValue(const CPropertyIndex &index, const T &value)
Add a value as non CVariant.
SWIFT_MISC_EXPORT friend bool operator!=(const CPropertyIndexVariantMap &a, const CPropertyIndexVariantMap &b)
Equal operator, required if maps are directly compared, not with CValueObject.
bool matches(const T &value) const
True if this map matches the value.
void unmarshallFromDbus(const QDBusArgument &argument)
Unmarshall without begin/endStructure, for when composed within another object.
bool matchesVariant(const CVariant &value) const
True if this map matches the value contained in the variant.
void addValue(const CPropertyIndex &index, const char *str)
Add QString as literal, disambiguate as I want to add QString.
void prependIndex(int index)
Prepend index to all property indexes.
CVariant value(const CPropertyIndex &index) const
Value.
const QMap< CPropertyIndex, CVariant > & map() const
Map.
QMap< CPropertyIndex, CVariant > m_values
values
bool isEmpty() const
Is empty?
CPropertyIndexVariantMap(const CPropertyIndex &index, const CVariant &value)
Single value constructor.
CPropertyIndexVariantMap(bool wildcard=false)
Constructor.
int size() const
Number of elements.
void setWildcard(bool wildcard)
Wildcard, only relevant when used in search.
void value(const CPropertyIndex &index, const CVariant &value)
Set value.
void addValue(const CPropertyIndex &index, const CVariant &value)
Add a value.
QString convertToQString(bool i18n=false) const
Cast as QString.
QList< CVariant > values() const
values
friend size_t qHash(const CPropertyIndexVariantMap &vm)
qHash overload, needed for storing value in a QSet.
bool contains(const CPropertyIndex &index) const
Contains index?
SWIFT_MISC_EXPORT friend bool operator==(const CPropertyIndexVariantMap &a, const CPropertyIndexVariantMap &b)
Equal operator, required if maps are directly compared, not with CValueObject.
void marshalToDataStream(QDataStream &stream) const
Marshal a value to a QDataStream.
size_t getValueHash() const
Hash value.
void addValue(const CPropertyIndex &index, const QVariant &value)
Add a value.
void marshallToDbus(QDBusArgument &argument) const
Marshall without begin/endStructure, for when composed within another object.
bool isWildcard() const
Wildcard, only relevant when used in search.
CPropertyIndexList indexes() const
Indexes.
void push_back(const T &value)
Appends an element at the end of the sequence.
Wrapper around QVariant which provides transparent access to CValueObject methods of the contained ob...
static CVariant fromValue(T &&value)
Construct a variant from a value.
T value() const
Return the value converted to the type T.
static CVariant from(T &&value)
Synonym for fromValue().
CRTP class template which will generate marshalling operators for a derived class with its own marsha...
CRTP class template to generate non-member QDataStream streaming operators.
CPropertyIndexList apply(const CPropertyIndexVariantMap &indexMap, bool skipEqualValues=false)
Update by variant map.
CRTP class template from which a derived class can inherit string streaming operations.
Free functions in swift::misc.
#define SWIFT_MISC_EXPORT
Export a class or function from the library.