UtilOptions.dcl 1.59 KB
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

:: 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
25
SimpleWithStringConversion :: ({#Char} -> {#Char}) -> (Conversions a) | toString, fromString a
26
SimpleWithStringConversions :: ({#Char} -> {#Char}) ({#Char} -> {#Char}) -> Conversions a | toString, fromString a
Diederik van Arkel's avatar
Diederik van Arkel committed
27
List	:: (OptionsTableEntry a) a -> Conversions (List a)
28
OptionalGroup :: (OptionsTable a) (a->Bool) -> Conversions a
Diederik van Arkel's avatar
Diederik van Arkel committed
29 30 31
Group	:: (OptionsTable a) -> Conversions a

SimpleOption l g p		:== {labelName = l, conversions = Simple, get = g, put = p}
32
SimpleWithStringConversionOption c l g p :== {labelName = l, conversions = SimpleWithStringConversion c, get = g, put = p}
33
SimpleWithStringConversionsOption cf ct l g p :== {labelName = l, conversions = SimpleWithStringConversions cf ct, get = g, put = p}
Diederik van Arkel's avatar
Diederik van Arkel committed
34
GroupedOption  l s g p	:== {labelName = l, conversions = Group s, get = g, put = p}
35
OptionalGroupedOption l e s g p :== {labelName = l, conversions = OptionalGroup s e, get = g, put = p}
Diederik van Arkel's avatar
Diederik van Arkel committed
36 37 38
ListOption  l s d g p	:== {labelName = l, conversions = List s d, get = g, put = p}

ConvertToString		:: !String -> String