// toValueTypeName returns varName with `*` if it is not set as "required"
963171
func toValueTypeName(varName, name string, att *design.AttributeDefinition) string {
	if att == nil {
		return varName
	}
	if att.IsRequired(name) {
		return varName
	}
	return "*" + varName
}
325809
func (ctx *context) PostValueFloat64(name string) (float64, error) {
	v := ctx.PostValue(name)
	if v == "" {
		return -1, errUnableToFindPostValue.Format(name)
	}
	return strconv.ParseFloat(v, 64)
}
88308
func TypeName(x interface{}) string {
	return strings.ToLower(reflect.Indirect(reflect.ValueOf(x)).Type().Name())
}
835173
func convertValueToString(ctx context.Context, app application.Application, uuidStringCache *map[string]string, fieldValueGeneric interface{}, fieldValueStrSlice []string, fieldKey string, kind workitem.Kind) (string, error) {
	if fieldValueGeneric != nil && len(fieldValueStrSlice) == 1 {
		switch kind {
		case workitem.KindUser:
			cachedValue, ok := (*uuidStringCache)[fieldValueStrSlice[0]]
			if ok {
				return cachedValue, nil
			}
			userID, err := uuid.FromString(fieldValueStrSlice[0])
			if err != nil {
				return "", errs.Wrapf(err, "failed to convert user type value to string for field key: %s, value %s", fieldKey, fieldValueStrSlice[0])
			}
			user, err := app.Identities().Load(ctx, userID)
			if err != nil {
				return "", errs.Wrapf(err, "failed to retrieve user for field key: %s", fieldKey)
			}
			(*uuidStringCache)[fieldValueStrSlice[0]] = user.Username
			return user.Username, nil
		case workitem.KindIteration:
			cachedValue, ok := (*uuidStringCache)[fieldValueStrSlice[0]]
			if ok {
				return cachedValue, nil
			}
			iterationID, err := uuid.FromString(fieldValueStrSlice[0])
			if err != nil {
				return "", errs.Wrapf(err, "failed to convert iteration type value to string for field key: %s", fieldKey)
			}
			iteration, err := app.Iterations().Load(ctx, iterationID)
			if err != nil {
				return "", errs.Wrapf(err, "failed to retrieve iteration for field key: %s", fieldKey)
			}
			(*uuidStringCache)[fieldValueStrSlice[0]] = iteration.Name
			return iteration.Name, nil
		case workitem.KindArea:
			cachedValue, ok := (*uuidStringCache)[fieldValueStrSlice[0]]
			if ok {
				return cachedValue, nil
			}
			areaID, err := uuid.FromString(fieldValueStrSlice[0])
			if err != nil {
				return "", errs.Wrapf(err, "failed to convert area type value to string for field key: %s", fieldKey)
			}
			area, err := app.Areas().Load(ctx, areaID)
			if err != nil {
				return "", errs.Wrapf(err, "failed to retrieve area for field key: %s", fieldKey)
			}
			(*uuidStringCache)[fieldValueStrSlice[0]] = area.Name
			return area.Name, nil
		case workitem.KindLabel:
			cachedValue, ok := (*uuidStringCache)[fieldValueStrSlice[0]]
			if ok {
				return cachedValue, nil
			}
			labelID, err := uuid.FromString(fieldValueStrSlice[0])
			if err != nil {
				return "", errs.Wrapf(err, "failed to convert label type value to string for field key: %s", fieldKey)
			}
			label, err := app.Labels().Load(ctx, labelID)
			if err != nil {
				return "", errs.Wrapf(err, "failed to retrieve label for field key: %s", fieldKey)
			}
			(*uuidStringCache)[fieldValueStrSlice[0]] = label.Name
			return label.Name, nil
		default:
			// the default case is also used for KindBoardcolumn as resolving the column is not provided by the
			// factories and the resolved name also has limited use for the exported data.
			return fieldValueStrSlice[0], nil
		}
	} else if len(fieldValueStrSlice) == 1 {
		// the value is nil, we append the returned converted string (which is not nil in this case depending on the baseType!).
		// this is an extra case because we may want to do some prosprocessing for some types here.
		return fieldValueStrSlice[0], nil
	} else {
		// ConvertToStringSlice returned nil/empty array, which is a valid response. We add an empty string in this case.
		return "", nil
	}
}
623395
func IsTypeNameSupported(t string) bool {
	for imageType, name := range ImageTypes {
		if name == t {
			return IsImageTypeSupportedByVips(imageType).Load
		}
	}
	return false
}
196285
func convertReflectValueToType(rv reflect.Value, rt reflect.Type) (reflect.Value, error) {
	if rt == interfaceType || rv.Type() == rt {
		// if reflect.Type is interface or the types match, return the provided reflect.Value
		return rv, nil
	}
	if rv.Type().ConvertibleTo(rt) {
		// if reflect can covert, do that conversion and return
		return rv.Convert(rt), nil
	}
	if (rv.Kind() == reflect.Slice || rv.Kind() == reflect.Array) &&
		(rt.Kind() == reflect.Slice || rt.Kind() == reflect.Array) {
		// covert slice or array
		return convertSliceOrArray(rv, rt)
	}
	if rv.Kind() == rt.Kind() {
		// kind matches
		switch rv.Kind() {
		case reflect.Map:
			// convert map
			return convertMap(rv, rt)
		case reflect.Func:
			// for runVMFunction conversions, call convertVMFunctionToType
			return convertVMFunctionToType(rv, rt)
		case reflect.Ptr:
			// both rv and rt are pointers, convert what they are pointing to
			value, err := convertReflectValueToType(rv.Elem(), rt.Elem())
			if err != nil {
				return rv, err
			}
			// need to make a new value to be able to set it
			ptrV, err := makeValue(rt)
			if err != nil {
				return rv, err
			}
			// set value and return new pointer
			ptrV.Elem().Set(value)
			return ptrV, nil
		}
	}
	if rv.Type() == interfaceType {
		if rv.IsNil() {
			// return nil of correct type
			return reflect.Zero(rt), nil
		}
		// try to convert the element
		return convertReflectValueToType(rv.Elem(), rt)
	}

	// TODO: need to handle the case where either rv or rt are a pointer but not both

	return rv, fmt.Errorf("invalid type conversion")
}
888531
func CheckValidObjectName(objectName string) error {
	if strings.TrimSpace(objectName) == "" {
		return errors.New("Object name cannot be empty")
	}
	return CheckValidObjectNamePrefix(objectName)
}
430709
func valuePrefix(typeName string) string {
	if v, ok := refValueMap[typeName]; ok {
		return v
	}

	return strings.ToLower(typeName)
}
94338
func (p Packet) ValueNames() []string {
	r := make([]string, len(p.DataTypes))
	for i := range p.DataTypes {
		name := p.Name()
		var valueName string
		switch {
		case p.Plugin == "df" && i == 0:
			valueName = ""
		case p.Plugin == "memory" && i == 0:
			valueName = ""
		case p.Plugin == "interface" && i == 0:
			valueName = "tx"
		case p.Plugin == "interface" && i == 1:
			valueName = "rx"
		case p.Plugin == "load" && i == 0:
			valueName = "1"
		case p.Plugin == "load" && i == 1:
			valueName = "5"
		case p.Plugin == "load" && i == 2:
			valueName = "15"
		default:
			valueName = strconv.FormatInt(int64(i), 10)
		}
		if valueName == "" {
			r[i] = name
		} else {
			r[i] = fmt.Sprintf("%s_%s", name, valueName)
		}
	}
	return r
}
1321051
func InvalidTypeName(typeName string) *Validation {
	return &Validation{
		code:    InvalidTypeCode,
		Value:   typeName,
		message: fmt.Sprintf(invalidType, typeName),
	}
}
800391
func ValidName(val string) bool {
	if val == "" {
		return false
	}
	for i, r := range val {
		switch {
		case 'a' <= r && r <= 'z':
		case 'A' <= r && r <= 'Z':
		case r == '_':
		case i > 0 && '0' <= r && r <= '9':
		default:
			return false
		}
	}
	return true
}
690083
func GoMapValueTypes(mapField, valueField *descriptor.FieldDescriptorProto, goValueType, goValueAliasType string) (nullable bool, outGoType string, outGoAliasType string) {
	nullable = gogoproto.IsNullable(mapField) && (valueField.IsMessage() || gogoproto.IsCustomType(mapField))
	if nullable {
		// ensure the non-aliased Go value type is a pointer for consistency
		if strings.HasPrefix(goValueType, "*") {
			outGoType = goValueType
		} else {
			outGoType = "*" + goValueType
		}
		outGoAliasType = goValueAliasType
	} else {
		outGoType = strings.Replace(goValueType, "*", "", 1)
		outGoAliasType = strings.Replace(goValueAliasType, "*", "", 1)
	}
	return
}
771698
func (mc MongoClient) ValueDescriptorByName(name string) (contract.ValueDescriptor, error) {
	mvd, err := mc.getValueDescriptor(bson.M{"name": name})
	if err != nil {
		return contract.ValueDescriptor{}, err
	}
	return mvd.ToContract(), nil
}
1268392
func typeOfValue(t *ast.ValueSpec) string {
	switch t := t.Type.(type) {
	case *ast.Ident:
		return t.String()
	}
	return ""
}
882620
func (_m *DBClient) ValueDescriptorByName(name string) (models.ValueDescriptor, error) {
	ret := _m.Called(name)

	var r0 models.ValueDescriptor
	if rf, ok := ret.Get(0).(func(string) models.ValueDescriptor); ok {
		r0 = rf(name)
	} else {
		r0 = ret.Get(0).(models.ValueDescriptor)
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(string) error); ok {
		r1 = rf(name)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1323801
func genericValue(v Value) interface{} {
	if g, ok := v.(*generic); ok {
		return g.p
	}
	return nil
}
1004735
func (dt *DbfTable) FieldValueByName(row int, fieldName string) string {
	fieldName = strings.ToUpper(fieldName)
	fieldIndex, ok := dt.fieldMap[fieldName]
	if !ok {
		panic("Field name '" + fieldName + "' does not exist")
	}
	return dt.FieldValue(row, fieldIndex)
}