6 #ifndef SWIFT_MISC_PROPERTYINDEX_H
7 #define SWIFT_MISC_PROPERTYINDEX_H
9 #include <initializer_list>
10 #include <type_traits>
71 bool isNested()
const;
74 bool isMyself()
const;
80 QList<int> indexList()
const;
83 void prepend(
int newLeftIndex);
86 bool contains(
int index)
const;
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");
108 return static_cast<CastType
>(frontToInt());
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)>;
127 return compare(a.propertyByIndex(index), b.propertyByIndex(index));
131 qFatal(
"Not implemented");
138 QString convertToQString(
bool i18n =
false)
const;
141 QJsonObject toJson()
const;
144 void convertFromJson(
const QJsonObject &json);
155 void parseFromString(
const QString &indexes);
158 QList<int> m_indexes;
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.
static const CPropertyIndex & empty()
an empty property 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.
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.