UtilOptions.dcl 1003 Bytes
Newer Older
Diederik van Arkel's avatar
Diederik van Arkel committed
1 2 3
definition module UtilOptions

import StdClass, StdString
4
from UtilStrictLists import :: List
Diederik van Arkel's avatar
Diederik van Arkel committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

:: Option
:: Conversions a
:: OptionsTableEntry a =
	E.value:
	{ labelName		:: !{#Char}
	, conversions	:: !Conversions value
	, get			:: a -> value
	, put			:: value a -> a
	}

:: OptionsTable a	:== {!OptionsTableEntry a}

WriteOptionsFile	:: !{#Char} ![Option] !*File -> *File
ReadOptionsFile		:: *File -> ([Option], *File)
ReadVersion			:: !*File -> (!{#Char}, !*File)
PutOptions			:: !(OptionsTable a) a -> [Option]
GetOptions			:: !(OptionsTable a) ![Option] !a -> a

Simple	:: Conversions a | toString, fromString a
List	:: (OptionsTableEntry a) a -> Conversions (List a)
Group	:: (OptionsTable a) -> Conversions a

SimpleOption l g p		:== {labelName = l, conversions = Simple, get = g, put = p}
GroupedOption  l s g p	:== {labelName = l, conversions = Group s, get = g, put = p}
ListOption  l s d g p	:== {labelName = l, conversions = List s d, get = g, put = p}

ConvertToString		:: !String -> String