aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/github.com/ClickHouse/ch-go/proto/interval_enum.go
blob: c7cb9f05117f7f5e931be489fdfd4053acc2a675 (plain) (blame)
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
// Code generated by "enumer -type IntervalScale -output interval_enum.go"; DO NOT EDIT.

package proto

import (
	"fmt"
	"strings"
)

const _IntervalScaleName = "IntervalSecondIntervalMinuteIntervalHourIntervalDayIntervalWeekIntervalMonthIntervalQuarterIntervalYear"

var _IntervalScaleIndex = [...]uint8{0, 14, 28, 40, 51, 63, 76, 91, 103}

const _IntervalScaleLowerName = "intervalsecondintervalminuteintervalhourintervaldayintervalweekintervalmonthintervalquarterintervalyear"

func (i IntervalScale) String() string {
	if i >= IntervalScale(len(_IntervalScaleIndex)-1) {
		return fmt.Sprintf("IntervalScale(%d)", i)
	}
	return _IntervalScaleName[_IntervalScaleIndex[i]:_IntervalScaleIndex[i+1]]
}

// An "invalid array index" compiler error signifies that the constant values have changed.
// Re-run the stringer command to generate them again.
func _IntervalScaleNoOp() {
	var x [1]struct{}
	_ = x[IntervalSecond-(0)]
	_ = x[IntervalMinute-(1)]
	_ = x[IntervalHour-(2)]
	_ = x[IntervalDay-(3)]
	_ = x[IntervalWeek-(4)]
	_ = x[IntervalMonth-(5)]
	_ = x[IntervalQuarter-(6)]
	_ = x[IntervalYear-(7)]
}

var _IntervalScaleValues = []IntervalScale{IntervalSecond, IntervalMinute, IntervalHour, IntervalDay, IntervalWeek, IntervalMonth, IntervalQuarter, IntervalYear}

var _IntervalScaleNameToValueMap = map[string]IntervalScale{
	_IntervalScaleName[0:14]:        IntervalSecond,
	_IntervalScaleLowerName[0:14]:   IntervalSecond,
	_IntervalScaleName[14:28]:       IntervalMinute,
	_IntervalScaleLowerName[14:28]:  IntervalMinute,
	_IntervalScaleName[28:40]:       IntervalHour,
	_IntervalScaleLowerName[28:40]:  IntervalHour,
	_IntervalScaleName[40:51]:       IntervalDay,
	_IntervalScaleLowerName[40:51]:  IntervalDay,
	_IntervalScaleName[51:63]:       IntervalWeek,
	_IntervalScaleLowerName[51:63]:  IntervalWeek,
	_IntervalScaleName[63:76]:       IntervalMonth,
	_IntervalScaleLowerName[63:76]:  IntervalMonth,
	_IntervalScaleName[76:91]:       IntervalQuarter,
	_IntervalScaleLowerName[76:91]:  IntervalQuarter,
	_IntervalScaleName[91:103]:      IntervalYear,
	_IntervalScaleLowerName[91:103]: IntervalYear,
}

var _IntervalScaleNames = []string{
	_IntervalScaleName[0:14],
	_IntervalScaleName[14:28],
	_IntervalScaleName[28:40],
	_IntervalScaleName[40:51],
	_IntervalScaleName[51:63],
	_IntervalScaleName[63:76],
	_IntervalScaleName[76:91],
	_IntervalScaleName[91:103],
}

// IntervalScaleString retrieves an enum value from the enum constants string name.
// Throws an error if the param is not part of the enum.
func IntervalScaleString(s string) (IntervalScale, error) {
	if val, ok := _IntervalScaleNameToValueMap[s]; ok {
		return val, nil
	}

	if val, ok := _IntervalScaleNameToValueMap[strings.ToLower(s)]; ok {
		return val, nil
	}
	return 0, fmt.Errorf("%s does not belong to IntervalScale values", s)
}

// IntervalScaleValues returns all values of the enum
func IntervalScaleValues() []IntervalScale {
	return _IntervalScaleValues
}

// IntervalScaleStrings returns a slice of all String values of the enum
func IntervalScaleStrings() []string {
	strs := make([]string, len(_IntervalScaleNames))
	copy(strs, _IntervalScaleNames)
	return strs
}

// IsAIntervalScale returns "true" if the value is listed in the enum definition. "false" otherwise
func (i IntervalScale) IsAIntervalScale() bool {
	for _, v := range _IntervalScaleValues {
		if i == v {
			return true
		}
	}
	return false
}