-
Notifications
You must be signed in to change notification settings - Fork 6
/
type.go
59 lines (51 loc) · 1.45 KB
/
type.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/* Go IPP - IPP core protocol implementation in pure Go
*
* Copyright (C) 2020 and up by Alexander Pevzner ([email protected])
* See LICENSE for license terms and conditions
*
* Enumeration of value types
*/
package goipp
import (
"fmt"
)
// Type enumerates all possible value types
type Type int
// Type values
const (
TypeInvalid Type = -1 // Invalid Value type
TypeVoid Type = iota // Value is Void
TypeInteger // Value is Integer
TypeBoolean // Value is Boolean
TypeString // Value is String
TypeDateTime // Value is Time
TypeResolution // Value is Resolution
TypeRange // Value is Range
TypeTextWithLang // Value is TextWithLang
TypeBinary // Value is Binary
TypeCollection // Value is Collection
)
// String converts Type to string, for debugging
func (t Type) String() string {
if t == TypeInvalid {
return "Invalid"
}
if 0 <= t && int(t) < len(typeNames) {
if s := typeNames[t]; s != "" {
return s
}
}
return fmt.Sprintf("0x%4.4x", uint(t))
}
var typeNames = [...]string{
TypeVoid: "Void",
TypeInteger: "Integer",
TypeBoolean: "Boolean",
TypeString: "String",
TypeDateTime: "DateTime",
TypeResolution: "Resolution",
TypeRange: "Range",
TypeTextWithLang: "TextWithLang",
TypeBinary: "Binary",
TypeCollection: "Collection",
}