// mapTypeToFeatureString maps a MapType into a string defined by run_probes.sh
973352
func mapTypeToFeatureString(mt MapType) string {
	var featureString string
	switch mt {
	case MapTypeLPMTrie:
		featureString = fmt.Sprintf("#define HAVE_LPM_MAP_TYPE")
	case MapTypeLRUHash:
		featureString = fmt.Sprintf("#define HAVE_LRU_MAP_TYPE")
	default:
		break
	}
	return featureString
}
297687
func (c ConfigAttributes) GetStringMap(attrName string, defaultValue map[string]string) (map[string]string, error) {
	if valData, ok := c[attrName]; ok {
		result := make(map[string]string)
		switch val := valData.(type) {
		case map[string]string:
			for k, v := range val {
				result[k] = v
			}
		case map[string]interface{}:
			for k, v := range val {
				result[k] = fmt.Sprintf("%v", v)
			}
		default:
			return nil, errors.NotValidf("string map value of type %T", val)
		}
		return result, nil
	}
	return defaultValue, nil
}
1023705
func ToStringMapStringSliceE(i interface{}) (map[string][]string, error) {
	var m = map[string][]string{}

	switch v := i.(type) {
	case map[string][]string:
		return v, nil
	case map[string][]interface{}:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[string]string:
		for k, val := range v {
			m[ToString(k)] = []string{val}
		}
	case map[string]interface{}:
		for k, val := range v {
			switch vt := val.(type) {
			case []interface{}:
				m[ToString(k)] = ToStringSlice(vt)
			case []string:
				m[ToString(k)] = vt
			default:
				m[ToString(k)] = []string{ToString(val)}
			}
		}
		return m, nil
	case map[interface{}][]string:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[interface{}]string:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[interface{}][]interface{}:
		for k, val := range v {
			m[ToString(k)] = ToStringSlice(val)
		}
		return m, nil
	case map[interface{}]interface{}:
		for k, val := range v {
			key, err := ToStringE(k)
			if err != nil {
				return m, fmt.Errorf("unable to cast %#v of type %T to map[string][]string", i, i)
			}
			value, err := ToStringSliceE(val)
			if err != nil {
				return m, fmt.Errorf("unable to cast %#v of type %T to map[string][]string", i, i)
			}
			m[key] = value
		}
	case string:
		err := jsonStringToObject(v, &m)
		return m, err
	default:
		return m, fmt.Errorf("unable to cast %#v of type %T to map[string][]string", i, i)
	}
	return m, nil
}
226148
func indexStringToType(indexTypeString string) (IndexType, error) {
	switch indexTypeString {
	case string(FullTextIndex):
		return FullTextIndex, nil
	case string(HashIndex):
		return HashIndex, nil
	case string(SkipListIndex):
		return SkipListIndex, nil
	case string(PrimaryIndex):
		return PrimaryIndex, nil
	case string(PersistentIndex):
		return PersistentIndex, nil
	case string(GeoIndex), "geo1", "geo2":
		return GeoIndex, nil
	case string(EdgeIndex):
		return EdgeIndex, nil

	default:
		return "", WithStack(InvalidArgumentError{Message: "unknown index type"})
	}
}
1092110
func (r Software_Description) GetFeatures() (resp []datatypes.Software_Description_Feature, err error) {
	err = r.Session.DoRequest("SoftLayer_Software_Description", "getFeatures", nil, &r.Options, &resp)
	return
}
317479
func MappingFuncFor(context ...map[string]string) func(string) string {
	return func(input string) string {
		for _, vars := range context {
			val, ok := vars[input]
			if ok {
				return val
			}
		}

		return syntaxWrap(input)
	}
}
1129291
func mapToString(extensions map[string]string, keyValSep string, elemSep string) string {
	buf := make([]string, 0, len(extensions))

	for k, v := range extensions {
		buf = append(buf, k+keyValSep+v)
	}

	sort.Strings(buf)

	return strings.Join(buf, elemSep)
}
479921
func parseAnnotationsString(a map[string]string, key string, def string) string {
	if v, ok := a[key]; ok {
		return v
	}
	return def
}
1027484
func (t SimpleType) ConvertToStringSlice(value interface{}) ([]string, error) {
	if value == nil {
		// if a value is nil, we return empty string.
		return []string{""}, nil
	}
	valueType := reflect.TypeOf(value)
	switch t.GetKind() {
	case KindString, KindUser, KindIteration, KindArea, KindLabel, KindBoardColumn:
		if valueType.Kind() != reflect.String {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "string", valueType.Name())
		}
		return []string{value.(string)}, nil
	case KindRemoteTracker:
		v, err := AnyToUUID(value)
		if err != nil {
			return nil, err
		}
		return []string{v.String()}, nil
	case KindURL:
		if valueType.Kind() == reflect.String && govalidator.IsURL(value.(string)) {
			return []string{value.(string)}, nil
		}
		return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %q", value, "URL", valueType.Name())
	case KindFloat:
		if valueType.Kind() != reflect.Float64 {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %q", value, "float64", valueType.Name())
		}
		fval, ok := value.(float64)
		if !ok {
			return nil, errs.Errorf("failed to cast value %+v (%[1]T) to float64", value)
		}
		return []string{strconv.FormatFloat(fval, 'f', 6, 64)}, nil
	case KindInteger:
		// NOTE(kwk): This will change soon to be more consistent.
		switch valueType.Kind() {
		case reflect.Int:
			ival, ok := value.(int)
			if !ok {
				return nil, errs.Errorf("failed to cast value %+v (%[1]T) to int", value)
			}
			return []string{strconv.Itoa(ival)}, nil
		case reflect.Int64:
			ival, ok := value.(int64)
			if !ok {
				return nil, errs.Errorf("failed to cast value %+v (%[1]T) to int64", value)
			}
			return []string{strconv.FormatInt((ival), 10)}, nil
		case reflect.Float64:
			fval, ok := value.(float64)
			if !ok {
				return nil, errs.Errorf("failed to cast value %+v (%[1]T) to float64", value)
			}
			if fval != math.Trunc(fval) {
				return nil, errs.Errorf("float64 value %+v (%[1]T) has digits after the decimal point and therefore cannot be represented by an integer", value)
			}
			return []string{strconv.FormatFloat(fval, 'f', 0, 64)}, nil
		default:
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s ", value, "int or float", valueType.Name())
		}
	case KindInstant:
		if valueType.Kind() != timeType.Kind() {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "time.Time", valueType.Name())
		}
		timeVal, ok := value.(time.Time)
		if !ok {
			return nil, errs.Errorf(`value should be of type "time.Time" but is of type "%[1]T": %[1]+v`, value)
		}
		return []string{timeVal.Format(time.RFC3339)}, nil
	case KindBoolean:
		if valueType.Kind() != reflect.Bool {
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "boolean", valueType.Name())
		}
		if value.(bool) {
			return []string{"true"}, nil
		}
		return []string{"false"}, nil
	case KindMarkup:
		// 'markup' is just a string in the API layer for now:
		// it corresponds to the MarkupContent.Content field. The MarkupContent.Markup is set to the default value
		switch value.(type) {
		case rendering.MarkupContent:
			markupContent := value.(rendering.MarkupContent)
			if !rendering.IsMarkupSupported(markupContent.Markup) {
				return nil, errs.Errorf("value %v (%[1]T) has no valid markup type %s", value, markupContent.Markup)
			}
			return []string{markupContent.Content}, nil
		case map[string]interface{}:
			markupContent := rendering.NewMarkupContentFromValue(value)
			if !rendering.IsMarkupSupported(markupContent.Markup) {
				return nil, errs.Errorf("value %v (%[1]T) has no valid markup type %s", value, markupContent.Markup)
			}
			return []string{markupContent.Content}, nil
		default:
			return nil, errs.Errorf("value %v (%[1]T) should be rendering.MarkupContent, but is %s", value, valueType)
		}
	case KindCodebase:
		switch value.(type) {
		case codebase.Content:
			cb := value.(codebase.Content)
			if err := cb.IsValid(); err != nil {
				return nil, errs.Wrapf(err, "value %v (%[1]T) is invalid %s", value, cb)
			}
			return []string{cb.Repository + "#" + cb.Branch + "#" + cb.FileName + ":" + strconv.Itoa(cb.LineNumber)}, nil
		default:
			return nil, errs.Errorf("value %v (%[1]T) should be %s, but is %s", value, "CodebaseContent", valueType)
		}
	// Note: the KindEnum and KindList cases are omitted as they are not used. We may want to remove them
	// from ConvertToModel() as well.
	default:
		return nil, errs.Errorf("unexpected type constant: '%s'", t.GetKind())
	}
}
1356556
func convertMapsToStringKeyMaps(i interface{}) (res interface{}, err error) {
	switch reflect.TypeOf(i).Kind() {
	case reflect.Map:
		res := make(map[string]interface{})
		v := reflect.ValueOf(i)
		for _, k := range v.MapKeys() {
			res[fmt.Sprintf("%v", k)], err = convertMapsToStringKeyMaps(v.MapIndex(k).Interface())
			if err != nil {
				return nil, err
			}
		}
		return res, nil
	case reflect.Slice:
		res := make([]interface{}, len(i.([]interface{})))
		for k, v := range i.([]interface{}) {
			res[k], err = convertMapsToStringKeyMaps(v)
			if err != nil {
				return nil, err
			}
		}
		return res, nil

	default:
		return i, nil
	}
}
531142
func TypeFromString(t string) value.ValueType {
	switch strings.ToLower(t) {
	case "integer":
		// This isn't necessarily true, as integer could be bool
		return value.IntType
	case "real":
		return value.NumberType
	default:
		return value.StringType
	}
}
191893
func FiltersFromString(newRegex string) (map[string]*regexp.Regexp, error) {
	if newRegex == "" {
		return nil, nil
	}
	lines := strings.Split(newRegex, "\n")
	newFilters := make(map[string]*regexp.Regexp, len(lines))
	for _, line := range lines {
		lineParts := strings.SplitN(line, ":", 2)
		if len(lineParts) != 2 || lineParts[0] == "" || lineParts[1] == "" {
			return nil, errors.Errorf("Cannot parse line %s", line)
		}
		reg, err := regexp.Compile(lineParts[1])
		if err != nil {
			return nil, errors.Annotatef(err, "Cannot parse regex line %s", line)
		}
		newFilters[lineParts[0]] = reg
	}
	return newFilters, nil
}
1227115
func (u *User) ToStringMap() map[string]interface{} {
	datumIn := map[string]interface{}{
		"FirstName": string(u.FirstName),
		"LastName":  string(u.LastName),
	}

	if len(u.Errors) > 0 {
		datumIn["Errors"] = goavro.Union("array", u.Errors)
	} else {
		datumIn["Errors"] = goavro.Union("null", nil)
	}

	if u.Address != nil {
		addDatum := map[string]interface{}{
			"Address1": string(u.Address.Address1),
			"City":     string(u.Address.City),
			"State":    string(u.Address.State),
			"Zip":      int(u.Address.Zip),
		}
		if u.Address.Address2 != "" {
			addDatum["Address2"] = goavro.Union("string", u.Address.Address2)
		} else {
			addDatum["Address2"] = goavro.Union("null", nil)
		}

		//important need namespace and record name
		datumIn["Address"] = goavro.Union("my.namespace.com.address", addDatum)

	} else {
		datumIn["Address"] = goavro.Union("null", nil)
	}
	return datumIn
}
870299
func NewMapTypeDef(init ...*MapTypeDef) *MapTypeDef {
	var o *MapTypeDef
	if len(init) == 1 {
		o = init[0]
	} else {
		o = new(MapTypeDef)
	}
	return o.Init()
}
1208956
func (v *Type) GetMapType() (o *TypePair) {
	if v != nil && v.MapType != nil {
		return v.MapType
	}

	return
}
980920
func compileMapType(src ast.MapType) (*MapSpec, error) {
	annots, err := compileAnnotations(src.Annotations)
	if err != nil {
		return nil, err
	}

	keySpec, err := compileTypeReference(src.KeyType)
	if err != nil {
		return nil, err
	}

	valueSpec, err := compileTypeReference(src.ValueType)
	if err != nil {
		return nil, err
	}

	return &MapSpec{
		KeySpec:     keySpec,
		ValueSpec:   valueSpec,
		Annotations: annots,
	}, nil
}
439291
func mapBytesToString(m map[string]interface{}) {
	for k, v := range m {
		if b, ok := v.([]byte); ok {
			m[k] = string(b)
		}
	}
}