/usr/lib/ocaml/atdgen/ag_util.mli is in libatdgen-ocaml-dev 1.3.1-1build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 | (** Various convenience types and functions *)
type 'a ocaml_array = 'a array
(** An alias for OCaml's standard array type,
used in generated code. *)
module Biniou :
sig
type 'a reader = Bi_inbuf.t -> 'a
(** Type of a [read_] function as produced by [atdgen -biniou]. *)
type 'a writer = Bi_outbuf.t -> 'a -> unit
(** Type of a [write_] function as produced by [atdgen -biniou]. *)
val from_channel :
?len:int ->
?shrlen:int ->
'a reader -> in_channel -> 'a
(** Read a biniou value from a channel.
@param len input buffer length.
@param shrlen initial length of the table used to store shared values.
*)
val from_file :
?len:int ->
?shrlen:int ->
'a reader -> string -> 'a
(** Read a biniou value from a file.
@param len input buffer length.
@param shrlen initial length of the table used to store shared values.
*)
val to_channel :
?len:int ->
?shrlen:int ->
'a writer -> out_channel -> 'a -> unit
(** Write a biniou value to a channel.
@param len output buffer length.
@param shrlen initial length of the table used to store shared values.
*)
val to_file :
?len:int ->
?shrlen:int ->
'a writer -> string -> 'a -> unit
(** Write a biniou value to a file.
@param len output buffer length.
@param shrlen initial length of the table used to store shared values.
*)
end
module Json :
sig
type 'a reader = Yojson.Safe.lexer_state -> Lexing.lexbuf -> 'a
(** Type of a [read_] function as produced by [atdgen -json].
In versions of yojson greater than 1.0.1,
type [Yojson.Safe.lexer_state] is equivalent to
[Yojson.lexer_state], [Yojson.Basic.lexer_state] and
[Yojson.Raw.lexer_state]. *)
type 'a writer = Bi_outbuf.t -> 'a -> unit
(** Type of a [write_] function as produced by [atdgen -json]. *)
val from_lexbuf :
?stream:bool ->
'a reader -> Yojson.Safe.lexer_state -> Lexing.lexbuf -> 'a
(** Read a JSON value from a lexbuf.
@param stream if [true], the JSON parser will not try
to consume whitespace until the end of file.
Default is [false], which raises a [Yojson.Json_error]
exception if the valid JSON value is followed
by anything other than standard JSON whitespace.
*)
val from_string :
?buf:Bi_outbuf.t ->
?fname:string ->
?lnum:int ->
'a reader -> string -> 'a
(** Convert a JSON value from a string.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fname input file name to be used in error messages.
It does not have to be the name of a real file,
it can be something like ["<stdin>"].
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val from_channel :
?buf:Bi_outbuf.t ->
?fname:string ->
?lnum:int ->
'a reader -> in_channel -> 'a
(** Read a JSON value from a channel.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fname input file name to be used in error messages.
It does not have to be the name of a real file,
it can be something like ["<stdin>"].
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val from_file :
?buf:Bi_outbuf.t ->
?fname:string ->
?lnum:int ->
'a reader -> string -> 'a
(** Read a JSON value from a channel.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fname input file name to be used in error messages.
It is intended to represent the source file
if it is different from the input file.
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val stream_from_lexbuf :
?fin:(unit -> unit) ->
'a reader -> Yojson.Safe.lexer_state -> Lexing.lexbuf -> 'a Stream.t
(** Read a stream of JSON values from a lexbuf.
@param fin finalization function executed once when the end of the
stream is reached either because there is no more
input or because of an exception. This is typically
used to close the input channel, e.g.
[fun () -> close_in_noerr ic].
*)
val stream_from_string :
?buf:Bi_outbuf.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
'a reader -> string -> 'a Stream.t
(** Read a stream of JSON values from a channel.
Values do not have to be separated by newline characters.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fin finalization function executed once when the end of the
stream is reached either because there is no more
input or because of an exception. This is typically
used to free the underlying resources, if any.
@param fname input file name to be used in error messages.
It does not have to be the name of a real file,
it can be something like ["<stdin>"].
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val stream_from_channel :
?buf:Bi_outbuf.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
'a reader -> in_channel -> 'a Stream.t
(** Read a stream of JSON values from a channel.
Values do not have to be separated by newline characters.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fin finalization function executed once when the end of the
stream is reached either because there is no more
input or because of an exception. This is typically
used to close the input channel, e.g.
[fun () -> close_in_noerr ic].
@param fname input file name to be used in error messages.
It does not have to be the name of a real file,
it can be something like ["<stdin>"].
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val stream_from_file :
?buf:Bi_outbuf.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
'a reader -> string -> 'a Stream.t
(** Read a stream of JSON values from a file.
Values do not have to be separated by newline characters.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fin finalization function executed once when the end of the
stream is reached either because there is no more
input or because of an exception. This can be used
to remove the input file if it was temporary, e.g.
[fun () -> Sys.remove fname].
@param fname input file name to be used in error messages.
It is intended to represent the source file
if it is different from the input file.
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val list_from_string :
?buf:Bi_outbuf.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
'a reader -> string -> 'a list
(** Read a list of JSON values from a channel.
Values do not have to be separated by newline characters.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fin finalization function executed once when the end of the
stream is reached either because there is no more
input or because of an exception. This is typically
used to free the underlying resources, if any.
@param fname input file name to be used in error messages.
It does not have to be the name of a real file,
it can be something like ["<stdin>"].
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val list_from_channel :
?buf:Bi_outbuf.t ->
?fin:(unit -> unit) ->
?fname:string ->
?lnum:int ->
'a reader -> in_channel -> 'a list
(** Read a list of JSON values from a channel.
Values do not have to be separated by newline characters.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fin finalization function executed once when the end of the
stream is reached either because there is no more
input or because of an exception. This is typically
used to close the input channel, e.g.
[fun () -> close_in_noerr ic].
@param fname input file name to be used in error messages.
It does not have to be the name of a real file,
it can be something like ["<stdin>"].
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val list_from_file :
?buf:Bi_outbuf.t ->
?fname:string ->
?lnum:int ->
'a reader -> string -> 'a list
(** Read a list of JSON values from a file.
Values do not have to be separated by newline characters.
@param buf buffer used to accumulate string data
during the lexing phase.
@param fname input file name to be used in error messages.
It is intended to represent the source file
if it is different from the input file.
@param lnum line number to assign to the first line of input.
For example [lnum=10] means that an error on the first
line of input will be reported as an error on line 10.
Default: 1.
*)
val to_string :
?len:int ->
'a writer -> 'a -> string
(** Write a JSON value to a string.
@param len output buffer length.
*)
val to_channel :
?len:int ->
'a writer -> out_channel -> 'a -> unit
(** Write a JSON value to a channel.
@param len output buffer length.
*)
val to_file :
?len:int ->
'a writer -> string -> 'a -> unit
(** Write a JSON value to a file.
@param len output buffer length.
*)
val stream_to_string :
?len:int ->
?lf:string ->
'a writer -> 'a Stream.t -> string
(** Write a stream of values to a string.
@param len output buffer length.
@param lf additional element terminator. Default: ["\n"].
*)
val stream_to_channel :
?len:int ->
?lf:string ->
'a writer -> out_channel -> 'a Stream.t -> unit
(** Write a stream of values to a channel.
@param len output buffer length.
@param lf additional element terminator. Default: ["\n"].
*)
val stream_to_file :
?len:int ->
?lf:string ->
'a writer -> string -> 'a Stream.t -> unit
(** Write a stream of values to a file.
@param len output buffer length.
@param lf additional element terminator. Default: ["\n"].
*)
val list_to_string :
?len:int ->
?lf:string ->
'a writer -> 'a list -> string
(** Write a list of values to a string.
@param len output buffer length.
@param lf additional element terminator. Default: ["\n"].
*)
val list_to_channel :
?len:int ->
?lf:string ->
'a writer -> out_channel -> 'a list -> unit
(** Write a list of values to a channel.
@param len output buffer length.
@param lf additional element terminator. Default: ["\n"].
*)
val list_to_file :
?len:int ->
?lf:string ->
'a writer -> string -> 'a list -> unit
(** Write a list of values to a file.
@param len output buffer length.
@param lf additional element terminator. Default: ["\n"].
*)
val preset_unknown_field_handler : string -> string -> unit
(**
[preset_unknown_field_handler src_loc field_name]
raises a [Failure] exception with a message containing
the location of the type definition in the source ATD file
([src_loc]) and the name of the field ([field_name]).
*)
val unknown_field_handler : (string -> string -> unit) ref
(** Function called when an unknown JSON field is encountered if
the code was generated by atdgen -json-strict-fields.
Its preset behavior is to call [preset_unknown_field_handler]
which raises a [Failure] exception.
Usage: [!Ag_util.Json.unknown_field_handler src_loc field_name]
where [src_loc] is the location of the type definition
in the source ATD file and [field_name] is the unknown
JSON field name.
*)
end
module Validation :
sig
type path_elem = [ `Field of string | `Index of int ]
type path = path_elem list
(** Path within a value, used to report validation errors. *)
val string_of_path : path -> string
(** Reverse and concatenate a path into a string
such as [".settings.ports[0]"] *)
type error = {
error_path : path;
error_msg : string option;
}
val error : ?msg: string -> path -> error
val string_of_error : error -> string
end
|