Convert str to a value of type VALUE.

Property definitions

opts $ OptionParameter :: convert
	# Convert `str` to a value of type `VALUE`.
	protected fun convert(str: String): VALUE is abstract
lib/opts/opts.nit:146,2--147,54

opts $ OptionString :: convert
	redef fun convert(str) do return str
lib/opts/opts.nit:186,2--37

opts $ OptionEnum :: convert
	redef fun convert(str)
	do
		var id = values.index_of(str)
		if id == -1 then
			var e = "Unrecognized value for option {names.join(", ")}.\n"
			e += "Expected values are: {values.join(", ")}."
			errors.add(e)
		end
		return id
	end
lib/opts/opts.nit:209,2--218,4

opts $ OptionInt :: convert
	redef fun convert(str)
	do
		if str.is_int then return str.to_i

		errors.add "Expected an integer for option {names.join(", ")}."
		return 0
	end
lib/opts/opts.nit:239,2--245,4

opts $ OptionFloat :: convert
	redef fun convert(str) do return str.to_f
lib/opts/opts.nit:258,2--42

opts $ OptionArray :: convert
	redef fun convert(str)
	do
		values.add(str)
		return values
	end
lib/opts/opts.nit:274,2--278,4

privileges $ OptionUserAndGroup :: convert
	redef fun convert(str)
	do
		var words = str.split(":")
		if words.length == 1 then
			return new UserGroup(str, null)
		else if words.length == 2 then
			return new UserGroup(words[0], words[1])
		else
			errors.add("Option {names.join(", ")} expected parameter in the format \"user:group\" or simply \"user\".\n")
			return null
		end
	end
lib/privileges/privileges.nit:85,2--96,4