forked from quay/goval-parser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
operation.go
44 lines (37 loc) · 1.15 KB
/
operation.go
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
package oval
import (
"encoding"
"fmt"
"strings"
)
type Operation int
const (
_ Operation = iota // Invalid
OpEquals // equals
OpNotEquals // not equals
OpCaseInsensitiveEquals // case insensitive equals
OpCaseInsensitiveNotEquals // case insensitive not equals
OpGreaterThan // greater than
OpLessThan // less than
OpGreaterThanOrEqual // greater than or equal
OpLessThanOrEqual // less than or equal
OpBitwiseAnd // bitwise and
OpBitwiseOr // bitwise or
OpPatternMatch // pattern match
OpSubset // subset of
OpSuperset // superset of
)
//go:generate stringer -type=Operation -linecomment
// UnmarshalText implements encoding.TextUnmarshaler.
func (o *Operation) UnmarshalText(text []byte) error {
off := strings.Index(_Operation_name, string(text))
for i, idx := range _Operation_index {
if int(idx) == off {
*o = Operation(i + 1)
return nil
}
}
o = new(Operation)
return fmt.Errorf("oval: unknown operation %q", string(text))
}
var _ encoding.TextUnmarshaler = (*Operation)(nil)