package types

import (
	
	
)
An IntMode is a mode for parsing integer values, representing a set of accepted bases.
IntMode values for ParseInt; can be combined using binary or.
const (
	Dec IntMode = 1 << iota
	Hex
	Oct
)
String returns a string representation of IntMode; e.g. `IntMode(Dec|Hex)`.
func ( IntMode) () string {
	var  []string
	if &Dec != 0 {
		 = append(, "Dec")
	}
	if &Hex != 0 {
		 = append(, "Hex")
	}
	if &Oct != 0 {
		 = append(, "Oct")
	}
	return "IntMode(" + strings.Join(, "|") + ")"
}

var errIntAmbig = fmt.Errorf("ambiguous integer value; must include '0' prefix")

func ( string) bool {
	return strings.HasPrefix(, "0") || strings.HasPrefix(, "-0")
}

func ( string) bool {
	return strings.HasPrefix(, "0x") || strings.HasPrefix(, "-0x")
}
ParseInt parses val using mode into intptr, which must be a pointer to an integer kind type. Non-decimal value require prefix `0` or `0x` in the cases when mode permits ambiguity of base; otherwise the prefix can be omitted.
func ( interface{},  string,  IntMode) error {
	 = strings.TrimSpace()
	 := byte(0)
	switch  {
	case Dec:
		 = 'd'
	case Dec + Hex:
		if prefix0x() {
			 = 'v'
		} else {
			 = 'd'
		}
	case Dec + Oct:
		if prefix0() && !prefix0x() {
			 = 'v'
		} else {
			 = 'd'
		}
	case Dec + Hex + Oct:
		 = 'v'
	case Hex:
		if prefix0x() {
			 = 'v'
		} else {
			 = 'x'
		}
	case Oct:
		 = 'o'
	case Hex + Oct:
		if prefix0() {
			 = 'v'
		} else {
			return errIntAmbig
		}
	}
	if  == 0 {
		panic("unsupported mode")
	}
	return ScanFully(, , )