Pure OCaml Yaml 1.2 reader and writer using Bytesrw
at main 1.8 kB view raw
1(*--------------------------------------------------------------------------- 2 Copyright (c) 2025 Anil Madhavapeddy <anil@recoil.org>. All rights reserved. 3 SPDX-License-Identifier: ISC 4 ---------------------------------------------------------------------------*) 5 6(** Full YAML representation with anchors, tags, and aliases *) 7 8type t = [ 9 | `Scalar of Scalar.t 10 | `Alias of string 11 | `A of t Sequence.t 12 | `O of (t, t) Mapping.t 13] 14 15(** {2 Pretty Printing} *) 16 17val pp : Format.formatter -> t -> unit 18 19(** {2 Equality} *) 20 21val equal : t -> t -> bool 22 23(** {2 Conversion from Value} *) 24 25val of_value : Value.t -> t 26(** Construct from JSON-compatible Value *) 27 28(** {2 Alias Resolution} *) 29 30val default_max_alias_nodes : int 31(** Default maximum nodes during alias expansion (10 million) *) 32 33val default_max_alias_depth : int 34(** Default maximum alias nesting depth (100) *) 35 36val resolve_aliases : ?max_nodes:int -> ?max_depth:int -> t -> t 37(** Resolve aliases by replacing them with referenced nodes. 38 39 @param max_nodes Maximum number of nodes to create during expansion 40 @param max_depth Maximum depth of alias-within-alias resolution 41 @raise Error.Yamlrw_error if limits exceeded or undefined alias found *) 42 43(** {2 Conversion to Value} *) 44 45val to_value : 46 ?resolve_aliases_first:bool -> 47 ?max_nodes:int -> 48 ?max_depth:int -> 49 t -> Value.t 50(** Convert to JSON-compatible Value. 51 52 @param resolve_aliases_first Whether to resolve aliases before conversion (default true) 53 @param max_nodes Maximum nodes during alias expansion 54 @param max_depth Maximum alias nesting depth 55 @raise Error.Yamlrw_error if unresolved aliases encountered *) 56 57(** {2 Node Accessors} *) 58 59val anchor : t -> string option 60(** Get anchor from any node *) 61 62val tag : t -> string option 63(** Get tag from any node *)