1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
use std::fmt::Debug;
use crate::common::*;
use crate::types::*;
use crate::error::*;
use crate::element::*;
use crate::document::*;
use crate::attrib::*;
use crate::metadata::*;
use crate::store::*;
use crate::elementstore::*;
#[derive(Clone)]
pub enum Action {
Select
}
impl Default for Action {
fn default() -> Action {
Action::Select
}
}
#[derive(Default,Clone)]
pub struct Query {
pub action: Action,
pub elementtype: Cmp<ElementType>,
pub elementgroup: Cmp<ElementGroup>,
pub contexttype: Cmp<ElementType>,
pub set: Cmp<String>,
pub class: Cmp<String>,
pub processor: Cmp<String>,
pub subset: Cmp<String>,
pub annotator: Cmp<String>,
pub annotatortype: Cmp<ProcessorType>,
pub confidence: Cmp<f64>
}
#[derive(Clone,PartialEq,Debug)]
pub enum Cmp<T> where T: Debug {
Any,
Is(T),
Some,
None,
Unmatchable,
}
impl<T> Default for Cmp<T> where T: Debug {
fn default() -> Cmp<T> {
Cmp::Any
}
}
impl<T> Cmp<T> where T: PartialEq, T: Debug {
pub fn matches(&self, other: Option<&T>) -> bool {
match self {
Cmp::Any => true,
Cmp::Is(value) => {
if let Some(refvalue) = other {
value == refvalue
} else {
false
}
},
Cmp::None => other.is_none(),
Cmp::Some => other.is_some(),
Cmp::Unmatchable => false,
}
}
}
impl Query {
pub fn element(mut self, value: Cmp<ElementType>) -> Self {
self.elementtype = value;
self
}
pub fn contexttype(mut self, value: Cmp<ElementType>) -> Self {
self.contexttype = value;
self
}
pub fn elementgroup(mut self, value: Cmp<ElementGroup>) -> Self {
self.elementgroup = value;
self
}
pub fn set(mut self, value: Cmp<String>) -> Self {
self.set = value;
self
}
pub fn class(mut self, value: Cmp<String>) -> Self {
self.class = value;
self
}
pub fn processor(mut self, value: Cmp<String>) -> Self {
self.processor = value;
self
}
pub fn annotator(mut self, value: Cmp<String>) -> Self {
self.annotator = value;
self
}
pub fn annotatortype(mut self, value: Cmp<ProcessorType>) -> Self {
self.annotatortype = value;
self
}
pub fn subset(mut self, value: Cmp<String>) -> Self {
self.subset = value;
self
}
pub fn confidence(mut self, value: Cmp<f64>) -> Self {
self.confidence = value;
self
}
pub fn select() -> Self {
Self::default()
}
}