// TypeInt will add an error to the Validator if the first
// element of data.Values[field] cannot be converted to an int.
172440
func (v *Validator) TypeInt(field string) *ValidationResult {
	if _, err := strconv.Atoi(v.data.Get(field)); err != nil {
		return v.addTypeError(field, "integer")
	} else {
		return validationOk
	}
}
904531
func Int(v int) *int32 {
	p := new(int32)
	*p = int32(v)
	return p
}
105690
func WriteInt(w io.ByteWriter, val int64) (int, error) {
	var inv byte
	if val < 0 {
		inv = 0xff
	}
	mag := uint64(val)
	if inv != 0 {
		mag = -mag
	}
	return writeSignMag(w, mag, inv)
}
1077934
func (v Value) invalidTypeError(err error, descr string) error {
	return errors.Annotate(err, ErrInvalidType, errorMessages, v.String(), descr)
}
55746
func TryToInt32(i interface{}) (r int32, err error) {
	switch t := i.(type) {
	case nil:
		r = 0
	case int:
		r = int32(t)
	case int8:
		r = int32(t)
	case int16:
		r = int32(t)
	case int32:
		r = t
	case *int32:
		r = *t
	case int64:
		r = int32(t)
	case uint:
		r = int32(t)
	case uint8:
		r = int32(t)
	case uint16:
		r = int32(t)
	case uint32:
		r = int32(t)
	case uint64:
		r = int32(t)
	case float32:
		r = int32(t)
	case float64:
		r = int32(t)
	case bool:
		if t {
			r = 1
		}
	case string:
		var v int64
		if v, err = strconv.ParseInt(t, 10, 32); err == nil {
			r = int32(v)
		}
	default:
		err = castError(i, "int32")
	}
	return
}
381407
func ToInt(value interface{}) (int64, error) {
	v := reflect.ValueOf(value)
	switch v.Kind() {
	case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64:
		return v.Int(), nil
	}
	return 0, fmt.Errorf("cannot convert %v to int64", v.Kind())
}
1182241
func (f *Queries) Int(key string) (int, error) {
	s, err := f.String(key)
	if err != nil {
		return 0, err
	}
	return strconv.Atoi(s)
}
769909
func (*GoFlags) Int(o string, d int, c string) *int {
	return flag.Int(o, d, c)
}
1297921
func Int(v int) *int {
	p := new(int)
	*p = v
	return p
}
752109
func (c *Distconf) Int(key string, defaultVal int64) *Int {
	c.grabInfo(key)
	s := &intConf{
		defaultVal: defaultVal,
		Int: Int{
			currentVal: defaultVal,
		},
	}
	// Note: in race conditions 's' may not be the thing actually returned
	ret, okCast := c.createOrGet(key, s).(*intConf)
	if !okCast {
		c.Logger.Log(logkey.DistconfKey, key, "Registering key with multiple types!  FIX ME!!!!")
		return nil
	}
	return &ret.Int
}
1214672
func typeOf(i interface{}) string {
	if i == nil {
		return ""
	}
	return reflect.TypeOf(i).Elem().Name()
}
759843
func (fsm *MapInputSource) Int(name string) (int, error) {
	otherGenericValue, exists := fsm.valueMap[name]
	if exists {
		otherValue, isType := otherGenericValue.(int)
		if !isType {
			return 0, incorrectTypeForFlagError(name, "int", otherGenericValue)
		}
		return otherValue, nil
	}
	nestedGenericValue, exists := nestedVal(name, fsm.valueMap)
	if exists {
		otherValue, isType := nestedGenericValue.(int)
		if !isType {
			return 0, incorrectTypeForFlagError(name, "int", nestedGenericValue)
		}
		return otherValue, nil
	}

	return 0, nil
}
675909
func ConvertToInt(target string, def int) int {
	fo, err := strconv.Atoi(target)
	if err != nil {
		return def
	}
	return fo
}
421902
func NumberToInt(x Value) (Int, error) {
	switch x := x.(type) {
	case Int:
		return x, nil
	case Float:
		f := float64(x)
		if math.IsInf(f, 0) {
			return zero, fmt.Errorf("cannot convert float infinity to integer")
		} else if math.IsNaN(f) {
			return zero, fmt.Errorf("cannot convert float NaN to integer")
		}
		return finiteFloatToInt(x), nil

	}
	return zero, fmt.Errorf("cannot convert %s to int", x.Type())
}
502368
func TryToInt(i interface{}) (r int, err error) {
	switch t := i.(type) {
	case nil:
		r = 0
	case int:
		r = t
	case *int:
		r = *t
	case int8:
		r = int(t)
	case int16:
		r = int(t)
	case int32:
		r = int(t)
	case int64:
		r = int(t)
	case uint:
		r = int(t)
	case uint8:
		r = int(t)
	case uint16:
		r = int(t)
	case uint32:
		r = int(t)
	case uint64:
		r = int(t)
	case float32:
		r = int(t)
	case float64:
		r = int(t)
	case bool:
		if t {
			r = 1
		}
	case string:
		r, err = strconv.Atoi(t)
	default:
		err = castError(i, "int")
	}
	return
}
1347598
func (e EventBuilder) Int(x int) EventBuilder {
	e.fields = append(e.fields, Field{valid: true, value: strconv.Itoa(x)})
	return e
}
411388
func asInt(param string) (int64, error) {
	i, err := strconv.ParseInt(param, 0, 64)
	if err != nil {
		return 0, ErrBadParameter
	}
	return i, nil
}