6#ifndef SWIFT_MISC_PROPERTYINDEX_H
7#define SWIFT_MISC_PROPERTYINDEX_H
9#include <initializer_list>
89 template <
class EnumType>
92 static_assert(std::is_enum_v<EnumType>,
"Argument must be an enum");
93 return this->
contains(
static_cast<int>(ev));
97 int frontToInt()
const;
100 bool startsWith(
int index)
const;
103 template <
class CastType>
106 static_assert(std::is_enum_v<CastType> || std::is_integral_v<CastType>,
107 "CastType must be an enum or integer");
112 template <
class EnumType>
115 static_assert(std::is_enum_v<EnumType>,
"Argument must be an enum");
116 return this->
startsWith(
static_cast<int>(ev));
122 return [index = *
this](
const auto &a,
const auto &b) {
123 using T = std::decay_t<
decltype(a)>;
126 return a.comparePropertyByIndex(index, b);
130 return compare(a.propertyByIndex(index), b.propertyByIndex(index));
134 qFatal(
"Not implemented");
141 QString convertToQString(
bool i18n =
false)
const;
158 void parseFromString(
const QString &indexes);
QList< int > indexList() const
Index list.
bool contains(EnumType ev) const
Compare with index given by enum.
bool startsWithPropertyIndexEnum(EnumType ev) const
Compare with index given by enum.
CPropertyIndex()=default
Default constructor.
bool isEmpty() const
Empty?
void prepend(int newLeftIndex)
Shift existing indexes to right and insert given index at front.
bool isMyself() const
Myself index, used with nesting.
static const CPropertyIndex & empty()
an empty property index
bool startsWith(int index) const
Starts with given index?
auto comparator() const
Return a predicate function which can compare two objects based on this index.
CastType frontCasted() const
First element casted to given type, usually the PropertIndex enum.
int frontToInt() const
Front to integer.
bool contains(int index) const
Contains index?
Q_REQUIRED_RESULT CPropertyIndex copyFrontRemoved() const
Copy with first element removed.
bool isNested() const
Is nested index?
Non-owning reference to a CPropertyIndex with a subset of its features.
CRTP class template which will generate marshalling operators for a derived class with its own marsha...
CRTP class template from which a derived class can inherit string streaming operations.
Free functions in swift::misc.
Trait which is true if the expression a.compareByPropertyIndex(b, i) is valid when a and b are instan...
Trait which is true if the expression a.propertyByIndex(i) is valid with a is an instance of T and i ...
#define SWIFT_MISC_EXPORT
Export a class or function from the library.