Orcus
Loading...
Searching...
No Matches
css_selector.hpp
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 */
7
8#ifndef INCLUDED_ORCUS_CSS_SELECTOR_HPP
9#define INCLUDED_ORCUS_CSS_SELECTOR_HPP
10
11#include "env.hpp"
12#include "css_types.hpp"
13
14#include <ostream>
15#include <variant>
16#include <vector>
17#include <unordered_set>
18#include <unordered_map>
19
20namespace orcus {
21
22struct ORCUS_DLLPUBLIC css_simple_selector_t
23{
24 typedef std::unordered_set<std::string_view> classes_type;
25
26 std::string_view name;
27 std::string_view id;
28 classes_type classes;
29 css::pseudo_class_t pseudo_classes;
30
32
33 void clear();
34 bool empty() const;
35
36 bool operator== (const css_simple_selector_t& r) const;
37 bool operator!= (const css_simple_selector_t& r) const;
38
39 struct hash
40 {
41 size_t operator() (const css_simple_selector_t& ss) const;
42 };
43};
44
45struct ORCUS_DLLPUBLIC css_chained_simple_selector_t
46{
47 css::combinator_t combinator;
48 css_simple_selector_t simple_selector;
49
50 bool operator== (const css_chained_simple_selector_t& r) const;
51
54 css_chained_simple_selector_t(css::combinator_t op, const css_simple_selector_t& ss);
55};
56
60struct ORCUS_DLLPUBLIC css_selector_t
61{
62 typedef std::vector<css_chained_simple_selector_t> chained_type;
64 chained_type chained;
65
66 void clear();
67
68 bool operator== (const css_selector_t& r) const;
69};
70
74struct ORCUS_DLLPUBLIC css_property_value_t
75{
76 using value_type = std::variant<std::string_view, css::rgba_color_t, css::hsla_color_t>;
77
78 css::property_value_t type;
79 value_type value;
80
83
92 css_property_value_t(std::string_view _str);
93
94 css_property_value_t& operator= (const css_property_value_t& r);
95
96 void swap(css_property_value_t& r);
97};
98
99typedef std::unordered_map<std::string_view, std::vector<css_property_value_t>> css_properties_t;
100typedef std::unordered_map<css::pseudo_element_t, css_properties_t> css_pseudo_element_properties_t;
101
102ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const css_simple_selector_t& v);
103ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const css_selector_t& v);
104ORCUS_DLLPUBLIC std::ostream& operator<< (std::ostream& os, const css_property_value_t& v);
105
106}
107
108#endif
109
110/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Definition: css_selector.hpp:46
Definition: css_selector.hpp:75
css_property_value_t(std::string_view _str)
Definition: css_selector.hpp:61
Definition: css_selector.hpp:40
Definition: css_selector.hpp:23