package pflag

import (
	
	
	
)

// -- net.IPMask value
type ipMaskValue net.IPMask

func newIPMaskValue( net.IPMask,  *net.IPMask) *ipMaskValue {
	* = 
	return (*ipMaskValue)()
}

func ( *ipMaskValue) () string { return net.IPMask(*).String() }
func ( *ipMaskValue) ( string) error {
	 := ParseIPv4Mask()
	if  == nil {
		return fmt.Errorf("failed to parse IP mask: %q", )
	}
	* = ipMaskValue()
	return nil
}

func ( *ipMaskValue) () string {
	return "ipMask"
}

// ParseIPv4Mask written in IP form (e.g. 255.255.255.0).
// This function should really belong to the net package.
func ( string) net.IPMask {
	 := net.ParseIP()
	if  == nil {
		if len() != 8 {
			return nil
		}
		// net.IPMask.String() actually outputs things like ffffff00
		// so write a horrible parser for that as well  :-(
		 := []int{}
		for  := 0;  < 4; ++ {
			 := "0x" + [2*:2*+2]
			,  := strconv.ParseInt(, 0, 0)
			if  != nil {
				return nil
			}
			 = append(, int())
		}
		 := fmt.Sprintf("%d.%d.%d.%d", [0], [1], [2], [3])
		 = net.ParseIP()
		if  == nil {
			return nil
		}
	}
	return net.IPv4Mask([12], [13], [14], [15])
}

func parseIPv4Mask( string) (interface{}, error) {
	 := ParseIPv4Mask()
	if  == nil {
		return nil, fmt.Errorf("unable to parse %s as net.IPMask", )
	}
	return , nil
}

// GetIPv4Mask return the net.IPv4Mask value of a flag with the given name
func ( *FlagSet) ( string) (net.IPMask, error) {
	,  := .getFlagType(, "ipMask", parseIPv4Mask)
	if  != nil {
		return nil, 
	}
	return .(net.IPMask), nil
}

// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string.
// The argument p points to an net.IPMask variable in which to store the value of the flag.
func ( *FlagSet) ( *net.IPMask,  string,  net.IPMask,  string) {
	.VarP(newIPMaskValue(, ), , "", )
}

// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) ( *net.IPMask, ,  string,  net.IPMask,  string) {
	.VarP(newIPMaskValue(, ), , , )
}

// IPMaskVar defines an net.IPMask flag with specified name, default value, and usage string.
// The argument p points to an net.IPMask variable in which to store the value of the flag.
func ( *net.IPMask,  string,  net.IPMask,  string) {
	CommandLine.VarP(newIPMaskValue(, ), , "", )
}

// IPMaskVarP is like IPMaskVar, but accepts a shorthand letter that can be used after a single dash.
func ( *net.IPMask, ,  string,  net.IPMask,  string) {
	CommandLine.VarP(newIPMaskValue(, ), , , )
}

// IPMask defines an net.IPMask flag with specified name, default value, and usage string.
// The return value is the address of an net.IPMask variable that stores the value of the flag.
func ( *FlagSet) ( string,  net.IPMask,  string) *net.IPMask {
	 := new(net.IPMask)
	.IPMaskVarP(, , "", , )
	return 
}

// IPMaskP is like IPMask, but accepts a shorthand letter that can be used after a single dash.
func ( *FlagSet) (,  string,  net.IPMask,  string) *net.IPMask {
	 := new(net.IPMask)
	.IPMaskVarP(, , , , )
	return 
}

// IPMask defines an net.IPMask flag with specified name, default value, and usage string.
// The return value is the address of an net.IPMask variable that stores the value of the flag.
func ( string,  net.IPMask,  string) *net.IPMask {
	return CommandLine.IPMaskP(, "", , )
}

// IPMaskP is like IP, but accepts a shorthand letter that can be used after a single dash.
func (,  string,  net.IPMask,  string) *net.IPMask {
	return CommandLine.IPMaskP(, , , )
}