| 28019 |      1 | (*  Title:      Pure/General/properties.ML
 | 
|  |      2 |     Author:     Makarius
 | 
|  |      3 | 
 | 
|  |      4 | Property lists.
 | 
|  |      5 | *)
 | 
|  |      6 | 
 | 
|  |      7 | signature PROPERTIES =
 | 
|  |      8 | sig
 | 
| 43780 |      9 |   type entry = string * string
 | 
|  |     10 |   type T = entry list
 | 
| 28019 |     11 |   val defined: T -> string -> bool
 | 
|  |     12 |   val get: T -> string -> string option
 | 
| 28032 |     13 |   val get_int: T -> string -> int option
 | 
| 43780 |     14 |   val put: entry -> T -> T
 | 
|  |     15 |   val put_int: string * int -> T -> T
 | 
| 28019 |     16 |   val remove: string -> T -> T
 | 
|  |     17 | end;
 | 
|  |     18 | 
 | 
|  |     19 | structure Properties: PROPERTIES =
 | 
|  |     20 | struct
 | 
|  |     21 | 
 | 
| 43780 |     22 | type entry = string * string;
 | 
|  |     23 | type T = entry list;
 | 
| 28019 |     24 | 
 | 
|  |     25 | fun defined (props: T) name = AList.defined (op =) props name;
 | 
| 28032 |     26 | 
 | 
| 28019 |     27 | fun get (props: T) name = AList.lookup (op =) props name;
 | 
| 28032 |     28 | fun get_int props name = (case get props name of NONE => NONE | SOME s => Int.fromString s);
 | 
|  |     29 | 
 | 
| 43780 |     30 | fun put entry (props: T) = AList.update (op =) entry props;
 | 
|  |     31 | fun put_int (name, i) = put (name, signed_string_of_int i);
 | 
|  |     32 | 
 | 
| 28019 |     33 | fun remove name (props: T) = AList.delete (op =) name props;
 | 
|  |     34 | 
 | 
|  |     35 | end;
 |