-
Notifications
You must be signed in to change notification settings - Fork 121
/
ast_val_enum_value.go
45 lines (36 loc) · 1.13 KB
/
ast_val_enum_value.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
45
package ast
import (
"github.com/wundergraph/graphql-go-tools/pkg/internal/unsafebytes"
)
// EnumValue
// example:
// Name but not true or false or null
type EnumValue struct {
Name ByteSliceReference // e.g. ORIGIN
}
func (d *Document) CopyEnumValue(ref int) int {
return d.AddEnumValue(EnumValue{
Name: d.copyByteSliceReference(d.EnumValues[ref].Name),
})
}
func (d *Document) EnumValueName(ref int) ByteSliceReference {
return d.EnumValues[ref].Name
}
func (d *Document) EnumValueNameBytes(ref int) ByteSlice {
return d.Input.ByteSlice(d.EnumValues[ref].Name)
}
func (d *Document) EnumValueNameString(ref int) string {
return unsafebytes.BytesToString(d.Input.ByteSlice(d.EnumValues[ref].Name))
}
func (d *Document) EnumValuesAreEqual(left, right int) bool {
return d.Input.ByteSliceReferenceContentEquals(d.EnumValueName(left), d.EnumValueName(right))
}
func (d *Document) AddEnumValue(value EnumValue) (ref int) {
d.EnumValues = append(d.EnumValues, value)
return len(d.EnumValues) - 1
}
func (d *Document) ImportEnumValue(name ByteSlice) (ref int) {
return d.AddEnumValue(EnumValue{
Name: d.Input.AppendInputBytes(name),
})
}