(* Auto-generated from "embed.atd" *) [@@@ocaml.warning "-27-32-35-39"] type video = Embed_t.video = { url: string option; height: int option; width: int option } type provider = Embed_t.provider = { name: string option; url: string option } type image = Embed_t.image = { url: string option; proxy_url: string option; height: int option; width: int option } type footer = Embed_t.footer = { text: string; icon_url: string option; proxy_icon_url: string option } type field = Embed_t.field = { name: string; value: string; inline: bool option } type t = Embed_t.t = { title: string option; kind: string option; description: string option; url: string option; timestamp: string option; colour: int option; footer: footer option; image: image option; thumbnail: image option; video: video option; provider: provider option; fields: field list option } let write__2 = ( Atdgen_runtime.Oj_run.write_option ( Yojson.Safe.write_int ) ) let string_of__2 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__2 ob x; Bi_outbuf.contents ob let read__2 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( Atdgen_runtime.Oj_run.read_int ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( Atdgen_runtime.Oj_run.read_int ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _2_of_string s = read__2 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__1 = ( Atdgen_runtime.Oj_run.write_option ( Yojson.Safe.write_string ) ) let string_of__1 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__1 ob x; Bi_outbuf.contents ob let read__1 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( Atdgen_runtime.Oj_run.read_string ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( Atdgen_runtime.Oj_run.read_string ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _1_of_string s = read__1 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_video : _ -> video -> _ = ( fun ob x -> Bi_outbuf.add_char ob '{'; let is_first = ref true in (match x.url with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"url\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.height with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"height\":"; ( Yojson.Safe.write_int ) ob x; ); (match x.width with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"width\":"; ( Yojson.Safe.write_int ) ob x; ); Bi_outbuf.add_char ob '}'; ) let string_of_video ?(len = 1024) x = let ob = Bi_outbuf.create len in write_video ob x; Bi_outbuf.contents ob let read_video = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; let field_url = ref (None) in let field_height = ref (None) in let field_width = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 0 ) else ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( 2 ) else ( -1 ) ) | 6 -> ( if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( 1 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_height := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_width := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); while true do Yojson.Safe.read_space p lb; Yojson.Safe.read_object_sep p lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 0 ) else ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( 2 ) else ( -1 ) ) | 6 -> ( if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( 1 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_height := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_width := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); done; assert false; with Yojson.End_of_object -> ( ( { url = !field_url; height = !field_height; width = !field_width; } : video) ) ) let video_of_string s = read_video (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_provider : _ -> provider -> _ = ( fun ob x -> Bi_outbuf.add_char ob '{'; let is_first = ref true in (match x.name with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"name\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.url with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"url\":"; ( Yojson.Safe.write_string ) ob x; ); Bi_outbuf.add_char ob '}'; ) let string_of_provider ?(len = 1024) x = let ob = Bi_outbuf.create len in write_provider ob x; Bi_outbuf.contents ob let read_provider = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; let field_name = ref (None) in let field_url = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 1 ) else ( -1 ) ) | 4 -> ( if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( 0 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_name := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); while true do Yojson.Safe.read_space p lb; Yojson.Safe.read_object_sep p lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 1 ) else ( -1 ) ) | 4 -> ( if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( 0 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_name := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); done; assert false; with Yojson.End_of_object -> ( ( { name = !field_name; url = !field_url; } : provider) ) ) let provider_of_string s = read_provider (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_image : _ -> image -> _ = ( fun ob x -> Bi_outbuf.add_char ob '{'; let is_first = ref true in (match x.url with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"url\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.proxy_url with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"proxy_url\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.height with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"height\":"; ( Yojson.Safe.write_int ) ob x; ); (match x.width with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"width\":"; ( Yojson.Safe.write_int ) ob x; ); Bi_outbuf.add_char ob '}'; ) let string_of_image ?(len = 1024) x = let ob = Bi_outbuf.create len in write_image ob x; Bi_outbuf.contents ob let read_image = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; let field_url = ref (None) in let field_proxy_url = ref (None) in let field_height = ref (None) in let field_width = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 0 ) else ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( 3 ) else ( -1 ) ) | 6 -> ( if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( 2 ) else ( -1 ) ) | 9 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'l' then ( 1 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_proxy_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_height := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_width := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); while true do Yojson.Safe.read_space p lb; Yojson.Safe.read_object_sep p lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 0 ) else ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'w' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'h' then ( 3 ) else ( -1 ) ) | 6 -> ( if String.unsafe_get s pos = 'h' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'i' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'h' && String.unsafe_get s (pos+5) = 't' then ( 2 ) else ( -1 ) ) | 9 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'u' && String.unsafe_get s (pos+7) = 'r' && String.unsafe_get s (pos+8) = 'l' then ( 1 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_proxy_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_height := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_width := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); done; assert false; with Yojson.End_of_object -> ( ( { url = !field_url; proxy_url = !field_proxy_url; height = !field_height; width = !field_width; } : image) ) ) let image_of_string s = read_image (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_footer : _ -> footer -> _ = ( fun ob x -> Bi_outbuf.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"text\":"; ( Yojson.Safe.write_string ) ob x.text; (match x.icon_url with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"icon_url\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.proxy_icon_url with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"proxy_icon_url\":"; ( Yojson.Safe.write_string ) ob x; ); Bi_outbuf.add_char ob '}'; ) let string_of_footer ?(len = 1024) x = let ob = Bi_outbuf.create len in write_footer ob x; Bi_outbuf.contents ob let read_footer = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; let field_text = ref (Obj.magic (Sys.opaque_identity 0.0)) in let field_icon_url = ref (None) in let field_proxy_icon_url = ref (None) in let bits0 = ref 0 in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 4 -> ( if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 't' then ( 0 ) else ( -1 ) ) | 8 -> ( if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'u' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'l' then ( 1 ) else ( -1 ) ) | 14 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'u' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'l' then ( 2 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> field_text := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x1; | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_icon_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_proxy_icon_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); while true do Yojson.Safe.read_space p lb; Yojson.Safe.read_object_sep p lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 4 -> ( if String.unsafe_get s pos = 't' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 'x' && String.unsafe_get s (pos+3) = 't' then ( 0 ) else ( -1 ) ) | 8 -> ( if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'c' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'n' && String.unsafe_get s (pos+4) = '_' && String.unsafe_get s (pos+5) = 'u' && String.unsafe_get s (pos+6) = 'r' && String.unsafe_get s (pos+7) = 'l' then ( 1 ) else ( -1 ) ) | 14 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'x' && String.unsafe_get s (pos+4) = 'y' && String.unsafe_get s (pos+5) = '_' && String.unsafe_get s (pos+6) = 'i' && String.unsafe_get s (pos+7) = 'c' && String.unsafe_get s (pos+8) = 'o' && String.unsafe_get s (pos+9) = 'n' && String.unsafe_get s (pos+10) = '_' && String.unsafe_get s (pos+11) = 'u' && String.unsafe_get s (pos+12) = 'r' && String.unsafe_get s (pos+13) = 'l' then ( 2 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> field_text := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x1; | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_icon_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_proxy_icon_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); done; assert false; with Yojson.End_of_object -> ( if !bits0 <> 0x1 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "text" |]; ( { text = !field_text; icon_url = !field_icon_url; proxy_icon_url = !field_proxy_icon_url; } : footer) ) ) let footer_of_string s = read_footer (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__3 = ( Atdgen_runtime.Oj_run.write_option ( Yojson.Safe.write_bool ) ) let string_of__3 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__3 ob x; Bi_outbuf.contents ob let read__3 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( Atdgen_runtime.Oj_run.read_bool ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( Atdgen_runtime.Oj_run.read_bool ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _3_of_string s = read__3 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_field : _ -> field -> _ = ( fun ob x -> Bi_outbuf.add_char ob '{'; let is_first = ref true in if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"name\":"; ( Yojson.Safe.write_string ) ob x.name; if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"value\":"; ( Yojson.Safe.write_string ) ob x.value; (match x.inline with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"inline\":"; ( Yojson.Safe.write_bool ) ob x; ); Bi_outbuf.add_char ob '}'; ) let string_of_field ?(len = 1024) x = let ob = Bi_outbuf.create len in write_field ob x; Bi_outbuf.contents ob let read_field = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; let field_name = ref (Obj.magic (Sys.opaque_identity 0.0)) in let field_value = ref (Obj.magic (Sys.opaque_identity 0.0)) in let field_inline = ref (None) in let bits0 = ref 0 in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 4 -> ( if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( 0 ) else ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'e' then ( 1 ) else ( -1 ) ) | 6 -> ( if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' then ( 2 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> field_name := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x1; | 1 -> field_value := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x2; | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_inline := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); while true do Yojson.Safe.read_space p lb; Yojson.Safe.read_object_sep p lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 4 -> ( if String.unsafe_get s pos = 'n' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' then ( 0 ) else ( -1 ) ) | 5 -> ( if String.unsafe_get s pos = 'v' && String.unsafe_get s (pos+1) = 'a' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'u' && String.unsafe_get s (pos+4) = 'e' then ( 1 ) else ( -1 ) ) | 6 -> ( if String.unsafe_get s pos = 'i' && String.unsafe_get s (pos+1) = 'n' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'i' && String.unsafe_get s (pos+4) = 'n' && String.unsafe_get s (pos+5) = 'e' then ( 2 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> field_name := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x1; | 1 -> field_value := ( ( Atdgen_runtime.Oj_run.read_string ) p lb ); bits0 := !bits0 lor 0x2; | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_inline := ( Some ( ( Atdgen_runtime.Oj_run.read_bool ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); done; assert false; with Yojson.End_of_object -> ( if !bits0 <> 0x3 then Atdgen_runtime.Oj_run.missing_fields p [| !bits0 |] [| "name"; "value" |]; ( { name = !field_name; value = !field_value; inline = !field_inline; } : field) ) ) let field_of_string s = read_field (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__8 = ( Atdgen_runtime.Oj_run.write_list ( write_field ) ) let string_of__8 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__8 ob x; Bi_outbuf.contents ob let read__8 = ( Atdgen_runtime.Oj_run.read_list ( read_field ) ) let _8_of_string s = read__8 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__9 = ( Atdgen_runtime.Oj_run.write_option ( write__8 ) ) let string_of__9 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__9 ob x; Bi_outbuf.contents ob let read__9 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read__8 ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read__8 ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _9_of_string s = read__9 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__7 = ( Atdgen_runtime.Oj_run.write_option ( write_provider ) ) let string_of__7 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__7 ob x; Bi_outbuf.contents ob let read__7 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read_provider ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read_provider ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _7_of_string s = read__7 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__6 = ( Atdgen_runtime.Oj_run.write_option ( write_video ) ) let string_of__6 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__6 ob x; Bi_outbuf.contents ob let read__6 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read_video ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read_video ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _6_of_string s = read__6 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__5 = ( Atdgen_runtime.Oj_run.write_option ( write_image ) ) let string_of__5 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__5 ob x; Bi_outbuf.contents ob let read__5 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read_image ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read_image ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _5_of_string s = read__5 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write__4 = ( Atdgen_runtime.Oj_run.write_option ( write_footer ) ) let string_of__4 ?(len = 1024) x = let ob = Bi_outbuf.create len in write__4 ob x; Bi_outbuf.contents ob let read__4 = ( fun p lb -> Yojson.Safe.read_space p lb; match Yojson.Safe.start_any_variant p lb with | `Edgy_bracket -> ( match Yojson.Safe.read_ident p lb with | "None" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (None : _ option) | "Some" -> Atdgen_runtime.Oj_run.read_until_field_value p lb; let x = ( read_footer ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_gt p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Double_quote -> ( match Yojson.Safe.finish_string p lb with | "None" -> (None : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) | `Square_bracket -> ( match Atdgen_runtime.Oj_run.read_string p lb with | "Some" -> Yojson.Safe.read_space p lb; Yojson.Safe.read_comma p lb; Yojson.Safe.read_space p lb; let x = ( read_footer ) p lb in Yojson.Safe.read_space p lb; Yojson.Safe.read_rbr p lb; (Some x : _ option) | x -> Atdgen_runtime.Oj_run.invalid_variant_tag p x ) ) let _4_of_string s = read__4 (Yojson.Safe.init_lexer ()) (Lexing.from_string s) let write_t : _ -> t -> _ = ( fun ob x -> Bi_outbuf.add_char ob '{'; let is_first = ref true in (match x.title with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"title\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.kind with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"kind\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.description with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"description\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.url with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"url\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.timestamp with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"timestamp\":"; ( Yojson.Safe.write_string ) ob x; ); (match x.colour with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"colour\":"; ( Yojson.Safe.write_int ) ob x; ); (match x.footer with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"footer\":"; ( write_footer ) ob x; ); (match x.image with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"image\":"; ( write_image ) ob x; ); (match x.thumbnail with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"thumbnail\":"; ( write_image ) ob x; ); (match x.video with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"video\":"; ( write_video ) ob x; ); (match x.provider with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"provider\":"; ( write_provider ) ob x; ); (match x.fields with None -> () | Some x -> if !is_first then is_first := false else Bi_outbuf.add_char ob ','; Bi_outbuf.add_string ob "\"fields\":"; ( write__8 ) ob x; ); Bi_outbuf.add_char ob '}'; ) let string_of_t ?(len = 1024) x = let ob = Bi_outbuf.create len in write_t ob x; Bi_outbuf.contents ob let read_t = ( fun p lb -> Yojson.Safe.read_space p lb; Yojson.Safe.read_lcurl p lb; let field_title = ref (None) in let field_kind = ref (None) in let field_description = ref (None) in let field_url = ref (None) in let field_timestamp = ref (None) in let field_colour = ref (None) in let field_footer = ref (None) in let field_image = ref (None) in let field_thumbnail = ref (None) in let field_video = ref (None) in let field_provider = ref (None) in let field_fields = ref (None) in try Yojson.Safe.read_space p lb; Yojson.Safe.read_object_end lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 3 ) else ( -1 ) ) | 4 -> ( if String.unsafe_get s pos = 'k' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' then ( 1 ) else ( -1 ) ) | 5 -> ( match String.unsafe_get s pos with | 'i' -> ( if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' then ( 7 ) else ( -1 ) ) | 't' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'e' then ( 0 ) else ( -1 ) ) | 'v' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'o' then ( 9 ) else ( -1 ) ) | _ -> ( -1 ) ) | 6 -> ( match String.unsafe_get s pos with | 'c' -> ( if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'r' then ( 5 ) else ( -1 ) ) | 'f' -> ( match String.unsafe_get s (pos+1) with | 'i' -> ( if String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 's' then ( 11 ) else ( -1 ) ) | 'o' -> ( if String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' then ( 6 ) else ( -1 ) ) | _ -> ( -1 ) ) | _ -> ( -1 ) ) | 8 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'v' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' then ( 10 ) else ( -1 ) ) | 9 -> ( if String.unsafe_get s pos = 't' then ( match String.unsafe_get s (pos+1) with | 'h' -> ( if String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'l' then ( 8 ) else ( -1 ) ) | 'i' -> ( if String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'p' then ( 4 ) else ( -1 ) ) | _ -> ( -1 ) ) else ( -1 ) ) | 11 -> ( if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( 2 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_title := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_kind := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_description := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_timestamp := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_colour := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_footer := ( Some ( ( read_footer ) p lb ) ); ) | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_image := ( Some ( ( read_image ) p lb ) ); ) | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_thumbnail := ( Some ( ( read_image ) p lb ) ); ) | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_video := ( Some ( ( read_video ) p lb ) ); ) | 10 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_provider := ( Some ( ( read_provider ) p lb ) ); ) | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_fields := ( Some ( ( read__8 ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); while true do Yojson.Safe.read_space p lb; Yojson.Safe.read_object_sep p lb; Yojson.Safe.read_space p lb; let f = fun s pos len -> if pos < 0 || len < 0 || pos + len > String.length s then invalid_arg "out-of-bounds substring position or length"; match len with | 3 -> ( if String.unsafe_get s pos = 'u' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'l' then ( 3 ) else ( -1 ) ) | 4 -> ( if String.unsafe_get s pos = 'k' && String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'n' && String.unsafe_get s (pos+3) = 'd' then ( 1 ) else ( -1 ) ) | 5 -> ( match String.unsafe_get s pos with | 'i' -> ( if String.unsafe_get s (pos+1) = 'm' && String.unsafe_get s (pos+2) = 'a' && String.unsafe_get s (pos+3) = 'g' && String.unsafe_get s (pos+4) = 'e' then ( 7 ) else ( -1 ) ) | 't' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 't' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'e' then ( 0 ) else ( -1 ) ) | 'v' -> ( if String.unsafe_get s (pos+1) = 'i' && String.unsafe_get s (pos+2) = 'd' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 'o' then ( 9 ) else ( -1 ) ) | _ -> ( -1 ) ) | 6 -> ( match String.unsafe_get s pos with | 'c' -> ( if String.unsafe_get s (pos+1) = 'o' && String.unsafe_get s (pos+2) = 'l' && String.unsafe_get s (pos+3) = 'o' && String.unsafe_get s (pos+4) = 'u' && String.unsafe_get s (pos+5) = 'r' then ( 5 ) else ( -1 ) ) | 'f' -> ( match String.unsafe_get s (pos+1) with | 'i' -> ( if String.unsafe_get s (pos+2) = 'e' && String.unsafe_get s (pos+3) = 'l' && String.unsafe_get s (pos+4) = 'd' && String.unsafe_get s (pos+5) = 's' then ( 11 ) else ( -1 ) ) | 'o' -> ( if String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 't' && String.unsafe_get s (pos+4) = 'e' && String.unsafe_get s (pos+5) = 'r' then ( 6 ) else ( -1 ) ) | _ -> ( -1 ) ) | _ -> ( -1 ) ) | 8 -> ( if String.unsafe_get s pos = 'p' && String.unsafe_get s (pos+1) = 'r' && String.unsafe_get s (pos+2) = 'o' && String.unsafe_get s (pos+3) = 'v' && String.unsafe_get s (pos+4) = 'i' && String.unsafe_get s (pos+5) = 'd' && String.unsafe_get s (pos+6) = 'e' && String.unsafe_get s (pos+7) = 'r' then ( 10 ) else ( -1 ) ) | 9 -> ( if String.unsafe_get s pos = 't' then ( match String.unsafe_get s (pos+1) with | 'h' -> ( if String.unsafe_get s (pos+2) = 'u' && String.unsafe_get s (pos+3) = 'm' && String.unsafe_get s (pos+4) = 'b' && String.unsafe_get s (pos+5) = 'n' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'i' && String.unsafe_get s (pos+8) = 'l' then ( 8 ) else ( -1 ) ) | 'i' -> ( if String.unsafe_get s (pos+2) = 'm' && String.unsafe_get s (pos+3) = 'e' && String.unsafe_get s (pos+4) = 's' && String.unsafe_get s (pos+5) = 't' && String.unsafe_get s (pos+6) = 'a' && String.unsafe_get s (pos+7) = 'm' && String.unsafe_get s (pos+8) = 'p' then ( 4 ) else ( -1 ) ) | _ -> ( -1 ) ) else ( -1 ) ) | 11 -> ( if String.unsafe_get s pos = 'd' && String.unsafe_get s (pos+1) = 'e' && String.unsafe_get s (pos+2) = 's' && String.unsafe_get s (pos+3) = 'c' && String.unsafe_get s (pos+4) = 'r' && String.unsafe_get s (pos+5) = 'i' && String.unsafe_get s (pos+6) = 'p' && String.unsafe_get s (pos+7) = 't' && String.unsafe_get s (pos+8) = 'i' && String.unsafe_get s (pos+9) = 'o' && String.unsafe_get s (pos+10) = 'n' then ( 2 ) else ( -1 ) ) | _ -> ( -1 ) in let i = Yojson.Safe.map_ident p f lb in Atdgen_runtime.Oj_run.read_until_field_value p lb; ( match i with | 0 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_title := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 1 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_kind := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 2 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_description := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 3 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_url := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 4 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_timestamp := ( Some ( ( Atdgen_runtime.Oj_run.read_string ) p lb ) ); ) | 5 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_colour := ( Some ( ( Atdgen_runtime.Oj_run.read_int ) p lb ) ); ) | 6 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_footer := ( Some ( ( read_footer ) p lb ) ); ) | 7 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_image := ( Some ( ( read_image ) p lb ) ); ) | 8 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_thumbnail := ( Some ( ( read_image ) p lb ) ); ) | 9 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_video := ( Some ( ( read_video ) p lb ) ); ) | 10 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_provider := ( Some ( ( read_provider ) p lb ) ); ) | 11 -> if not (Yojson.Safe.read_null_if_possible p lb) then ( field_fields := ( Some ( ( read__8 ) p lb ) ); ) | _ -> ( Yojson.Safe.skip_json p lb ) ); done; assert false; with Yojson.End_of_object -> ( ( { title = !field_title; kind = !field_kind; description = !field_description; url = !field_url; timestamp = !field_timestamp; colour = !field_colour; footer = !field_footer; image = !field_image; thumbnail = !field_thumbnail; video = !field_video; provider = !field_provider; fields = !field_fields; } : t) ) ) let t_of_string s = read_t (Yojson.Safe.init_lexer ()) (Lexing.from_string s)