AeonGUI
A portable video game graphic user interface library.
Loading...
Searching...
No Matches
CSSSelector.hpp
1/*
2Copyright (C) 2026 Rodrigo Jose Hernandez Cordoba
3
4Licensed under the Apache License, Version 2.0 (the "License");
5you may not use this file except in compliance with the License.
6You may obtain a copy of the License at
7
8http://www.apache.org/licenses/LICENSE-2.0
9
10Unless required by applicable law or agreed to in writing, software
11distributed under the License is distributed on an "AS IS" BASIS,
12WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13See the License for the specific language governing permissions and
14limitations under the License.
15*/
16#ifndef AEONGUI_CSS_SELECTOR_H
17#define AEONGUI_CSS_SELECTOR_H
18
19#include <string>
20#include <vector>
21#include "aeongui/Platform.hpp"
22
23namespace AeonGUI
24{
25 namespace DOM
26 {
27 class Element;
28 }
29
58
61 {
62 std::vector<SimpleSelector> selectors{};
63 };
64
66 enum class Combinator
67 {
68 None,
69 Descendant,
70 Child,
71 AdjacentSibling,
72 GeneralSibling
73 };
74
78 {
80 struct Part
81 {
83 Combinator combinator{Combinator::None};
84 };
85 std::vector<Part> parts{};
86 };
87
89 DLL std::vector<ComplexSelector> ParseSelector ( const std::string& aSelector );
90
92 DLL bool MatchesCompound ( const DOM::Element& aElement, const CompoundSelector& aCompound );
93
95 DLL bool MatchesSelector ( const DOM::Element& aElement, const ComplexSelector& aSelector );
96
98 DLL bool MatchesAny ( const DOM::Element& aElement, const std::vector<ComplexSelector>& aSelectors );
99}
100
101#endif
Platform-specific DLL import/export macros and compiler helpers.
Base class for DOM elements.
Definition Element.hpp:46
A compound selector together with the combinator that precedes it.
Definition CSSSelector.hpp:81
CompoundSelector compound
The compound selector for this part.
Definition CSSSelector.hpp:82
Combinator combinator
Combinator linking to the next part.
Definition CSSSelector.hpp:83
Definition CSSSelector.hpp:78
std::vector< Part > parts
Parts in left-to-right order as written in CSS.
Definition CSSSelector.hpp:85
A compound selector: a sequence of simple selectors that must all match the same element.
Definition CSSSelector.hpp:61
std::vector< SimpleSelector > selectors
Simple selectors in this compound.
Definition CSSSelector.hpp:62
A single simple selector component (type, id, class, or attribute).
Definition CSSSelector.hpp:32
AttrOp
Attribute matching operator.
Definition CSSSelector.hpp:47
@ Exists
[attr]
Definition CSSSelector.hpp:48
@ Includes
[attr~=value]
Definition CSSSelector.hpp:50
@ Substring
[attr*=value]
Definition CSSSelector.hpp:54
@ Equals
[attr=value]
Definition CSSSelector.hpp:49
@ DashMatch
[attr|=value]
Definition CSSSelector.hpp:51
@ Prefix
[attr^=value]
Definition CSSSelector.hpp:52
@ Suffix
[attr$=value]
Definition CSSSelector.hpp:53
std::string value
Definition CSSSelector.hpp:44
Type
Kind of simple selector.
Definition CSSSelector.hpp:35
@ Id
#myId
Definition CSSSelector.hpp:38
@ Attribute
[attr] or [attr=value]
Definition CSSSelector.hpp:40
@ Universal
Definition CSSSelector.hpp:36
@ Class
.myClass
Definition CSSSelector.hpp:39
@ TypeSel
e.g. rect, text
Definition CSSSelector.hpp:37
AttrOp attrOp
The attribute match operation.
Definition CSSSelector.hpp:56
Type type
The selector kind.
Definition CSSSelector.hpp:42
std::string name
Selector name (tag name, id, class, or attribute name).
Definition CSSSelector.hpp:43