fontconfig_parser/types/match_/
test.rs

1use crate::Property;
2
3/// This element contains a single value which is compared with the target ('pattern', 'font', 'scan' or 'default') property "property" (substitute any of the property names seen above).
4/// 'compare' can be one of "eq", "not_eq", "less", "less_eq", "more", "more_eq", "contains" or "not_contains".
5/// 'qual' may either be the default, "any", in which case the match succeeds if any value associated with the property matches the test value,
6/// or "all", in which case all of the values associated with the property must match the test value. 'ignore-blanks' takes a boolean value.
7/// if 'ignore-blanks' is set "true", any blanks in the string will be ignored on its comparison. this takes effects only when compare="eq" or compare="not_eq".
8/// When used in a <match target="font"> element, the target= attribute in the <test> element selects between matching the original pattern or the font.
9/// "default" selects whichever target the outer <match> element has selected.
10#[derive(Clone, Debug, Default, PartialEq)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
12pub struct Test {
13    pub qual: TestQual,
14    pub target: TestTarget,
15    pub compare: TestCompare,
16    pub value: Property,
17}
18
19#[derive(Clone, Copy, Debug, PartialEq, Eq)]
20#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
21pub enum TestTarget {
22    Default,
23    Pattern,
24    Font,
25    Scan,
26}
27
28parse_enum! {
29    TestTarget,
30    (Default, "default"),
31    (Pattern, "pattern"),
32    (Font, "font"),
33    (Scan, "scan"),
34}
35
36impl Default for TestTarget {
37    fn default() -> Self {
38        TestTarget::Default
39    }
40}
41
42#[derive(Clone, Copy, Debug, PartialEq, Eq)]
43#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
44pub enum TestCompare {
45    Eq,
46    NotEq,
47    Less,
48    LessEq,
49    More,
50    MoreEq,
51    Contains,
52    NotContains,
53}
54
55parse_enum! {
56    TestCompare,
57    (Eq, "eq"),
58    (NotEq, "not_eq"),
59    (Less, "less"),
60    (LessEq, "less_eq"),
61    (More, "more"),
62    (MoreEq, "more_eq"),
63    (Contains, "contains"),
64    (NotContains, "not_contains"),
65}
66
67impl Default for TestCompare {
68    fn default() -> Self {
69        TestCompare::Eq
70    }
71}
72
73#[derive(Clone, Copy, Debug, PartialEq, Eq)]
74#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
75pub enum TestQual {
76    Any,
77    All,
78}
79
80parse_enum! {
81    TestQual,
82    (Any, "any"),
83    (All, "all"),
84}
85
86impl Default for TestQual {
87    fn default() -> Self {
88        TestQual::Any
89    }
90}