forked from xapi-project/xen-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
string_unmarshall_helper.ml
32 lines (27 loc) · 1.05 KB
/
string_unmarshall_helper.ml
1
2
3
4
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
(*
* Copyright (C) 2006-2009 Citrix Systems Inc.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation; version 2.1 only. with the special
* exception on linking described in file LICENSE.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*)
(** Called in the autogenerated String_to_DM module *)
exception Failure of string
let set f (m: string) =
match SExpr_TS.of_string m with
| SExpr.Node xs ->
List.map (function SExpr.String x -> f x
| _ -> raise (Failure m)) xs
| _ -> raise (Failure m)
let map f g (m: string) =
match SExpr_TS.of_string m with
| SExpr.Node xs ->
List.map (function SExpr.Node [ SExpr.String k; SExpr.String v ] -> f k, g v
| _ -> raise (Failure m)) xs
| _ -> raise (Failure m)