// PostValueInt64Default returns the parsed form data from POST, PATCH,
// or PUT body parameters based on a "name", as float64.
//
// If not found returns -1 and a non-nil error.
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)
}
797430
func (ctx *context) URLParamInt64Default(name string, def int64) int64 {
	v, err := ctx.URLParamInt64(name)
	if err != nil {
		return def
	}

	return v
}
221862
func (s *MetricTransformation) SetDefaultValue(v float64) *MetricTransformation {
	s.DefaultValue = &v
	return s
}
1144918
func (s *DoubleArrayOptions) SetDefaultValue(v float64) *DoubleArrayOptions {
	s.DefaultValue = &v
	return s
}
949775
func (ctx *context) PostValueIntDefault(name string, def int) int {
	if v, err := ctx.PostValueInt(name); err == nil {
		return v
	}

	return def
}
682364
func (e Entry) Uint8Default(def uint8) (uint8, error) {
	v := e.ValueRaw
	if v == nil {
		return def, errFindParse.Format("uint8", e.Key)
	}

	switch vv := v.(type) {
	case string:
		val, err := strconv.ParseUint(vv, 10, 8)
		if err != nil {
			return def, err
		}
		if val > math.MaxUint8 {
			return def, errFindParse.Format("uint8", e.Key)
		}
		return uint8(val), nil
	case uint:
		if vv > math.MaxUint8 {
			return def, errFindParse.Format("uint8", e.Key)
		}
		return uint8(vv), nil
	case uint8:
		return vv, nil
	case uint16:
		if vv > math.MaxUint8 {
			return def, errFindParse.Format("uint8", e.Key)
		}
		return uint8(vv), nil
	case uint32:
		if vv > math.MaxUint8 {
			return def, errFindParse.Format("uint8", e.Key)
		}
		return uint8(vv), nil
	case uint64:
		if vv > math.MaxUint8 {
			return def, errFindParse.Format("uint8", e.Key)
		}
		return uint8(vv), nil
	case int:
		if vv < 0 || vv > math.MaxUint8 {
			return def, errFindParse.Format("uint8", e.Key)
		}
		return uint8(vv), nil
	}

	return def, errFindParse.Format("uint8", e.Key)
}
264204
func Float64(key string, fallback float64) float64 {
	return DefaultClient.Float64(key, fallback)
}
1177593
func (c *JSONConfigContainer) DefaultInt64(key string, defaultval int64) int64 {
	if v, err := c.Int64(key); err == nil {
		return v
	}
	return defaultval
}
1209292
func ParamInt64(r *http.Request, name string, defaultValue int64) int64 {
	value, err := strconv.ParseInt(r.FormValue(name), 10, 64)
	if err != nil {
		return defaultValue
	}
	return value
}
349441
func DefaultFloat64(obj interface{}, defaultValue float64) float64 {
	returnValue, ok := obj.(float64)
	if ok {
		return returnValue
	}

	returnValue, err := strconv.ParseFloat(fmt.Sprint(obj), 64)
	if err != nil {
		return defaultValue
	}

	return returnValue
}
1026986
func Int64Value(val string) (*wrappers.Int64Value, error) {
	parsedVal, err := Int64(val)
	return &wrappers.Int64Value{Value: parsedVal}, err
}
598592
func (t EnumType) GetDefaultValue() interface{} {
	// manual default value has precedence over first value in list of allowed
	// values
	if t.DefaultValue != nil {
		return t.DefaultValue
	}
	// fallback to first permitted element
	if len(t.Values) > 0 {
		return t.Values[0]
	}
	return nil
}
43094
func Float64ToUintValueFunc() mapstructure.DecodeHookFunc {
	return func(
		f reflect.Type,
		t reflect.Type,
		data interface{}) (interface{}, error) {
		if f.Kind() != reflect.Float64 {
			return data, nil
		}

		val := UintValue{}
		if t != reflect.TypeOf(val) {
			return data, nil
		}

		fv := data.(float64)
		if fv < 0 {
			return nil, fmt.Errorf("value cannot be negative")
		}

		// The standard guarantees at least this, and this is fine for
		// values we expect to use in configs vs. being fancy with the
		// machine's size for uint.
		if fv > (1<<32 - 1) {
			return nil, fmt.Errorf("value is too large")
		}

		val.v = new(uint)
		*(val.v) = (uint)(fv)
		return val, nil
	}
}
773046
func ValueToInt64(val Value) (int64, bool) {
	if val == nil || val.Nil() || val.Err() {
		return 0, false
	}
	switch v := val.(type) {
	case NumericValue:
		return v.Int(), true
	case StringValue:
		return convertStringToInt64(0, v.Val())
	case Slice:
		if v.Len() > 0 {
			return ValueToInt64(v.SliceValue()[0])
		}
	}
	return 0, false
}
55924
func DefaultParamTypeForValue(value interface{}, tp *FieldType) {
	switch value.(type) {
	case nil:
		tp.Tp = mysql.TypeVarString
		tp.Flen = UnspecifiedLength
		tp.Decimal = UnspecifiedLength
	default:
		DefaultTypeForValue(value, tp)
		if hasVariantFieldLength(tp) {
			tp.Flen = UnspecifiedLength
		}
		if tp.Tp == mysql.TypeUnspecified {
			tp.Tp = mysql.TypeVarString
		}
	}
}
845769
func Int64ValueOrDefault(r *http.Request, field string, def int64) (int64, error) {
	if r.Form.Get(field) != "" {
		value, err := strconv.ParseInt(r.Form.Get(field), 10, 64)
		return value, err
	}
	return def, nil
}
261305
func (s *HyperParameterSpecification) SetDefaultValue(v string) *HyperParameterSpecification {
	s.DefaultValue = &v
	return s
}