Union::Selector Class
class Union::SelectorA class to handle matching some data to an element. More...
| Header: | #include <Selector.h> |
| 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, SubElement, Id, State, …, 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::SelectorType::Empty | 0 | An empty selector, which does nothing. |
Union::SelectorType::Type | 1 | A selector matching on the type property. Checks if the specified string compares equal to the property. |
Union::SelectorType::SubElement | 2 | A selector matching on the Union::Element::subElement property. Checks if the specified string compares equal to the property. |
Union::SelectorType::Id | 3 | A selector matching on the id property. Checks if the specified string compares equal to the property. |
Union::SelectorType::State | 4 | A selector matching on the state property. Checks if the specified state is set in the property. |
Union::SelectorType::Hint | 5 | A selector matching on the hints property. Checks if the specified string compares equal to any of the hints set in the property. |
Union::SelectorType::AttributeExists | 6 | A selector matching on an attribute in the attributes property. Checks if the provided attribute name exists in the property. |
Union::SelectorType::AttributeEquals | 7 | 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::SelectorType::AttributeSubstringMatch | 8 | 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::SelectorType::AnyElement | 9 | A selector that matches anything. Note that this has a low weight and most other selectors will override it. |
Union::SelectorType::ChildCombinator | 10 | A combinator that will match if the element is a direct child of the parent. |
Union::SelectorType::DescendantCombinator | 11 | 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.