forked from brettlangdon/forge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
value.go
65 lines (53 loc) · 1.04 KB
/
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package forge
// ValueType is an int type for representing the types of values forge can handle
type ValueType int
const (
// UNKNOWN ValueType
UNKNOWN ValueType = iota
//===primativesStart
// BOOLEAN ValueType
BOOLEAN
// FLOAT ValueType
FLOAT
// INTEGER ValueType
INTEGER
// NULL ValueType
NULL
// STRING ValueType
STRING
//===primativesEnd
//===complexStart
// LIST ValueType
LIST
// REFERENCE ValueType
REFERENCE
// SECTION ValueType
SECTION
//===complexEnd
)
var valueTypes = [...]string{
BOOLEAN: "BOOLEAN",
FLOAT: "FLOAT",
INTEGER: "INTEGER",
NULL: "NULL",
STRING: "STRING",
LIST: "LIST",
REFERENCE: "REFERENCE",
SECTION: "SECTION",
}
func (valueType ValueType) String() string {
str := ""
if 0 <= valueType && valueType < ValueType(len(valueTypes)) {
str = valueTypes[valueType]
}
if str == "" {
str = "UNKNOWN"
}
return str
}
// Value is the base interface for Primative and Section data types
type Value interface {
GetType() ValueType
GetValue() interface{}
UpdateValue(interface{}) error
}