Union::Selector Class
class Union::SelectorA class to handle matching some data to an element. More...
| Header: | #include <Selector> |
| CMake: | find_package(Union REQUIRED)target_link_libraries(mytarget PRIVATE Union::Union) |
Public Functions
| bool | isCombinator() const |
| bool | isValid() const |
| bool | matches(Union::Element *element) const |
| QString | toString() const |
| Union::SelectorType | type() const |
| int | weight() const |
Static Public Members
| Union::Selector | create() |
| Union::Selector | create(DataType &&data) |
| Union::Selector | create(Union::SelectorType _t = type) |
Related Non-Members
| enum class | SelectorType { Empty, Type, Id, State, Hint, …, DescendantCombinator } |
| QDebug | operator<<(QDebug debug, const Union::Selector &selector) |
Detailed Description
Member Function Documentation
[static] Union::Selector Selector::create()
Create an empty, invalid selector.
[static] template <Union::SelectorType type, typename DataType> requires detail::ArgumentTypesMatch<type, std::decay_t<DataType>> Union::Selector Selector::create(DataType &&data)
Create a new selector of a specific type.
See SelectorType for the available types.
data The data to match on.
This function overloads Union::Selector::create().
[static] template <Union::SelectorType type> requires detail::ArgumentTypesMatch<type, detail::Empty> Union::Selector Selector::create(Union::SelectorType _t = type)
Create a new selector of a specific type, that doesn't need any data.
This function overloads Union::Selector::create().
bool Selector::isCombinator() const
Return whether this selector is a combinator.
bool Selector::isValid() const
Returns whether this selector is valid.
An invalid selector will never match anything.
bool Selector::matches(Union::Element *element) const
Returns whether this selector matches an element.
element The element to match against.
QString Selector::toString() const
Return a string representation of this selector.
Union::SelectorType Selector::type() const
Returns the type of selector.
int Selector::weight() const
Returns the weight of this selector.
Related Non-Members
enum class SelectorType
The type of selector.
| Constant | Value | Description |
|---|---|---|
Union::Selector::SelectorType::Empty | 0 | An empty selector, which does nothing. |
Union::Selector::SelectorType::Type | 1 | A selector matching on the type property. Checks if the specified string is equal to that of the property. |
Union::Selector::SelectorType::Id | 2 | A selector matching on the id property. Checks if the specified string is equal to that of the property. |
Union::Selector::SelectorType::State | 3 | A selector matching on the state property. Checks if the specified state is set in the property. |
Union::Selector::SelectorType::Hint | 4 | A selector matching on the hints property. Checks if the specified string matches any of the hints set in the property. |
Union::Selector::SelectorType::AttributeExists | 5 | A selector matching on an attribute in the attributes property. Checks if the provided attribute name exists in the property. |
Union::Selector::SelectorType::AttributeEquals | 6 | A selector matching on an attribute in the attributes property. Checks if the provided attribute's value is the same as the property's value. |
Union::Selector::SelectorType::AttributeSubstringMatch | 7 | A selector matching on an attribute in the attributes property. Checks if the provided attribute's value is a substring match of the property's value. |
Union::Selector::SelectorType::AnyElement | 8 | A selector that matches anything. Note that this has a low weight and most other selectors will override it. |
Union::Selector::SelectorType::ChildCombinator | 9 | A combinator that will match if the element is a direct child of the parent. |
Union::Selector::SelectorType::DescendantCombinator | 10 | A combinator that will match if the element is a descendant at any level of the parent. |
QDebug operator<<(QDebug debug, const Union::Selector &selector)
QDebug support for Selector.