// GetEnum returns the Enum value with the colIdx.
351032
func (r Row) GetEnum(colIdx int) types.Enum {
	name, val := r.getNameValue(colIdx)
	return types.Enum{Name: name, Value: val}
}
584551
func (m *StatusResponseClusterCiliumHealth) validateStateEnum(path, location string, value string) error {
	if err := validate.Enum(path, location, value, statusResponseClusterCiliumHealthTypeStatePropEnum); err != nil {
		return err
	}
	return nil
}
1260931
func (nc *NumberConstraint) Enum(l ...interface{}) *NumberConstraint {
	if nc.enums == nil {
		nc.enums = Enum()
	}
	nc.enums.Enum(l...)
	return nc
}
753225
func FindEnumValue(e *pb.EnumDescriptorProto, name string) int {
	for i, x := range e.GetValue() {
		if x.GetName() == name {
			return i
		}
	}
	return -1
}
66914
func Enum(path, in string, data interface{}, enum interface{}) *errors.Validation {
	val := reflect.ValueOf(enum)
	if val.Kind() != reflect.Slice {
		return nil
	}

	var values []interface{}
	for i := 0; i < val.Len(); i++ {
		ele := val.Index(i)
		enumValue := ele.Interface()
		if data != nil {
			if reflect.DeepEqual(data, enumValue) {
				return nil
			}
			actualType := reflect.TypeOf(enumValue)
			if actualType == nil { // Safeguard. Frankly, I don't know how we may get a nil
				continue
			}
			expectedValue := reflect.ValueOf(data)
			if expectedValue.IsValid() && expectedValue.Type().ConvertibleTo(actualType) {
				// Attempt comparison after type conversion
				if reflect.DeepEqual(expectedValue.Convert(actualType).Interface(), enumValue) {
					return nil
				}
			}
		}
		values = append(values, enumValue)
	}
	return errors.EnumFail(path, in, data, values)
}
1045982
func RegisterEnum(typeName string, unusedNameMap map[int32]string, valueMap map[string]int32) {
	if _, ok := enumValueMaps[typeName]; ok {
		panic("proto: duplicate enum registered: " + typeName)
	}
	enumValueMaps[typeName] = valueMap
	if _, ok := enumStringMaps[typeName]; ok {
		panic("proto: duplicate enum registered: " + typeName)
	}
	enumStringMaps[typeName] = unusedNameMap
}
287694
func (tl TypeLoader) LoadEnums(args *ArgType) (map[string]*Enum, error) {
	var err error

	// not supplied, so bail
	if tl.EnumList == nil {
		return nil, nil
	}

	// load enums
	enumList, err := tl.EnumList(args.DB, args.Schema)
	if err != nil {
		return nil, err
	}

	// process enums
	enumMap := map[string]*Enum{}
	for _, e := range enumList {
		enumTpl := &Enum{
			Name:              SingularizeIdentifier(e.EnumName),
			Schema:            args.Schema,
			Values:            []*EnumValue{},
			Enum:              e,
			ReverseConstNames: args.UseReversedEnumConstNames,
		}

		err = tl.LoadEnumValues(args, enumTpl)
		if err != nil {
			return nil, err
		}

		enumMap[enumTpl.Name] = enumTpl
		args.KnownTypeMap[enumTpl.Name] = true
	}

	// generate enum templates
	for _, e := range enumMap {
		err = args.ExecuteTemplate(EnumTemplate, e.Name, "", e)
		if err != nil {
			return nil, err
		}
	}

	return enumMap, nil
}
156776
func MyEnumValues(db models.XODB, schema string, enum string) ([]*models.EnumValue, error) {
	var err error

	// load enum vals
	res, err := models.MyEnumValues(db, schema, enum)
	if err != nil {
		return nil, err
	}

	// process enum vals
	enumVals := []*models.EnumValue{}
	for i, ev := range strings.Split(res.EnumValues[1:len(res.EnumValues)-1], "','") {
		enumVals = append(enumVals, &models.EnumValue{
			EnumValue:  ev,
			ConstValue: i + 1,
		})
	}

	return enumVals, nil
}
1337220
func EnumIn(db XODB, v0 pgtypes.Cstring, v1 pgtypes.Oid) (pgtypes.Anyenum, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.enum_in($1, $2)`

	// run query
	var ret pgtypes.Anyenum
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return pgtypes.Anyenum{}, err
	}

	return ret, nil
}
1080798
func (m *Descriptor) GetEnum(name string) *EnumDescriptor {
	for _, e := range m.GetEnums() {
		// can lookup by name or message prefixed name (qualified)
		if e.GetName() == name || e.GetLongName() == name {
			return e
		}
	}

	return nil
}
1270172
func (o *Organization) GetType() string {
	if o == nil || o.Type == nil {
		return ""
	}
	return *o.Type
}
289975
func FindEnumForFile(f *pb.FileDescriptorProto, name string) int {
	for i, x := range f.GetEnumType() {
		if x.GetName() == name {
			return i
		}
	}
	return -1
}
80067
func getEnv(name, deflt string) string {
	if val, ok := os.LookupEnv(name); ok {
		return val
	}
	return deflt
}
1334175
func Enum(name rune, values []string, helpvalue ...string) *string {
	return CommandLine.Enum(name, values, helpvalue...)
}
96769
func MyEnumValues(db XODB, schema string, enum string) (*MyEnumValue, error) {
	var err error

	// sql query
	const sqlstr = `SELECT ` +
		`SUBSTRING(column_type, 6, CHAR_LENGTH(column_type) - 6) AS enum_values ` +
		`FROM information_schema.columns ` +
		`WHERE data_type = 'enum' AND table_schema = ? AND column_name = ?`

	// run query
	XOLog(sqlstr, schema, enum)
	var mev MyEnumValue
	err = db.QueryRow(sqlstr, schema, enum).Scan(&mev.EnumValues)
	if err != nil {
		return nil, err
	}

	return &mev, nil
}
759481
func EnumRecv(db XODB, v0 pgtypes.Internal, v1 pgtypes.Oid) (pgtypes.Anyenum, error) {
	var err error

	// sql query
	const sqlstr = `SELECT pg_catalog.enum_recv($1, $2)`

	// run query
	var ret pgtypes.Anyenum
	XOLog(sqlstr, v0, v1)
	err = db.QueryRow(sqlstr, v0, v1).Scan(&ret)
	if err != nil {
		return pgtypes.Anyenum{}, err
	}

	return ret, nil
}
487309
func EnumName(m map[int32]string, v int32) string {
	s, ok := m[v]
	if ok {
		return s
	}
	return strconv.Itoa(int(v))
}