package types

import (
	
	
	
)
EnumParser parses "enum" values; i.e. a predefined set of strings to predefined values.
type EnumParser struct {
	Type      string // type name; if not set, use type of first value added
PrefixMatch bool
	vals map[string]interface{}
}
AddVals adds strings and values to an EnumParser.
func ( *EnumParser) ( map[string]interface{}) {
	if .vals == nil {
		.vals = make(map[string]interface{})
	}
	for ,  := range  {
		if .Type == "" {
			.Type = reflect.TypeOf().Name()
		}
		if !.CaseMatch {
			 = strings.ToLower()
		}
		.vals[] = 
	}
}
Parse parses the string and returns the value or an error.
func ( EnumParser) ( string) (interface{}, error) {
	if !.CaseMatch {
		 = strings.ToLower()
	}
	,  := .vals[]
	if ! {
		return false, fmt.Errorf("failed to parse %s %#q", .Type, )
	}
	return , nil